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 "ProData.h"
7 #include "Message.h"
8 
9 /* ------------------------------------------------------------------------ */
10 /*  B F _ N o d e _ 3                                                       */
11 /* ------------------------------------------------------------------------ */
12 
13 /* ------- */
14 /*  Edges  */
15 /* ------- */
16 
17 #define WrongNumEntity   Message::Error("Wrong Edge number in 'BF_Node_3E'")
18 
BF_Node_3E(struct Element * Element,int NumEntity,double u,double v,double w,double * s)19 void  BF_Node_3E(struct Element * Element, int NumEntity,
20 		   double u, double v, double w,  double *s)
21 {
22   switch (Element->Type) {
23   case LINE   : case LINE_2 :
24   case LINE_3 : case LINE_4 :
25     switch(NumEntity) {
26     case 1  : *s = 0.25 * (1.-u) * (1.+u) * (-u) ; break ;
27     default : WrongNumEntity ;
28     }
29     break ;
30 
31   case TRIANGLE   : case TRIANGLE_2 :
32   case TRIANGLE_3 : case TRIANGLE_4 :
33     switch(NumEntity) {
34     case 1  : *s = (1.-u-v) * u * (1.-2*u-v) ; break ;
35     case 2  : *s = (1.-u-v) * v * (1.-u-2*v) ; break ;
36     case 3  : *s = u * v * (u-v)             ; break ;
37     default : WrongNumEntity ;
38     }
39     break ;
40 
41   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
42   case QUADRANGLE_3 : case QUADRANGLE_4 :
43     switch(NumEntity) {
44     default : Message::Error("BF_Node_3E not ready for QUADRANGLE");
45     }
46     break ;
47 
48   case TETRAHEDRON   : case TETRAHEDRON_2 :
49   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
50     switch(NumEntity) {
51     case 1  : *s = (1.-u-v-w) * u * (1.-2*u-v-w) ; break ;
52     case 2  : *s = (1.-u-v-w) * v * (1.-u-2*v-w) ; break ;
53     case 3  : *s = (1.-u-v-w) * w * (1.-u-v-2*w) ; break ;
54     case 4  : *s = u * v * (u-v)                 ; break ;
55     case 5  : *s = u * w * (u-w)                 ; break ;
56     case 6  : *s = v * w * (v-w)                 ; break ;
57     default : WrongNumEntity ;
58     }
59     break ;
60 
61   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
62   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
63     switch(NumEntity) {
64     default : Message::Error("BF_Node_3E not ready for HEXAHEDRON");
65     }
66     break ;
67 
68   case PRISM   : case PRISM_2 : case PRISM_2_15N :
69   case PRISM_3 : case PRISM_4 :
70     switch(NumEntity) {
71     default : Message::Error("BF_Node_3E not ready for PRISM");
72     }
73     break ;
74 
75   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
76   case PYRAMID_3 : // case PYRAMID_4
77     switch(NumEntity) {
78     default : Message::Error("BF_Node_3E not ready for PYRAMID");
79     }
80     break ;
81 
82   default :
83     Message::Error("Unknown type of Element in BF_Node_3E");
84     break ;
85   }
86 
87   if (Element->GeoElement->NumEdges[NumEntity-1] < 0)
88     *s = -*s ;
89 
90 }
91 
92 #undef WrongNumEntity
93 
94 /* -------- */
95 /*  Facets  */
96 /* -------- */
97 
98 #define WrongNumEntity   Message::Error("Wrong Face number in 'BF_Node_3F'")
99 
BF_Node_3F(struct Element * Element,int NumEntity,double u,double v,double w,double * s)100 void  BF_Node_3F(struct Element * Element, int NumEntity,
101 		 double u, double v, double w,  double *s)
102 {
103   switch (Element->Type) {
104 
105   case LINE   : case LINE_2 :
106   case LINE_3 : case LINE_4 :
107     Message::Error("BF_Node_3F cannot be associated with this type of element");
108     break;
109 
110   case TRIANGLE   : case TRIANGLE_2 :
111   case TRIANGLE_3 : case TRIANGLE_4 :
112     switch(NumEntity) {
113     case 1  : *s = (1.-u-v) * u * v ; break ;
114     default : WrongNumEntity ;
115     }
116     break ;
117 
118   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
119   case QUADRANGLE_3 : case QUADRANGLE_4 :
120     switch(NumEntity) {
121     default : Message::Error("BF_Node_3F not ready for QUADRANGLE");
122     }
123     break ;
124 
125   case TETRAHEDRON   : case TETRAHEDRON_2 :
126   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
127     switch(NumEntity) {
128     case 1  : *s = (1.-u-v-w) * u * w ; break ;
129     case 2  : *s = (1.-u-v-w) * v * u ; break ;
130     case 3  : *s = (1.-u-v-w) * w * v ; break ;
131     case 4  : *s = u * v * w          ; break ;
132     default : WrongNumEntity ;
133     }
134     break ;
135 
136   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
137   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
138     switch(NumEntity) {
139     default : Message::Error("BF_Node_3F not ready for HEXAHEDRON");
140     }
141     break ;
142 
143   case PRISM   : case PRISM_2 : case PRISM_2_15N :
144   case PRISM_3 : case PRISM_4 :
145     switch(NumEntity) {
146     default : Message::Error("BF_Node_3F not ready for PRISM");
147     }
148     break ;
149 
150   default :
151     Message::Error("Unknown Element Type in BF_Node_3F");
152     break ;
153   }
154 
155 }
156 
157 #undef WrongNumEntity
158 
159 /* -------- */
160 /*  Volume  */
161 /* -------- */
162 
BF_Node_3V(struct Element * Element,int NumEntity,double u,double v,double w,double * s)163 void  BF_Node_3V(struct Element * Element, int NumEntity,
164 		 double u, double v, double w,  double *s)
165 {
166   switch (Element->Type) {
167 
168   case LINE   : case LINE_2 :
169   case LINE_3 : case LINE_4 :
170   case TRIANGLE   : case TRIANGLE_2 :
171   case TRIANGLE_3 : case TRIANGLE_4 :
172   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
173   case QUADRANGLE_3 : case QUADRANGLE_4 :
174   case TETRAHEDRON   : case TETRAHEDRON_2 :
175   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
176     Message::Error("BF_Node_3V cannot be associated with this type of element");
177     break;
178 
179   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
180   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
181     switch(NumEntity) {
182     default : Message::Error("BF_Node_3V not ready for HEXAHEDRON");
183     }
184     break ;
185 
186   case PRISM   : case PRISM_2 : case PRISM_2_15N :
187   case PRISM_3 : case PRISM_4 :
188     switch(NumEntity) {
189     default : Message::Error("BF_Node_3V not ready for PRISM");
190     }
191     break ;
192 
193   default :
194     Message::Error("Unknown type of Element in BF_Node_3V");
195     break ;
196   }
197 
198 }
199 
200 
201 /* ------------------------------------------------------------------------ */
202 /*  B F _ G r a d N o d e _ 3                                               */
203 /* ------------------------------------------------------------------------ */
204 
205 /* ------- */
206 /*  Edges  */
207 /* ------- */
208 
209 #define WrongNumEntity   Message::Error("Wrong Edge number in 'BF_GradNode_3E'")
210 
BF_GradNode_3E(struct Element * Element,int NumEntity,double u,double v,double w,double s[])211 void BF_GradNode_3E(struct Element * Element, int NumEntity,
212 		    double u, double v, double w,  double s[])
213 {
214   switch (Element->Type) {
215   case LINE   : case LINE_2 :
216   case LINE_3 : case LINE_4 :
217     switch(NumEntity) {
218     case 1  : s[0] = -0.25 + 0.75 * u * u ; s[1] = 0. ; s[2] = 0. ; break ;
219     default : WrongNumEntity ;
220     }
221     break ;
222 
223   case TRIANGLE   : case TRIANGLE_2 :
224   case TRIANGLE_3 : case TRIANGLE_4 :
225     switch(NumEntity) {
226     case 1  : s[0] = 1.0-6.0*u-2.0*v+6.0*u*u+6.0*u*v+v*v ;
227               s[1] = -2.0*u+3.0*u*u+2.0*u*v ;
228 	      s[2] = 0. ;
229 	      break ;
230     case 2  : s[0] = -2.0*v+2.0*u*v+3.0*v*v ;
231               s[1] = 1.0-2.0*u-6.0*v+u*u+6.0*u*v+6.0*v*v ;
232               s[2] = 0. ;
233 	      break ;
234     case 3  : s[0] = 2.0*u*v-v*v ;
235               s[1] = u*u-2.0*u*v ;
236               s[2] = 0. ;
237 	      break ;
238     default : WrongNumEntity ;
239     }
240     break ;
241 
242   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
243   case QUADRANGLE_3 : case QUADRANGLE_4 :
244     switch(NumEntity) {
245     default : Message::Error("BF_GradNode_3E not ready for QUADRANGLE");
246     }
247     break ;
248 
249   case TETRAHEDRON   : case TETRAHEDRON_2 :
250   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
251     switch(NumEntity) {
252     case 1  : s[0] = 1.0-6.0*u-2.0*v-2.0*w+6.0*u*u+6.0*u*v+6.0*u*w+v*v+2.0*v*w+w*w ;
253               s[1] = -2.0*u+3.0*u*u+2.0*u*v+2.0*u*w ;
254               s[2] = -2.0*u+3.0*u*u+2.0*u*v+2.0*u*w ;
255 	      break ;
256     case 2  : s[0] = -2.0*v+2.0*u*v+3.0*v*v+2.0*v*w ;
257               s[1] =  1.0-2.0*u-6.0*v-2.0*w+u*u+6.0*u*v+2.0*u*w+6.0*v*v+6.0*v*w+w*w ;
258               s[2] = -2.0*v+2.0*u*v+3.0*v*v+2.0*v*w ;
259 	      break ;
260     case 3  : s[0] = -2.0*w+2.0*u*w+2.0*v*w+3.0*w*w ;
261               s[1] = -2.0*w+2.0*u*w+2.0*v*w+3.0*w*w ;
262               s[2] = 1.0-2.0*u-2.0*v-6.0*w+u*u+2.0*u*v+6.0*u*w+v*v+6.0*v*w+6.0*w*w ;
263 	      break ;
264     case 4  : s[0] = 2.0*u*v-v*v ;
265               s[1] = u*u-2.0*u*v ;
266               s[2] = 0.0 ;
267 	      break ;
268     case 5  : s[0] = 2.0*u*w-w*w ;
269               s[1] = 0.0 ;
270               s[2] = u*u-2.0*u*w ;
271 	      break ;
272     case 6  : s[0] = 0.0 ;
273               s[1] = 2.0*v*w-w*w ;
274               s[2] = v*v-2.0*v*w ;
275 	      break ;
276     default : WrongNumEntity ;
277     }
278     break ;
279 
280   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
281   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
282     switch(NumEntity) {
283     default : Message::Error("BF_GradNode_3E not ready for HEXAHEDRON");
284     }
285     break ;
286 
287   case PRISM   : case PRISM_2 : case PRISM_2_15N :
288   case PRISM_3 : case PRISM_4 :
289     switch(NumEntity) {
290     default : Message::Error("BF_GradNode_3E not ready for PRISM");
291     }
292     break ;
293 
294   default :
295     Message::Error("Unknown type of Element in BF_GradNode_3E");
296     break ;
297   }
298 
299   if (Element->GeoElement->NumEdges[NumEntity-1] < 0) {
300     s[0] = - s[0] ; s[1] = - s[1] ; s[2] = - s[2] ;
301   }
302 
303 }
304 
305 #undef WrongNumEntity
306 
307 /* -------- */
308 /*  Facets  */
309 /* -------- */
310 
311 #define WrongNumEntity   Message::Error("Wrong Face number in 'BF_GradNode_3F'")
312 
BF_GradNode_3F(struct Element * Element,int NumEntity,double u,double v,double w,double s[])313 void BF_GradNode_3F(struct Element * Element, int NumEntity,
314 		    double u, double v, double w,  double s[])
315 {
316   switch (Element->Type) {
317 
318   case LINE   : case LINE_2 :
319   case LINE_3 : case LINE_4 :
320     Message::Error("BF_GradNode_3F cannot be associated with this type of element");
321     break ;
322 
323   case TRIANGLE   : case TRIANGLE_2 :
324   case TRIANGLE_3 : case TRIANGLE_4 :
325     switch(NumEntity) {
326     case 1  : s[0] = v-2.0*u*v-v*v ; s[1] = u-u*u-2.0*u*v ; s[2] = 0. ; break ;
327     default : WrongNumEntity ;
328     }
329     break ;
330 
331   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
332   case QUADRANGLE_3 : case QUADRANGLE_4 :
333     switch(NumEntity) {
334     default : Message::Error("BF_GradNode_3F not ready for QUADRANGLE");
335     }
336     break ;
337 
338   case TETRAHEDRON   : case TETRAHEDRON_2 :
339   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
340     switch(NumEntity) {
341     case 1  : s[0] = w-2.0*u*w-v*w-w*w ; s[1] = -u*w ; s[2] = u-u*u-u*v-2.0*u*w ; break ;
342     case 2  : s[0] = v-2.0*u*v-v*v-v*w ; s[1] = u-u*u-2.0*u*v-u*w ; s[2] = -u*v ; break ;
343     case 3  : s[0] = -v*w ; s[1] = w-u*w-2.0*v*w-w*w ; s[2] = v-u*v-v*v-2.0*v*w ; break ;
344     case 4  : s[0] = v*w ; s[1] = u*w ; s[2] = u*v ; break ;
345     default : WrongNumEntity ;
346     }
347     break ;
348 
349   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
350   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
351     switch(NumEntity) {
352     default : Message::Error("BF_GradNode_3F not ready for HEXAHEDRON");
353     }
354     break ;
355 
356   case PRISM   : case PRISM_2 : case PRISM_2_15N :
357   case PRISM_3 : case PRISM_4 :
358     switch(NumEntity) {
359     default : Message::Error("BF_GradNode_3F not ready for PRISM");
360     }
361     break ;
362 
363   default :
364     Message::Error("Unknown type of Element in BF_GradNode_3F");
365     break ;
366   }
367 
368 }
369 
370 #undef WrongNumEntity
371 
372 /* -------- */
373 /*  Volume  */
374 /* -------- */
375 
BF_GradNode_3V(struct Element * Element,int NumEntity,double u,double v,double w,double s[])376 void BF_GradNode_3V(struct Element * Element, int NumEntity,
377 		    double u, double v, double w,  double s[])
378 {
379   switch (Element->Type) {
380 
381   case LINE   : case LINE_2 :
382   case LINE_3 : case LINE_4 :
383   case TRIANGLE   : case TRIANGLE_2 :
384   case TRIANGLE_3 : case TRIANGLE_4 :
385   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
386   case QUADRANGLE_3 : case QUADRANGLE_4 :
387   case TETRAHEDRON   : case TETRAHEDRON_2 :
388   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
389     Message::Error("BF_GradNode_3V cannot be associated with this type of element");
390     break;
391 
392   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
393   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
394     switch(NumEntity) {
395     default : Message::Error("BF_GradNode_3V not ready for HEXAHEDRON");
396     }
397     break ;
398 
399   case PRISM   : case PRISM_2 : case PRISM_2_15N :
400   case PRISM_3 : case PRISM_4 :
401     switch(NumEntity) {
402     default : Message::Error("BF_GradNode_3V not ready for PRISM");
403     }
404     break ;
405 
406   default :
407     Message::Error("Unknown type of Element in BF_GradNode_3V");
408     break ;
409   }
410 }
411