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 _ 2                                                       */
11 /* ------------------------------------------------------------------------ */
12 
13 /* ------- */
14 /*  Edges  */
15 /* ------- */
16 
17 #define WrongNumEntity   Message::Error("Wrong Edge number in 'BF_Node_2E'")
18 
BF_Node_2E(struct Element * Element,int NumEntity,double u,double v,double w,double * s)19 void BF_Node_2E(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) ; 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 ; break ;
35     case 2  : *s = (1.-u-v) * v ; break ;
36     case 3  : *s = 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     case 1  : *s = 0.0625 * (1.-u*u) * (1.-v)*(1.-v) ; break ;
45     case 2  : *s = 0.0625 * (1.-u)*(1.-u) * (1.-v*v) ; break ;
46     case 3  : *s = 0.0625 * (1.+u)*(1.+u) * (1.-v*v) ; break ;
47     case 4  : *s = 0.0625 * (1.-u*u) * (1.+v)*(1.+v) ; break ;
48     default : WrongNumEntity ;
49     }
50     break ;
51 
52   case TETRAHEDRON   : case TETRAHEDRON_2 :
53   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
54     switch(NumEntity) {
55     case 1  : *s = (1.-u-v-w) * u ; break ;
56     case 2  : *s = (1.-u-v-w) * v ; break ;
57     case 3  : *s = (1.-u-v-w) * w ; break ;
58     case 4  : *s = u * v          ; break ;
59     case 5  : *s = u * w          ; break ;
60     case 6  : *s = v * w          ; break ;
61     default : WrongNumEntity ;
62     }
63     break ;
64 
65   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
66   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
67     switch(NumEntity) {
68     case 1  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.+u) * (1.-v) * (1.-w) ; break ;
69     case 2  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.-u) * (1.+v) * (1.-w) ; break ;
70     case 3  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.-u) * (1.-v) * (1.+w) ; break ;
71     case 4  : *s = 0.015625 * (1.+u) * (1.-v) * (1.-w) * (1.+u) * (1.+v) * (1.-w) ; break ;
72     case 5  : *s = 0.015625 * (1.+u) * (1.-v) * (1.-w) * (1.+u) * (1.-v) * (1.+w) ; break ;
73     case 6  : *s = 0.015625 * (1.+u) * (1.+v) * (1.-w) * (1.-u) * (1.+v) * (1.-w) ; break ;
74     case 7  : *s = 0.015625 * (1.+u) * (1.+v) * (1.-w) * (1.+u) * (1.+v) * (1.+w) ; break ;
75     case 8  : *s = 0.015625 * (1.-u) * (1.+v) * (1.-w) * (1.-u) * (1.+v) * (1.+w) ; break ;
76     case 9  : *s = 0.015625 * (1.-u) * (1.-v) * (1.+w) * (1.+u) * (1.-v) * (1.+w) ; break ;
77     case 10 : *s = 0.015625 * (1.-u) * (1.-v) * (1.+w) * (1.-u) * (1.+v) * (1.+w) ; break ;
78     case 11 : *s = 0.015625 * (1.+u) * (1.-v) * (1.+w) * (1.+u) * (1.+v) * (1.+w) ; break ;
79     case 12 : *s = 0.015625 * (1.+u) * (1.+v) * (1.+w) * (1.-u) * (1.+v) * (1.+w) ; break ;
80     default : WrongNumEntity ;
81     }
82     break ;
83 
84   case PRISM   : case PRISM_2 : case PRISM_2_15N :
85   case PRISM_3 : case PRISM_4 :
86     // FIXME: not tested!
87     switch(NumEntity) {
88     case 1  : *s = 0.25 * (1.-u-v) * (1.-w) *     u    * (1.-w) ; break ;
89     case 2  : *s = 0.25 * (1.-u-v) * (1.-w) *       v  * (1.-w) ; break ;
90     case 3  : *s = 0.25 * (1.-u-v) * (1.-w) * (1.-u-v) * (1.+w) ; break ;
91     case 4  : *s = 0.25 *     u    * (1.-w) *       v  * (1.-w) ; break ;
92     case 5  : *s = 0.25 *     u    * (1.-w) *     u    * (1.+w) ; break ;
93     case 6  : *s = 0.25 *       v  * (1.-w) *       v  * (1.+w) ; break ;
94     case 7  : *s = 0.25 * (1.-u-v) * (1.+w) *     u    * (1.+w) ; break ;
95     case 8  : *s = 0.25 * (1.-u-v) * (1.+w) *       v  * (1.+w) ; break ;
96     case 9  : *s = 0.25 *     u    * (1.+w) *       v  * (1.+w) ; break ;
97     default : WrongNumEntity ;
98     }
99     break ;
100 
101   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
102   case PYRAMID_3 : // case PYRAMID_4
103     switch(NumEntity) {
104     default : Message::Error("BF_Node_2E not ready for PYRAMID");
105     }
106     break ;
107 
108   default :
109     Message::Error("Unknown type of Element in BF_Node_2E");
110     break ;
111   }
112 }
113 
114 #undef WrongNumEntity
115 
116 
117 /* -------- */
118 /*  Facets  */
119 /* -------- */
120 
121 #define WrongNumEntity   Message::Error("Wrong Face number in 'BF_Node_2F'")
122 
BF_Node_2F(struct Element * Element,int NumEntity,double u,double v,double w,double * s)123 void BF_Node_2F(struct Element * Element, int NumEntity,
124 		double u, double v, double w,  double *s)
125 {
126   switch (Element->Type) {
127 
128   case LINE   : case LINE_2 :
129   case LINE_3 : case LINE_4 :
130   case TRIANGLE   : case TRIANGLE_2 :
131   case TRIANGLE_3 : case TRIANGLE_4 :
132   case TETRAHEDRON   : case TETRAHEDRON_2 :
133   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
134     Message::Error("BF_Node_2F cannot be associated with this type of element");
135     break;
136 
137   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
138   case QUADRANGLE_3 : case QUADRANGLE_4 :
139     *s = 0.0625 * (1.-u) * (1.-v) * (1.+u) * (1.+v) ;
140     break ;
141 
142   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
143   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
144     switch(NumEntity) {
145     case 1  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.+u) * (1.-v) * (1.+w) ; break ;
146     case 2  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.+u) * (1.+v) * (1.-w) ; break ;
147     case 3  : *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.-u) * (1.+v) * (1.+w) ; break ;
148     case 4  : *s = 0.015625 * (1.+u) * (1.-v) * (1.-w) * (1.+u) * (1.+v) * (1.+w) ; break ;
149     case 5  : *s = 0.015625 * (1.+u) * (1.+v) * (1.-w) * (1.-u) * (1.+v) * (1.+w) ; break ;
150     case 6  : *s = 0.015625 * (1.-u) * (1.-v) * (1.+w) * (1.+u) * (1.+v) * (1.+w) ; break ;
151     default : WrongNumEntity ;
152     }
153     break ;
154 
155   case PRISM   : case PRISM_2 : case PRISM_2_15N :
156   case PRISM_3 : case PRISM_4 :
157     switch(NumEntity) {
158     default : Message::Error("BF_Node_2F not ready for PRISM");
159       // cannot do this, as dofs should only be associated with quad-faces; use
160       // 15 and 18-node prisms instead, i.e. through BF_Node (which calls Gmsh).
161       /*
162     case 1  : *s = 0.25 * (1.-u-v) * (1.-w) *     u    * (1.+w) ; break ;
163     case 3  : *s = 0.25 * (1.-u-v) * (1.-w) *       v  * (1.+w) ; break ;
164     case 4  : *s = 0.25 *     u    * (1.-w) *       v  * (1.+w) ; break ;
165     default : WrongNumEntity ;
166       */
167     }
168     break ;
169 
170   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
171   case PYRAMID_3 : // case PYRAMID_4
172     switch(NumEntity) {
173     default : Message::Error("BF_Node_2F not ready for PYRAMID");
174     }
175     break ;
176 
177   default :
178     Message::Error("Unknown Element Type in BF_Node_2F");
179     break ;
180   }
181 
182 }
183 
184 #undef WrongNumEntity
185 
186 /* -------- */
187 /*  Volume  */
188 /* -------- */
189 
BF_Node_2V(struct Element * Element,int NumEntity,double u,double v,double w,double * s)190 void BF_Node_2V(struct Element * Element, int NumEntity,
191 		double u, double v, double w,  double *s)
192 {
193   switch (Element->Type) {
194 
195   case LINE   : case LINE_2 :
196   case LINE_3 : case LINE_4 :
197   case TRIANGLE   : case TRIANGLE_2 :
198   case TRIANGLE_3 : case TRIANGLE_4 :
199   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
200   case QUADRANGLE_3 : case QUADRANGLE_4 :
201   case TETRAHEDRON   : case TETRAHEDRON_2 :
202   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
203   case PRISM   : case PRISM_2 : case PRISM_2_15N :
204   case PRISM_3 : case PRISM_4 :
205   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
206   case PYRAMID_3 : // case PYRAMID_4
207     Message::Error("BF_Node_2V cannot be associated with this type of element");
208     break;
209 
210   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
211   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
212     *s = 0.015625 * (1.-u) * (1.-v) * (1.-w) * (1.+u) * (1.+v) * (1.+w) ;
213     break ;
214 
215   default :
216     Message::Error("Unknown type of Element in BF_Node_2V");
217     break ;
218   }
219 
220 }
221 
222 
223 /* ------------------------------------------------------------------------ */
224 /*  B F _ G r a d N o d e _ 2                                               */
225 /* ------------------------------------------------------------------------ */
226 
227 /* ------- */
228 /*  Edges  */
229 /* ------- */
230 
231 #define WrongNumEntity   Message::Error("Wrong Edge number in 'BF_GradNode_2E'")
232 
BF_GradNode_2E(struct Element * Element,int NumEntity,double u,double v,double w,double s[])233 void  BF_GradNode_2E(struct Element * Element, int NumEntity,
234 		     double u, double v, double w,  double s[])
235 {
236   switch (Element->Type) {
237   case LINE   : case LINE_2 :
238   case LINE_3 : case LINE_4 :
239     switch(NumEntity) {
240     case 1  : s[0] = -0.5*u ; s[1] = 0. ; s[2] = 0. ; break ;
241     default : WrongNumEntity ;
242     }
243     break ;
244 
245   case TRIANGLE   : case TRIANGLE_2 :
246   case TRIANGLE_3 : case TRIANGLE_4 :
247     switch(NumEntity) {
248     case 1  : s[0] = 1.-2.*u-v ; s[1] = -u        ; s[2] = 0. ; break ;
249     case 2  : s[0] = -v        ; s[1] = 1.-u-2.*v ; s[2] = 0. ; break ;
250     case 3  : s[0] = v         ; s[1] = u         ; s[2] = 0. ; break ;
251     default : WrongNumEntity ;
252     }
253     break ;
254 
255   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
256   case QUADRANGLE_3 : case QUADRANGLE_4 :
257     switch(NumEntity) {
258     case 1  : s[0] = 0.0625 * (-2.*u) * (1.-v)*(1.-v) ;
259               s[1] = 0.0625 * (1.-u*u) * (-2.)*(1.-v) ;
260               s[2] = 0. ; break ;
261     case 2  : s[0] = 0.0625 * (-2.)*(1.-u) * (1.-v*v) ;
262               s[1] = 0.0625 * (1.-u)*(1.-u) * (-2.*v) ;
263               s[2] = 0. ; break ;
264     case 3  : s[0] = 0.0625 * (2.)*(1.+u) * (1.-v*v) ;
265               s[1] = 0.0625 * (1.+u)*(1.+u) * (-2.*v) ;
266               s[2] = 0. ; break ;
267     case 4  : s[0] = 0.0625 * (-2.*u) * (1.+v)*(1.+v) ;
268               s[1] = 0.0625 * (1.-u*u) * (2.)*(1.+v) ;
269               s[2] = 0. ; break ;
270     default : WrongNumEntity;
271     }
272     break ;
273 
274   case TETRAHEDRON   : case TETRAHEDRON_2 :
275   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
276     switch(NumEntity) {
277     case 1  : s[0] =  1.-2.*u-v-w ; s[1] = -u           ; s[2] = -u           ; break ;
278     case 2  : s[0] = -v           ; s[1] =  1.-u-2.*v-w ; s[2] = -v           ; break ;
279     case 3  : s[0] = -w           ; s[1] = -w           ; s[2] =  1.-u-v-2.*w ; break ;
280     case 4  : s[0] =  v           ; s[1] =  u           ; s[2] =  0.          ; break ;
281     case 5  : s[0] =  w           ; s[1] =  0.          ; s[2] =  u           ; break ;
282     case 6  : s[0] =  0.          ; s[1] =  w           ; s[2] =  v           ; break ;
283     default : WrongNumEntity ;
284     }
285     break ;
286 
287   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
288   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
289     switch(NumEntity) {
290     case 1   : s[0] = 0.015625 * (-2.*u) * (1.-v) * (1.-w) * (1.-v) * (1.-w) ;
291                s[1] = 0.015625 * (1.-u) * (-2.)*(1.-v) * (1.-w) * (1.+u) * (1.-w) ;
292                s[2] = 0.015625 * (1.-u) * (1.-v) * (-2.)*(1.-w) * (1.+u) * (1.-v) ; break ;
293 
294     case 2   : s[0] = 0.015625 * (-2.)*(1.-u) * (1.-v) * (1.-w) * (1.+v) * (1.-w) ;
295                s[1] = 0.015625 * (1.-u) * (-2.*v) * (1.-w) * (1.-u) * (1.-w) ;
296 	       s[2] = 0.015625 * (1.-u) * (1.-v) * (-2.)*(1.-w) * (1.-u) * (1.+v) ; break ;
297 
298     case 3   : s[0] = 0.015625 *  (-2.)*(1.-u) * (1.-v) * (1.-w) * (1.-v) * (1.+w) ;
299                s[1] = 0.015625 *  (1.-u) * (-2.)*(1.-v) * (1.-w) * (1.-u) * (1.+w) ;
300 	       s[2] = 0.015625 *  (1.-u) * (1.-v) * (-2.*w) * (1.-u) * (1.-v) ; break ;
301 
302     case 4   : s[0] = 0.015625 *  2.*(1.+u) * (1.-v) * (1.-w) * (1.+v) * (1.-w) ;
303                s[1] = 0.015625 *  (1.+u) * (-2.*v) * (1.-w) * (1.+u) * (1.-w) ;
304 	       s[2] = 0.015625 *  (1.+u) * (1.-v) * (-2.)*(1.-w) * (1.+u) * (1.+v) ; break ;
305 
306     case 5   : s[0] = 0.015625 *  2.*(1.+u) * (1.-v) * (1.-w) * (1.-v) * (1.+w) ;
307                s[1] = 0.015625 *  (1.+u) * (-2.)*(1.-v) * (1.-w) * (1.+u) * (1.+w) ;
308 	       s[2] = 0.015625 *  (1.+u) * (1.-v) * (-2.*w) * (1.+u) * (1.-v) ; break ;
309 
310     case 6   : s[0] = 0.015625 *  (-2.*u) * (1.+v) * (1.-w) * (1.+v) * (1.-w) ;
311                s[1] = 0.015625 *  (1.+u) * 2.*(1.+v) * (1.-w) * (1.-u) * (1.-w) ;
312 	       s[2] = 0.015625 *  (1.+u) * (1.+v) * (-2.)*(1.-w) * (1.-u) * (1.+v) ; break ;
313 
314     case 7   : s[0] = 0.015625 *  2.*(1.+u) * (1.+v) * (1.-w) * (1.+v) * (1.+w) ;
315                s[1] = 0.015625 *  (1.+u) * 2.*(1.+v) * (1.-w) * (1.+u) * (1.+w) ;
316 	       s[2] = 0.015625 *  (1.+u) * (1.+v) * (-2.*w) * (1.+u) * (1.+v) ; break ;
317 
318     case 8   : s[0] = 0.015625 *  (-2.)*(1.-u) * (1.+v) * (1.-w) * (1.+v) * (1.+w) ;
319                s[1] = 0.015625 *  (1.-u) * 2.*(1.+v) * (1.-w) * (1.-u) * (1.+w) ;
320 	       s[2] = 0.015625 *  (1.-u) * (1.+v) * (-2.*w) * (1.-u) * (1.+v) ; break ;
321 
322     case 9   : s[0] = 0.015625 *  (-2.*u) * (1.-v) * (1.+w) * (1.-v) * (1.+w) ;
323                s[1] = 0.015625 *  (1.-u) * (-2.)*(1.-v) * (1.+w) * (1.+u) * (1.+w) ;
324 	       s[2] = 0.015625 *  (1.-u) * (1.-v) * 2.*(1.+w) * (1.+u) * (1.-v) ; break ;
325 
326     case 10  : s[0] = 0.015625 *  (-2.)*(1.-u) * (1.-v) * (1.+w) * (1.+v) * (1.+w) ;
327                s[1] = 0.015625 *  (1.-u) * (-2.*v) * (1.+w) * (1.-u) * (1.+w) ;
328 	       s[2] = 0.015625 *  (1.-u) * (1.-v) * 2.*(1.+w) * (1.-u) * (1.+v) ; break ;
329 
330     case 11  : s[0] = 0.015625 *  2.*(1.+u) * (1.-v) * (1.+w) * (1.+v) * (1.+w) ;
331                s[1] = 0.015625 *  (1.+u) * (-2.*v) * (1.+w) * (1.+u) * (1.+w) ;
332 	       s[2] = 0.015625 *  (1.+u) * (1.-v) * 2.*(1.+w) * (1.+u) * (1.+v) ; break ;
333 
334     case 12  : s[0] = 0.015625 *  (-2.*u) * (1.+v) * (1.+w) * (1.+v) * (1.+w) ;
335                s[1] = 0.015625 *  (1.+u) * 2.*(1.+v) * (1.+w) * (1.-u) * (1.+w) ;
336 	       s[2] = 0.015625 *  (1.+u) * (1.+v) * 2.*(1.+w) * (1.-u) * (1.+v) ; break ;
337 
338     default : WrongNumEntity ;
339     }
340     break ;
341 
342   case PRISM   : case PRISM_2 : case PRISM_2_15N :
343   case PRISM_3 : case PRISM_4 :
344     // FIXME: not tested!
345     switch(NumEntity) {
346     case 1   : s[0] = 0.25 * (1.-2.*u-v) * (1.-w) * (1.-w) ;
347                s[1] = 0.25 * (-u) * (1.-w) * (1.-w) ;
348                s[2] = 0.25 * (u-u*u-v*u) * (-2.)*(1.-w) ; break ;
349 
350     case 2   : s[0] = 0.25 * (-v) * (1.-w) * (1.-w) ;
351                s[1] = 0.25 * (1-u-2*v) * (1.-w) * (1.-w) ;
352                s[2] = 0.25 * (v-u*v-v*v) * (-2.) * (1.-w) ; break ;
353 
354     case 3   : s[0] = 0.25 * (-2. + 2.*u + 2.*v) * (1.-w) * (1.+w) ;
355                s[1] = 0.25 * (-2. + 2.*u + 2.*v) * (1.-w) * (1.+w) ;
356                s[2] = 0.25 * (1.- 2.*u - 2.*v + u*u + 2.*u*v + v*v) * (-2.*w) ; break ;
357 
358     case 4   : s[0] = 0.25 * (1.-w) * v * (1.-w) ;
359                s[1] = 0.25 * u * (1.-w) * (1.-w) ;
360                s[2] = 0.25 * u * (-2.) * (1.-w) * v ; break ;
361 
362     case 5   : s[0] = 0.25 * 2.*u * (1.-w) * (1.+w) ;
363                s[1] = 0. ;
364                s[2] = 0.25 * u*u * (-2.*w) ; break ;
365 
366     case 6   : s[0] = 0. ;
367                s[1] = 0.25 * 2.*v  * (1.-w) * (1.+w) ;
368                s[2] = 0.25 * v*v  * (-2.*w) ; break ;
369 
370     case 7   : s[0] = 0.25 * (1.-2.*u-v) * (1.+w) * (1.+w) ;
371                s[1] = 0.25 * (-u) * (1.+w) * (1.+w) ;
372                s[2] = 0.25 * (u-u*u-u*v) * 2.*(1.+w) ; break ;
373 
374     case 8   : s[0] = 0.25 * (-v) * (1.+w) * (1.+w) ;
375                s[1] = 0.25 * (1.-u-2.*v) * (1.+w) * (1.+w) ;
376                s[2] = 0.25 * (v-u*v-v*v) * 2.*(1.+w) ; break ;
377 
378     case 9   : s[0] = 0.25 * (1.+w) * v * (1.+w) ;
379                s[1] = 0.25 * u * (1.+w) * (1.+w) ;
380                s[2] = 0.25 * u * 2.*(1.+w) * v ; break ;
381 
382     default : WrongNumEntity ;
383     }
384     break ;
385 
386   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
387   case PYRAMID_3 : // case PYRAMID_4
388     switch(NumEntity) {
389     default : Message::Error("BF_GradNode_2E not ready for PYRAMID");
390     }
391     break ;
392 
393   default :
394     Message::Error("Unknown type of Element in BF_GradNode_2E");
395     break ;
396   }
397 
398 }
399 
400 #undef WrongNumEntity
401 
402 /* -------- */
403 /*  Facets  */
404 /* -------- */
405 
406 #define WrongNumEntity   Message::Error("Wrong Face number in 'BF_GradNode_2F'")
407 
BF_GradNode_2F(struct Element * Element,int NumEntity,double u,double v,double w,double s[])408 void BF_GradNode_2F(struct Element * Element, int NumEntity,
409 		    double u, double v, double w,  double s[])
410 {
411   switch (Element->Type) {
412 
413   case LINE   : case LINE_2 :
414   case LINE_3 : case LINE_4 :
415   case TRIANGLE   : case TRIANGLE_2 :
416   case TRIANGLE_3 : case TRIANGLE_4 :
417   case TETRAHEDRON   : case TETRAHEDRON_2 :
418   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
419     Message::Error("BF_GradNode_2F cannot be associated with this type of element");
420     break;
421 
422   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
423   case QUADRANGLE_3 : case QUADRANGLE_4 :
424     s[0] = 0.0625 * (-2.*u) * (1.-v) * (1.+v) ;
425     s[1] = 0.0625 * (1.-u) * (-2.*v) * (1.+u) ;
426     s[2] = 0. ;
427     break ;
428 
429   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
430   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
431     switch(NumEntity) {
432     case 1   : s[0] = 0.015625 *  (-2.*u) * (1.-v) * (1.-w) * (1.-v) * (1.+w) ;
433                s[1] = 0.015625 *  (1.-u) * (-2.)*(1.-v) * (1.-w) * (1.+u) * (1.+w) ;
434                s[2] = 0.015625 *  (1.-u) * (1.-v) * (-2.*w) * (1.+u) * (1.-v) ; break ;
435 
436     case 2   : s[0] = 0.015625 *  (-2.*u) * (1.-v) * (1.-w) * (1.+v) * (1.-w) ;
437                s[1] = 0.015625 *  (1.-u) * (-2.*v) * (1.-w) * (1.+u) * (1.-w) ;
438                s[2] = 0.015625 *  (1.-u) * (1.-v) * (-2.)*(1.-w) * (1.+u) * (1.+v) ; break;
439 
440     case 3   : s[0] = 0.015625 *  (-2.)*(1.-u) * (1.-v) * (1.-w) * (1.+v) * (1.+w) ;
441                s[1] = 0.015625 *  (1.-u) * (-2.*v) * (1.-w) * (1.-u) * (1.+w) ;
442                s[2] = 0.015625 *  (1.-u) * (1.-v) * (-2.*w) * (1.-u) * (1.+v) ; break;
443 
444     case 4   : s[0] = 0.015625 *  2.*(1.+u) * (1.-v) * (1.-w) * (1.+v) * (1.+w) ;
445                s[1] = 0.015625 *  (1.+u) * (-2.*v) * (1.-w) * (1.+u) * (1.+w) ;
446                s[2] = 0.015625 *  (1.+u) * (1.-v) * (-2.*w) * (1.+u) * (1.+v) ; break;
447 
448     case 5   : s[0] = 0.015625 *  (-2.*u) * (1.+v) * (1.-w) * (1.+v) * (1.+w) ;
449                s[1] = 0.015625 *  (1.+u) * 2.*(1.+v) * (1.-w) * (1.-u) * (1.+w) ;
450                s[2] = 0.015625 *  (1.+u) * (1.+v) * (-2.*w) * (1.-u) * (1.+v) ; break;
451 
452     case 6   : s[0] = 0.015625 *  (-2.*u) * (1.-v) * (1.+w) * (1.+v) * (1.+w) ;
453                s[1] = 0.015625 *  (1.-u) * (-2.*v) * (1.+w) * (1.+u) * (1.+w) ;
454                s[2] = 0.015625 *  (1.-u) * (1.-v) * 2.*(1.+w) * (1.+u) * (1.+v) ; break;
455     default : WrongNumEntity ;
456     }
457     break ;
458 
459   case PRISM   : case PRISM_2 : case PRISM_2_15N :
460   case PRISM_3 : case PRISM_4 :
461     switch(NumEntity) {
462     default : Message::Error("BF_GradNode_2F not ready for PRISM");
463       // cannot do this yet in getdp, as dofs should only be
464       // associated with quad-faces: if really necessary we could
465       // implement actual 15 and 18-node prisms
466       /*
467     case 1   : s[0] = 0.25 * (1.-2.*u-v) * (1.-w) * (1.+w) ;
468                s[1] = 0.25 * (-u) * (1.-w) * (1.+w);
469                s[2] = 0.25 * (u-u*u-u*v) * (-2.*w); break ;
470 
471     case 3   : s[0] = 0.25 * (-v) * (1.-w) * (1.+w) ;
472                s[1] = 0.25 * (1.-u-2.*v) * (1.-w) * (1.+w) ;
473                s[2] = 0.25 * (v-u*v-v*v) * (-2.*w) ; break;
474 
475     case 4   : s[0] = 0.25 * (1.-w) * v * (1.+w) ;
476                s[1] = 0.25 * u * (1.-w) * (1.+w) ;
477                s[2] = 0.25 * u * (-2.*w) * v ; break;
478       */
479     }
480     break ;
481 
482   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
483   case PYRAMID_3 : // case PYRAMID_4
484     switch(NumEntity) {
485     default : Message::Error("BF_GradNode_2F not ready for PYRAMID");
486     }
487     break ;
488 
489   default :
490     Message::Error("Unknown type of Element in BF_GradNode_2F");
491     break ;
492   }
493 
494 }
495 
496 #undef WrongNumEntity
497 
498 /* -------- */
499 /*  Volume  */
500 /* -------- */
501 
BF_GradNode_2V(struct Element * Element,int NumEntity,double u,double v,double w,double s[])502 void BF_GradNode_2V(struct Element * Element, int NumEntity,
503 		    double u, double v, double w,  double s[])
504 {
505   switch (Element->Type) {
506 
507   case LINE   : case LINE_2 :
508   case LINE_3 : case LINE_4 :
509   case TRIANGLE   : case TRIANGLE_2 :
510   case TRIANGLE_3 : case TRIANGLE_4 :
511   case QUADRANGLE   : case QUADRANGLE_2 : case QUADRANGLE_2_8N :
512   case QUADRANGLE_3 : case QUADRANGLE_4 :
513   case TETRAHEDRON   : case TETRAHEDRON_2 :
514   case TETRAHEDRON_3 : case TETRAHEDRON_4 :
515   case PRISM   : case PRISM_2 : case PRISM_2_15N :
516   case PRISM_3 : case PRISM_4 :
517   case PYRAMID : case PYRAMID_2 : case PYRAMID_2_13N :
518   case PYRAMID_3 : // case PYRAMID_4
519     Message::Error("BF_GradNode_2V cannot be associated with this type of element");
520     break;
521 
522   case HEXAHEDRON   : case HEXAHEDRON_2 : case HEXAHEDRON_2_20N :
523   case HEXAHEDRON_3 : case HEXAHEDRON_4 :
524     s[0] = 0.015625 * (-2.*u) * (1.-v) * (1.-w) * (1.+v) * (1.+w) ;
525     s[1] = 0.015625 * (1.-u) * (-2.*v) * (1.-w) * (1.+u) * (1.+w) ;
526     s[2] = 0.015625 * (1.-u) * (1.-v) * (-2.*w) * (1.+u) * (1.+v) ;
527     break ;
528 
529   default :
530     Message::Error("Unknown type of Element in BF_GradNode_2V");
531     break ;
532   }
533 
534 }
535