commit | author | age
|
7f6076
|
1 |
/* vim: set ts=4 sts=4 sw=4 noet : */ |
d7639a
|
2 |
#ifndef _GENERAL_H |
SP |
3 |
#define _GENERAL_H |
|
4 |
|
|
5 |
#include<stdarg.h> |
7958e9
|
6 |
#include<stdio.h> |
459ff9
|
7 |
#include<gsl/gsl_complex.h> |
d7639a
|
8 |
/* @brief This is a header file, defining general constants and structures. |
SP |
9 |
* @file header.h |
|
10 |
* @author Samo Penic |
|
11 |
* @date 5.3.2001 |
311301
|
12 |
* |
d7639a
|
13 |
* Header file for general inclusion in all the code, defining data structures |
SP |
14 |
* and general constans. All datatypes used in the code is also defined here. |
|
15 |
* |
311301
|
16 |
* Miha: branch trisurf-polyel |
d7639a
|
17 |
*/ |
SP |
18 |
|
|
19 |
/* Defines */ |
|
20 |
/** @brief Return value of type bz_bool that indiceates successful function finish |
|
21 |
* |
|
22 |
* Function usualy return some value, which are the result of certain operation. Functions that don't |
|
23 |
* return any parameters can return value, that indicates if the function call finished successfully. |
|
24 |
* In case of successful function run, the functions should return TS_SUCCESS to the caller. This define |
|
25 |
* is set here to get uniformity among all the functions used in program. |
|
26 |
* |
|
27 |
* Example of usage: |
|
28 |
* ts_boot somefunction(ts_int param1, ....){ |
|
29 |
* ... |
|
30 |
* return TS_SUCCESS; |
|
31 |
* } |
|
32 |
*/ |
|
33 |
#define TS_SUCCESS 0 |
|
34 |
|
|
35 |
/** @brief Return value of type bz_bool that indicates unsuccessful function finish |
|
36 |
* |
|
37 |
* Function usualy return some value, which are the result of certain operation. Functions that don't |
|
38 |
* return any parameters can return value, that indicates if the function call finished successfully. |
|
39 |
* In case of unsuccessful function run, the functions should return TS_FAIL to the caller. This define |
|
40 |
* is set here to get uniformity among all the functions used in program. |
|
41 |
* |
|
42 |
* Example of usage: |
|
43 |
* |
|
44 |
* ts_boot somefunction(ts_int param1, ....){ |
|
45 |
* ... |
|
46 |
* return TS_FAIL; |
|
47 |
* } |
|
48 |
*/ |
|
49 |
#define TS_FAIL 1 |
|
50 |
|
|
51 |
/* CONSTANTS */ |
|
52 |
|
ea1cce
|
53 |
#define TS_ID_FILAMENT 1 |
M |
54 |
|
d7639a
|
55 |
/* DATA TYPES */ |
SP |
56 |
/** @brief Sets the default datatype for ts_double |
|
57 |
* |
|
58 |
* Requred for some functions to work, like "pow" from math.h. If ts_double is defined as |
|
59 |
* float program must run with "powf". Where type dependant function is used it checks this |
|
60 |
* define directive to decide which version to compile in. Available options |
|
61 |
* |
|
62 |
* TS_DOUBLE_FLOAT |
|
63 |
* TS_DOUBLE_DOUBLE |
|
64 |
* TS_DOUBLE_LONGDOUBLE |
|
65 |
*/ |
|
66 |
#define TS_DOUBLE_DOUBLE |
|
67 |
|
|
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_int (uses int) |
|
71 |
*/ |
|
72 |
typedef int ts_int; |
|
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_uint (uses unsigned int) |
|
76 |
*/ |
|
77 |
typedef unsigned int ts_uint; |
|
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_long (uses long) |
|
81 |
*/ |
|
82 |
typedef long ts_long; |
|
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_ulong (uses unsigned long) |
|
86 |
*/ |
|
87 |
typedef unsigned long ts_ulong; |
|
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_float (uses float) |
|
91 |
*/ |
|
92 |
typedef float ts_float; |
|
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_double (uses double) |
|
96 |
*/ |
|
97 |
typedef double ts_double; |
|
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_char (uses char) |
|
101 |
*/ |
|
102 |
typedef char ts_char; |
|
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_uchar (uses unsigned char) |
|
106 |
*/ |
|
107 |
typedef unsigned char ts_uchar; |
|
108 |
/** For the purpose of greater flexibility all data types used in the program |
|
109 |
* shouldn't use standard C types, but should use types defined here. |
|
110 |
* ts_bool (uses char) |
|
111 |
*/ |
|
112 |
typedef char ts_bool; |
|
113 |
|
|
114 |
|
|
115 |
/* STRUCTURES */ |
|
116 |
|
523bf1
|
117 |
|
SP |
118 |
/** @brief Data structure for keeping the coordinates in selected coordinate |
|
119 |
* system |
|
120 |
*/ |
|
121 |
#define TS_COORD_CARTESIAN 0 |
|
122 |
#define TS_COORD_SPHERICAL 1 |
|
123 |
#define TS_COORD_CYLINDRICAL 2 |
|
124 |
|
|
125 |
typedef struct { |
|
126 |
ts_double e1; |
|
127 |
ts_double e2; |
|
128 |
ts_double e3; |
|
129 |
ts_uint coord_type; |
|
130 |
} ts_coord; |
|
131 |
|
d7639a
|
132 |
/** @brief Data structure of all data connected to a vertex |
SP |
133 |
* |
8f6a69
|
134 |
* ts_vertex holds the data for one single point (bead, vertex). To understand how to use it |
d7639a
|
135 |
* here is a detailed description of the fields in the data structure. */ |
8f6a69
|
136 |
struct ts_vertex { |
SP |
137 |
ts_uint idx; |
a10dd5
|
138 |
ts_double x; /**< The x coordinate of vertex. */ |
d7639a
|
139 |
ts_double y; /**< The y coordinate of vertex. */ |
SP |
140 |
ts_double z; /**< The z coordinate of vertex. */ |
|
141 |
ts_uint neigh_no; /**< The number of neighbours. */ |
a10dd5
|
142 |
struct ts_vertex **neigh; /**< The pointer that holds neigh_no pointers to this structure. */ |
SP |
143 |
ts_double *bond_length; /**< Obsolete! The bond lenght is moved to ts_bond */ |
|
144 |
ts_double *bond_length_dual; /**< Obsolete! Bond length in dual lattice is moved to ts_bond! */ |
d7639a
|
145 |
ts_double curvature; |
SP |
146 |
ts_double energy; |
|
147 |
ts_double energy_h; |
|
148 |
ts_uint tristar_no; |
a10dd5
|
149 |
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 |
150 |
ts_uint bond_no; |
|
151 |
struct ts_bond **bond; /**< Array of pointers of lenght bond_no that stores information on bonds. */ |
|
152 |
struct ts_cell *cell; /**< Which cell do we belong to? */ |
d7639a
|
153 |
ts_double xk; |
SP |
154 |
ts_double c; |
|
155 |
ts_uint id; |
523bf1
|
156 |
ts_double projArea; |
SP |
157 |
ts_double relR; |
|
158 |
ts_double solAngle; |
759169
|
159 |
struct ts_poly *grafted_poly; |
SP |
160 |
struct ts_cluster *cluster; |
737714
|
161 |
}; |
d7639a
|
162 |
typedef struct ts_vertex ts_vertex; |
SP |
163 |
|
73f967
|
164 |
typedef struct { |
SP |
165 |
ts_uint n; |
a10dd5
|
166 |
ts_vertex **vtx; |
73f967
|
167 |
|
SP |
168 |
} ts_vertex_list; |
|
169 |
|
e016c4
|
170 |
struct ts_bond { |
fedf2b
|
171 |
ts_uint idx; |
d7639a
|
172 |
ts_vertex *vtx1; |
SP |
173 |
ts_vertex *vtx2; |
58230a
|
174 |
ts_double bond_length; |
M |
175 |
ts_double bond_length_dual; |
|
176 |
ts_bool tainted; //TODO: remove |
fedf2b
|
177 |
ts_double energy; |
58230a
|
178 |
ts_double x,y,z; |
a10dd5
|
179 |
}; |
SP |
180 |
typedef struct ts_bond ts_bond; |
|
181 |
|
|
182 |
struct ts_bond_list { |
|
183 |
ts_uint n; |
|
184 |
ts_bond **bond; |
|
185 |
}; |
|
186 |
typedef struct ts_bond_list ts_bond_list; |
|
187 |
|
41a035
|
188 |
struct ts_triangle { |
SP |
189 |
ts_uint idx; |
d7639a
|
190 |
ts_vertex *vertex[3]; |
SP |
191 |
ts_uint neigh_no; |
|
192 |
struct ts_triangle **neigh; |
|
193 |
ts_double xnorm; |
|
194 |
ts_double ynorm; |
|
195 |
ts_double znorm; |
523bf1
|
196 |
ts_double area; // firstly needed for sh.c |
c9d07c
|
197 |
ts_double volume; // firstly needed for sh.c |
2ae815
|
198 |
ts_double energy; |
a10dd5
|
199 |
}; |
d7639a
|
200 |
typedef struct ts_triangle ts_triangle; |
a10dd5
|
201 |
|
SP |
202 |
struct ts_triangle_list{ |
|
203 |
ts_uint n; |
7ec6fb
|
204 |
ts_double a0; |
a10dd5
|
205 |
ts_triangle **tria; |
SP |
206 |
}; |
a2a676
|
207 |
typedef struct ts_triangle_list ts_triangle_list; |
d7639a
|
208 |
|
SP |
209 |
|
bb77ca
|
210 |
typedef struct ts_cell { |
SP |
211 |
ts_uint idx; |
34d3de
|
212 |
ts_vertex **vertex; |
SP |
213 |
ts_uint nvertex; |
bb77ca
|
214 |
} ts_cell; |
SP |
215 |
|
|
216 |
typedef struct ts_cell_list{ |
|
217 |
ts_uint ncmax[3]; |
|
218 |
ts_uint cellno; |
|
219 |
ts_cell **cell; |
d7639a
|
220 |
ts_double dcell; |
SP |
221 |
ts_double shift; |
|
222 |
ts_double max_occupancy; |
ea1cce
|
223 |
ts_double dmin_interspecies; |
bb77ca
|
224 |
} ts_cell_list; |
SP |
225 |
|
|
226 |
|
|
227 |
typedef struct { |
523bf1
|
228 |
ts_uint l; |
SP |
229 |
ts_double **ulm; |
459ff9
|
230 |
gsl_complex **ulmComplex; |
262607
|
231 |
ts_double **sumUlm2; |
SP |
232 |
ts_uint N; |
621830
|
233 |
ts_double **co; |
eb8605
|
234 |
ts_double ***Ylmi; |
523bf1
|
235 |
} ts_spharm; |
SP |
236 |
|
|
237 |
|
|
238 |
|
1d5dff
|
239 |
struct ts_poly { |
M |
240 |
ts_vertex_list *vlist; |
|
241 |
ts_bond_list *blist; |
|
242 |
ts_vertex *grafted_vtx; |
48bb92
|
243 |
ts_double k; |
1d5dff
|
244 |
}; |
M |
245 |
typedef struct ts_poly ts_poly; |
|
246 |
|
|
247 |
|
|
248 |
struct ts_poly_list { |
|
249 |
ts_uint n; |
|
250 |
ts_poly **poly; |
|
251 |
}; |
|
252 |
typedef struct ts_poly_list ts_poly_list; |
|
253 |
|
|
254 |
|
514ebc
|
255 |
typedef struct{ |
SP |
256 |
ts_float z_max; |
|
257 |
ts_float z_min; |
|
258 |
ts_int force_switch; |
|
259 |
} ts_confinement_plane; |
1d5dff
|
260 |
|
9166cb
|
261 |
typedef struct { |
SP |
262 |
long int nshell; |
|
263 |
long int ncxmax; |
|
264 |
long int ncymax; |
|
265 |
long int nczmax; |
|
266 |
long int npoly; |
|
267 |
long int nmono; |
e98482
|
268 |
long int internal_poly; |
9166cb
|
269 |
long int nfil; |
SP |
270 |
long int nfono; |
|
271 |
long int R_nucleus; |
37791b
|
272 |
ts_double R_nucleusX; |
SP |
273 |
ts_double R_nucleusY; |
|
274 |
ts_double R_nucleusZ; |
9166cb
|
275 |
long int pswitch; |
SP |
276 |
long int constvolswitch; |
c0ae90
|
277 |
long int constareaswitch; |
2ae815
|
278 |
long int stretchswitch; |
SP |
279 |
ts_double xkA0; |
43c042
|
280 |
ts_double constvolprecision; |
9166cb
|
281 |
char *multiprocessing; |
SP |
282 |
long int brezveze0; |
|
283 |
long int brezveze1; |
|
284 |
long int brezveze2; |
|
285 |
ts_double xk0; |
|
286 |
ts_double dmax; |
|
287 |
ts_double dmin_interspecies; |
|
288 |
ts_double stepsize; |
|
289 |
ts_double kspring; |
|
290 |
ts_double xi; |
|
291 |
ts_double pressure; |
|
292 |
long int iterations; |
|
293 |
long int inititer; |
|
294 |
long int mcsweeps; |
|
295 |
long int quiet; |
|
296 |
long int shc; |
e5858f
|
297 |
long int number_of_vertices_with_c0; |
SP |
298 |
ts_double c0; |
|
299 |
ts_double w; |
250de4
|
300 |
ts_double F; |
514ebc
|
301 |
long int plane_confinement_switch; |
SP |
302 |
ts_double plane_d; |
|
303 |
ts_double plane_F; |
9166cb
|
304 |
} ts_tape; |
SP |
305 |
|
|
306 |
|
eb7d7e
|
307 |
/* plugins */ |
SP |
308 |
typedef struct { |
51b4f0
|
309 |
void (*at_start)(int argc, char **argv); |
SP |
310 |
void *(*after_vesicle_init)(void *vesicle); |
eb7d7e
|
311 |
ts_bool (*vm_hard_constraint)(void *vesicle, ts_vertex *vtx, ts_vertex *odl_vtx); |
36dba8
|
312 |
void (*vm_energy_before_prepare)(void *vesicle, ts_vertex *vtx); |
51b4f0
|
313 |
ts_double (*vm_energy_before_execute)(void *vesicle, ts_vertex *vtx); |
SP |
314 |
ts_double (*vm_energy_after_prepare)(void *vesicle, ts_vertex *vtx); |
|
315 |
ts_double (*vm_energy_after_execute)(void *vesicle, ts_vertex *vtx); |
77a2c7
|
316 |
ts_double (*vm_before_montecarlo_constraint)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); |
2afc2f
|
317 |
ts_double (*vm_new_state_accepted)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); |
SP |
318 |
ts_double (*vm_new_state_rejected)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); |
eb7d7e
|
319 |
void (*cleanup)(void); |
SP |
320 |
} ts_plugin_function; |
|
321 |
|
|
322 |
typedef struct { |
|
323 |
ts_char *name; |
|
324 |
ts_char *description; |
|
325 |
ts_char *author; |
36dba8
|
326 |
void *data; |
eb7d7e
|
327 |
} ts_plugin_details; |
SP |
328 |
|
|
329 |
typedef struct { |
|
330 |
ts_plugin_details *details; |
|
331 |
ts_plugin_function *function; |
|
332 |
ts_char *filename; |
|
333 |
void *libhandle; |
|
334 |
} ts_plugin; |
|
335 |
|
ca9f26
|
336 |
struct ts_plugin_chain { |
SP |
337 |
ts_plugin *plugin; |
|
338 |
struct ts_plugin_chain *next; |
|
339 |
}; |
|
340 |
typedef struct ts_plugin_chain ts_plugin_chain; |
|
341 |
|
|
342 |
typedef struct { |
|
343 |
ts_plugin_chain *at_start; |
|
344 |
ts_plugin_chain *after_vesicle_init; |
b5cd8c
|
345 |
ts_plugin_chain *vm_hard_constraint; |
36dba8
|
346 |
ts_plugin_chain *vm_energy_before_prepare; |
SP |
347 |
ts_plugin_chain *vm_energy_after_execute; |
77a2c7
|
348 |
ts_plugin_chain *vm_before_montecarlo_constraint; |
2afc2f
|
349 |
ts_plugin_chain *vm_new_state_accepted; |
7522b8
|
350 |
ts_plugin_chain *vm_new_state_rejected; |
ca9f26
|
351 |
ts_plugin_chain *cleanup; |
SP |
352 |
} ts_plugin_chains; |
|
353 |
|
|
354 |
|
eb7d7e
|
355 |
typedef struct { |
SP |
356 |
ts_uint n; |
|
357 |
ts_plugin **plugin; |
ca9f26
|
358 |
ts_plugin_chains *chain; |
36dba8
|
359 |
ts_plugin_chain *pointer; |
eb7d7e
|
360 |
} ts_plugin_list; |
SP |
361 |
|
|
362 |
/* end plugins */ |
9166cb
|
363 |
|
1d5dff
|
364 |
|
523bf1
|
365 |
typedef struct { |
bb77ca
|
366 |
ts_vertex_list *vlist; |
SP |
367 |
ts_bond_list *blist; |
|
368 |
ts_triangle_list *tlist; |
48bb92
|
369 |
ts_cell_list *clist; |
bb77ca
|
370 |
ts_uint nshell; |
48bb92
|
371 |
ts_double bending_rigidity; |
M |
372 |
ts_double dmax; |
|
373 |
ts_double stepsize; |
|
374 |
ts_double cm[3]; |
|
375 |
ts_double volume; |
|
376 |
ts_spharm *sphHarmonics; |
624f81
|
377 |
// Polymers outside the vesicle and attached to the vesicle membrane (polymer brush): |
1d5dff
|
378 |
ts_poly_list *poly_list; |
624f81
|
379 |
// Filaments inside the vesicle (not attached to the vesicel membrane: |
M |
380 |
ts_poly_list *filament_list; |
|
381 |
|
48bb92
|
382 |
ts_double spring_constant; |
e86357
|
383 |
ts_double pressure; |
b866cf
|
384 |
ts_int pswitch; |
514ebc
|
385 |
ts_tape *tape; |
624f81
|
386 |
ts_double R_nucleus; |
37791b
|
387 |
ts_double R_nucleusX; |
SP |
388 |
ts_double R_nucleusY; |
|
389 |
ts_double R_nucleusZ; |
4891eb
|
390 |
ts_double nucleus_center[3]; |
514ebc
|
391 |
ts_double area; |
SP |
392 |
ts_confinement_plane confinement_plane; |
51b4f0
|
393 |
ts_plugin_list *plist; |
d7639a
|
394 |
} ts_vesicle; |
SP |
395 |
|
|
396 |
|
523bf1
|
397 |
|
759169
|
398 |
struct ts_cluster{ |
69a174
|
399 |
ts_uint nvtx; |
SP |
400 |
ts_uint idx; |
|
401 |
ts_vertex **vtx; |
759169
|
402 |
}; |
SP |
403 |
|
|
404 |
typedef struct ts_cluster ts_cluster; |
69a174
|
405 |
|
SP |
406 |
typedef struct{ |
|
407 |
ts_uint n; |
|
408 |
ts_cluster **cluster; |
|
409 |
} ts_cluster_list; |
|
410 |
|
|
411 |
|
d7639a
|
412 |
/* GLOBAL VARIABLES */ |
SP |
413 |
|
|
414 |
int quiet; |
1121fa
|
415 |
ts_double V0; |
c0ae90
|
416 |
ts_double A0; |
1121fa
|
417 |
ts_double epsvol; |
c0ae90
|
418 |
ts_double epsarea; |
d7639a
|
419 |
/* FUNCTIONS */ |
SP |
420 |
|
|
421 |
/** Non-fatal error function handler: |
|
422 |
* @param text is a description of an error |
|
423 |
* @returns doesn't return anything |
|
424 |
*/ |
|
425 |
void err(char *text); |
|
426 |
|
|
427 |
/** Fatal error function handler: |
|
428 |
* @param text is a description of an error |
|
429 |
* @param errcode is a (non-zero) error code |
|
430 |
* @returns terminates the execution of program with errcode set |
|
431 |
*/ |
|
432 |
void fatal(char *text, ts_int errcode); |
|
433 |
|
7958e9
|
434 |
ts_uint ts_fprintf(FILE *fd, char *fmt, ...); |
d7639a
|
435 |
|
737714
|
436 |
#define VTX(n) &(vlist->vtx[n]) |
SP |
437 |
#define VTX_DATA(n) vlist->vtx[n].data |
73f967
|
438 |
|
fbbc8e
|
439 |
|
SP |
440 |
/* FOR PID GENERATION ROUTINE */ |
|
441 |
#define CPF_CLOEXEC 1 |
|
442 |
|
|
443 |
int createPidFile(const char *progName, const char *pidFile, int flags); |
|
444 |
|
|
445 |
int lockRegion(int fd, int type, int whence, int start, int len); |
cb2faf
|
446 |
char *libVersion(); |
d7639a
|
447 |
#endif |