Line data Source code
1 : // The libMesh Finite Element Library.
2 : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 :
4 : // This library is free software; you can redistribute it and/or
5 : // modify it under the terms of the GNU Lesser General Public
6 : // License as published by the Free Software Foundation; either
7 : // version 2.1 of the License, or (at your option) any later version.
8 :
9 : // This library is distributed in the hope that it will be useful,
10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 : // Lesser General Public License for more details.
13 :
14 : // You should have received a copy of the GNU Lesser General Public
15 : // License along with this library; if not, write to the Free Software
16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 :
18 :
19 : #include "libmesh/libmesh_config.h"
20 :
21 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
22 :
23 : // libmesh includes
24 : #include "libmesh/fe.h"
25 : #include "libmesh/elem.h"
26 : #include "libmesh/number_lookups.h"
27 : #include "libmesh/utility.h"
28 : #include "libmesh/enum_to_string.h"
29 :
30 :
31 : namespace {
32 :
33 : using namespace libMesh;
34 :
35 : /*
36 : * Helper function for finding indices, when computing quad shape
37 : * functions and derivatives via a tensor-product of 1D functions and
38 : * derivatives.
39 : */
40 283921414 : std::pair<unsigned int, unsigned int> quad_i0_i1 (const unsigned int i,
41 : const Order totalorder,
42 : const Elem & elem)
43 : {
44 79768567 : libmesh_assert_less (i, (totalorder+1u)*(totalorder+1u));
45 :
46 : unsigned int i0, i1;
47 :
48 : // Vertex DoFs
49 158406860 : if (i == 0)
50 8866291 : { i0 = 0; i1 = 0; }
51 140799864 : else if (i == 1)
52 8866291 : { i0 = 1; i1 = 0; }
53 123192868 : else if (i == 2)
54 8866291 : { i0 = 1; i1 = 1; }
55 105585872 : else if (i == 3)
56 8866291 : { i0 = 0; i1 = 1; }
57 :
58 :
59 : // Edge DoFs
60 157684302 : else if (i < totalorder + 3u)
61 31506398 : { i0 = i - 2; i1 = 0; }
62 126177904 : else if (i < 2u*totalorder + 2)
63 31506398 : { i0 = 1; i1 = i - totalorder - 1; }
64 94671506 : else if (i < 3u*totalorder + 1)
65 31506398 : { i0 = i - 2u*totalorder; i1 = 1; }
66 63165108 : else if (i < 4u*totalorder)
67 31506398 : { i0 = 0; i1 = i - 3u*totalorder + 1; }
68 : // Interior DoFs
69 : else
70 : {
71 31658710 : unsigned int basisnum = i - 4*totalorder;
72 31658710 : i0 = square_number_column[basisnum] + 2;
73 31658710 : i1 = square_number_row[basisnum] + 2;
74 : }
75 :
76 :
77 : // Flip odd degree of freedom values if necessary
78 : // to keep continuity on sides
79 283921414 : if ((i>= 4 && i<= 4+ totalorder-2u) && elem.point(0) > elem.point(1)) i0=totalorder+2-i0;
80 253642130 : else if ((i>= 4+ totalorder-1u && i<= 4+2*totalorder-3u) && elem.point(1) > elem.point(2)) i1=totalorder+2-i1;
81 223285574 : else if ((i>= 4+2*totalorder-2u && i<= 4+3*totalorder-4u) && elem.point(3) > elem.point(2)) i0=totalorder+2-i0;
82 193007910 : else if ((i>= 4+3*totalorder-3u && i<= 4+4*totalorder-5u) && elem.point(0) > elem.point(3)) i1=totalorder+2-i1;
83 :
84 363689981 : return std::make_pair(i0, i1);
85 : }
86 :
87 : }
88 :
89 : namespace libMesh
90 : {
91 :
92 :
93 5515725 : LIBMESH_DEFAULT_VECTORIZED_FE(2,BERNSTEIN)
94 :
95 :
96 : template <>
97 173893482 : Real FE<2,BERNSTEIN>::shape(const Elem * elem,
98 : const Order order,
99 : const unsigned int i,
100 : const Point & p,
101 : const bool add_p_level)
102 : {
103 49151321 : libmesh_assert(elem);
104 :
105 173893482 : const ElemType type = elem->type();
106 :
107 : const Order totalorder =
108 221914529 : order + add_p_level*elem->p_level();
109 :
110 : // Declare that we are using our own special power function
111 : // from the Utility namespace. This saves typing later.
112 : using Utility::pow;
113 :
114 173893482 : switch (type)
115 : {
116 : // Hierarchic shape functions on the quadrilateral.
117 168937006 : case QUAD4:
118 : case QUADSHELL4:
119 : case QUAD9:
120 : case QUADSHELL9:
121 : {
122 : // Compute quad shape functions as a tensor-product
123 168937006 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
124 :
125 215591476 : return (FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i0, p(0))*
126 215591476 : FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i1, p(1)));
127 : }
128 : // handle serendipity QUAD8 element separately
129 588272 : case QUAD8:
130 : case QUADSHELL8:
131 : {
132 147104 : libmesh_assert_less (totalorder, 3);
133 :
134 588272 : const Real xi = p(0);
135 588272 : const Real eta = p(1);
136 :
137 147104 : libmesh_assert_less (i, 8);
138 :
139 : // 0 1 2 3 4 5 6 7 8
140 : static const unsigned int i0[] = {0, 1, 1, 0, 2, 1, 2, 0, 2};
141 : static const unsigned int i1[] = {0, 0, 1, 1, 0, 2, 1, 2, 2};
142 : static const Real scal[] = {-0.25, -0.25, -0.25, -0.25, 0.5, 0.5, 0.5, 0.5};
143 :
144 : //B_t,i0(i)|xi * B_s,i1(i)|eta + scal(i) * B_t,2|xi * B_t,2|eta
145 588272 : return (FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i0[i], xi)*
146 588272 : FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i1[i], eta)
147 735376 : +scal[i]*
148 588272 : FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i0[8], xi)*
149 588272 : FE<1,BERNSTEIN>::shape(EDGE3, totalorder, i1[8], eta));
150 :
151 : }
152 63104 : case QUAD16:
153 : {
154 : // Compute quad shape functions as a tensor-product
155 63104 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
156 :
157 78880 : return (FE<1,BERNSTEIN>::shape(EDGE4, totalorder, i0, p(0))*
158 78880 : FE<1,BERNSTEIN>::shape(EDGE4, totalorder, i1, p(1)));
159 : }
160 3272862 : case TRI3:
161 : case TRISHELL3:
162 171459 : libmesh_assert_less (totalorder, 2);
163 : libmesh_fallthrough();
164 : case TRI6:
165 : case TRI7:
166 4305100 : switch (totalorder)
167 : {
168 601254 : case FIRST:
169 : {
170 601254 : const Real x=p(0);
171 601254 : const Real y=p(1);
172 601254 : const Real r=1.-x-y;
173 :
174 171459 : libmesh_assert_less (i, 3);
175 :
176 601254 : switch(i)
177 : {
178 57153 : case 0: return r; //f0,0,1
179 200418 : case 1: return x; //f0,1,1
180 200418 : case 2: return y; //f1,0,1
181 :
182 0 : default:
183 0 : libmesh_error_msg("Invalid shape function index i = " << i);
184 : }
185 : }
186 1776276 : case SECOND:
187 : {
188 1776276 : const Real x=p(0);
189 1776276 : const Real y=p(1);
190 1776276 : const Real r=1.-x-y;
191 :
192 492048 : libmesh_assert_less (i, 6);
193 :
194 1776276 : switch(i)
195 : {
196 296046 : case 0: return r*r;
197 296046 : case 1: return x*x;
198 296046 : case 2: return y*y;
199 :
200 296046 : case 3: return 2.*x*r;
201 296046 : case 4: return 2.*x*y;
202 296046 : case 5: return 2.*r*y;
203 :
204 0 : default:
205 0 : libmesh_error_msg("Invalid shape function index i = " << i);
206 : }
207 : }
208 727180 : case THIRD:
209 : {
210 727180 : const Real x=p(0);
211 727180 : const Real y=p(1);
212 727180 : const Real r=1.-x-y;
213 203980 : libmesh_assert_less (i, 10);
214 :
215 203980 : unsigned int shape=i;
216 :
217 :
218 727180 : if ((i==3||i==4) && elem->positive_edge_orientation(0)) shape=7-i;
219 727180 : if ((i==5||i==6) && elem->positive_edge_orientation(1)) shape=11-i;
220 727180 : if ((i==7||i==8) && !elem->positive_edge_orientation(2)) shape=15-i;
221 :
222 727180 : switch(shape)
223 : {
224 72718 : case 0: return r*r*r;
225 72718 : case 1: return x*x*x;
226 72718 : case 2: return y*y*y;
227 :
228 72718 : case 3: return 3.*x*r*r;
229 72718 : case 4: return 3.*x*x*r;
230 :
231 72718 : case 5: return 3.*y*x*x;
232 72718 : case 6: return 3.*y*y*x;
233 :
234 72718 : case 7: return 3.*y*r*r;
235 72718 : case 8: return 3.*y*y*r;
236 :
237 72718 : case 9: return 6.*x*y*r;
238 :
239 0 : default:
240 0 : libmesh_error_msg("Invalid shape function index shape = " << shape);
241 : }
242 : }
243 1200390 : case FOURTH:
244 : {
245 1200390 : const Real x=p(0);
246 1200390 : const Real y=p(1);
247 1200390 : const Real r=1-x-y;
248 336210 : unsigned int shape=i;
249 :
250 336210 : libmesh_assert_less (i, 15);
251 :
252 1200390 : if ((i==3||i== 5) && elem->positive_edge_orientation(0)) shape=8-i;
253 1200390 : if ((i==6||i== 8) && elem->positive_edge_orientation(1)) shape=14-i;
254 1200390 : if ((i==9||i==11) && !elem->positive_edge_orientation(2)) shape=20-i;
255 :
256 :
257 1200390 : switch(shape)
258 : {
259 : // point functions
260 80026 : case 0: return r*r*r*r;
261 80026 : case 1: return x*x*x*x;
262 80026 : case 2: return y*y*y*y;
263 :
264 : // edge functions
265 80026 : case 3: return 4.*x*r*r*r;
266 80026 : case 4: return 6.*x*x*r*r;
267 80026 : case 5: return 4.*x*x*x*r;
268 :
269 80026 : case 6: return 4.*y*x*x*x;
270 80026 : case 7: return 6.*y*y*x*x;
271 80026 : case 8: return 4.*y*y*y*x;
272 :
273 80026 : case 9: return 4.*y*r*r*r;
274 80026 : case 10: return 6.*y*y*r*r;
275 80026 : case 11: return 4.*y*y*y*r;
276 :
277 : // inner functions
278 80026 : case 12: return 12.*x*y*r*r;
279 80026 : case 13: return 12.*x*x*y*r;
280 80026 : case 14: return 12.*x*y*y*r;
281 :
282 0 : default:
283 0 : libmesh_error_msg("Invalid shape function index shape = " << shape);
284 : }
285 : }
286 0 : case FIFTH:
287 : {
288 0 : const Real x=p(0);
289 0 : const Real y=p(1);
290 0 : const Real r=1-x-y;
291 0 : unsigned int shape=i;
292 :
293 0 : libmesh_assert_less (i, 21);
294 :
295 0 : if ((i>= 3&&i<= 6) && elem->positive_edge_orientation(0)) shape=9-i;
296 0 : if ((i>= 7&&i<=10) && elem->positive_edge_orientation(1)) shape=17-i;
297 0 : if ((i>=11&&i<=14) && !elem->positive_edge_orientation(2)) shape=25-i;
298 :
299 0 : switch(shape)
300 : {
301 : //point functions
302 0 : case 0: return pow<5>(r);
303 0 : case 1: return pow<5>(x);
304 0 : case 2: return pow<5>(y);
305 :
306 : //edge functions
307 0 : case 3: return 5.*x *pow<4>(r);
308 0 : case 4: return 10.*pow<2>(x)*pow<3>(r);
309 0 : case 5: return 10.*pow<3>(x)*pow<2>(r);
310 0 : case 6: return 5.*pow<4>(x)*r;
311 :
312 0 : case 7: return 5.*y *pow<4>(x);
313 0 : case 8: return 10.*pow<2>(y)*pow<3>(x);
314 0 : case 9: return 10.*pow<3>(y)*pow<2>(x);
315 0 : case 10: return 5.*pow<4>(y)*x;
316 :
317 0 : case 11: return 5.*y *pow<4>(r);
318 0 : case 12: return 10.*pow<2>(y)*pow<3>(r);
319 0 : case 13: return 10.*pow<3>(y)*pow<2>(r);
320 0 : case 14: return 5.*pow<4>(y)*r;
321 :
322 : //inner functions
323 0 : case 15: return 20.*x*y*pow<3>(r);
324 0 : case 16: return 30.*x*pow<2>(y)*pow<2>(r);
325 0 : case 17: return 30.*pow<2>(x)*y*pow<2>(r);
326 0 : case 18: return 20.*x*pow<3>(y)*r;
327 0 : case 19: return 20.*pow<3>(x)*y*r;
328 0 : case 20: return 30.*pow<2>(x)*pow<2>(y)*r;
329 :
330 0 : default:
331 0 : libmesh_error_msg("Invalid shape function index shape = " << shape);
332 : }
333 : }
334 0 : case SIXTH:
335 : {
336 0 : const Real x=p(0);
337 0 : const Real y=p(1);
338 0 : const Real r=1-x-y;
339 0 : unsigned int shape=i;
340 :
341 0 : libmesh_assert_less (i, 28);
342 :
343 0 : if ((i>= 3&&i<= 7) && elem->positive_edge_orientation(0)) shape=10-i;
344 0 : if ((i>= 8&&i<=12) && elem->positive_edge_orientation(1)) shape=20-i;
345 0 : if ((i>=13&&i<=17) && !elem->positive_edge_orientation(2)) shape=30-i;
346 :
347 0 : switch(shape)
348 : {
349 : //point functions
350 0 : case 0: return pow<6>(r);
351 0 : case 1: return pow<6>(x);
352 0 : case 2: return pow<6>(y);
353 :
354 : //edge functions
355 0 : case 3: return 6.*x *pow<5>(r);
356 0 : case 4: return 15.*pow<2>(x)*pow<4>(r);
357 0 : case 5: return 20.*pow<3>(x)*pow<3>(r);
358 0 : case 6: return 15.*pow<4>(x)*pow<2>(r);
359 0 : case 7: return 6.*pow<5>(x)*r;
360 :
361 0 : case 8: return 6.*y *pow<5>(x);
362 0 : case 9: return 15.*pow<2>(y)*pow<4>(x);
363 0 : case 10: return 20.*pow<3>(y)*pow<3>(x);
364 0 : case 11: return 15.*pow<4>(y)*pow<2>(x);
365 0 : case 12: return 6.*pow<5>(y)*x;
366 :
367 0 : case 13: return 6.*y *pow<5>(r);
368 0 : case 14: return 15.*pow<2>(y)*pow<4>(r);
369 0 : case 15: return 20.*pow<3>(y)*pow<3>(r);
370 0 : case 16: return 15.*pow<4>(y)*pow<2>(r);
371 0 : case 17: return 6.*pow<5>(y)*r;
372 :
373 : //inner functions
374 0 : case 18: return 30.*x*y*pow<4>(r);
375 0 : case 19: return 60.*x*pow<2>(y)*pow<3>(r);
376 0 : case 20: return 60.* pow<2>(x)*y*pow<3>(r);
377 0 : case 21: return 60.*x*pow<3>(y)*pow<2>(r);
378 0 : case 22: return 60.*pow<3>(x)*y*pow<2>(r);
379 0 : case 23: return 90.*pow<2>(x)*pow<2>(y)*pow<2>(r);
380 0 : case 24: return 30.*x*pow<4>(y)*r;
381 0 : case 25: return 60.*pow<2>(x)*pow<3>(y)*r;
382 0 : case 26: return 60.*pow<3>(x)*pow<2>(y)*r;
383 0 : case 27: return 30.*pow<4>(x)*y*r;
384 :
385 0 : default:
386 0 : libmesh_error_msg("Invalid shape function index shape = " << shape);
387 : } // switch shape
388 : }
389 0 : default:
390 0 : libmesh_error_msg("Invalid totalorder = " << totalorder);
391 : } // switch order
392 :
393 0 : default:
394 0 : libmesh_error_msg("ERROR: Unsupported element type = " << Utility::enum_to_string(type));
395 : } // switch type
396 : }
397 :
398 :
399 : template <>
400 0 : Real FE<2,BERNSTEIN>::shape(const ElemType,
401 : const Order,
402 : const unsigned int,
403 : const Point &)
404 : {
405 0 : libmesh_error_msg("Bernstein polynomials require the element type \nbecause edge orientation is needed.");
406 : return 0.;
407 : }
408 :
409 :
410 : template <>
411 0 : Real FE<2,BERNSTEIN>::shape(const FEType fet,
412 : const Elem * elem,
413 : const unsigned int i,
414 : const Point & p,
415 : const bool add_p_level)
416 : {
417 0 : return FE<2,BERNSTEIN>::shape(elem, fet.order, i, p, add_p_level);
418 : }
419 :
420 :
421 :
422 : template <>
423 115587684 : Real FE<2,BERNSTEIN>::shape_deriv(const Elem * elem,
424 : const Order order,
425 : const unsigned int i,
426 : const unsigned int j,
427 : const Point & p,
428 : const bool add_p_level)
429 : {
430 32176716 : libmesh_assert(elem);
431 :
432 115587684 : const ElemType type = elem->type();
433 :
434 : const Order totalorder =
435 147764400 : order + add_p_level*elem->p_level();
436 :
437 115587684 : switch (type)
438 : {
439 : // Hierarchic shape functions on the quadrilateral.
440 113726860 : case QUAD4:
441 : case QUAD9:
442 : case QUADSHELL9:
443 : {
444 : // Compute quad shape functions as a tensor-product
445 113726860 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
446 :
447 113726860 : switch (j)
448 : {
449 : // d()/dxi
450 56863430 : case 0:
451 72698148 : return (FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i0, 0, p(0))*
452 72698148 : FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i1, p(1)));
453 :
454 : // d()/deta
455 56863430 : case 1:
456 72698148 : return (FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i0, p(0))*
457 72698148 : FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i1, 0, p(1)));
458 :
459 0 : default:
460 0 : libmesh_error_msg("Invalid shape function derivative j = " << j);
461 : }
462 : }
463 :
464 : // Bernstein shape functions on the 8-noded quadrilateral
465 : // is handled separately.
466 369120 : case QUAD8:
467 : case QUADSHELL8:
468 : {
469 92352 : libmesh_assert_less (totalorder, 3);
470 :
471 369120 : const Real xi = p(0);
472 369120 : const Real eta = p(1);
473 :
474 92352 : libmesh_assert_less (i, 8);
475 :
476 : // 0 1 2 3 4 5 6 7 8
477 : static const unsigned int i0[] = {0, 1, 1, 0, 2, 1, 2, 0, 2};
478 : static const unsigned int i1[] = {0, 0, 1, 1, 0, 2, 1, 2, 2};
479 : static const Real scal[] = {-0.25, -0.25, -0.25, -0.25, 0.5, 0.5, 0.5, 0.5};
480 369120 : switch (j)
481 : {
482 : // d()/dxi
483 46176 : case 0:
484 184560 : return (FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i0[i], 0, xi)*
485 184560 : FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i1[i], eta)
486 230736 : +scal[i]*
487 184560 : FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i0[8], 0, xi)*
488 184560 : FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i1[8], eta));
489 :
490 : // d()/deta
491 46176 : case 1:
492 184560 : return (FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i0[i], xi)*
493 184560 : FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i1[i], 0, eta)
494 230736 : +scal[i]*
495 184560 : FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i0[8], xi)*
496 184560 : FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i1[8], 0, eta));
497 :
498 0 : default:
499 0 : libmesh_error_msg("Invalid shape function derivative j = " << j);
500 : }
501 : }
502 66816 : case QUAD16:
503 : {
504 : // Compute quad shape functions as a tensor-product
505 66816 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
506 :
507 66816 : switch (j)
508 : {
509 : // d()/dxi
510 33408 : case 0:
511 41760 : return (FE<1,BERNSTEIN>::shape_deriv(EDGE4, totalorder, i0, 0, p(0))*
512 41760 : FE<1,BERNSTEIN>::shape (EDGE4, totalorder, i1, p(1)));
513 :
514 : // d()/deta
515 33408 : case 1:
516 41760 : return (FE<1,BERNSTEIN>::shape (EDGE4, totalorder, i0, p(0))*
517 41760 : FE<1,BERNSTEIN>::shape_deriv(EDGE4, totalorder, i1, 0, p(1)));
518 :
519 0 : default:
520 0 : libmesh_error_msg("Invalid shape function derivative j = " << j);
521 : }
522 : }
523 :
524 1100944 : case TRI3:
525 : case TRISHELL3:
526 74280 : libmesh_assert_less (totalorder, 2);
527 : libmesh_fallthrough();
528 : case TRI6:
529 : case TRI7:
530 : {
531 1424888 : return fe_fdm_deriv(elem, order, i, j, p, add_p_level, FE<2,BERNSTEIN>::shape);
532 : }
533 :
534 0 : default:
535 0 : libmesh_error_msg("ERROR: Unsupported element type = " << Utility::enum_to_string(type));
536 : }
537 : }
538 :
539 :
540 :
541 :
542 : template <>
543 0 : Real FE<2,BERNSTEIN>::shape_deriv(const ElemType,
544 : const Order,
545 : const unsigned int,
546 : const unsigned int,
547 : const Point &)
548 : {
549 0 : libmesh_error_msg("Bernstein polynomials require the element type \nbecause edge orientation is needed.");
550 : return 0.;
551 : }
552 :
553 : template <>
554 0 : Real FE<2,BERNSTEIN>::shape_deriv(const FEType fet,
555 : const Elem * elem,
556 : const unsigned int i,
557 : const unsigned int j,
558 : const Point & p,
559 : const bool add_p_level)
560 : {
561 0 : return FE<2,BERNSTEIN>::shape_deriv(elem, fet.order, i, j, p, add_p_level);
562 : }
563 :
564 :
565 :
566 :
567 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
568 :
569 :
570 :
571 : template <>
572 1582518 : Real FE<2,BERNSTEIN>::shape_second_deriv(const Elem * elem,
573 : const Order order,
574 : const unsigned int i,
575 : const unsigned int j,
576 : const Point & p,
577 : const bool add_p_level)
578 : {
579 410622 : libmesh_assert(elem);
580 :
581 1582518 : const ElemType type = elem->type();
582 :
583 : const Order totalorder =
584 1993140 : order + add_p_level*elem->p_level();
585 :
586 1171896 : switch (type)
587 : {
588 : // Hierarchic shape functions on the quadrilateral.
589 1027404 : case QUAD4:
590 : case QUAD9:
591 : case QUADSHELL9:
592 : {
593 : // Compute quad shape functions as a tensor-product
594 1027404 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
595 :
596 1027404 : switch (j)
597 : {
598 : // d^2() / dxi^2
599 342468 : case 0:
600 428085 : return (FE<1,BERNSTEIN>::shape_second_deriv(EDGE3, totalorder, i0, 0, p(0))*
601 428085 : FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i1, p(1)));
602 :
603 : // d^2() / dxi deta
604 342468 : case 1:
605 428085 : return (FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i0, 0, p(0))*
606 428085 : FE<1,BERNSTEIN>::shape_deriv(EDGE3, totalorder, i1, 0, p(1)));
607 :
608 : // d^2() / deta^2
609 342468 : case 2:
610 428085 : return (FE<1,BERNSTEIN>::shape (EDGE3, totalorder, i0, p(0))*
611 428085 : FE<1,BERNSTEIN>::shape_second_deriv(EDGE3, totalorder, i1, 0, p(1)));
612 :
613 0 : default:
614 0 : libmesh_error_msg("Invalid shape function derivative j = " << j);
615 : }
616 : }
617 :
618 100224 : case QUAD16:
619 : {
620 : // Compute quad shape functions as a tensor-product
621 100224 : auto [i0, i1] = quad_i0_i1(i, totalorder, *elem);
622 :
623 100224 : switch (j)
624 : {
625 : // d^2() / dxi^2
626 33408 : case 0:
627 41760 : return (FE<1,BERNSTEIN>::shape_second_deriv(EDGE4, totalorder, i0, 0, p(0))*
628 41760 : FE<1,BERNSTEIN>::shape (EDGE4, totalorder, i1, p(1)));
629 :
630 : // d^2() / dxi deta
631 33408 : case 1:
632 41760 : return (FE<1,BERNSTEIN>::shape_deriv(EDGE4, totalorder, i0, 0, p(0))*
633 41760 : FE<1,BERNSTEIN>::shape_deriv(EDGE4, totalorder, i1, 0, p(1)));
634 :
635 : // d^2() / deta^2
636 33408 : case 2:
637 41760 : return (FE<1,BERNSTEIN>::shape (EDGE4, totalorder, i0, p(0))*
638 41760 : FE<1,BERNSTEIN>::shape_second_deriv(EDGE4, totalorder, i1, 0, p(1)));
639 :
640 0 : default:
641 0 : libmesh_error_msg("Invalid shape function derivative j = " << j);
642 : }
643 : }
644 :
645 : // Going to be lazy again about the hard cases.
646 348216 : case TRI3:
647 : case TRISHELL3:
648 22041 : libmesh_assert_less (totalorder, 2);
649 : libmesh_fallthrough();
650 : case QUAD8:
651 : case QUADSHELL8:
652 : case TRI6:
653 : case TRI7:
654 : {
655 454890 : return fe_fdm_second_deriv(elem, order, i, j, p, add_p_level,
656 454890 : FE<2,BERNSTEIN>::shape_deriv);
657 : }
658 :
659 0 : default:
660 0 : libmesh_error_msg("ERROR: Unsupported element type = " << Utility::enum_to_string(type));
661 : }
662 : }
663 :
664 :
665 : template <>
666 0 : Real FE<2,BERNSTEIN>::shape_second_deriv(const ElemType,
667 : const Order,
668 : const unsigned int,
669 : const unsigned int,
670 : const Point &)
671 : {
672 0 : libmesh_error_msg("Bernstein polynomials require the element type \nbecause edge orientation is needed.");
673 : return 0.;
674 : }
675 :
676 :
677 : template <>
678 0 : Real FE<2,BERNSTEIN>::shape_second_deriv(const FEType fet,
679 : const Elem * elem,
680 : const unsigned int i,
681 : const unsigned int j,
682 : const Point & p,
683 : const bool add_p_level)
684 : {
685 0 : libmesh_assert(elem);
686 0 : return FE<2,BERNSTEIN>::shape_second_deriv(elem, fet.order, i, j, p, add_p_level);
687 : }
688 :
689 :
690 :
691 : #endif
692 :
693 : } // namespace libMesh
694 :
695 :
696 : #endif// LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
|