1 // GetDP - Copyright (C) 1997-2021 P. Dular and C. Geuzaine, University of Liege
2 //
3 // See the LICENSE.txt file for license information. Please report all
4 // issues on https://gitlab.onelab.info/getdp/getdp/issues.
5
6 #include <stdlib.h>
7 #include "GetDPConfig.h"
8 #include "ProData.h"
9 #include "BF.h"
10 #include "Message.h"
11
12 #if defined(HAVE_KERNEL)
13 #include "Get_Geometry.h"
14 #endif
15
16 #define ARGS \
17 struct Element * Element, int NumGroup, \
18 double u, double v, double w, double *s
19
20 void BF_SubFunction(struct Element * Element, int NumExpression,
21 int Dim, double s[]);
22
23 /* ------------------------------------------------------------------------ */
24 /* B F _ G r o u p O f N o d e s */
25 /* ------------------------------------------------------------------------ */
26
27 #define BF(BF_GroupOfNodes_X,BF_Node_X) \
28 int i ; \
29 double val ; \
30 \
31 *s = 0. ; \
32 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
33 (BF_Node_X) \
34 (Element, Element->NumEntitiesInGroups[NumGroup-1][i], u, v, w, &val) ; \
35 *s += val ; \
36 } \
37 \
38 if (Element->NumSubFunction[0][NumGroup-1] >= 0) \
39 BF_SubFunction(Element, Element->NumSubFunction[0][NumGroup-1], 1, s) ;
40
BF_GroupOfNodes(ARGS)41 void BF_GroupOfNodes(ARGS) { BF("BF_GroupOfNodes",BF_Node) ; }
BF_GroupOfNodes_2E(ARGS)42 void BF_GroupOfNodes_2E(ARGS) { BF("BF_GroupOfNodes_2E",BF_Node_2E) ; }
BF_GroupOfNodes_2F(ARGS)43 void BF_GroupOfNodes_2F(ARGS) { BF("BF_GroupOfNodes_2F",BF_Node_2F) ; }
BF_GroupOfNodes_2V(ARGS)44 void BF_GroupOfNodes_2V(ARGS) { BF("BF_GroupOfNodes_2V",BF_Node_2V) ; }
BF_GroupOfNodes_3E(ARGS)45 void BF_GroupOfNodes_3E(ARGS) { BF("BF_GroupOfNodes_3E",BF_Node_3E) ; }
BF_GroupOfNodes_3F(ARGS)46 void BF_GroupOfNodes_3F(ARGS) { BF("BF_GroupOfNodes_3F",BF_Node_3F) ; }
BF_GroupOfNodes_3V(ARGS)47 void BF_GroupOfNodes_3V(ARGS) { BF("BF_GroupOfNodes_3V",BF_Node_3V) ; }
48
49 #undef BF
50
51 /* ------------------------------------------------------------------------ */
52 /* B F _ G r a d G r o u p O f N o d e s */
53 /* ------------------------------------------------------------------------ */
54
55 #define BF(BF_GradGroupOfNodes_X,BF_GradNode_X) \
56 int i ; \
57 double val[3] ; \
58 \
59 s[0] = s[1] = s[2] = 0. ; \
60 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
61 (BF_GradNode_X) \
62 (Element, Element->NumEntitiesInGroups[NumGroup-1][i], u, v, w, val) ; \
63 s[0] += val[0] ; s[1] += val[1] ; s[2] += val[2] ; \
64 } \
65 \
66 if (Element->NumSubFunction[0][NumGroup-1] >= 0) \
67 BF_SubFunction(Element, Element->NumSubFunction[0][NumGroup-1], 3, s) ;
68
BF_GradGroupOfNodes(ARGS)69 void BF_GradGroupOfNodes (ARGS) { BF("BF_GradGroupOfNodes",BF_GradNode) ; }
BF_GradGroupOfNodes_2E(ARGS)70 void BF_GradGroupOfNodes_2E(ARGS) { BF("BF_GradGroupOfNodes_2E",BF_GradNode_2E) ; }
BF_GradGroupOfNodes_2F(ARGS)71 void BF_GradGroupOfNodes_2F(ARGS) { BF("BF_GradGroupOfNodes_2F",BF_GradNode_2F) ; }
BF_GradGroupOfNodes_2V(ARGS)72 void BF_GradGroupOfNodes_2V(ARGS) { BF("BF_GradGroupOfNodes_2V",BF_GradNode_2V) ; }
BF_GradGroupOfNodes_3E(ARGS)73 void BF_GradGroupOfNodes_3E(ARGS) { BF("BF_GradGroupOfNodes_3E",BF_GradNode_3E) ; }
BF_GradGroupOfNodes_3F(ARGS)74 void BF_GradGroupOfNodes_3F(ARGS) { BF("BF_GradGroupOfNodes_3F",BF_GradNode_3F) ; }
BF_GradGroupOfNodes_3V(ARGS)75 void BF_GradGroupOfNodes_3V(ARGS) { BF("BF_GradGroupOfNodes_3V",BF_GradNode_3V) ; }
76
77 #undef BF
78
79 /* ------------------------------------------------------------------------ */
80 /* B F _ G r o u p O f P e r p e n d i c u l a r E d g e s */
81 /* ------------------------------------------------------------------------ */
82
83 #define BF(BF_GroupOfPerpendicularEdges_X,BF_Node_X) \
84 int i ; \
85 double val ; \
86 \
87 s[0] = s[1] = s[2] = 0. ; \
88 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
89 (BF_Node_X) \
90 (Element, Element->NumEntitiesInGroups[NumGroup-1][i], u, v, w, &val) ; \
91 s[2] += val ; \
92 } \
93 \
94 if (Element->NumSubFunction[0][NumGroup-1] >= 0) \
95 BF_SubFunction(Element, Element->NumSubFunction[0][NumGroup-1], 3, s) ;
96
BF_GroupOfPerpendicularEdges(ARGS)97 void BF_GroupOfPerpendicularEdges (ARGS){ BF("BF_GroupOfPerpendicularEdges",BF_Node) ; }
BF_GroupOfPerpendicularEdges_2E(ARGS)98 void BF_GroupOfPerpendicularEdges_2E(ARGS){ BF("BF_GroupOfPerpendicularEdges_2E",BF_Node_2E) ; }
BF_GroupOfPerpendicularEdges_2F(ARGS)99 void BF_GroupOfPerpendicularEdges_2F(ARGS){ BF("BF_GroupOfPerpendicularEdges_2F",BF_Node_2F) ; }
BF_GroupOfPerpendicularEdges_2V(ARGS)100 void BF_GroupOfPerpendicularEdges_2V(ARGS){ BF("BF_GroupOfPerpendicularEdges_2V",BF_Node_2V) ; }
BF_GroupOfPerpendicularEdges_3E(ARGS)101 void BF_GroupOfPerpendicularEdges_3E(ARGS){ BF("BF_GroupOfPerpendicularEdges_3E",BF_Node_3E) ; }
BF_GroupOfPerpendicularEdges_3F(ARGS)102 void BF_GroupOfPerpendicularEdges_3F(ARGS){ BF("BF_GroupOfPerpendicularEdges_3F",BF_Node_3F) ; }
BF_GroupOfPerpendicularEdges_3V(ARGS)103 void BF_GroupOfPerpendicularEdges_3V(ARGS){ BF("BF_GroupOfPerpendicularEdges_3V",BF_Node_3V) ; }
104
105 #undef BF
106
107 /* ------------------------------------------------------------------------ */
108 /* B F _ C u r l G r o u p O f P e r p e n d i c u l a r E d g e s */
109 /* ------------------------------------------------------------------------ */
110
111 #define BF(BF_CurlGroupOfPerpendicularEdges_X,BF_GradNode_X) \
112 int i ; \
113 double val[3] ; \
114 \
115 s[0] = s[1] = s[2] = 0. ; \
116 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
117 (BF_GradNode_X) \
118 (Element, Element->NumEntitiesInGroups[NumGroup-1][i], u, v, w, val) ; \
119 s[0] += val[1] ; s[1] += -val[0] ; \
120 } \
121 \
122 if (Element->NumSubFunction[0][NumGroup-1] >= 0) \
123 BF_SubFunction(Element, Element->NumSubFunction[0][NumGroup-1], 3, s) ;
124
BF_CurlGroupOfPerpendicularEdges(ARGS)125 void BF_CurlGroupOfPerpendicularEdges (ARGS){ BF("BF_CurlGroupOfPerpendicularEdges",BF_GradNode) ; }
BF_CurlGroupOfPerpendicularEdges_2E(ARGS)126 void BF_CurlGroupOfPerpendicularEdges_2E(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_2E",BF_GradNode_2E) ; }
BF_CurlGroupOfPerpendicularEdges_2F(ARGS)127 void BF_CurlGroupOfPerpendicularEdges_2F(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_2F",BF_GradNode_2F) ; }
BF_CurlGroupOfPerpendicularEdges_2V(ARGS)128 void BF_CurlGroupOfPerpendicularEdges_2V(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_2V",BF_GradNode_2V) ; }
BF_CurlGroupOfPerpendicularEdges_3E(ARGS)129 void BF_CurlGroupOfPerpendicularEdges_3E(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_3E",BF_GradNode_3E) ; }
BF_CurlGroupOfPerpendicularEdges_3F(ARGS)130 void BF_CurlGroupOfPerpendicularEdges_3F(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_3F",BF_GradNode_3F) ; }
BF_CurlGroupOfPerpendicularEdges_3V(ARGS)131 void BF_CurlGroupOfPerpendicularEdges_3V(ARGS){ BF("BF_CurlGroupOfPerpendicularEdges_3V",BF_GradNode_3V) ; }
132
133 #undef BF
134
135 /* ------------------------------------------------------------------------ */
136 /* B F _ G r o u p O f E d g e s */
137 /* ------------------------------------------------------------------------ */
138
139 #define BF(BF_GroupOfEdges_X,BF_Edge_X) \
140 int i, Num ; \
141 double val[3] ; \
142 \
143 s[0] = s[1] = s[2] = 0. ; \
144 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
145 (BF_Edge_X) \
146 (Element, abs(Num = Element->NumEntitiesInGroups[NumGroup-1][i]), \
147 u, v, w, val) ; \
148 if (Num > 0) { s[0] += val[0] ; s[1] += val[1] ; s[2] += val[2] ; } \
149 else { s[0] -= val[0] ; s[1] -= val[1] ; s[2] -= val[2] ; } \
150 }
151
152
BF_GroupOfEdges(ARGS)153 void BF_GroupOfEdges (ARGS){ BF("BF_GroupOfEdges",BF_Edge) ; }
BF_GroupOfEdges_2E(ARGS)154 void BF_GroupOfEdges_2E(ARGS){ BF("BF_GroupOfEdges_2E",BF_Edge_2E) ; }
BF_GroupOfEdges_2F(ARGS)155 void BF_GroupOfEdges_2F(ARGS){ BF("BF_GroupOfEdges_2F",BF_Edge_2F) ; }
BF_GroupOfEdges_2V(ARGS)156 void BF_GroupOfEdges_2V(ARGS){ BF("BF_GroupOfEdges_2V",BF_Edge_2V) ; }
BF_GroupOfEdges_3E(ARGS)157 void BF_GroupOfEdges_3E(ARGS){ BF("BF_GroupOfEdges",BF_Edge_3E) ; }
BF_GroupOfEdges_3F_a(ARGS)158 void BF_GroupOfEdges_3F_a(ARGS){ BF("BF_GroupOfEdges_3F_a",BF_Edge_3F_a) ; }
BF_GroupOfEdges_3F_b(ARGS)159 void BF_GroupOfEdges_3F_b(ARGS){ BF("BF_GroupOfEdges_3F_b", BF_Edge_3F_b) ; }
BF_GroupOfEdges_3F_c(ARGS)160 void BF_GroupOfEdges_3F_c(ARGS){ BF("BF_GroupOfEdges_3F_c", BF_Edge_3F_c) ; }
BF_GroupOfEdges_3V(ARGS)161 void BF_GroupOfEdges_3V(ARGS){ BF("BF_GroupOfEdges_3V",BF_Edge_3V) ; }
BF_GroupOfEdges_4E(ARGS)162 void BF_GroupOfEdges_4E(ARGS){ BF("BF_GroupOfEdges_4E",BF_Edge_4E) ; }
BF_GroupOfEdges_4F(ARGS)163 void BF_GroupOfEdges_4F(ARGS){ BF("BF_GroupOfEdges_4F",BF_Edge_4F) ; }
BF_GroupOfEdges_4V(ARGS)164 void BF_GroupOfEdges_4V(ARGS){ BF("BF_GroupOfEdges_4V",BF_Edge_4V) ; }
165
166 #undef BF
167
168 /* ------------------------------------------------------------------------ */
169 /* B F _ C u r l G r o u p O f E d g e s */
170 /* ------------------------------------------------------------------------ */
171
172 #define BF(BF_CurlGroupOfEdges_X,BF_CurlEdge_X) \
173 int i, Num ; \
174 double val[3] ; \
175 \
176 s[0] = s[1] = s[2] = 0. ; \
177 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
178 (BF_CurlEdge_X) \
179 (Element, abs(Num = Element->NumEntitiesInGroups[NumGroup-1][i]), \
180 u, v, w, val) ; \
181 if (Num > 0) { s[0] += val[0] ; s[1] += val[1] ; s[2] += val[2] ; } \
182 else { s[0] -= val[0] ; s[1] -= val[1] ; s[2] -= val[2] ; } \
183 }
184
BF_CurlGroupOfEdges(ARGS)185 void BF_CurlGroupOfEdges(ARGS){ BF("BF_CurlGroupOfEdges",BF_CurlEdge) ; }
BF_CurlGroupOfEdges_2E(ARGS)186 void BF_CurlGroupOfEdges_2E(ARGS){ BF("BF_CurlGroupOfEdges_2E",BF_CurlEdge_2E) ; }
BF_CurlGroupOfEdges_2F(ARGS)187 void BF_CurlGroupOfEdges_2F(ARGS){ BF("BF_CurlGroupOfEdges_2F",BF_CurlEdge_2F) ; }
BF_CurlGroupOfEdges_2V(ARGS)188 void BF_CurlGroupOfEdges_2V(ARGS){ BF("BF_CurlGroupOfEdges_2V",BF_CurlEdge_2V) ; }
BF_CurlGroupOfEdges_3E(ARGS)189 void BF_CurlGroupOfEdges_3E(ARGS){ BF("BF_CurlGroupOfEdges_3E",BF_CurlEdge_3E) ; }
BF_CurlGroupOfEdges_3F_a(ARGS)190 void BF_CurlGroupOfEdges_3F_a(ARGS){ BF("BF_CurlGroupOfEdges_3F_a",BF_CurlEdge_3F_a) ; }
BF_CurlGroupOfEdges_3F_b(ARGS)191 void BF_CurlGroupOfEdges_3F_b(ARGS){ BF("BF_CurlGroupOfEdges_3F_b",BF_CurlEdge_3F_b) ; }
BF_CurlGroupOfEdges_3F_c(ARGS)192 void BF_CurlGroupOfEdges_3F_c(ARGS){ BF("BF_CurlGroupOfEdges_3F_c",BF_CurlEdge_3F_c) ; }
BF_CurlGroupOfEdges_3V(ARGS)193 void BF_CurlGroupOfEdges_3V(ARGS){ BF("BF_CurlGroupOfEdges_3V",BF_CurlEdge_3V) ; }
BF_CurlGroupOfEdges_4E(ARGS)194 void BF_CurlGroupOfEdges_4E(ARGS){ BF("BF_CurlGroupOfEdges_4E",BF_CurlEdge_4E) ; }
BF_CurlGroupOfEdges_4F(ARGS)195 void BF_CurlGroupOfEdges_4F(ARGS){ BF("BF_CurlGroupOfEdges_4F",BF_CurlEdge_4F) ; }
BF_CurlGroupOfEdges_4V(ARGS)196 void BF_CurlGroupOfEdges_4V(ARGS){ BF("BF_CurlGroupOfEdges_4V",BF_CurlEdge_4V) ; }
197
198 #undef BF
199
200 /* ------------------------------------------------------------------------ */
201 /* B F _ G r o u p O f F a c e t s */
202 /* ------------------------------------------------------------------------ */
203
204 #define BF(BF_GroupOfFacets_X,BF_Facet_X) \
205 int i, Num ; \
206 double val[3] ; \
207 \
208 s[0] = s[1] = s[2] = 0. ; \
209 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
210 (BF_Facet_X) \
211 (Element, abs(Num = Element->NumEntitiesInGroups[NumGroup-1][i]), \
212 u, v, w, val) ; \
213 if (Num > 0) { s[0] += val[0] ; s[1] += val[1] ; s[2] += val[2] ; } \
214 else { s[0] -= val[0] ; s[1] -= val[1] ; s[2] -= val[2] ; } \
215 }
216
217
BF_GroupOfFacets(ARGS)218 void BF_GroupOfFacets (ARGS){ BF("BF_GroupOfFacets",BF_Facet) ; }
219
220 #undef BF
221
222 /* ------------------------------------------------------------------------ */
223 /* B F _ D i v G r o u p O f F a c e t s */
224 /* ------------------------------------------------------------------------ */
225
226 #define BF(BF_DivGroupOfFacets_X,BF_DivFacet_X) \
227 int i, Num ; \
228 double val ; \
229 \
230 *s = 0. ; \
231 for (i = 0; i < Element->NbrEntitiesInGroups[NumGroup-1]; i++) { \
232 (BF_DivFacet_X) \
233 (Element, abs(Num = Element->NumEntitiesInGroups[NumGroup-1][i]), \
234 u, v, w, &val) ; \
235 if (Num > 0) { *s += val ; } \
236 else { *s -= val ; } \
237 }
238
BF_DivGroupOfFacets(ARGS)239 void BF_DivGroupOfFacets(ARGS){ BF("BF_DivGroupOfFacets",BF_DivFacet) ; }
240
241 #undef BF
242
243 /* ------------------------------------------------------------------------ */
244 /* B F _ G r o u p O f N o d e s X , Y , Z */
245 /* ------------------------------------------------------------------------ */
246
BF_GroupOfNodesX(struct Element * Element,int NumGroup,double u,double v,double w,double s[])247 void BF_GroupOfNodesX(struct Element * Element, int NumGroup,
248 double u, double v, double w, double s[])
249 {
250 s[1] = s[2] = 0. ;
251 BF_GroupOfNodes(Element, NumGroup, u, v, w, &s[0]) ;
252 }
253
BF_GroupOfNodesY(struct Element * Element,int NumGroup,double u,double v,double w,double s[])254 void BF_GroupOfNodesY(struct Element * Element, int NumGroup,
255 double u, double v, double w, double s[])
256 {
257 s[0] = s[2] = 0. ;
258 BF_GroupOfNodes(Element, NumGroup, u, v, w, &s[1]) ;
259 }
260
BF_GroupOfNodesZ(struct Element * Element,int NumGroup,double u,double v,double w,double s[])261 void BF_GroupOfNodesZ(struct Element * Element, int NumGroup,
262 double u, double v, double w, double s[])
263 {
264 s[0] = s[1] = 0. ;
265 BF_GroupOfNodes(Element, NumGroup, u, v, w, &s[2]) ;
266 }
267
268 /* ------------------------------------------------------------------------ */
269 /* B F _ G r o u p O f N o d e X , Y , Z _ D . . . */
270 /* ------------------------------------------------------------------------ */
271
272 #if !defined(HAVE_KERNEL)
273 #define ChangeOfCoord_Form1(Element, su, s) \
274 Message::Error("ChangeOfCoord_Form1 requires Kernel");
275 #endif
276
BF_GroupOfNodesX_D12(struct Element * Element,int NumNode,double u,double v,double w,double s[])277 void BF_GroupOfNodesX_D12(struct Element * Element, int NumNode,
278 double u, double v, double w, double s[])
279 {
280 double su[3] ;
281
282 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
283 ChangeOfCoord_Form1(Element, su, s) ;
284
285 s[2] = s[1] ;
286 s[1] = 0. ;
287 }
288
BF_GroupOfNodesY_D12(struct Element * Element,int NumNode,double u,double v,double w,double s[])289 void BF_GroupOfNodesY_D12(struct Element * Element, int NumNode,
290 double u, double v, double w, double s[])
291 {
292 double su[3] ;
293
294 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
295 ChangeOfCoord_Form1(Element, su, s) ;
296
297 s[2] = s[0] ;
298 s[0] = 0. ;
299 }
300
BF_GroupOfNodesZ_D12(struct Element * Element,int NumNode,double u,double v,double w,double s[])301 void BF_GroupOfNodesZ_D12(struct Element * Element, int NumNode,
302 double u, double v, double w, double s[])
303 {
304
305 s[0] = s[1] = s[2] = 0. ;
306 }
307
308 /* ------------------------------------------------------------------------ */
309
BF_GroupOfNodesX_D1(struct Element * Element,int NumNode,double u,double v,double w,double s[])310 void BF_GroupOfNodesX_D1(struct Element * Element, int NumNode,
311 double u, double v, double w, double s[])
312 {
313 double su[3] ;
314
315 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
316 ChangeOfCoord_Form1(Element, su, s) ;
317
318 s[1] = s[2] = 0;
319 }
320
BF_GroupOfNodesY_D1(struct Element * Element,int NumNode,double u,double v,double w,double s[])321 void BF_GroupOfNodesY_D1(struct Element * Element, int NumNode,
322 double u, double v, double w, double s[])
323 {
324 double su[3] ;
325
326 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
327 ChangeOfCoord_Form1(Element, su, s) ;
328
329 s[0] = s[2] = 0;
330 }
331
BF_GroupOfNodesZ_D1(struct Element * Element,int NumNode,double u,double v,double w,double s[])332 void BF_GroupOfNodesZ_D1(struct Element * Element, int NumNode,
333 double u, double v, double w, double s[])
334 {
335 double su[3] ;
336
337 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
338 ChangeOfCoord_Form1(Element, su, s) ;
339
340 s[0] = s[1] = 0;
341 }
342
343 /* ------------------------------------------------------------------------ */
344
BF_GroupOfNodesX_D2(struct Element * Element,int NumNode,double u,double v,double w,double s[])345 void BF_GroupOfNodesX_D2(struct Element * Element, int NumNode,
346 double u, double v, double w, double s[])
347 {
348 double su[3] ;
349
350 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
351 ChangeOfCoord_Form1(Element, su, s) ;
352
353 s[0] = s[1] ; s[1] = 0 ;
354 }
355
BF_GroupOfNodesY_D2(struct Element * Element,int NumNode,double u,double v,double w,double s[])356 void BF_GroupOfNodesY_D2(struct Element * Element, int NumNode,
357 double u, double v, double w, double s[])
358 {
359 double su[3] ;
360
361 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
362 ChangeOfCoord_Form1(Element, su, s) ;
363
364 s[1] = s[2] ; s[2] = 0 ;
365 }
366
BF_GroupOfNodesZ_D2(struct Element * Element,int NumNode,double u,double v,double w,double s[])367 void BF_GroupOfNodesZ_D2(struct Element * Element, int NumNode,
368 double u, double v, double w, double s[])
369 {
370 double su[3] ;
371
372 BF_GradGroupOfNodes(Element, NumNode, u, v, w, su) ;
373 ChangeOfCoord_Form1(Element, su, s) ;
374
375 s[2] = s[0] ;
376 s[0] = 0 ;
377 }
378