Trisurf Monte Carlo simulator
Miha
2013-11-29 311301bef2f4762781817a7553b56d827d2d8d7e
commit | author | age
d7639a 1 #ifndef _GENERAL_H
SP 2 #define _GENERAL_H
3
4 #include<stdarg.h>
7958e9 5 #include<stdio.h>
d7639a 6
SP 7 /* @brief This is a header file, defining general constants and structures.
8   * @file header.h
9   * @author Samo Penic
10   * @date 5.3.2001
311301 11   * 
d7639a 12   * Header file for general inclusion in all the code, defining data structures
SP 13   * and general constans. All datatypes used in the code is also defined here.
14   *
311301 15   * Miha: branch trisurf-polyel
d7639a 16   */
SP 17
18 /* Defines */
19 /** @brief Return value of type bz_bool that indiceates successful function finish 
20   *
21   * Function usualy return some value, which are the result of certain operation. Functions that don't
22   * return any parameters can return value, that indicates if the function call finished successfully.
23   * In case of successful function run, the functions should return TS_SUCCESS to the caller. This define
24   * is set here to get uniformity among all the functions used in program.
25   *
26   * Example of usage:
27   *        ts_boot somefunction(ts_int param1, ....){
28   *            ...
29   *            return TS_SUCCESS;
30   *        }
31   */
32 #define TS_SUCCESS 0
33
34 /** @brief Return value of type bz_bool that indicates unsuccessful function finish 
35   *
36   * Function usualy return some value, which are the result of certain operation. Functions that don't
37   * return any parameters can return value, that indicates if the function call finished successfully.
38   * In case of unsuccessful function run, the functions should return TS_FAIL to the caller. This define
39   * is set here to get uniformity among all the functions used in program.
40   *
41   * Example of usage:
42   *
43   *        ts_boot somefunction(ts_int param1, ....){
44   *            ...
45   *            return TS_FAIL;
46   *        }
47   */
48 #define TS_FAIL 1
49
50 /* CONSTANTS */
51
52 /* DATA TYPES */
53 /** @brief Sets the default datatype for ts_double
54  *
55  * Requred for some functions to work, like "pow" from math.h. If ts_double is defined as
56  * float program must run with "powf". Where type dependant function is used it checks this
57  * define directive to decide which version to compile in. Available options
58  *
59  *    TS_DOUBLE_FLOAT
60  *    TS_DOUBLE_DOUBLE
61  *    TS_DOUBLE_LONGDOUBLE
62 */
63 #define TS_DOUBLE_DOUBLE
64
65 /** For the purpose of greater flexibility all data types used in the program
66  *  shouldn't use standard C types, but should use types defined here.
67  *    ts_int (uses int)
68  */
69 typedef int ts_int;
70 /** For the purpose of greater flexibility all data types used in the program
71  *  shouldn't use standard C types, but should use types defined here.
72  *    ts_uint (uses unsigned int)
73  */
74 typedef unsigned int ts_uint;
75 /** For the purpose of greater flexibility all data types used in the program
76  *  shouldn't use standard C types, but should use types defined here.
77  *    ts_long (uses long)
78  */
79 typedef long ts_long;
80 /** For the purpose of greater flexibility all data types used in the program
81  *  shouldn't use standard C types, but should use types defined here.
82  *    ts_ulong (uses unsigned long)
83  */
84 typedef unsigned long ts_ulong;
85 /** For the purpose of greater flexibility all data types used in the program
86  *  shouldn't use standard C types, but should use types defined here.
87  *    ts_float (uses float)
88  */
89 typedef float ts_float;
90 /** For the purpose of greater flexibility all data types used in the program
91  *  shouldn't use standard C types, but should use types defined here.
92  *    ts_double (uses double)
93  */
94 typedef double ts_double;
95 /** For the purpose of greater flexibility all data types used in the program
96  *  shouldn't use standard C types, but should use types defined here.
97  *    ts_char (uses char)
98  */
99 typedef char ts_char;
100 /** For the purpose of greater flexibility all data types used in the program
101  *  shouldn't use standard C types, but should use types defined here.
102  *    ts_uchar (uses unsigned char)
103  */
104 typedef unsigned char ts_uchar;
105 /** For the purpose of greater flexibility all data types used in the program
106  *  shouldn't use standard C types, but should use types defined here.
107  *    ts_bool (uses char)
108  */
109 typedef char ts_bool;
110
111
112 /* STRUCTURES */
113
523bf1 114
SP 115 /** @brief Data structure for keeping the coordinates in selected coordinate
116  * system
117  */
118 #define TS_COORD_CARTESIAN 0
119 #define TS_COORD_SPHERICAL 1
120 #define TS_COORD_CYLINDRICAL 2
121
122 typedef struct {
123     ts_double e1;
124     ts_double e2;
125     ts_double e3;
126     ts_uint coord_type;
127 } ts_coord;
128
129
130
d7639a 131 /** @brief Data structure of all data connected to a vertex
SP 132  *
8f6a69 133  *  ts_vertex holds the data for one single point (bead, vertex). To understand how to use it
d7639a 134  *  here is a detailed description of the fields in the data structure. */
8f6a69 135 struct ts_vertex {
SP 136         ts_uint idx;
a10dd5 137         ts_double x; /**< The x coordinate of vertex. */
d7639a 138         ts_double y; /**< The y coordinate of vertex. */
SP 139         ts_double z; /**< The z coordinate of vertex. */
140         ts_uint neigh_no; /**< The number of neighbours. */
a10dd5 141         struct ts_vertex **neigh; /**< The pointer that holds neigh_no pointers to this structure. */
SP 142         ts_double *bond_length; /**< Obsolete! The bond lenght is moved to ts_bond */
143         ts_double *bond_length_dual; /**< Obsolete! Bond length in dual lattice is moved to ts_bond! */
d7639a 144         ts_double curvature;
SP 145         ts_double energy;
146         ts_double energy_h;
147         ts_uint tristar_no;
a10dd5 148         struct ts_triangle **tristar; /**< The list of triangles this vertex belongs to. This is an array of pointers to ts_triangle structure of tristar_no length */
SP 149         ts_uint bond_no;
150         struct ts_bond **bond; /**< Array of pointers of lenght bond_no that stores information on bonds. */
151         struct ts_cell *cell; /**< Which cell do we belong to? */
d7639a 152         ts_double xk;
SP 153         ts_double c;
154         ts_uint id;
523bf1 155         ts_double projArea;
SP 156         ts_double relR;
157         ts_double solAngle;
737714 158 };
d7639a 159 typedef struct ts_vertex ts_vertex;
SP 160
73f967 161 typedef struct {
SP 162     ts_uint n;
a10dd5 163     ts_vertex **vtx;
73f967 164
SP 165 } ts_vertex_list;
166
e016c4 167 struct ts_bond {
SP 168     ts_uint idx;
d7639a 169     ts_vertex *vtx1;
SP 170     ts_vertex *vtx2;
171     ts_double bond_length;
172     ts_double bond_length_dual;
a63f17 173     ts_bool tainted;
a10dd5 174 };
SP 175 typedef struct ts_bond ts_bond;
176
177 struct ts_bond_list {
178     ts_uint n;
179     ts_bond **bond;
180 };
181 typedef struct ts_bond_list ts_bond_list;
182
41a035 183 struct ts_triangle {
SP 184     ts_uint idx;
d7639a 185     ts_vertex *vertex[3];
SP 186     ts_uint neigh_no;
187     struct ts_triangle **neigh;
188     ts_double xnorm;
189     ts_double ynorm;
190     ts_double znorm;
523bf1 191     ts_double area; // firstly needed for sh.c
c9d07c 192     ts_double volume; // firstly needed for sh.c
a10dd5 193 };
d7639a 194 typedef struct ts_triangle ts_triangle;
a10dd5 195
SP 196 struct ts_triangle_list{
197     ts_uint n;
198     ts_triangle **tria;
199 };
a2a676 200 typedef struct ts_triangle_list ts_triangle_list;
d7639a 201
SP 202
bb77ca 203 typedef struct ts_cell {
SP 204     ts_uint idx;
34d3de 205     ts_vertex **vertex;
SP 206     ts_uint nvertex;
bb77ca 207 } ts_cell; 
SP 208
209 typedef struct ts_cell_list{
210     ts_uint ncmax[3];
211     ts_uint cellno;
212     ts_cell **cell;
d7639a 213     ts_double dcell;
SP 214     ts_double shift;
215     ts_double max_occupancy;
bb77ca 216 } ts_cell_list;
SP 217
218
219 typedef struct {
523bf1 220     ts_uint l;
SP 221     ts_double **ulm;
262607 222     ts_double **sumUlm2;
SP 223     ts_uint N;
621830 224     ts_double **co;
eb8605 225     ts_double ***Ylmi;
523bf1 226 } ts_spharm;
SP 227
228
229
230 typedef struct {
bb77ca 231     ts_vertex_list *vlist;
SP 232     ts_bond_list *blist;
233     ts_triangle_list *tlist;
234     ts_cell_list *clist;
235     ts_uint nshell;
d7639a 236     ts_double bending_rigidity;
SP 237     ts_double dmax;
238     ts_double stepsize;
239     ts_double cm[3];
523bf1 240     ts_double volume;
SP 241     ts_spharm *sphHarmonics;
d7639a 242 } ts_vesicle;
SP 243
244
523bf1 245
SP 246
d7639a 247 /* GLOBAL VARIABLES */
SP 248
249 int quiet;
250
251
252 /* FUNCTIONS */
253
254 /** Non-fatal error function handler:
255  *      @param text is a description of an error
256  *      @returns doesn't return anything
257 */
258 void err(char *text);
259
260 /** Fatal error function handler:
261  *      @param text is a description of an error
262  *      @param errcode is a (non-zero) error code
263  *      @returns terminates the execution of program with errcode set
264 */
265 void fatal(char *text, ts_int errcode);
266
7958e9 267 ts_uint ts_fprintf(FILE *fd, char *fmt, ...);
d7639a 268
737714 269 #define VTX(n) &(vlist->vtx[n])
SP 270 #define VTX_DATA(n) vlist->vtx[n].data
73f967 271
d7639a 272 #endif