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