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