| 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 |
| a10dd5 | 198 | }; |
| d7639a | 199 | typedef struct ts_triangle ts_triangle; |
| a10dd5 | 200 | |
| SP | 201 | struct ts_triangle_list{ |
| 202 | ts_uint n; | |
| 203 | ts_triangle **tria; | |
| 204 | }; | |
| a2a676 | 205 | typedef struct ts_triangle_list ts_triangle_list; |
| d7639a | 206 | |
| SP | 207 | |
| bb77ca | 208 | typedef struct ts_cell { |
| SP | 209 | ts_uint idx; |
| 34d3de | 210 | ts_vertex **vertex; |
| SP | 211 | ts_uint nvertex; |
| bb77ca | 212 | } ts_cell; |
| SP | 213 | |
| 214 | typedef struct ts_cell_list{ | |
| 215 | ts_uint ncmax[3]; | |
| 216 | ts_uint cellno; | |
| 217 | ts_cell **cell; | |
| d7639a | 218 | ts_double dcell; |
| SP | 219 | ts_double shift; |
| 220 | ts_double max_occupancy; | |
| ea1cce | 221 | ts_double dmin_interspecies; |
| bb77ca | 222 | } ts_cell_list; |
| SP | 223 | |
| 224 | ||
| 225 | typedef struct { | |
| 523bf1 | 226 | ts_uint l; |
| SP | 227 | ts_double **ulm; |
| 459ff9 | 228 | gsl_complex **ulmComplex; |
| 262607 | 229 | ts_double **sumUlm2; |
| SP | 230 | ts_uint N; |
| 621830 | 231 | ts_double **co; |
| eb8605 | 232 | ts_double ***Ylmi; |
| 523bf1 | 233 | } ts_spharm; |
| SP | 234 | |
| 235 | ||
| 236 | ||
| 1d5dff | 237 | struct ts_poly { |
| M | 238 | ts_vertex_list *vlist; |
| 239 | ts_bond_list *blist; | |
| 240 | ts_vertex *grafted_vtx; | |
| 48bb92 | 241 | ts_double k; |
| 1d5dff | 242 | }; |
| M | 243 | typedef struct ts_poly ts_poly; |
| 244 | ||
| 245 | ||
| 246 | struct ts_poly_list { | |
| 247 | ts_uint n; | |
| 248 | ts_poly **poly; | |
| 249 | }; | |
| 250 | typedef struct ts_poly_list ts_poly_list; | |
| 251 | ||
| 252 | ||
| 514ebc | 253 | typedef struct{ |
| SP | 254 | ts_float z_max; |
| 255 | ts_float z_min; | |
| 256 | ts_int force_switch; | |
| 257 | } ts_confinement_plane; | |
| 1d5dff | 258 | |
| 9166cb | 259 | typedef struct { |
| SP | 260 | long int nshell; |
| 261 | long int ncxmax; | |
| 262 | long int ncymax; | |
| 263 | long int nczmax; | |
| 264 | long int npoly; | |
| 265 | long int nmono; | |
| e98482 | 266 | long int internal_poly; |
| 9166cb | 267 | long int nfil; |
| SP | 268 | long int nfono; |
| 269 | long int R_nucleus; | |
| 37791b | 270 | ts_double R_nucleusX; |
| SP | 271 | ts_double R_nucleusY; |
| 272 | ts_double R_nucleusZ; | |
| 9166cb | 273 | long int pswitch; |
| SP | 274 | long int constvolswitch; |
| c0ae90 | 275 | long int constareaswitch; |
| 43c042 | 276 | ts_double constvolprecision; |
| 9166cb | 277 | char *multiprocessing; |
| SP | 278 | long int brezveze0; |
| 279 | long int brezveze1; | |
| 280 | long int brezveze2; | |
| 281 | ts_double xk0; | |
| 282 | ts_double dmax; | |
| 283 | ts_double dmin_interspecies; | |
| 284 | ts_double stepsize; | |
| 285 | ts_double kspring; | |
| 286 | ts_double xi; | |
| 287 | ts_double pressure; | |
| 288 | long int iterations; | |
| 289 | long int inititer; | |
| 290 | long int mcsweeps; | |
| 291 | long int quiet; | |
| 292 | long int shc; | |
| e5858f | 293 | long int number_of_vertices_with_c0; |
| SP | 294 | ts_double c0; |
| 295 | ts_double w; | |
| 250de4 | 296 | ts_double F; |
| 514ebc | 297 | long int plane_confinement_switch; |
| SP | 298 | ts_double plane_d; |
| 299 | ts_double plane_F; | |
| 9166cb | 300 | } ts_tape; |
| SP | 301 | |
| 302 | ||
| 303 | ||
| 1d5dff | 304 | |
| 523bf1 | 305 | typedef struct { |
| bb77ca | 306 | ts_vertex_list *vlist; |
| SP | 307 | ts_bond_list *blist; |
| 308 | ts_triangle_list *tlist; | |
| 48bb92 | 309 | ts_cell_list *clist; |
| bb77ca | 310 | ts_uint nshell; |
| 48bb92 | 311 | ts_double bending_rigidity; |
| M | 312 | ts_double dmax; |
| 313 | ts_double stepsize; | |
| 314 | ts_double cm[3]; | |
| 315 | ts_double volume; | |
| 316 | ts_spharm *sphHarmonics; | |
| 624f81 | 317 | // Polymers outside the vesicle and attached to the vesicle membrane (polymer brush): |
| 1d5dff | 318 | ts_poly_list *poly_list; |
| 624f81 | 319 | // Filaments inside the vesicle (not attached to the vesicel membrane: |
| M | 320 | ts_poly_list *filament_list; |
| 321 | ||
| 48bb92 | 322 | ts_double spring_constant; |
| e86357 | 323 | ts_double pressure; |
| b866cf | 324 | ts_int pswitch; |
| 514ebc | 325 | ts_tape *tape; |
| 624f81 | 326 | ts_double R_nucleus; |
| 37791b | 327 | ts_double R_nucleusX; |
| SP | 328 | ts_double R_nucleusY; |
| 329 | ts_double R_nucleusZ; | |
| 4891eb | 330 | ts_double nucleus_center[3]; |
| 514ebc | 331 | ts_double area; |
| SP | 332 | ts_confinement_plane confinement_plane; |
| d7639a | 333 | } ts_vesicle; |
| SP | 334 | |
| 335 | ||
| 523bf1 | 336 | |
| 759169 | 337 | struct ts_cluster{ |
| 69a174 | 338 | ts_uint nvtx; |
| SP | 339 | ts_uint idx; |
| 340 | ts_vertex **vtx; | |
| 759169 | 341 | }; |
| SP | 342 | |
| 343 | typedef struct ts_cluster ts_cluster; | |
| 69a174 | 344 | |
| SP | 345 | typedef struct{ |
| 346 | ts_uint n; | |
| 347 | ts_cluster **cluster; | |
| 348 | } ts_cluster_list; | |
| 349 | ||
| 350 | ||
| d7639a | 351 | /* GLOBAL VARIABLES */ |
| SP | 352 | |
| 353 | int quiet; | |
| 1121fa | 354 | ts_double V0; |
| c0ae90 | 355 | ts_double A0; |
| 1121fa | 356 | ts_double epsvol; |
| c0ae90 | 357 | ts_double epsarea; |
| d7639a | 358 | /* FUNCTIONS */ |
| SP | 359 | |
| 360 | /** Non-fatal error function handler: | |
| 361 | * @param text is a description of an error | |
| 362 | * @returns doesn't return anything | |
| 363 | */ | |
| 364 | void err(char *text); | |
| 365 | ||
| 366 | /** Fatal error function handler: | |
| 367 | * @param text is a description of an error | |
| 368 | * @param errcode is a (non-zero) error code | |
| 369 | * @returns terminates the execution of program with errcode set | |
| 370 | */ | |
| 371 | void fatal(char *text, ts_int errcode); | |
| 372 | ||
| 7958e9 | 373 | ts_uint ts_fprintf(FILE *fd, char *fmt, ...); |
| d7639a | 374 | |
| 737714 | 375 | #define VTX(n) &(vlist->vtx[n]) |
| SP | 376 | #define VTX_DATA(n) vlist->vtx[n].data |
| 73f967 | 377 | |
| fbbc8e | 378 | |
| SP | 379 | /* FOR PID GENERATION ROUTINE */ |
| 380 | #define CPF_CLOEXEC 1 | |
| 381 | ||
| 382 | int createPidFile(const char *progName, const char *pidFile, int flags); | |
| 383 | ||
| 384 | int lockRegion(int fd, int type, int whence, int start, int len); | |
| cb2faf | 385 | char *libVersion(); |
| d7639a | 386 | #endif |