AdH Kraken 0.0.0
Next generation Adaptive Hydraulics
Loading...
Searching...
No Matches
macro.h
1/* this is the macro file for the adh model */
2
3/* macros for adh */
4
5#define ELEM2D_DOF3_COPY(f1, f2) \
6 f1[0].x_eq = f2[0].x_eq; \
7 f1[1].x_eq = f2[1].x_eq; \
8 f1[2].x_eq = f2[2].x_eq; \
9 f1[0].y_eq = f2[0].y_eq; \
10 f1[1].y_eq = f2[1].y_eq; \
11 f1[2].y_eq = f2[2].y_eq; \
12 f1[0].c_eq = f2[0].c_eq; \
13 f1[1].c_eq = f2[1].c_eq; \
14 f1[2].c_eq = f2[2].c_eq; \
15
16
17#define LOCAL_INIT_VECT2D(local) local.x = 0.; local.y = 0.;
18
19#define VECT2D_MAG(vec) sqrt(vec.x * vec.x + vec.y * vec.y);
20#define VECT2D_MAG_SAFE(vec) sqrt(vec.x * vec.x + vec.y * vec.y + NOT_QUITE_SMALL);
21#define VECT3D_MAG(vec) sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
22#define VECT3D_MAG_SAFE(vec) sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z + NOT_QUITE_SMALL);
23
24#define ELEM1D_LOCAL_VECT2D_AVG(vect, ovg) \
25 avg.x = (1./2.) * (vect[0].x + vect[1].x); \
26 avg.y = (1./2.) * (vect[0].y + vect[1].y);
27
28#define ELEM2D_LOCAL_VECT2D_AVG(vect, avg) \
29 avg.x = (1./3.) * (vect[0].x + vect[1].x + vect[2].x); \
30 avg.y = (1./3.) * (vect[0].y + vect[1].y + vect[2].y);
31
32#define ELEM3D_LOCAL_VECT2D_AVG(vect, avg) \
33 avg.x = (1./4.) * (vect[0].x + vect[1].x + vect[2].x + vect[3].x); \
34 avg.y = (1./4.) * (vect[0].y + vect[1].y + vect[2].y + vect[3].y);
35
36
37#define ELEM3D_LOCAL_VECT_AVG(vect, avg) \
38 avg.x = (1./4.) * (vect[0].x + vect[1].x + vect[2].x + vect[3].x); \
39 avg.y = (1./4.) * (vect[0].y + vect[1].y + vect[2].y + vect[3].y); \
40 avg.z = (1./4.) * (vect[0].z + vect[1].z + vect[2].z + vect[3].z);
41
42#define ELEM3D_LOCAL_AVG(func, avg) \
43 avg = (1./4.) * (func[0] + func[1] + func[2] + func[3]);
44
45#define ELEM3D_LOCAL_VECT_SUM(vect, sum) \
46 sum.x = vect[0].x + vect[1].x + vect[2].x + vect[3].x; \
47 sum.y = vect[0].y + vect[1].y + vect[2].y + vect[3].y; \
48 sum.z = vect[0].z + vect[1].z + vect[2].z + vect[3].z;
49
50#define ELEM3D_LOCAL_SUM(func, sum) \
51 sum = func[0] + func[1] + func[2] + func[3];
52
53#define GRAD2D_FUNC(grad_shp, var, grad) \
54 grad.x = var[0] * grad_shp[0].x + var[1] * grad_shp[1].x + var[2] * grad_shp[2].x;\
55 grad.y = var[0] * grad_shp[0].y + var[1] * grad_shp[1].y + var[2] * grad_shp[2].y;
56
57#define GRAD2D_VECT2D_X(grad_shp, var, grad) \
58 grad.x = var[0].x * grad_shp[0].x + var[1].x * grad_shp[1].x + var[2].x * grad_shp[2].x;\
59 grad.y = var[0].x * grad_shp[0].y + var[1].x * grad_shp[1].y + var[2].x * grad_shp[2].y;
60
61#define GRAD2D_VECT2D_Y(grad_shp, var, grad) \
62 grad.x = var[0].y * grad_shp[0].x + var[1].y * grad_shp[1].x + var[2].y * grad_shp[2].x;\
63 grad.y = var[0].y * grad_shp[0].y + var[1].y * grad_shp[1].y + var[2].y * grad_shp[2].y;
64
65#define VECT3D_MAG(vec) sqrt(vec.x * vec.x + vec.y * vec.y + vec.z * vec.z);
66
67#define GRAD3D_FUNC(grad_shp, var, grad) \
68 grad.x = var[0] * grad_shp[0].x + var[1] * grad_shp[1].x + var[2] * grad_shp[2].x + var[3] * grad_shp[3].x; \
69 grad.y = var[0] * grad_shp[0].y + var[1] * grad_shp[1].y + var[2] * grad_shp[2].y + var[3] * grad_shp[3].y; \
70 grad.z = var[0] * grad_shp[0].z + var[1] * grad_shp[1].z + var[2] * grad_shp[2].z + var[3] * grad_shp[3].z;
71
72#define GRAD3D_VECT3D_X(grad_shp, var, grad) \
73 grad.x = var[0].x * grad_shp[0].x + var[1].x * grad_shp[1].x + var[2].x * grad_shp[2].x + var[3].x * grad_shp[3].x;\
74 grad.y = var[0].x * grad_shp[0].y + var[1].x * grad_shp[1].y + var[2].x * grad_shp[2].y + var[3].x * grad_shp[3].y;\
75 grad.z = var[0].x * grad_shp[0].z + var[1].x * grad_shp[1].z + var[2].x * grad_shp[2].z + var[3].x * grad_shp[3].z;
76
77#define GRAD3D_VECT3D_Y(grad_shp, var, grad) \
78 grad.x = var[0].y * grad_shp[0].x + var[1].y * grad_shp[1].x + var[2].y * grad_shp[2].x + var[3].y * grad_shp[3].x;\
79 grad.y = var[0].y * grad_shp[0].y + var[1].y * grad_shp[1].y + var[2].y * grad_shp[2].y + var[3].y * grad_shp[3].y;\
80 grad.z = var[0].y * grad_shp[0].z + var[1].y * grad_shp[1].z + var[2].y * grad_shp[2].z + var[3].y * grad_shp[3].z;
81
82#define GRAD3D_VECT3D_Z(grad_shp, var, grad) \
83 grad.x = var[0].z * grad_shp[0].x + var[1].z * grad_shp[1].x + var[2].z * grad_shp[2].x + var[3].z * grad_shp[3].x;\
84 grad.y = var[0].z * grad_shp[0].y + var[1].z * grad_shp[1].y + var[2].z * grad_shp[2].y + var[3].z * grad_shp[3].y;\
85 grad.z = var[0].z * grad_shp[0].z + var[1].z * grad_shp[1].z + var[2].z * grad_shp[2].z + var[3].z * grad_shp[3].z;
86
87#define NUM_GET_TPOSITION(local1,local2,local3,scale,time1,time2) \
88 local1=scale*(1.5*local2-0.5*local3)-(1.-scale)*time1*local2/time2;
89
90#define NUM_GET_TPOSITION_VECT3D(local1,local2,local3,scale,time1,time2) \
91 local1.x = scale*(1.5*local2.x - 0.5*local3.x) - (1.-scale)*time1 * local2.x/time2; \
92 local1.y = scale*(1.5*local2.y - 0.5*local3.y) - (1.-scale)*time1 * local2.y/time2; \
93 local1.z = scale*(1.5*local2.z - 0.5*local3.z) - (1.-scale)*time1 * local2.z/time2;
94
95#define NUM_GET_TPOSITION_VECT2D(local1,local2,local3,scale,time1,time2) \
96 local1.x = scale*(1.5*local2.x - 0.5*local3.x) - (1.-scale)*time1 * local2.x/time2; \
97 local1.y = scale*(1.5*local2.y - 0.5*local3.y) - (1.-scale)*time1 * local2.y/time2;
98
99#define NUM_GET_SECONDORDER(local1, local2, local3) \
100 local1=(1.5*local2-0.5*local3);
101
102#define ELEM3D_GET_VECT_TPOSITION(local1,local2,local3,scale,time1,time2) \
103 local1[0].x=scale*(1.5*local2[0].x-0.5*local3[0].x)+(1.-scale)*time1*local2[0].x/time2; \
104 local1[0].y=scale*(1.5*local2[0].y-0.5*local3[0].y)+(1.-scale)*time1*local2[0].y/time2; \
105 local1[0].z=scale*(1.5*local2[0].z-0.5*local3[0].z)+(1.-scale)*time1*local2[0].z/time2; \
106 local1[1].x=scale*(1.5*local2[1].x-0.5*local3[1].x)+(1.-scale)*time1*local2[1].x/time2; \
107 local1[1].y=scale*(1.5*local2[1].y-0.5*local3[1].y)+(1.-scale)*time1*local2[1].y/time2; \
108 local1[1].z=scale*(1.5*local2[1].z-0.5*local3[1].z)+(1.-scale)*time1*local2[1].z/time2; \
109 local1[2].x=scale*(1.5*local2[2].x-0.5*local3[2].x)+(1.-scale)*time1*local2[2].x/time2; \
110 local1[2].y=scale*(1.5*local2[2].y-0.5*local3[2].y)+(1.-scale)*time1*local2[2].y/time2; \
111 local1[2].z=scale*(1.5*local2[2].z-0.5*local3[2].z)+(1.-scale)*time1*local2[2].z/time2; \
112 local1[3].x=scale*(1.5*local2[3].x-0.5*local3[3].x)+(1.-scale)*time1*local2[3].x/time2; \
113 local1[3].y=scale*(1.5*local2[3].y-0.5*local3[3].y)+(1.-scale)*time1*local2[3].y/time2; \
114 local1[3].z=scale*(1.5*local2[3].z-0.5*local3[3].z)+(1.-scale)*time1*local2[3].z/time2;
115
116#define ELEM3D_GET_VECT_SECONDORDER(local1,local2,local3) \
117 local1[0].x=(1.5*local2[0].x-0.5*local3[0].x); \
118 local1[0].y=(1.5*local2[0].y-0.5*local3[0].y); \
119 local1[0].z=(1.5*local2[0].z-0.5*local3[0].z); \
120 local1[1].x=(1.5*local2[1].x-0.5*local3[1].x); \
121 local1[1].y=(1.5*local2[1].y-0.5*local3[1].y); \
122 local1[1].z=(1.5*local2[1].z-0.5*local3[1].z); \
123 local1[2].x=(1.5*local2[2].x-0.5*local3[2].x); \
124 local1[2].y=(1.5*local2[2].y-0.5*local3[2].y); \
125 local1[2].z=(1.5*local2[2].z-0.5*local3[2].z); \
126 local1[3].x=(1.5*local2[3].x-0.5*local3[3].x); \
127 local1[3].y=(1.5*local2[3].y-0.5*local3[3].y); \
128 local1[3].z=(1.5*local2[3].z-0.5*local3[3].z);
129
130#define ELEM3D_GET_TPOSITION(local1,local2,local3,scale,time1,time2) \
131 local1[0]=scale*(1.5*local2[0]-0.5*local3[0])+(1.-scale)*time1*local2[0]/time2; \
132 local1[1]=scale*(1.5*local2[1]-0.5*local3[1])+(1.-scale)*time1*local2[1]/time2; \
133 local1[2]=scale*(1.5*local2[2]-0.5*local3[2])+(1.-scale)*time1*local2[2]/time2; \
134 local1[3]=scale*(1.5*local2[3]-0.5*local3[3])+(1.-scale)*time1*local2[3]/time2;
135
136#define ELEM3D_GET_TPOSITION_VECT(local1,local2,local3,scale,time1,time2) \
137 local1[0].x=scale*(1.5*local2[0].x-0.5*local3[0].x)+(1.-scale)*time1*local2[0].x/time2; \
138 local1[1].x=scale*(1.5*local2[1].x-0.5*local3[1].x)+(1.-scale)*time1*local2[1].x/time2; \
139 local1[2].x=scale*(1.5*local2[2].x-0.5*local3[2].x)+(1.-scale)*time1*local2[2].x/time2; \
140 local1[3].x=scale*(1.5*local2[3].x-0.5*local3[3].x)+(1.-scale)*time1*local2[3].x/time2; \
141 local1[0].y=scale*(1.5*local2[0].y-0.5*local3[0].y)+(1.-scale)*time1*local2[0].y/time2; \
142 local1[1].y=scale*(1.5*local2[1].y-0.5*local3[1].y)+(1.-scale)*time1*local2[1].y/time2; \
143 local1[2].y=scale*(1.5*local2[2].y-0.5*local3[2].y)+(1.-scale)*time1*local2[2].y/time2; \
144 local1[3].y=scale*(1.5*local2[3].y-0.5*local3[3].y)+(1.-scale)*time1*local2[3].y/time2; \
145 local1[0].z=scale*(1.5*local2[0].z-0.5*local3[0].z)+(1.-scale)*time1*local2[0].z/time2; \
146 local1[1].z=scale*(1.5*local2[1].z-0.5*local3[1].z)+(1.-scale)*time1*local2[1].z/time2; \
147 local1[2].z=scale*(1.5*local2[2].z-0.5*local3[2].z)+(1.-scale)*time1*local2[2].z/time2; \
148 local1[3].z=scale*(1.5*local2[3].z-0.5*local3[3].z)+(1.-scale)*time1*local2[3].z/time2;
149
150#define ELEM3D_GET_TPOSITION_VECT2D(local1,local2,local3,scale,time1,time2) \
151 local1[0].x=scale*(1.5*local2[0].x-0.5*local3[0].x)+(1.-scale)*time1*local2[0].x/time2; \
152 local1[1].x=scale*(1.5*local2[1].x-0.5*local3[1].x)+(1.-scale)*time1*local2[1].x/time2; \
153 local1[2].x=scale*(1.5*local2[2].x-0.5*local3[2].x)+(1.-scale)*time1*local2[2].x/time2; \
154 local1[3].x=scale*(1.5*local2[3].x-0.5*local3[3].x)+(1.-scale)*time1*local2[3].x/time2; \
155 local1[0].y=scale*(1.5*local2[0].y-0.5*local3[0].y)+(1.-scale)*time1*local2[0].y/time2; \
156 local1[1].y=scale*(1.5*local2[1].y-0.5*local3[1].y)+(1.-scale)*time1*local2[1].y/time2; \
157 local1[2].y=scale*(1.5*local2[2].y-0.5*local3[2].y)+(1.-scale)*time1*local2[2].y/time2; \
158 local1[3].y=scale*(1.5*local2[3].y-0.5*local3[3].y)+(1.-scale)*time1*local2[3].y/time2;
159
160#define ELEM3D_GET_SECONDORDER(local1,local2,local3) \
161 local1[0]=(1.5*local2[0]-0.5*local3[0]); \
162 local1[1]=(1.5*local2[1]-0.5*local3[1]); \
163 local1[2]=(1.5*local2[2]-0.5*local3[2]); \
164 local1[3]=(1.5*local2[3]-0.5*local3[3]);
165
166#define ELEM2D_GET_SECONDORDER(local1,local2,local3) \
167 local1[0]=(1.5*local2[0]-0.5*local3[0]); \
168 local1[1]=(1.5*local2[1]-0.5*local3[1]); \
169 local1[2]=(1.5*local2[2]-0.5*local3[2]);
170
171#define ELEM2D_GET_TPOSITION(local1,local2,local3,scale,time1,time2) \
172 local1[0]=scale*(1.5*local2[0]-0.5*local3[0])+(1.-scale)*time1*local2[0]/time2; \
173 local1[1]=scale*(1.5*local2[1]-0.5*local3[1])+(1.-scale)*time1*local2[1]/time2; \
174 local1[2]=scale*(1.5*local2[2]-0.5*local3[2])+(1.-scale)*time1*local2[2]/time2;
175
176#define ELEM3D_GET_LOCAL(global, local, nodes) \
177 local[0] = global[nodes[0]]; \
178 local[1] = global[nodes[1]]; \
179 local[2] = global[nodes[2]]; \
180 local[3] = global[nodes[3]];
181
182#define ELEM2D_GET_LOCAL(global, local, nodes) \
183 local[0] = global[nodes[0]]; \
184 local[1] = global[nodes[1]]; \
185 local[2] = global[nodes[2]];
186
187#define ELEM1D_GET_LOCAL(global, local, nodes) \
188 local[0] = global[nodes[0]]; \
189 local[1] = global[nodes[1]];
190
191#define ELEM3D_GET_LOCAL_VECT(global, local, nodes) \
192 local[0].x = global[nodes[0]].x; \
193 local[0].y = global[nodes[0]].y; \
194 local[0].z = global[nodes[0]].z; \
195 local[1].x = global[nodes[1]].x; \
196 local[1].y = global[nodes[1]].y; \
197 local[1].z = global[nodes[1]].z; \
198 local[2].x = global[nodes[2]].x; \
199 local[2].y = global[nodes[2]].y; \
200 local[2].z = global[nodes[2]].z; \
201 local[3].x = global[nodes[3]].x; \
202 local[3].y = global[nodes[3]].y; \
203 local[3].z = global[nodes[3]].z;
204
205#define ELEM3D_GET_LOCAL_VECT2D(global, local, nodes) \
206 local[0].x = global[nodes[0]].x; \
207 local[0].y = global[nodes[0]].y; \
208 local[1].x = global[nodes[1]].x; \
209 local[1].y = global[nodes[1]].y; \
210 local[2].x = global[nodes[2]].x; \
211 local[2].y = global[nodes[2]].y; \
212 local[3].x = global[nodes[3]].x; \
213 local[3].y = global[nodes[3]].y;
214
215#define ELEM2D_GET_LOCAL_VECT(global, local, nodes) \
216 local[0].x = global[nodes[0]].x; \
217 local[0].y = global[nodes[0]].y; \
218 local[0].z = global[nodes[0]].z; \
219 local[1].x = global[nodes[1]].x; \
220 local[1].y = global[nodes[1]].y; \
221 local[1].z = global[nodes[1]].z; \
222 local[2].x = global[nodes[2]].x; \
223 local[2].y = global[nodes[2]].y; \
224 local[2].z = global[nodes[2]].z;
225
226#define ELEM1D_GET_LOCAL_VECT(global, local, nodes) \
227 local[0].x = global[nodes[0]].x; \
228 local[0].y = global[nodes[0]].y; \
229 local[0].z = global[nodes[0]].z; \
230 local[1].x = global[nodes[1]].x; \
231 local[1].y = global[nodes[1]].y; \
232 local[1].z = global[nodes[1]].z;
233
234#define ELEM2D_GET_LOCAL_TENSOR2D(global, local, nodes) \
235 local[0].xx = global[nodes[0]].xx; \
236 local[0].yy = global[nodes[0]].yy; \
237 local[0].xy = global[nodes[0]].xy; \
238 local[1].xx = global[nodes[1]].xx; \
239 local[1].yy = global[nodes[1]].yy; \
240 local[1].xy = global[nodes[1]].xy; \
241 local[2].xx = global[nodes[2]].xx; \
242 local[2].yy = global[nodes[2]].yy; \
243 local[2].xy = global[nodes[2]].xy;
244
245#define ELEM2D_GET_LOCAL_VECT2D(global, local, nodes) \
246 local[0].x = global[nodes[0]].x; \
247 local[0].y = global[nodes[0]].y; \
248 local[1].x = global[nodes[1]].x; \
249 local[1].y = global[nodes[1]].y; \
250 local[2].x = global[nodes[2]].x; \
251 local[2].y = global[nodes[2]].y;
252
253#define ELEM1D_GET_LOCAL_VECT2D(global, local, nodes) \
254 local[0].x = global[nodes[0]].x; \
255 local[0].y = global[nodes[0]].y; \
256 local[1].x = global[nodes[1]].x; \
257 local[1].y = global[nodes[1]].y;
258
259#define ELEM3D_GET_ELEVATION(local_z, nodes) \
260 local_z[0] = node[nodes[0]].z; \
261 local_z[1] = node[nodes[1]].z; \
262 local_z[2] = node[nodes[2]].z; \
263 local_z[3] = node[nodes[3]].z;
264
265#define ELEM2D_GET_ELEVATION(local_z, nodes) \
266 local_z[0] = node[nodes[0]].z; \
267 local_z[1] = node[nodes[1]].z; \
268 local_z[2] = node[nodes[2]].z;
269
270#define ELEM1D_GET_ELEVATION(local_z, nodes) \
271 local_z[0] = node[nodes[0]].z; \
272 local_z[1] = node[nodes[1]].z;
273
274#define ELEM3D_GET_SUM(local) (local[0]+local[1]+local[2]+local[3])
275
276#define ELEM3D_GET_AVG(global, nodes) (0.25*(global[nodes[0]]+global[nodes[1]]+global[nodes[2]]+global[nodes[3]]))
277
278#define ELEM2D_GET_AVG(global, nodes) ((global[nodes[0]]+global[nodes[1]]+global[nodes[2]])/3.0)
279
280#define ELEM1D_GET_AVG(global, nodes) (0.5*(global[nodes[0]]+global[nodes[1]]))
281
282#define ELEM3D_ASSMB_M_1DOF(global, local, nodes) \
283 global[nodes[0]] -= local[0]; \
284 global[nodes[1]] -= local[1]; \
285 global[nodes[2]] -= local[2]; \
286 global[nodes[3]] -= local[3];
287
288#define ELEM2D_ASSMB_M_1DOF(global, local, nodes) \
289 global[nodes[0]] -= local[0]; \
290 global[nodes[1]] -= local[1]; \
291 global[nodes[2]] -= local[2];
292
293#define ELEM1D_ASSMB_M_1DOF(global, local, nodes) \
294 global[nodes[0]] -= local[0]; \
295 global[nodes[1]] -= local[1];
296
297#define ELEM3D_LOCAL_COPY(local1, local2) \
298 local2[0] = local1[0]; \
299 local2[1] = local1[1]; \
300 local2[2] = local1[2]; \
301 local2[3] = local1[3];
302
303#define ELEM2D_LOCAL_COPY(local1, local2) \
304 local2[0] = local1[0]; \
305 local2[1] = local1[1]; \
306 local2[2] = local1[2];
307
308#define ELEM1D_LOCAL_COPY(local1, local2) \
309 local2[0] = local1[0]; \
310 local2[1] = local1[1];
311
312#define ELEM3D_GET_VECT_SUM(local1, local2) \
313 local2.x = local1[0].x+local1[1].x+local1[2].x+local1[3].x; \
314 local2.y = local1[0].y+local1[1].y+local1[2].y+local1[3].y; \
315 local2.z = local1[0].z+local1[1].z+local1[2].z+local1[3].z;
316
317#define ELEM2D_GET_VECT_SUM(local1, local2) \
318 local2.x = local1[0].x+local1[1].x+local1[2].x; \
319 local2.y = local1[0].y+local1[1].y+local1[2].y; \
320 local2.z = local1[0].z+local1[1].z+local1[2].z;
321
322#define ELEM2D_GET_VECT2D_SUM(local1, local2) \
323 local2.x = local1[0].x+local1[1].x+local1[2].x; \
324 local2.y = local1[0].y+local1[1].y+local1[2].y;
325
326#define ELEM3D_VECT_DIFF(result,local1, local2) \
327 result[0].x = local1[0].x-local2[0].x; \
328 result[1].x = local1[1].x-local2[1].x; \
329 result[2].x = local1[2].x-local2[2].x; \
330 result[3].x = local1[3].x-local2[3].x; \
331 result[0].y = local1[0].y-local2[0].y; \
332 result[1].y = local1[1].y-local2[1].y; \
333 result[2].y = local1[2].y-local2[2].y; \
334 result[3].y = local1[3].y-local2[3].y; \
335 result[0].z = local1[0].z-local2[0].z; \
336 result[1].z = local1[1].z-local2[1].z; \
337 result[2].z = local1[2].z-local2[2].z; \
338 result[3].z = local1[3].z-local2[3].z;
339
340#define ELEM2D_VECT_DIFF(result,local1, local2) \
341 result[0].x = local1[0].x-local2[0].x; \
342 result[1].x = local1[1].x-local2[1].x; \
343 result[2].x = local1[2].x-local2[2].x; \
344 result[0].y = local1[0].y-local2[0].y; \
345 result[1].y = local1[1].y-local2[1].y; \
346 result[2].y = local1[2].y-local2[2].y; \
347 result[0].z = local1[0].z-local2[0].z; \
348 result[1].z = local1[1].z-local2[1].z; \
349 result[2].z = local1[2].z-local2[2].z;
350
351#define ELEM2D_VECT2D_SCALE(local,scale) \
352 local[0].x *= scale; \
353 local[0].y *= scale; \
354 local[1].x *= scale; \
355 local[1].y *= scale; \
356 local[2].x *= scale; \
357 local[2].y *= scale;
358
359#define ELEM3D_VECT_SCALE(local,scale) \
360 local[0].x *= scale; \
361 local[0].y *= scale; \
362 local[0].z *= scale; \
363 local[1].x *= scale; \
364 local[1].y *= scale; \
365 local[1].z *= scale; \
366 local[2].x *= scale; \
367 local[2].y *= scale; \
368 local[2].z *= scale; \
369 local[3].x *= scale; \
370 local[3].y *= scale; \
371 local[3].z *= scale;
372
373#define ELEM2D_VECT_SCALE(local,scale) \
374 local[0].x *= scale; \
375 local[0].y *= scale; \
376 local[0].z *= scale; \
377 local[1].x *= scale; \
378 local[1].y *= scale; \
379 local[1].z *= scale; \
380 local[2].x *= scale; \
381 local[2].y *= scale; \
382 local[2].z *= scale;
383
384#define ELEM1D_VECT_SCALE(local,scale) \
385 local[0].x *= scale; \
386 local[0].y *= scale; \
387 local[0].z *= scale; \
388 local[1].x *= scale; \
389 local[1].y *= scale; \
390 local[1].z *= scale;
391
392#define ELEM3D_SCALE(local,scale) \
393 local[0] *= scale; \
394 local[1] *= scale; \
395 local[2] *= scale; \
396 local[3] *= scale;
397
398#define ELEM2D_SCALE(local,scale) \
399 local[0] *= scale; \
400 local[1] *= scale; \
401 local[2] *= scale;
402
403#define ELEM1D_SCALE(local,scale) \
404 local[0] *= scale; \
405 local[1] *= scale;
406
407#define ELEM3D_LOCAL_VECT_COPY(local1, local2) \
408 local2[0].x = local1[0].x; \
409 local2[1].x = local1[1].x; \
410 local2[2].x = local1[2].x; \
411 local2[3].x = local1[3].x; \
412 local2[0].y = local1[0].y; \
413 local2[1].y = local1[1].y; \
414 local2[2].y = local1[2].y; \
415 local2[3].y = local1[3].y; \
416 local2[0].z = local1[0].z; \
417 local2[1].z = local1[1].z; \
418 local2[2].z = local1[2].z; \
419 local2[3].z = local1[3].z;
420
421#define ELEM2D_LOCAL_VECT2D_COPY(local1, local2) \
422 local2[0].x = local1[0].x; \
423 local2[1].x = local1[1].x; \
424 local2[2].x = local1[2].x; \
425 local2[0].y = local1[0].y; \
426 local2[1].y = local1[1].y; \
427 local2[2].y = local1[2].y;
428
429#define ELEM1D_LOCAL_VECT2D_COPY(local1, local2) \
430 local2[0].x = local1[0].x; \
431 local2[1].x = local1[1].x; \
432 local2[0].y = local1[0].y; \
433 local2[1].y = local1[1].y;
434
435#define ELEM2D_LOCAL_VECT_COPY(local1, local2) \
436 local2[0].x = local1[0].x; \
437 local2[1].x = local1[1].x; \
438 local2[2].x = local1[2].x; \
439 local2[0].y = local1[0].y; \
440 local2[1].y = local1[1].y; \
441 local2[2].y = local1[2].y; \
442 local2[0].z = local1[0].z; \
443 local2[1].z = local1[1].z; \
444 local2[2].z = local1[2].z;
445
446#define ELEM3D_LOCAL_DIFF(result, local1, local2) \
447 result[0] = local1[0]-local2[0]; \
448 result[1] = local1[1]-local2[1]; \
449 result[2] = local1[2]-local2[2]; \
450 result[3] = local1[3]-local2[3];
451
452#define ELEM2D_LOCAL_DIFF(result, local1, local2) \
453 result[0] = local1[0]-local2[0]; \
454 result[1] = local1[1]-local2[1]; \
455 result[2] = local1[2]-local2[2];
456
457#define ELEM1D_LOCAL_DIFF(result, local1, local2) \
458 result[0] = local1[0]-local2[0]; \
459 result[1] = local1[1]-local2[1];
460
461#define ELEM2D_LOCAL_ADD(result, local1, local2)\
462 result[0] = local1[0]+local2[0]; \
463 result[1] = local1[1]+local2[1]; \
464 result[2] = local1[2]+local2[2];
465
466#define ELEM1D_LOCAL_ADD(result, local1, local2) \
467 result[0] = local1[0]+local2[0]; \
468 result[1] = local1[1]+local2[1];
469
470
471#define ELEM3D_INIT_MAT_1DOF(emat) \
472 emat[ 0] = 1.0; emat[ 1] = 0.0; emat[ 2] = 0.0; emat[ 3] = 0.0; \
473 emat[ 4] = 0.0; emat[ 5] = 1.0; emat[ 6] = 0.0; emat[ 7] = 0.0; \
474 emat[ 8] = 0.0; emat[ 9] = 0.0; emat[10] = 1.0; emat[11] = 0.0; \
475 emat[12] = 0.0; emat[13] = 0.0; emat[14] = 0.0; emat[15] = 1.0;
476
477#define ELEM3D_ZERO_MAT_1DOF(emat) \
478 emat[ 0] = 0.0; emat[ 1] = 0.0; emat[ 2] = 0.0; emat[ 3] = 0.0; \
479 emat[ 4] = 0.0; emat[ 5] = 0.0; emat[ 6] = 0.0; emat[ 7] = 0.0; \
480 emat[ 8] = 0.0; emat[ 9] = 0.0; emat[10] = 0.0; emat[11] = 0.0; \
481 emat[12] = 0.0; emat[13] = 0.0; emat[14] = 0.0; emat[15] = 0.0;
482
483#define ELEM2D_INIT_MAT_1DOF(emat) \
484 emat[ 0] = 1.0; emat[ 1] = 0.0; emat[ 2] = 0.0; \
485 emat[ 3] = 0.0; emat[ 4] = 1.0; emat[ 5] = 0.0; \
486 emat[ 6] = 0.0; emat[ 7] = 0.0; emat[ 8] = 1.0;
487
488#define ELEM2D_ZERO_MAT_1DOF(emat) \
489 emat[ 0] = 0.0; emat[ 1] = 0.0; emat[ 2] = 0.0; \
490 emat[ 3] = 0.0; emat[ 4] = 0.0; emat[ 5] = 0.0; \
491 emat[ 6] = 0.0; emat[ 7] = 0.0; emat[ 8] = 0.0;
492
493#define ELEM2D_INIT_MAT_3DOF(emat) \
494 emat[ 0].x_eq = 1.0; emat[ 1].x_eq = 0.0; emat[ 2].x_eq = 0.0; \
495 emat[ 3].x_eq = 0.0; emat[ 4].x_eq = 1.0; emat[ 5].x_eq = 0.0; \
496 emat[ 6].x_eq = 0.0; emat[ 7].x_eq = 0.0; emat[ 8].x_eq = 1.0; \
497 emat[ 0].y_eq = 1.0; emat[ 1].y_eq = 0.0; emat[ 2].y_eq = 0.0; \
498 emat[ 3].y_eq = 0.0; emat[ 4].y_eq = 1.0; emat[ 5].y_eq = 0.0; \
499 emat[ 6].y_eq = 0.0; emat[ 7].y_eq = 0.0; emat[ 8].y_eq = 1.0; \
500 emat[ 0].c_eq = 1.0; emat[ 1].c_eq = 0.0; emat[ 2].c_eq = 0.0; \
501 emat[ 3].c_eq = 0.0; emat[ 4].c_eq = 1.0; emat[ 5].c_eq = 0.0; \
502 emat[ 6].c_eq = 0.0; emat[ 7].c_eq = 0.0; emat[ 8].c_eq = 1.0;
503
504#define ELEM3D_ZERO_MAT_3DOF(emat) \
505 emat[0].x_eq = 0.; emat[1].x_eq=0.; emat[2].x_eq=0.; emat[3].x_eq=0.; \
506 emat[4].x_eq = 0.; emat[5].x_eq=0.; emat[6].x_eq=0.; emat[7].x_eq=0.; \
507 emat[8].x_eq = 0.; emat[9].x_eq=0.; emat[10].x_eq=0.; emat[11].x_eq=0.; \
508 emat[12].x_eq = 0.; emat[13].x_eq=0.; emat[14].x_eq=0.; emat[15].x_eq=0.;\
509 emat[0].y_eq = 0.; emat[1].y_eq=0.; emat[2].y_eq=0.; emat[3].y_eq=0.; \
510 emat[4].y_eq = 0.; emat[5].y_eq=0.; emat[6].y_eq=0.; emat[7].y_eq=0.; \
511 emat[8].y_eq = 0.; emat[9].y_eq=0.; emat[10].y_eq=0.; emat[11].y_eq=0.; \
512 emat[12].y_eq = 0.; emat[13].y_eq=0.; emat[14].y_eq=0.; emat[15].y_eq=0.;\
513 emat[0].c_eq = 0.; emat[1].c_eq=0.; emat[2].c_eq=0.; emat[3].c_eq=0.; \
514 emat[4].c_eq = 0.; emat[5].c_eq=0.; emat[6].c_eq=0.; emat[7].c_eq=0.; \
515 emat[8].c_eq = 0.; emat[9].c_eq=0.; emat[10].c_eq=0.; emat[11].c_eq=0.; \
516 emat[12].c_eq = 0.; emat[13].c_eq=0.; emat[14].c_eq=0.; emat[15].c_eq=0.;
517
518#define ELEM2D_ZERO_MAT_3DOF(emat) \
519 emat[0].x_eq = 0.; emat[1].x_eq = 0.; emat[2].x_eq = 0.; \
520 emat[3].x_eq = 0.; emat[4].x_eq = 0.; emat[5].x_eq = 0.; \
521 emat[6].x_eq = 0.; emat[7].x_eq = 0.; emat[8].x_eq = 0.; \
522 emat[0].y_eq = 0.; emat[1].y_eq = 0.; emat[2].y_eq = 0.; \
523 emat[3].y_eq = 0.; emat[4].y_eq = 0.; emat[5].y_eq = 0.; \
524 emat[6].y_eq = 0.; emat[7].y_eq = 0.; emat[8].y_eq = 0.; \
525 emat[0].c_eq = 0.; emat[1].c_eq = 0.; emat[2].c_eq = 0.; \
526 emat[3].c_eq = 0.; emat[4].c_eq = 0.; emat[5].c_eq = 0.; \
527 emat[6].c_eq = 0.; emat[7].c_eq = 0.; emat[8].c_eq = 0.;
528
529#define ELEM1D_INIT_MAT_3DOF(emat) \
530 emat[ 0].x_eq = 1.0; emat[ 1].x_eq = 0.0; \
531 emat[ 2].x_eq = 0.0; emat[ 3].x_eq = 1.0; \
532 emat[ 0].y_eq = 1.0; emat[ 1].y_eq = 0.0; \
533 emat[ 2].y_eq = 0.0; emat[ 3].y_eq = 1.0; \
534 emat[ 0].c_eq = 1.0; emat[ 1].c_eq = 0.0; \
535 emat[ 2].c_eq = 0.0; emat[ 3].c_eq = 1.0;
536
537#define ELEM1D_INIT_MAT_1DOF(emat) \
538 emat[ 0] = 1.0; emat[ 1] = 0.0; \
539 emat[ 2] = 0.0; emat[ 3] = 1.0;
540
541#define ELEM3D_DERIV_1DOF(emat, local1, local2, index, diff_ep) \
542 emat[ index] = (local1[0]-local2[0])/diff_ep; \
543 emat[ 4+index] = (local1[1]-local2[1])/diff_ep; \
544 emat[ 8+index] = (local1[2]-local2[2])/diff_ep; \
545 emat[12+index] = (local1[3]-local2[3])/diff_ep;
546
547#define ELEM3D_DERIV_3DOF(emat, local1, local2, index, diff_ep) \
548 emat[ index].x_eq = (local1[0].x_eq-local2[0].x_eq)/diff_ep; \
549 emat[ 4+index].x_eq = (local1[1].x_eq-local2[1].x_eq)/diff_ep; \
550 emat[ 8+index].x_eq = (local1[2].x_eq-local2[2].x_eq)/diff_ep; \
551 emat[12+index].x_eq = (local1[3].x_eq-local2[3].x_eq)/diff_ep; \
552 emat[ index].y_eq = (local1[0].y_eq-local2[0].y_eq)/diff_ep; \
553 emat[ 4+index].y_eq = (local1[1].y_eq-local2[1].y_eq)/diff_ep; \
554 emat[ 8+index].y_eq = (local1[2].y_eq-local2[2].y_eq)/diff_ep; \
555 emat[12+index].y_eq = (local1[3].y_eq-local2[3].y_eq)/diff_ep; \
556 emat[ index].c_eq = (local1[0].c_eq-local2[0].c_eq)/diff_ep; \
557 emat[ 4+index].c_eq = (local1[1].c_eq-local2[1].c_eq)/diff_ep; \
558 emat[ 8+index].c_eq = (local1[2].c_eq-local2[2].c_eq)/diff_ep; \
559 emat[12+index].c_eq = (local1[3].c_eq-local2[3].c_eq)/diff_ep;
560
561#define ELEM3D_DERIV_3DOF_2(emat, local1, local2, index, diff_ep_inv) \
562 emat[ index].x_eq = diff_ep_inv * (local1[0].x_eq-local2[0].x_eq); \
563 emat[ 4+index].x_eq = diff_ep_inv * (local1[1].x_eq-local2[1].x_eq); \
564 emat[ 8+index].x_eq = diff_ep_inv * (local1[2].x_eq-local2[2].x_eq); \
565 emat[12+index].x_eq = diff_ep_inv * (local1[3].x_eq-local2[3].x_eq); \
566 emat[ index].y_eq = diff_ep_inv * (local1[0].y_eq-local2[0].y_eq); \
567 emat[ 4+index].y_eq = diff_ep_inv * (local1[1].y_eq-local2[1].y_eq); \
568 emat[ 8+index].y_eq = diff_ep_inv * (local1[2].y_eq-local2[2].y_eq); \
569 emat[12+index].y_eq = diff_ep_inv * (local1[3].y_eq-local2[3].y_eq); \
570 emat[ index].c_eq = diff_ep_inv * (local1[0].c_eq-local2[0].c_eq); \
571 emat[ 4+index].c_eq = diff_ep_inv * (local1[1].c_eq-local2[1].c_eq); \
572 emat[ 8+index].c_eq = diff_ep_inv * (local1[2].c_eq-local2[2].c_eq); \
573 emat[12+index].c_eq = diff_ep_inv * (local1[3].c_eq-local2[3].c_eq);
574
575#define ELEM2D_DERIV_1DOF(emat, local1, local2, index, diff_ep) \
576 emat[ index] = (local1[0]-local2[0])/diff_ep; \
577 emat[ 3+index] = (local1[1]-local2[1])/diff_ep; \
578 emat[ 6+index] = (local1[2]-local2[2])/diff_ep;
579
580#define ELEM2D_DERIV_3DOF(emat, local1, local2, index, diff_ep) \
581 emat[ index].x_eq = (local1[0].x_eq-local2[0].x_eq)/diff_ep; \
582 emat[ 3+index].x_eq = (local1[1].x_eq-local2[1].x_eq)/diff_ep; \
583 emat[ 6+index].x_eq = (local1[2].x_eq-local2[2].x_eq)/diff_ep; \
584 emat[ index].y_eq = (local1[0].y_eq-local2[0].y_eq)/diff_ep; \
585 emat[ 3+index].y_eq = (local1[1].y_eq-local2[1].y_eq)/diff_ep; \
586 emat[ 6+index].y_eq = (local1[2].y_eq-local2[2].y_eq)/diff_ep; \
587 emat[ index].c_eq = (local1[0].c_eq-local2[0].c_eq)/diff_ep; \
588 emat[ 3+index].c_eq = (local1[1].c_eq-local2[1].c_eq)/diff_ep; \
589 emat[ 6+index].c_eq = (local1[2].c_eq-local2[2].c_eq)/diff_ep;
590
591#define ELEM1D_DERIV_3DOF(emat, local1, local2, index, diff_ep) \
592 emat[ index].x_eq = (local1[0].x_eq-local2[0].x_eq)/diff_ep; \
593 emat[ 2+index].x_eq = (local1[1].x_eq-local2[1].x_eq)/diff_ep; \
594 emat[ index].y_eq = (local1[0].y_eq-local2[0].y_eq)/diff_ep; \
595 emat[ 2+index].y_eq = (local1[1].y_eq-local2[1].y_eq)/diff_ep; \
596 emat[ index].c_eq = (local1[0].c_eq-local2[0].c_eq)/diff_ep; \
597 emat[ 2+index].c_eq = (local1[1].c_eq-local2[1].c_eq)/diff_ep;
598
599#define ELEM1D_DERIV_1DOF(emat, local1, local2, index, diff_ep) \
600 emat[ index] = (local1[0]-local2[0])/diff_ep; \
601 emat[ 2+index] = (local1[1]-local2[1])/diff_ep;
602
603#define ELEM1D_LOCAL_INIT_DBL(local) local[0] = 0.0; local[1] = 0.0;
604
605#define ELEM2D_LOCAL_INIT_DBL(local) local[0] = 0.0; local[1] = 0.0; local[2] = 0.0;
606
607#define ELEM2D_LOCAL_INIT_INT(local) local[0] = 0; local[1] = 0; local[2] = 0;
608
609#define ELEM3D_LOCAL_INIT_INT(local) local[0] = 0; local[1] = 0; local[2] = 0; local[3] = 0;
610
611#define ELEM3D_LOCAL_INIT_DBL(local) local[0] = 0.0; local[1] = 0.0; local[2] = 0.0; local[3] = 0.0;
612
613#define ELEM3D_LOCAL_QUAD_INIT_DBL(local) local[0] = 0.0; local[1] = 0.0; local[2] = 0.0; local[3] = 0.0; \
614 local[4] = 0.0; local[5] = 0.0; local[6] = 0.0; local[7] = 0.0; local[8] = 0.0; local[9] = 0.0;
615
616#define ELEM1D_LOCAL_INIT_IDNT_DBL(local) local[0]=1.; local[1]=1.;
617
618#define ELEM2D_LOCAL_INIT_IDNT_DBL(local) local[0]=1.; local[1]=1.; local[2]=1.;
619
620#define ELEM3D_LOCAL_INIT_IDNT_DBL(local) local[0]=1.; local[1]=1.; local[2]=1.; local[3]=1.;
621
622#define ELEM3D_LOCAL_INIT_4DOF(local) local[0].x_eq=0.; local[0].y_eq=0.; local[0].z_eq=0.; local[0].c_eq=0.; \
623 local[1].x_eq=0.; local[1].y_eq=0.; local[1].z_eq=0.; local[1].c_eq=0.; \
624 local[2].x_eq=0.; local[2].y_eq=0.; local[2].z_eq=0.; local[2].c_eq=0.; \
625 local[3].x_eq=0.; local[3].y_eq=0.; local[3].z_eq=0.; local[3].c_eq=0.;
626
627#define ELEM2D_LOCAL_INIT_3DOF(local) local[0].x_eq=0.; local[0].y_eq=0.; local[0].c_eq=0.; \
628 local[1].x_eq=0.; local[1].y_eq=0.; local[1].c_eq=0.; \
629 local[2].x_eq=0.; local[2].y_eq=0.; local[2].c_eq=0.;
630
631#define ELEM1D_LOCAL_INIT_3DOF(local) local[0].x_eq=0.; local[0].y_eq=0.; local[0].c_eq=0.; \
632 local[1].x_eq=0.; local[1].y_eq=0.; local[1].c_eq=0.;
633
634#define ELEM3D_LOCAL_INIT_2DOF(local) local[0].x_eq=0.; local[0].y_eq=0.; \
635 local[1].x_eq=0.; local[1].y_eq=0.; \
636 local[2].x_eq=0.; local[2].y_eq=0.; \
637 local[3].x_eq=0.; local[3].y_eq=0.;
638
639#define ELEM3D_LOCAL_INIT_3DOF(local) local[0].x_eq=0.; local[0].y_eq=0.; local[0].c_eq=0.; \
640 local[1].x_eq=0.; local[1].y_eq=0.; local[1].c_eq=0.; \
641 local[2].x_eq=0.; local[2].y_eq=0.; local[2].c_eq=0.; \
642 local[3].x_eq=0.; local[3].y_eq=0.; local[3].c_eq=0.;
643
644#define ELEM3D_LOCAL_INIT_VECT(local) local[0].x=0.; local[0].y=0.; local[0].z=0.; \
645 local[1].x=0.; local[1].y=0.; local[1].z=0.; \
646 local[2].x=0.; local[2].y=0.; local[2].z=0.; \
647 local[3].x=0.; local[3].y=0.; local[3].z=0.;
648
649#define ELEM3D_LOCAL_INIT_VECT2D(local) local[0].x=0.; local[0].y=0.; \
650 local[1].x=0.; local[1].y=0.; \
651 local[2].x=0.; local[2].y=0.; \
652 local[3].x=0.; local[3].y=0.;
653
654#define ELEM2D_LOCAL_INIT_VECT(local) local[0].x=0.; local[0].y=0.; local[0].z=0.; \
655 local[1].x=0.; local[1].y=0.; local[1].z=0.; \
656 local[2].x=0.; local[2].y=0.; local[2].z=0.;
657
658#define ELEM2D_LOCAL_INIT_VECT2D(local) local[0].x = 0.; local[0].y = 0.; \
659 local[1].x = 0.; local[1].y = 0.; local[2].x = 0.; local[2].y = 0.;
660
661#define ELEM2D_LOCAL_INIT_TENSOR2D(local) local[0].xx = 0.; local[0].xy = 0.; local[0].yy = 0.; \
662 local[1].xx = 0.; local[1].xy = 0.; local[1].yy = 0.; \
663 local[2].xx = 0.; local[2].xy = 0.; local[2].yy = 0.;
664
665#define ELEM2D_INTGRT_DBLDBL(local1,local2) (local1[0]*local2[0]+local1[1]*local2[1]+local1[2]*local2[2]+ \
666 (local1[0]+local1[1]+local1[2])*(local2[0]+local2[1]+local2[2]))/12.
667
668/* in NUM_DIFF_EPSILON we scale by nodal variable */
669#define NUM_DIFF_EPSILON(diff_ep, diff_ep2, var, perturbation) \
670 diff_ep = fabs(var)*(1.+perturbation); \
671 diff_ep -= fabs(var); \
672 if(diff_ep <perturbation ) diff_ep=perturbation; \
673 diff_ep2 = 2.0*diff_ep;
674
675/* NUM_DIFF_EPSILON_GENERAL we scale by nodla variable and user specified fraction */
676#define NUM_DIFF_EPSILON_GENERAL(diff_ep, diff_ep2, var1, var2) \
677 diff_ep = fabs(var1)*(1.+var2); \
678 diff_ep -= fabs(var1); \
679 if(diff_ep < var2 ) diff_ep=var2; \
680 diff_ep2 = 2.0*diff_ep;
681
682#define MAX_ON_ELEMENT(local,var); \
683 var = fabs(local[0]); \
684 if(fabs(local[1])>var)var=fabs(local[1]); \
685 if(fabs(local[2])>var)var=fabs(local[2]); \
686 if(fabs(local[3])>var)var=fabs(local[3]);
687
688#define MAX_ON_FACE(local,var); \
689 var = fabs(local[0]); \
690 if(fabs(local[1])>var)var=fabs(local[1]); \
691 if(fabs(local[2])>var)var=fabs(local[2]);
692
693#define VT_3D_TCOPY(tens, target) \
694 target.xx = tens.xx; \
695 target.yy = tens.yy; \
696 target.zz = tens.zz; \
697 target.xy = tens.xy; \
698 target.xz = tens.xz; \
699 target.yz = tens.yz;
700
701#define VT_3D_VCOPY(vect, target) \
702 target.x = vect.x; \
703 target.y = vect.y; \
704 target.z = vect.z;
705
706#define VT_3D_INIT(vect) \
707 vect.x = DZERO; \
708 vect.y = DZERO; \
709 vect.z = DZERO;
710
711#define VT_1D_DOT(v1, v2) (v1*v2)
712
713#define VT_2D_DOT(v1, v2) (v1.x*v2.x+v1.y*v2.y)
714
715#define VT_3D_DOT(v1, v2) (v1.x*v2.x+v1.y*v2.y+v1.z*v2.z)
716
717#define VT_3D_TENS_VECT_PROD(result, tens, vect) \
718 result.x = tens.xx*vect.x+tens.xy*vect.y+tens.xz*vect.z; \
719 result.y = tens.xy*vect.x+tens.yy*vect.y+tens.yz*vect.z; \
720 result.z = tens.xz*vect.x+tens.yz*vect.y+tens.zz*vect.z;
721
722#define VT_2D_TENS2D_VECT2D_PROD(result, tens, vect) \
723 result.x = tens.xx*vect.x+tens.xy*vect.y; \
724 result.y = tens.xy*vect.x+tens.yy*vect.y;
725
726#define VT_2D_TENS2D_VECT2D_PROD_AI(result, tens, vect, vdir) \
727 result.x = tens.xx*vdir.x*(vdir.x*vect.x+vdir.y*vect.y) + tens.xy*vect.x; \
728 result.y = tens.yy*vdir.y*(vdir.x*vect.x+vdir.y*vect.y) + tens.xy*vect.y;
729
730#define VT_3D_TSCALE(tens, scale) \
731 tens.xx *= scale; \
732 tens.xy *= scale; \
733 tens.xz *= scale; \
734 tens.yy *= scale; \
735 tens.yz *= scale; \
736 tens.zz *= scale;
737
738#define VT_3D_VSCALE(vect, scale) \
739 vect.x *= scale; \
740 vect.y *= scale; \
741 vect.z *= scale; \
742
743#define VT_3D_TSIGN(tens) \
744 tens.xx = -tens.xx; \
745 tens.xy = -tens.xy; \
746 tens.xz = -tens.xz; \
747 tens.yy = -tens.yy; \
748 tens.yz = -tens.yz; \
749 tens.zz = -tens.zz;
750
751#define VT_3D_VSIGN(vect) \
752 vect.x = -vect.x; \
753 vect.y = -vect.y; \
754 vect.z = -vect.z; \
755
756#define FIXED_POS(loc1,loc2,weight,new_loc)\
757{\
758 new_loc = loc1 + weight*(loc2-loc1);\
759}
760
761#define DIR_LENGTH(loc1,loc2) (loc1-loc2)
762
763#define DIR_LENGTH_VEC(v0,v1,v2,vec99) \
764{ \
765 vec99[0].x=DIR_LENGTH(v1.x,v0.x); \
766 vec99[0].y=DIR_LENGTH(v1.y,v0.y); \
767 vec99[1].x=DIR_LENGTH(v2.x,v0.x); \
768 vec99[1].y=DIR_LENGTH(v2.y,v0.y); \
769}
770
771#define TRI_AREA(v0,v1,v2,area) \
772{ \
773 SVECT2D vec[2]; \
774 DIR_LENGTH_VEC(v0,v1,v2,vec); \
775 area = (vec[0].x*vec[1].y-vec[0].y*vec[1].x)/2.0; \
776}
777
778#define GRAD_SHAPE(v0,v1,v2,area99,grad99) \
779{ \
780 grad99[0].x = 0.5*(v1.y-v2.y)/area99; \
781 grad99[1].x = 0.5*(v2.y-v0.y)/area99; \
782 grad99[2].x = 0.5*(v0.y-v1.y)/area99; \
783 grad99[0].y = 0.5*(v2.x-v1.x)/area99; \
784 grad99[1].y = 0.5*(v0.x-v2.x)/area99; \
785 grad99[2].y = 0.5*(v1.x-v0.x)/area99; \
786}
787
788#define RE_DISTRIBUTE(x99,new_x99,new_elem_rhs99,only99) \
789{ \
790 int i99, j99; \
791 double xsi99, l99[2]; \
792 SVECT2D vec[2]; \
793 for(i99=0;i99<3;i99++) { \
794 if(i99==only99) continue; \
795 DIR_LENGTH_VEC(x99[only99],new_x99[i99],x99[i99],vec); \
796 for(j99=0;j99<2;j99++) \
797 l99[j99] = vec[j99].x*vec[j99].x + vec[j99].y*vec[j99].y; \
798 xsi99 = sqrt(l99[0]/l99[1]); \
799 new_elem_rhs99[only99*3] += (1.0-xsi99) * new_elem_rhs99[i99*3]; \
800 new_elem_rhs99[only99*3+1] += (1.0-xsi99) * new_elem_rhs99[i99*3+1]; \
801 new_elem_rhs99[only99*3+2] += (1.0-xsi99) * new_elem_rhs99[i99*3+2]; \
802 new_elem_rhs99[i99*3] *= xsi99; \
803 new_elem_rhs99[i99*3+1] *= xsi99; \
804 new_elem_rhs99[i99*3+2] *= xsi99; \
805 } \
806}
807#define RE_DISTRIBUTE_1D(x99,new_x99,new_elem_rhs99,only99) \
808{ \
809 int i99, j99; \
810 double xsi99, l99[2]; \
811 SVECT2D vec[2]; \
812 for(i99=0;i99<2;i99++) { \
813 if(i99==only99) continue; \
814 DIR_LENGTH_VEC(x99[only99],new_x99[i99],x99[i99],vec); \
815 for(j99=0;j99<2;j99++) \
816 l99[j99] = vec[j99].x*vec[j99].x + vec[j99].y*vec[j99].y; \
817 xsi99 = sqrt(l99[0]/l99[1]); \
818 new_elem_rhs99[only99*3] += (1.0-xsi99) * new_elem_rhs99[i99*3]; \
819 new_elem_rhs99[only99*3+1] += (1.0-xsi99) * new_elem_rhs99[i99*3+1]; \
820 new_elem_rhs99[only99*3+2] += (1.0-xsi99) * new_elem_rhs99[i99*3+2]; \
821 new_elem_rhs99[i99*3] *= xsi99; \
822 new_elem_rhs99[i99*3+1] *= xsi99; \
823 new_elem_rhs99[i99*3+2] *= xsi99; \
824 } \
825}
826#define RE_DISTRIBUTE_RES(x99,new_x99,new_elem_rhs99,only99) \
827{ \
828 int i99, j99; \
829 double xsi99, l99[2]; \
830 SVECT2D vec[2]; \
831 for(i99=0;i99<3;i99++) { \
832 if(i99==only99) continue; \
833 DIR_LENGTH_VEC(x99[only99],new_x99[i99],x99[i99],vec); \
834 for(j99=0;j99<2;j99++) \
835 l99[j99] = vec[j99].x*vec[j99].x + vec[j99].y*vec[j99].y; \
836 xsi99 = sqrt(l99[0]/l99[1]); \
837 new_elem_rhs99[only99] += (1.0-xsi99) * new_elem_rhs99[i99]; \
838 new_elem_rhs99[i99] *= xsi99; \
839 } \
840}
841
842#define IS_ABOUT(a,b,c) (a<(1.+c/100.)*b && a>(1.-c/100.)*b ? 1 : 0)
843
844#define MIN(a,b) (a < b ? a : b)
845#define MAX(a,b) \
846 ({ __typeof__ (a) _a = (a); \
847 __typeof__ (b) _b = (b); \
848 _a > _b ? _a : _b; })
849
850#define IS_OVER_UPPER_BOUND(a,b) (a >= b ? 1 : 0)
851
852#define IS_BELOW_LOWER_BOUND(a,b) (a <= b ? 1 : 0)
853
854#define IS_BTWN_BOUNDS(val,low,up) ((((low) < (val)) && ((val) < (up))) ? 1 : 0)
855
856#define IS_OUT_BOUNDS(val,low,up) (((val) < (low) || (up) < (val)) ? 1 : 0)
857
858#define IS_WTHN_BOUNDS(val,low,up) ((val) >= (low) ? ((val) <= (up) ? 1 : 0) : 0)
859
860#define CELL_AVG(a) ((a[0]+a[1]+a[2])/3.0)
861
862#define CELL_AVG_X(a) ((a[0].x+a[1].x+a[2].x)/3.0)
863
864#define CELL_AVG_Y(a) ((a[0].y+a[1].y+a[2].y)/3.0)
865
866#define DIST_2D(a,b) sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))
867
868#define DIST_3D(a,b) sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z))
869
870#define POS_IP(result,src1,src2) \
871{ \
872 result = src1[0] * src2[0]; \
873 result += src1[1] * src2[1]; \
874}
875
876#define POS_NORM(result,src) \
877{ \
878 POS_IP(result, src, src); \
879 result = sqrt(result); \
880}
881
882/* macros for debugging/diagnostics */
883#define DEBUG_GENERAL (mask_debug & 15)
884#define DEBUG_SOLV ((mask_debug>>4) & 15)
885#define DEBUG_FE ((mask_debug>>8) & 15)
886#define DEBUG_GRID ((mask_debug>>12) & 15)
887#define DEBUG_COMM ((mask_debug>>16) & 15)
888#define DEBUG_ELEM ((mask_debug>>20) & 15)
889#define DEBUG_NODE ((mask_debug>>24) & 15)
890#define DEBUG_OTHER ((mask_debug>>28) & 15)