libMesh
Loading...
Searching...
No Matches
fe_interface.C
Go to the documentation of this file.
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
20// Local includes
21#include "libmesh/fe_interface.h"
22#include "libmesh/fe_lagrange_gll_shape_1D.h"
23
24#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
25#include "libmesh/fe_interface_macros.h"
26#include "libmesh/inf_fe.h"
27#endif
28
29#include "libmesh/elem.h"
30#include "libmesh/fe.h"
31#include "libmesh/fe_compute_data.h"
32#include "libmesh/dof_map.h"
33#include "libmesh/enum_fe_family.h"
34#include "libmesh/enum_order.h"
35#include "libmesh/enum_elem_type.h"
36#include "libmesh/enum_to_string.h"
37
38namespace libMesh
39{
40
41//------------------------------------------------------------
42//FEInterface class members
44{
45 libmesh_error_msg("ERROR: Do not define an object of this type.");
46}
47
48
49
50#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
51
52bool
54{
55 return false;
56}
57
58#else
59
60bool
62{
63
64 switch (et)
65 {
66 case INFEDGE2:
67 case INFQUAD4:
68 case INFQUAD6:
69 case INFHEX8:
70 case INFHEX16:
71 case INFHEX18:
72 case INFPRISM6:
73 case INFPRISM12:
74 return true;
75
76 default:
77 return false;
78 }
79}
80
81#endif //ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
82
83#define fe_family_case_func(family, dim, func_and_args, prefix, suffix) \
84 case family: \
85 prefix FE<dim,family>::func_and_args suffix \
86
87#define fe_family_case(family) \
88 case family:
89
90#define fe_family_scalar_case_func(dim, func_and_args, prefix, suffix) \
91 fe_family_case_func(CLOUGH, dim, func_and_args, prefix, suffix) \
92 fe_family_case_func(HERMITE, dim, func_and_args, prefix, suffix) \
93 fe_family_case_func(HIERARCHIC, dim, func_and_args, prefix, suffix) \
94 fe_family_case_func(L2_HIERARCHIC, dim, func_and_args, prefix, suffix) \
95 fe_family_case_func(SIDE_HIERARCHIC, dim, func_and_args, prefix, suffix) \
96 fe_family_case_func(LAGRANGE, dim, func_and_args, prefix, suffix) \
97 fe_family_case_func(L2_LAGRANGE, dim, func_and_args, prefix, suffix) \
98 fe_family_case_func(L2_LAGRANGE_GLL, dim, func_and_args, prefix, suffix) \
99 fe_family_case_func(LAGRANGE_GLL, dim, func_and_args, prefix, suffix) \
100 fe_family_case_func(MONOMIAL, dim, func_and_args, prefix, suffix) \
101 fe_family_case_func(SCALAR, dim, func_and_args, prefix, suffix) \
102 fe_family_case_func(XYZ, dim, func_and_args, prefix, suffix) \
103 fe_family_case_func(SUBDIVISION, 2, func_and_args, \
104 libmesh_assert_equal_to (dim, 2); prefix, suffix)
105
106#define fe_family_scalar_case() \
107 fe_family_case(CLOUGH) \
108 fe_family_case(HERMITE) \
109 fe_family_case(HIERARCHIC) \
110 fe_family_case(L2_HIERARCHIC) \
111 fe_family_case(SIDE_HIERARCHIC) \
112 fe_family_case(LAGRANGE) \
113 fe_family_case(L2_LAGRANGE) \
114 fe_family_case(L2_LAGRANGE_GLL) \
115 fe_family_case(LAGRANGE_GLL) \
116 fe_family_case(MONOMIAL) \
117 fe_family_case(SCALAR) \
118 fe_family_case(XYZ) \
119 fe_family_case(SUBDIVISION) \
120
121#ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
122
123#define fe_family_horder_case_func(dim, func_and_args, prefix, suffix) \
124 fe_family_case_func(BERNSTEIN, dim, func_and_args, prefix, suffix) \
125 fe_family_case_func(SZABAB, dim, func_and_args, prefix, suffix) \
126 fe_family_case_func(RATIONAL_BERNSTEIN, dim, func_and_args, prefix, suffix) \
127
128#define fe_family_horder_case() \
129 fe_family_case(BERNSTEIN) \
130 fe_family_case(SZABAB) \
131 fe_family_case(RATIONAL_BERNSTEIN) \
132
133#else
134
135#define fe_family_horder_case_func(dim, func_and_args, prefix, suffix)
136#define fe_family_horder_case()
137
138#endif
139
140#define fe_family_vector_case_func(dim, func_and_args, prefix, suffix) \
141 fe_family_case_func(HIERARCHIC_VEC, dim, func_and_args, prefix, suffix) \
142 fe_family_case_func(L2_HIERARCHIC_VEC, dim, func_and_args, prefix, suffix) \
143 fe_family_case_func(LAGRANGE_VEC, dim, func_and_args, prefix, suffix) \
144 fe_family_case_func(L2_LAGRANGE_VEC, dim, func_and_args, prefix, suffix) \
145 fe_family_case_func(MONOMIAL_VEC, dim, func_and_args, prefix, suffix) \
146 fe_family_case_func(NEDELEC_ONE, dim, func_and_args, prefix, suffix) \
147 fe_family_case_func(RAVIART_THOMAS, dim, func_and_args, prefix, suffix) \
148 fe_family_case_func(L2_RAVIART_THOMAS, dim, func_and_args, prefix, suffix) \
149
150#define fe_family_vector_case() \
151 fe_family_case(HIERARCHIC_VEC) \
152 fe_family_case(L2_HIERARCHIC_VEC) \
153 fe_family_case(LAGRANGE_VEC) \
154 fe_family_case(L2_LAGRANGE_VEC) \
155 fe_family_case(MONOMIAL_VEC) \
156 fe_family_case(NEDELEC_ONE) \
157 fe_family_case(RAVIART_THOMAS) \
158 fe_family_case(L2_RAVIART_THOMAS) \
159
160#define fe_family_switch(dim, func_and_args, prefix, suffix) \
161 do { \
162 switch (fe_t.family) \
163 { \
164 fe_family_scalar_case_func(dim, func_and_args, prefix, suffix) \
165 fe_family_horder_case_func(dim, func_and_args, prefix, suffix) \
166 default: \
167 libmesh_error_msg("Unsupported family = " << Utility::enum_to_string(fe_t.family)); \
168 } \
169 } while (0)
170
171#define fe_family_with_vec_switch(dim, func_and_args, prefix, suffix) \
172 do { \
173 switch (fe_t.family) \
174 { \
175 fe_family_scalar_case_func(dim, func_and_args, prefix, suffix) \
176 fe_family_horder_case_func(dim, func_and_args, prefix, suffix) \
177 fe_family_vector_case_func(dim, func_and_args, prefix, suffix) \
178 default: \
179 libmesh_error_msg("Unsupported family = " << Utility::enum_to_string(fe_t.family)); \
180 } \
181 } while (0)
182
183#define fe_scalar_vec_error_switch(dim, func_and_args, prefix, suffix) \
184 do { \
185 switch (fe_t.family) \
186 { \
187 fe_family_scalar_case_func(dim, func_and_args, prefix, suffix) \
188 fe_family_horder_case_func(dim, func_and_args, prefix, suffix) \
189 fe_family_vector_case() \
190 libmesh_error_msg("Error: Can only request scalar valued elements for Real FEInterface::func_and_args"); \
191 default: \
192 libmesh_error_msg("Unsupported family = " << Utility::enum_to_string(fe_t.family)); \
193 } \
194 } while (0)
195
196
197#define fe_vector_scalar_error_switch(dim, func_and_args, prefix, suffix) \
198 do { \
199 switch (fe_t.family) \
200 { \
201 fe_family_vector_case_func(dim, func_and_args, prefix, suffix) \
202 fe_family_scalar_case() \
203 fe_family_horder_case() \
204 libmesh_error_msg("Error: Can only request vector valued elements for RealGradient FEInterface::func_and_args"); \
205 default: \
206 libmesh_error_msg("Unsupported family = " << Utility::enum_to_string(fe_t.family)); \
207 } \
208 } while (0)
209
210
211#define fe_switch(func_and_args) \
212 do { \
213 switch (dim) \
214 { \
215 /* 0D */ \
216 case 0: \
217 fe_family_switch (0, func_and_args, return, ;); \
218 /* 1D */ \
219 case 1: \
220 fe_family_switch (1, func_and_args, return, ;); \
221 /* 2D */ \
222 case 2: \
223 fe_family_switch (2, func_and_args, return, ;); \
224 /* 3D */ \
225 case 3: \
226 fe_family_switch (3, func_and_args, return, ;); \
227 default: \
228 libmesh_error_msg("Invalid dim = " << dim); \
229 } \
230 } while (0)
231
232#define fe_with_vec_switch(func_and_args) \
233 do { \
234 switch (dim) \
235 { \
236 /* 0D */ \
237 case 0: \
238 fe_family_with_vec_switch (0, func_and_args, return, ;); \
239 /* 1D */ \
240 case 1: \
241 fe_family_with_vec_switch (1, func_and_args, return, ;); \
242 /* 2D */ \
243 case 2: \
244 fe_family_with_vec_switch (2, func_and_args, return, ;); \
245 /* 3D */ \
246 case 3: \
247 fe_family_with_vec_switch (3, func_and_args, return, ;); \
248 default: \
249 libmesh_error_msg("Invalid dim = " << dim); \
250 } \
251 } while (0)
252
253#define void_fe_with_vec_switch(func_and_args) \
254 do { \
255 switch (dim) \
256 { \
257 /* 0D */ \
258 case 0: \
259 fe_family_with_vec_switch (0, func_and_args, , ; return;); \
260 /* 1D */ \
261 case 1: \
262 fe_family_with_vec_switch (1, func_and_args, , ; return;); \
263 /* 2D */ \
264 case 2: \
265 fe_family_with_vec_switch (2, func_and_args, , ; return;); \
266 /* 3D */ \
267 case 3: \
268 fe_family_with_vec_switch (3, func_and_args, , ; return;); \
269 default: \
270 libmesh_error_msg("Invalid dim = " << dim); \
271 } \
272 } while (0)
273
274
275
276#ifdef LIBMESH_ENABLE_DEPRECATED
277unsigned int FEInterface::n_shape_functions(const unsigned int dim,
278 const FEType & fe_t,
279 const ElemType t)
280{
281 libmesh_deprecated();
282
283#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
284
285 // We no longer support calling this function with an infinite
286 // ElemType, you must call the FeInterface::n_shape_functions()
287 // taking an Elem* instead.
288 if (is_InfFE_elem(t))
289 libmesh_not_implemented();
290
291#endif
292
293 const Order o = fe_t.order;
294
295 fe_with_vec_switch(n_shape_functions(t, o));
296}
297#endif // LIBMESH_ENABLE_DEPRECATED
298
299
300
301unsigned int
303 const Elem * elem,
304 const bool add_p_level)
305{
306 // dim is required by the fe_with_vec_switch macro
307 auto dim = elem->dim();
308
309#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
310 /*
311 * Since the FEType, stored in DofMap/(some System child), has to
312 * be the _same_ for InfFE and FE, we have to catch calls
313 * to infinite elements through the element type.
314 */
315
316 if (is_InfFE_elem(elem->type()))
317 return ifem_n_shape_functions(fe_t, elem);
318
319#endif
320
321 // Account for Elem::p_level() when computing total_order
322 auto total_order = fe_t.order + add_p_level*elem->p_level();
323
324 fe_with_vec_switch(n_dofs(elem, total_order));
325}
326
327
328
329unsigned int
331 const int extra_order,
332 const Elem * elem)
333{
334 // dim is required by the fe_with_vec_switch macro
335 auto dim = elem->dim();
336
337#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
338 /*
339 * Since the FEType, stored in DofMap/(some System child), has to
340 * be the _same_ for InfFE and FE, we have to catch calls
341 * to infinite elements through the element type.
342 */
343
344 if (is_InfFE_elem(elem->type()))
345 return ifem_n_shape_functions(fe_t, elem);
346
347#endif
348
349 // Ignore Elem::p_level() and instead use extra_order to compute total_order.
350 auto total_order = fe_t.order + extra_order;
351
352 fe_with_vec_switch(n_dofs(elem, total_order));
353}
354
355
356
357#ifdef LIBMESH_ENABLE_DEPRECATED
358unsigned int FEInterface::n_dofs(const unsigned int dim,
359 const FEType & fe_t,
360 const ElemType t)
361{
362 libmesh_deprecated();
363
364#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
365
366 // We no longer support calling this function with an infinite
367 // ElemType, you must call the FeInterface::n_dofs() taking an Elem*
368 // instead.
369 if (is_InfFE_elem(t))
370 libmesh_not_implemented();
371
372#endif
373
374 const Order o = fe_t.order;
375
376 fe_with_vec_switch(n_dofs(t, o));
377}
378
379
380
381
382unsigned int
383FEInterface::n_dofs (const unsigned int dim,
384 const FEType & fe_t,
385 const Elem * elem)
386{
387 libmesh_deprecated();
388
389 fe_with_vec_switch(n_dofs(elem, fe_t.order + elem->p_level()));
390}
391#endif // LIBMESH_ENABLE_DEPRECATED
392
393
394
395unsigned int
397 const Elem * elem,
398 const bool add_p_level)
399{
400 // dim is required by the fe_with_vec_switch macro
401 auto dim = elem->dim();
402
403#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
404
405 // InfElems currently don't support p_level()
406 if (is_InfFE_elem(elem->type()))
407 return ifem_n_dofs(fe_t, elem);
408
409#endif
410
411 // Account for Elem::p_level() when computing total_order
412 fe_with_vec_switch(n_dofs(elem, fe_t.order + add_p_level*elem->p_level()));
413}
414
415
416
417unsigned int
419 int extra_order,
420 const Elem * elem)
421{
422 // dim is required by the fe_with_vec_switch macro
423 auto dim = elem->dim();
424
425#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
426
427 // InfElems currently don't support p_level()
428 if (is_InfFE_elem(elem->type()))
429 return ifem_n_dofs(fe_t, elem);
430
431#endif
432
433 // Elem::p_level() is ignored, extra_order is used instead.
434 auto total_order = fe_t.order + extra_order;
435
436 fe_with_vec_switch(n_dofs(elem, total_order));
437}
438
439
440
441#ifdef LIBMESH_ENABLE_DEPRECATED
442unsigned int FEInterface::n_dofs_at_node(const unsigned int dim,
443 const FEType & fe_t,
444 const ElemType t,
445 const unsigned int n)
446{
447 libmesh_deprecated();
448
449#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
450
451 if (is_InfFE_elem(t))
452 return ifem_n_dofs_at_node(dim, fe_t, t, n);
453
454#endif
455
456 const Order o = fe_t.order;
457
458 fe_with_vec_switch(n_dofs_at_node(t, o, n));
459}
460
461
462
465 const FEType & fe_t)
466{
467 libmesh_deprecated();
468
469 fe_with_vec_switch(n_dofs_at_node);
470}
471#endif // LIBMESH_ENABLE_DEPRECATED
472
473
474
477 const Elem * elem)
478{
479 // dim is required by the fe_with_vec_switch macro
480 auto dim = elem->dim();
481
482 fe_with_vec_switch(n_dofs_at_node);
483}
484
485
486
487unsigned int
489 const Elem * elem,
490 const unsigned int n,
491 const bool add_p_level)
492{
493 // dim is required by the fe_with_vec_switch macro
494 auto dim = elem->dim();
495
496#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
497
498 if (is_InfFE_elem(elem->type()))
499 return ifem_n_dofs_at_node(fe_t, elem, n);
500
501#endif
502
503 // Account for Elem::p_level() when computing total_order
504 auto total_order = fe_t.order + add_p_level*elem->p_level();
505
506 fe_with_vec_switch(n_dofs_at_node(*elem, total_order, n));
507}
508
509
510
511unsigned int
513 const int extra_order,
514 const Elem * elem,
515 const unsigned int n)
516{
517 // dim is required by the fe_with_vec_switch macro
518 auto dim = elem->dim();
519
520#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
521
522 if (is_InfFE_elem(elem->type()))
523 return ifem_n_dofs_at_node(fe_t, elem, n);
524
525#endif
526
527 // Ignore Elem::p_level() and instead use extra_order to compute total_order.
528 auto total_order = fe_t.order + extra_order;
529
530 fe_with_vec_switch(n_dofs_at_node(*elem, total_order, n));
531}
532
533
534
535#ifdef LIBMESH_ENABLE_DEPRECATED
536unsigned int FEInterface::n_dofs_per_elem(const unsigned int dim,
537 const FEType & fe_t,
538 const ElemType t)
539{
540 libmesh_deprecated();
541
542#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
543
544 if (is_InfFE_elem(t))
545 return ifem_n_dofs_per_elem(dim, fe_t, t);
546
547#endif
548
549 const Order o = fe_t.order;
550
551 fe_with_vec_switch(n_dofs_per_elem(t, o));
552}
553#endif // LIBMESH_ENABLE_DEPRECATED
554
555
556
557unsigned int
559 const Elem * elem,
560 const bool add_p_level)
561{
562 // dim is required by the fe_with_vec_switch macro
563 auto dim = elem->dim();
564
565#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
566
567 if (is_InfFE_elem(elem->type()))
568 return ifem_n_dofs_per_elem(fe_t, elem);
569
570#endif
571
572 // Account for Elem::p_level() when computing total_order
573 auto total_order = fe_t.order + add_p_level*elem->p_level();
574
575 fe_with_vec_switch(n_dofs_per_elem(*elem, total_order));
576}
577
578
579
580unsigned int
582 const int extra_order,
583 const Elem * elem)
584{
585 // dim is required by the fe_with_vec_switch macro
586 auto dim = elem->dim();
587
588#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
589
590 if (is_InfFE_elem(elem->type()))
591 return ifem_n_dofs_per_elem(fe_t, elem);
592
593#endif
594
595 // Ignore Elem::p_level() and instead use extra_order to compute total_order.
596 auto total_order = fe_t.order + extra_order;
597
598 fe_with_vec_switch(n_dofs_per_elem(*elem, total_order));
599}
600
601
602
603void FEInterface::dofs_on_side(const Elem * const elem,
604 const unsigned int dim,
605 const FEType & fe_t,
606 unsigned int s,
607 std::vector<unsigned int> & di,
608 const bool add_p_level)
609{
610 const Order o = fe_t.order;
611
612 void_fe_with_vec_switch(dofs_on_side(elem, o, s, di, add_p_level));
613}
614
615
616
617void FEInterface::dofs_on_edge(const Elem * const elem,
618 const unsigned int dim,
619 const FEType & fe_t,
620 unsigned int e,
621 std::vector<unsigned int> & di,
622 const bool add_p_level)
623{
624 const Order o = fe_t.order;
625
626 void_fe_with_vec_switch(dofs_on_edge(elem, o, e, di, add_p_level));
627}
628
629
630
631void FEInterface::nodal_soln(const unsigned int dim,
632 const FEType & fe_t,
633 const Elem * elem,
634 const std::vector<Number> & elem_soln,
635 std::vector<Number> & nodal_soln,
636 const bool add_p_level,
637 const unsigned int vdim)
638{
639#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
640
641 if (is_InfFE_elem(elem->type()))
642 {
643 ifem_nodal_soln(dim, fe_t, elem, elem_soln, nodal_soln);
644 return;
645 }
646
647#endif
648
649 const Order order = fe_t.order;
650
651 void_fe_with_vec_switch(nodal_soln(elem, order, elem_soln, nodal_soln, add_p_level, vdim));
652}
653
654
655
657 const Elem * elem,
658 const unsigned int side,
659 const std::vector<Number> & elem_soln,
660 std::vector<Number> & nodal_soln,
661 const bool add_p_level,
662 const unsigned int vdim)
663{
664#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
665
666 if (is_InfFE_elem(elem->type()))
667 {
668 libmesh_not_implemented();
669 return;
670 }
671
672#endif
673
674 const Order order = fe_t.order;
675 const unsigned int dim = elem->dim();
676
677 void_fe_with_vec_switch(side_nodal_soln(elem, order, side, elem_soln, nodal_soln, add_p_level, vdim));
678}
679
680
681
682#ifdef LIBMESH_ENABLE_DEPRECATED
684 const FEType & fe_t,
685 const Elem * elem,
686 const Point & p)
687{
688 libmesh_deprecated();
689#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
690 if (is_InfFE_elem(elem->type()))
691 return ifem_map(dim, fe_t, elem, p);
692#endif
693 fe_with_vec_switch(map(elem, p));
694}
695
696
697
699 const FEType & fe_t,
700 const Elem * elem,
701 const Point & p,
702 const Real tolerance,
703 const bool secure)
704{
705 libmesh_deprecated();
706#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
707
708 if (is_InfFE_elem(elem->type()))
709 return ifem_inverse_map(dim, fe_t, elem, p,tolerance, secure);
710
711#endif
712
713 fe_with_vec_switch(inverse_map(elem, p, tolerance, secure));
714}
715
716
717
718void FEInterface::inverse_map (const unsigned int dim,
719 const FEType & fe_t,
720 const Elem * elem,
721 const std::vector<Point> & physical_points,
722 std::vector<Point> & reference_points,
723 const Real tolerance,
724 const bool secure)
725{
726 libmesh_deprecated();
727
728 const std::size_t n_pts = physical_points.size();
729
730 // Resize the vector
731 reference_points.resize(n_pts);
732
733 if (n_pts == 0)
734 {
735 libMesh::err << "WARNING: empty vector physical_points!"
736 << std::endl;
737 libmesh_here();
738 return;
739 }
740
741#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
742
743 if (is_InfFE_elem(elem->type()))
744 {
745 ifem_inverse_map(dim, fe_t, elem, physical_points, reference_points, tolerance, secure);
746 return;
747 // libmesh_not_implemented();
748 }
749
750#endif
751
752 void_fe_with_vec_switch(inverse_map(elem, physical_points, reference_points, tolerance, secure));
753}
754
755
756
758 const ElemType t,
759 const Real eps)
760{
761 return FEBase::on_reference_element(p,t,eps);
762}
763
764
765
766Real FEInterface::shape(const unsigned int dim,
767 const FEType & fe_t,
768 const ElemType t,
769 const unsigned int i,
770 const Point & p)
771{
772 libmesh_deprecated();
773
774#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
775
776 if (is_InfFE_elem(t))
777 return ifem_shape(dim, fe_t, t, i, p);
778
779#endif
780
781 const Order o = fe_t.order;
782
783 fe_switch(shape(t,o,i,p));
784}
785
786Real FEInterface::shape(const unsigned int dim,
787 const FEType & fe_t,
788 const Elem * elem,
789 const unsigned int i,
790 const Point & p)
791{
792 libmesh_deprecated();
793
794#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
795
796 if (elem && is_InfFE_elem(elem->type()))
797 return ifem_shape(fe_t, elem, i, p);
798
799#endif
800
801 const Order o = fe_t.order;
802
803 fe_switch(shape(elem,o,i,p));
804}
805#endif // LIBMESH_ENABLE_DEPRECATED
806
807
808
809Real
811 const Elem * elem,
812 const unsigned int i,
813 const Point & p,
814 const bool add_p_level)
815{
816 // dim is required by the fe_switch macro
817 auto dim = elem->dim();
818
819#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
820
821 if (elem && is_InfFE_elem(elem->type()))
822 return ifem_shape(fe_t, elem, i, p);
823
824#endif
825
826 // We are calling
827 //
828 // FE<X,Y>::shape(Elem *, Order, unsigned, Point, true)
829 //
830 // See fe.h for more details.
831 fe_switch(shape(elem, fe_t.order, i, p, add_p_level));
832}
833
834
835
836Real
838 int extra_order,
839 const Elem * elem,
840 const unsigned int i,
841 const Point & p)
842{
843 // dim is required by the fe_switch macro
844 auto dim = elem->dim();
845
846#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
847
848 if (elem && is_InfFE_elem(elem->type()))
849 return ifem_shape(fe_t, elem, i, p);
850
851#endif
852
853 // We are calling
854 //
855 // FE<X,Y>::shape(Elem *, Order, unsigned, Point, false)
856 //
857 // with the last parameter set to "false" so that the
858 // Elem::p_level() is not used internally and the "total_order" that
859 // we compute is used instead. See fe.h for more details.
860 auto total_order = fe_t.order + extra_order;
861
862 fe_switch(shape(elem, total_order, i, p, false));
863}
864
865
866
867#ifdef LIBMESH_ENABLE_DEPRECATED
868template<>
869void FEInterface::shape<Real>(const unsigned int dim,
870 const FEType & fe_t,
871 const ElemType t,
872 const unsigned int i,
873 const Point & p,
874 Real & phi)
875{
876 libmesh_deprecated();
877
878#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
879
880 if (is_InfFE_elem(t))
881 {
882 phi = ifem_shape(dim, fe_t, t, i, p);
883 return;
884 }
885
886#endif
887
888 const Order o = fe_t.order;
889
890 switch(dim)
891 {
892 case 0:
893 fe_scalar_vec_error_switch(0, shape(t,o,i,p), phi = , ; break;);
894 break;
895 case 1:
896 fe_scalar_vec_error_switch(1, shape(t,o,i,p), phi = , ; break;);
897 break;
898 case 2:
899 fe_scalar_vec_error_switch(2, shape(t,o,i,p), phi = , ; break;);
900 break;
901 case 3:
902 fe_scalar_vec_error_switch(3, shape(t,o,i,p), phi = , ; break;);
903 break;
904 default:
905 libmesh_error_msg("Invalid dimension = " << dim);
906 }
907
908 return;
909}
910
911
912
913template<>
914void FEInterface::shape<Real>(const unsigned int dim,
915 const FEType & fe_t,
916 const Elem * elem,
917 const unsigned int i,
918 const Point & p,
919 Real & phi)
920{
921 libmesh_deprecated();
922
923#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
924
925 if (elem && is_InfFE_elem(elem->type()))
926 {
927 phi = ifem_shape(fe_t, elem, i, p);
928 return;
929 }
930#endif
931
932 const Order o = fe_t.order;
933
934 switch(dim)
935 {
936 case 0:
937 fe_scalar_vec_error_switch(0, shape(elem,o,i,p), phi = , ; break;);
938 break;
939 case 1:
940 fe_scalar_vec_error_switch(1, shape(elem,o,i,p), phi = , ; break;);
941 break;
942 case 2:
943 fe_scalar_vec_error_switch(2, shape(elem,o,i,p), phi = , ; break;);
944 break;
945 case 3:
946 fe_scalar_vec_error_switch(3, shape(elem,o,i,p), phi = , ; break;);
947 break;
948 default:
949 libmesh_error_msg("Invalid dimension = " << dim);
950 }
951
952 return;
953}
954#endif // LIBMESH_ENABLE_DEPRECATED
955
956
957
958template<>
959void FEInterface::shape<Real>(const FEType & fe_t,
960 const Elem * elem,
961 const unsigned int i,
962 const Point & p,
963 Real & phi)
964{
965 // dim is required by the fe_switch macro
966 auto dim = elem->dim();
967
968#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
969
970 if (is_InfFE_elem(elem->type()))
971 {
972 phi = ifem_shape(fe_t, elem, i, p);
973 return;
974 }
975
976#endif
977
978 // Below we call FE<X,Y>::shape(Elem *, Order, unsigned, Point, true)
979 // so that the Elem::p_level() is accounted for internally.
980 switch(dim)
981 {
982 case 0:
983 fe_scalar_vec_error_switch(0, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
984 break;
985 case 1:
986 fe_scalar_vec_error_switch(1, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
987 break;
988 case 2:
989 fe_scalar_vec_error_switch(2, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
990 break;
991 case 3:
992 fe_scalar_vec_error_switch(3, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
993 break;
994 default:
995 libmesh_error_msg("Invalid dimension = " << dim);
996 }
997}
998
999
1000
1001template<>
1002void FEInterface::shape<Real>(const FEType & fe_t,
1003 int extra_order,
1004 const Elem * elem,
1005 const unsigned int i,
1006 const Point & p,
1007 Real & phi)
1008{
1009 // dim is required by the fe_switch macro
1010 auto dim = elem->dim();
1011
1012#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1013
1014 if (is_InfFE_elem(elem->type()))
1015 {
1016 phi = ifem_shape(fe_t, elem, i, p);
1017 return;
1018 }
1019
1020#endif
1021
1022 // Ignore Elem::p_level() and instead use extra_order to compute total_order
1023 auto total_order = fe_t.order + extra_order;
1024
1025 // Below we call
1026 //
1027 // FE<X,Y>::shape(Elem *, Order, unsigned, Point, false)
1028 //
1029 // so that the Elem::p_level() is ignored and the total_order that
1030 // we compute is used instead.
1031 switch(dim)
1032 {
1033 case 0:
1034 fe_scalar_vec_error_switch(0, shape(elem, total_order, i, p, false), phi = , ; break;);
1035 break;
1036 case 1:
1037 fe_scalar_vec_error_switch(1, shape(elem, total_order, i, p, false), phi = , ; break;);
1038 break;
1039 case 2:
1040 fe_scalar_vec_error_switch(2, shape(elem, total_order, i, p, false), phi = , ; break;);
1041 break;
1042 case 3:
1043 fe_scalar_vec_error_switch(3, shape(elem, total_order, i, p, false), phi = , ; break;);
1044 break;
1045 default:
1046 libmesh_error_msg("Invalid dimension = " << dim);
1047 }
1048}
1049
1050
1051
1052template<>
1053void FEInterface::shapes<Real>(const unsigned int dim,
1054 const FEType & fe_t,
1055 const Elem * elem,
1056 const unsigned int i,
1057 const std::vector<Point> & p,
1058 std::vector<Real> & phi,
1059 const bool add_p_level)
1060{
1061#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1062
1063 if (elem && is_InfFE_elem(elem->type()))
1064 {
1065 FEType elevated = fe_t;
1066 elevated.order = fe_t.order + add_p_level * elem->p_level();
1067 for (auto qpi : index_range(p))
1068 phi[qpi] = ifem_shape(elevated, elem, i, p[qpi]);
1069 return;
1070 }
1071#endif
1072
1073 const Order o = fe_t.order;
1074
1075 switch(dim)
1076 {
1077 case 0:
1078 fe_scalar_vec_error_switch(0, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1079 break;
1080 case 1:
1081 fe_scalar_vec_error_switch(1, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1082 break;
1083 case 2:
1084 fe_scalar_vec_error_switch(2, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1085 break;
1086 case 3:
1087 fe_scalar_vec_error_switch(3, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1088 break;
1089 default:
1090 libmesh_error_msg("Invalid dimension = " << dim);
1091 }
1092
1093 return;
1094}
1095
1096
1097template<>
1098void FEInterface::all_shapes<Real>(const unsigned int dim,
1099 const FEType & fe_t,
1100 const Elem * elem,
1101 const std::vector<Point> & p,
1102 std::vector<std::vector<Real>> & phi,
1103 const bool add_p_level)
1104{
1105#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1106
1107 if (elem && is_InfFE_elem(elem->type()))
1108 {
1109 for (auto i : index_range(phi))
1110 FEInterface::shapes<Real>(dim, fe_t, elem, i, p, phi[i], add_p_level);
1111 return;
1112 }
1113#endif
1114
1115 const Order o = fe_t.order;
1116
1117 switch(dim)
1118 {
1119 case 0:
1120 fe_scalar_vec_error_switch(0, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1121 break;
1122 case 1:
1123 fe_scalar_vec_error_switch(1, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1124 break;
1125 case 2:
1126 fe_scalar_vec_error_switch(2, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1127 break;
1128 case 3:
1129 fe_scalar_vec_error_switch(3, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1130 break;
1131 default:
1132 libmesh_error_msg("Invalid dimension = " << dim);
1133 }
1134
1135 return;
1136}
1137
1138
1139
1140#ifdef LIBMESH_ENABLE_DEPRECATED
1141template<>
1142void FEInterface::shape<RealGradient>(const unsigned int dim,
1143 const FEType & fe_t,
1144 const ElemType t,
1145 const unsigned int i,
1146 const Point & p,
1147 RealGradient & phi)
1148{
1149 libmesh_deprecated();
1150
1151 // This API does not currently support infinite elements.
1152#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1153 if (is_InfFE_elem(t))
1154 {
1155 libmesh_not_implemented();
1156 }
1157#endif
1158 const Order o = fe_t.order;
1159
1160 switch(dim)
1161 {
1162 case 0:
1163 fe_vector_scalar_error_switch(0, shape(t,o,i,p), phi = , ; break;);
1164 break;
1165 case 1:
1166 fe_vector_scalar_error_switch(1, shape(t,o,i,p), phi = , ; break;);
1167 break;
1168 case 2:
1169 fe_vector_scalar_error_switch(2, shape(t,o,i,p), phi = , ; break;);
1170 break;
1171 case 3:
1172 fe_vector_scalar_error_switch(3, shape(t,o,i,p), phi = , ; break;);
1173 break;
1174 default:
1175 libmesh_error_msg("Invalid dimension = " << dim);
1176 }
1177}
1178#endif // LIBMESH_ENABLE_DEPRECATED
1179
1180
1181
1182template<>
1183void FEInterface::shape<RealGradient>(const FEType & fe_t,
1184 const Elem * elem,
1185 const unsigned int i,
1186 const Point & p,
1187 RealGradient & phi)
1188{
1189 // This API does not currently support infinite elements.
1190#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1191 if (is_InfFE_elem(elem->type()))
1192 {
1193 libmesh_not_implemented();
1194 }
1195#endif
1196
1197 auto dim = elem->dim();
1198
1199 // We are calling
1200 //
1201 // FE<X,Y>::shape(Elem *, Order, unsigned, Point, true)
1202 //
1203 // with the last parameter set to "true" so that the Elem::p_level()
1204 // is accounted for internally. See fe.h for more details.
1205
1206 switch(dim)
1207 {
1208 case 0:
1209 fe_vector_scalar_error_switch(0, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
1210 break;
1211 case 1:
1212 fe_vector_scalar_error_switch(1, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
1213 break;
1214 case 2:
1215 fe_vector_scalar_error_switch(2, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
1216 break;
1217 case 3:
1218 fe_vector_scalar_error_switch(3, shape(elem, fe_t.order, i, p, true), phi = , ; break;);
1219 break;
1220 default:
1221 libmesh_error_msg("Invalid dimension = " << dim);
1222 }
1223}
1224
1225
1226
1227template<>
1228void FEInterface::shape<RealGradient>(const FEType & fe_t,
1229 int extra_order,
1230 const Elem * elem,
1231 const unsigned int i,
1232 const Point & p,
1233 RealGradient & phi)
1234{
1235 // This API does not currently support infinite elements.
1236#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1237 if (is_InfFE_elem(elem->type()))
1238 {
1239 libmesh_not_implemented();
1240 }
1241#endif
1242
1243 auto dim = elem->dim();
1244
1245 // We are calling
1246 //
1247 // FE<X,Y>::shape(Elem *, Order, unsigned, Point, false)
1248 //
1249 // with the last parameter set to "false" so that the
1250 // Elem::p_level() is not used internally and the "total_order" that
1251 // we compute is used instead. See fe.h for more details.
1252 auto total_order = fe_t.order + extra_order;
1253
1254 switch(dim)
1255 {
1256 case 0:
1257 fe_vector_scalar_error_switch(0, shape(elem, total_order, i, p, false), phi = , ; break;);
1258 break;
1259 case 1:
1260 fe_vector_scalar_error_switch(1, shape(elem, total_order, i, p, false), phi = , ; break;);
1261 break;
1262 case 2:
1263 fe_vector_scalar_error_switch(2, shape(elem, total_order, i, p, false), phi = , ; break;);
1264 break;
1265 case 3:
1266 fe_vector_scalar_error_switch(3, shape(elem, total_order, i, p, false), phi = , ; break;);
1267 break;
1268 default:
1269 libmesh_error_msg("Invalid dimension = " << dim);
1270 }
1271}
1272
1273
1274
1275template<>
1276void FEInterface::shapes<RealGradient>(const unsigned int dim,
1277 const FEType & fe_t,
1278 const Elem * elem,
1279 const unsigned int i,
1280 const std::vector<Point> & p,
1281 std::vector<RealGradient> & phi,
1282 const bool add_p_level)
1283{
1284 // This is actually an issue for infinite elements: They require type 'Gradient'!
1285 if (elem->infinite())
1286 libmesh_not_implemented();
1287
1288 const Order o = fe_t.order;
1289
1290 switch(dim)
1291 {
1292 case 0:
1293 fe_vector_scalar_error_switch(0, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1294 break;
1295 case 1:
1296 fe_vector_scalar_error_switch(1, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1297 break;
1298 case 2:
1299 fe_vector_scalar_error_switch(2, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1300 break;
1301 case 3:
1302 fe_vector_scalar_error_switch(3, shapes(elem,o,i,p,phi,add_p_level), , ; return;);
1303 break;
1304 default:
1305 libmesh_error_msg("Invalid dimension = " << dim);
1306 }
1307
1308 return;
1309}
1310
1311
1312
1313template<>
1314void FEInterface::all_shapes<RealGradient>(const unsigned int dim,
1315 const FEType & fe_t,
1316 const Elem * elem,
1317 const std::vector<Point> & p,
1318 std::vector<std::vector<RealGradient>> & phi,
1319 const bool add_p_level)
1320{
1321 // This is actually an issue for infinite elements: They require type 'Gradient'!
1322 if (elem->infinite())
1323 libmesh_not_implemented();
1324
1325 const Order o = fe_t.order;
1326
1327 switch(dim)
1328 {
1329 case 0:
1330 fe_vector_scalar_error_switch(0, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1331 break;
1332 case 1:
1333 fe_vector_scalar_error_switch(1, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1334 break;
1335 case 2:
1336 fe_vector_scalar_error_switch(2, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1337 break;
1338 case 3:
1339 fe_vector_scalar_error_switch(3, all_shapes(elem,o,p,phi,add_p_level), , ; return;);
1340 break;
1341 default:
1342 libmesh_error_msg("Invalid dimension = " << dim);
1343 }
1344
1345 return;
1346}
1347
1348
1349#ifdef LIBMESH_ENABLE_DEPRECATED
1351FEInterface::shape_function(const unsigned int dim,
1352 const FEType & fe_t,
1353 const ElemType libmesh_inf_var(t))
1354{
1355 libmesh_deprecated();
1356
1357#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1358 if (is_InfFE_elem(t))
1359 {
1360 inf_fe_switch(shape);
1361 }
1362#endif
1363 fe_switch(shape);
1364}
1365#endif // LIBMESH_ENABLE_DEPRECATED
1366
1367
1368
1371 const Elem * elem)
1372{
1373 // dim is needed by the fe_switch macros below
1374 auto dim = elem->dim();
1375
1376#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1377 if (is_InfFE_elem(elem->type()))
1378 inf_fe_switch(shape);
1379#endif
1380 fe_switch(shape);
1381}
1382
1383
1384
1385#ifdef LIBMESH_ENABLE_DEPRECATED
1387 const FEType & fe_t,
1388 const ElemType t,
1389 const unsigned int i,
1390 const unsigned int j,
1391 const Point & p)
1392{
1393 libmesh_deprecated();
1394
1395 libmesh_assert_greater (dim,j);
1396#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1397
1398 if (is_InfFE_elem(t)){
1399 return ifem_shape_deriv(dim, fe_t, t, i, j, p);
1400 }
1401
1402#endif
1403
1404 const Order o = fe_t.order;
1405 fe_switch(shape_deriv(t,o,i,j,p));
1406 return 0;
1407}
1408
1409
1411 const FEType & fe_t,
1412 const Elem * elem,
1413 const unsigned int i,
1414 const unsigned int j,
1415 const Point & p)
1416{
1417 libmesh_deprecated();
1418
1419 libmesh_assert_greater (dim,j);
1420#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1421
1422 if (elem->infinite()){
1423 return ifem_shape_deriv(fe_t, elem, i, j, p);
1424 }
1425
1426#endif
1427
1428 const Order o = fe_t.order;
1429
1430 switch(dim)
1431 {
1432 case 0:
1433 fe_family_switch (0, shape_deriv(elem, o, i, j, p), return , ;);
1434 case 1:
1435 fe_family_switch (1, shape_deriv(elem, o, i, j, p), return , ;);
1436 case 2:
1437 fe_family_switch (2, shape_deriv(elem, o, i, j, p), return , ;);
1438 case 3:
1439 fe_family_switch (3, shape_deriv(elem, o, i, j, p), return , ;);
1440 default:
1441 libmesh_error_msg("Invalid dimension = " << dim);
1442 }
1443 return 0;
1444}
1445#endif // LIBMESH_ENABLE_DEPRECATED
1446
1447
1448
1450 const Elem * elem,
1451 const unsigned int i,
1452 const unsigned int j,
1453 const Point & p)
1454{
1455 auto dim = elem->dim();
1456
1457 libmesh_assert_greater (dim, j);
1458#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1459
1460 if (is_InfFE_elem(elem->type())){
1461 return ifem_shape_deriv(fe_t, elem, i, j, p);
1462 }
1463
1464#endif
1465
1466 // Account for Elem::p_level() when computing total order. Note: we are calling
1467 // FE::shape_deriv() with the final argument == true so that the Elem::p_level()
1468 // is accounted for automatically internally.
1469 fe_switch(shape_deriv(elem, fe_t.order, i, j, p, true));
1470
1471 // We'll never get here
1472 return 0;
1473}
1474
1475
1476
1478 int extra_order,
1479 const Elem * elem,
1480 const unsigned int i,
1481 const unsigned int j,
1482 const Point & p)
1483{
1484 auto dim = elem->dim();
1485
1486 libmesh_assert_greater (dim, j);
1487#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1488
1489 if (elem->infinite()){
1490 return ifem_shape_deriv(fe_t, elem, i, j, p);
1491 }
1492
1493#endif
1494
1495 // Ignore Elem::p_level() when computing total order, use
1496 // extra_order instead.
1497 auto total_order = fe_t.order + extra_order;
1498
1499 // We call shape_deriv() with the final argument == false so that
1500 // the Elem::p_level() is ignored internally.
1501 switch(dim)
1502 {
1503 case 0:
1504 fe_family_switch (0, shape_deriv(elem, total_order, i, j, p, false), return , ;);
1505 case 1:
1506 fe_family_switch (1, shape_deriv(elem, total_order, i, j, p, false), return , ;);
1507 case 2:
1508 fe_family_switch (2, shape_deriv(elem, total_order, i, j, p, false), return , ;);
1509 case 3:
1510 fe_family_switch (3, shape_deriv(elem, total_order, i, j, p, false), return , ;);
1511 default:
1512 libmesh_error_msg("Invalid dimension = " << dim);
1513 }
1514
1515 // We'll never get here
1516 return 0;
1517}
1518
1519
1520
1521template<>
1522void FEInterface::shape_derivs<Real>(const FEType & fe_t,
1523 const Elem * elem,
1524 const unsigned int i,
1525 const unsigned int j,
1526 const std::vector<Point> & p,
1527 std::vector<Real> & dphi,
1528 const bool add_p_level)
1529{
1530 const Order o = fe_t.order;
1531
1532 switch(elem->dim())
1533 {
1534 case 0:
1535 fe_scalar_vec_error_switch(0, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1536 break;
1537 case 1:
1538 fe_scalar_vec_error_switch(1, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1539 break;
1540 case 2:
1541 fe_scalar_vec_error_switch(2, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1542 break;
1543 case 3:
1544 fe_scalar_vec_error_switch(3, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1545 break;
1546 default:
1547 libmesh_error_msg("Invalid dimension = " << elem->dim());
1548 }
1549
1550 return;
1551}
1552
1553
1554
1555// Only instantiating Real because we don't expect vector-valued
1556// mapping functions, and that's what's using this interface.
1557template<>
1558void FEInterface::all_shape_derivs<Real>(const unsigned int dim,
1559 const FEType & fe_t,
1560 const Elem * elem,
1561 const std::vector<Point> & p,
1562 std::vector<std::vector<Real>> * comps[3],
1563 const bool add_p_level)
1564{
1565#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1566
1567 if (elem && is_InfFE_elem(elem->type()))
1568 {
1569 for (auto j : make_range(dim))
1570 for (auto i : index_range(*comps[j]))
1571 FEInterface::shape_derivs<Real>(fe_t, elem, i, j, p, (*comps[j])[i], add_p_level);
1572 return;
1573 }
1574#endif
1575
1576 const Order o = fe_t.order;
1577
1578 switch(dim)
1579 {
1580 case 0:
1581 fe_scalar_vec_error_switch(0, all_shape_derivs(elem,o,p,comps,add_p_level), , ; return;);
1582 break;
1583 case 1:
1584 fe_scalar_vec_error_switch(1, all_shape_derivs(elem,o,p,comps,add_p_level), , ; return;);
1585 break;
1586 case 2:
1587 fe_scalar_vec_error_switch(2, all_shape_derivs(elem,o,p,comps,add_p_level), , ; return;);
1588 break;
1589 case 3:
1590 fe_scalar_vec_error_switch(3, all_shape_derivs(elem,o,p,comps,add_p_level), , ; return;);
1591 break;
1592 default:
1593 libmesh_error_msg("Invalid dimension = " << dim);
1594 }
1595
1596 return;
1597}
1598
1599
1600
1601template<>
1602void FEInterface::shape_derivs<RealGradient>(const FEType & fe_t,
1603 const Elem * elem,
1604 const unsigned int i,
1605 const unsigned int j,
1606 const std::vector<Point> & p,
1607 std::vector<RealGradient> & dphi,
1608 const bool add_p_level)
1609{
1610 const Order o = fe_t.order;
1611
1612 switch(elem->dim())
1613 {
1614 case 0:
1615 fe_vector_scalar_error_switch(0, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1616 break;
1617 case 1:
1618 fe_vector_scalar_error_switch(1, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1619 break;
1620 case 2:
1621 fe_vector_scalar_error_switch(2, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1622 break;
1623 case 3:
1624 fe_vector_scalar_error_switch(3, shape_derivs(elem,o,i,j,p,dphi,add_p_level), , ; break;);
1625 break;
1626 default:
1627 libmesh_error_msg("Invalid dimension = " << elem->dim());
1628 }
1629
1630 return;
1631}
1632
1633
1634
1635#ifdef LIBMESH_ENABLE_DEPRECATED
1637FEInterface::shape_deriv_function(const unsigned int dim,
1638 const FEType & fe_t,
1639 const ElemType libmesh_inf_var(t))
1640{
1641 libmesh_deprecated();
1642
1643#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1644 if (is_InfFE_elem(t))
1645 {
1646 inf_fe_switch(shape_deriv);
1647 }
1648#endif
1649 fe_switch(shape_deriv);
1650}
1651#endif // LIBMESH_ENABLE_DEPRECATED
1652
1653
1654
1657 const Elem * elem)
1658{
1659 // dim is needed by the fe_switch macros below
1660 auto dim = elem->dim();
1661
1662#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1663 if (is_InfFE_elem(elem->type()))
1664 {
1665 inf_fe_switch(shape_deriv);
1666 }
1667#endif
1668 fe_switch(shape_deriv);
1669}
1670
1671
1672#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1673#ifdef LIBMESH_ENABLE_DEPRECATED
1675 const FEType & fe_t,
1676 const ElemType t,
1677 const unsigned int i,
1678 const unsigned int j,
1679 const Point & p)
1680{
1681 libmesh_deprecated();
1682
1683 libmesh_assert_greater_equal (dim*(dim-1),j);
1684#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1685 if (is_InfFE_elem(t))
1686 libmesh_not_implemented();
1687#endif
1688
1689 const Order o = fe_t.order;
1690
1691 switch(dim)
1692 {
1693 case 0:
1694 fe_family_switch (0, shape_second_deriv(t, o, i, j, p), return , ;);
1695 case 1:
1696 fe_family_switch (1, shape_second_deriv(t, o, i, j, p), return , ;);
1697 case 2:
1698 fe_family_switch (2, shape_second_deriv(t, o, i, j, p), return , ;);
1699 case 3:
1700 fe_family_switch (3, shape_second_deriv(t, o, i, j, p), return , ;);
1701 default:
1702 libmesh_error_msg("Invalid dimension = " << dim);
1703 }
1704 return 0;
1705}
1706
1707
1709 const FEType & fe_t,
1710 const Elem * elem,
1711 const unsigned int i,
1712 const unsigned int j,
1713 const Point & p)
1714{
1715 libmesh_deprecated();
1716
1717 libmesh_assert_greater_equal (dim*(dim-1),j);
1718
1719 if (elem->infinite())
1720 libmesh_not_implemented();
1721
1722 const Order o = fe_t.order;
1723
1724 switch(dim)
1725 {
1726 case 0:
1727 fe_family_switch (0, shape_second_deriv(elem, o, i, j, p), return , ;);
1728 case 1:
1729 fe_family_switch (1, shape_second_deriv(elem, o, i, j, p), return , ;);
1730 case 2:
1731 fe_family_switch (2, shape_second_deriv(elem, o, i, j, p), return , ;);
1732 case 3:
1733 fe_family_switch (3, shape_second_deriv(elem, o, i, j, p), return , ;);
1734 default:
1735 libmesh_error_msg("Invalid dimension = " << dim);
1736 }
1737 return 0;
1738}
1739#endif // LIBMESH_ENABLE_DEPRECATED
1740
1741
1742
1744 const Elem * elem,
1745 const unsigned int i,
1746 const unsigned int j,
1747 const Point & p)
1748{
1749 auto dim = elem->dim();
1750
1751 libmesh_assert_greater_equal (dim*(dim-1),j);
1752#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1753 if (is_InfFE_elem(elem->type()))
1754 libmesh_not_implemented();
1755#endif
1756
1757 // We are calling FE::shape_second_deriv() with the final argument
1758 // == true so that the Elem::p_level() is accounted for
1759 // automatically internally.
1760 switch(dim)
1761 {
1762 case 0:
1763 fe_family_switch (0, shape_second_deriv(elem, fe_t.order, i, j, p, true), return , ;);
1764 case 1:
1765 fe_family_switch (1, shape_second_deriv(elem, fe_t.order, i, j, p, true), return , ;);
1766 case 2:
1767 fe_family_switch (2, shape_second_deriv(elem, fe_t.order, i, j, p, true), return , ;);
1768 case 3:
1769 fe_family_switch (3, shape_second_deriv(elem, fe_t.order, i, j, p, true), return , ;);
1770 default:
1771 libmesh_error_msg("Invalid dimension = " << dim);
1772 }
1773
1774 // We'll never get here
1775 return 0;
1776}
1777
1778
1779
1781 int extra_order,
1782 const Elem * elem,
1783 const unsigned int i,
1784 const unsigned int j,
1785 const Point & p)
1786{
1787 auto dim = elem->dim();
1788
1789 libmesh_assert_greater_equal (dim*(dim-1),j);
1790
1791 if (elem->infinite())
1792 libmesh_not_implemented();
1793
1794 // Ignore Elem::p_level() when computing total order, use
1795 // extra_order instead.
1796 auto total_order = fe_t.order + extra_order;
1797
1798 // We are calling FE::shape_second_deriv() with the final argument
1799 // == false so that the Elem::p_level() is ignored and the
1800 // total_order we compute is used instead.
1801 switch(dim)
1802 {
1803 case 0:
1804 fe_family_switch (0, shape_second_deriv(elem, total_order, i, j, p, false), return , ;);
1805 case 1:
1806 fe_family_switch (1, shape_second_deriv(elem, total_order, i, j, p, false), return , ;);
1807 case 2:
1808 fe_family_switch (2, shape_second_deriv(elem, total_order, i, j, p, false), return , ;);
1809 case 3:
1810 fe_family_switch (3, shape_second_deriv(elem, total_order, i, j, p, false), return , ;);
1811 default:
1812 libmesh_error_msg("Invalid dimension = " << dim);
1813 }
1814
1815 // We'll never get here
1816 return 0;
1817}
1818
1819
1820
1821#ifdef LIBMESH_ENABLE_DEPRECATED
1824 const FEType & fe_t,
1825 const ElemType libmesh_inf_var(t))
1826{
1827 libmesh_deprecated();
1828
1829#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1830 if (is_InfFE_elem(t))
1831 libmesh_not_implemented();
1832#endif
1833 fe_switch(shape_second_deriv);
1834}
1835#endif // LIBMESH_ENABLE_DEPRECATED
1836
1837
1838
1841 const Elem * elem)
1842{
1843 auto dim = elem->dim();
1844
1845#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1846 if (is_InfFE_elem(elem->type()))
1847 libmesh_not_implemented();
1848#endif
1849 fe_switch(shape_second_deriv);
1850}
1851
1852#endif //LIBMESH_ENABLE_SECOND_DERIVATIVES
1853
1854
1855#ifdef LIBMESH_ENABLE_DEPRECATED
1856template<>
1857void FEInterface::shape<RealGradient>(const unsigned int dim,
1858 const FEType & fe_t,
1859 const Elem * elem,
1860 const unsigned int i,
1861 const Point & p,
1862 RealGradient & phi)
1863{
1864 libmesh_deprecated();
1865
1866 // This is actually an issue for infinite elements: They require type 'Gradient'!
1867 if (elem->infinite())
1868 libmesh_not_implemented();
1869
1870 const Order o = fe_t.order;
1871
1872 switch(dim)
1873 {
1874 case 0:
1875 fe_vector_scalar_error_switch(0, shape(elem,o,i,p), phi = , ; break;);
1876 break;
1877 case 1:
1878 fe_vector_scalar_error_switch(1, shape(elem,o,i,p), phi = , ; break;);
1879 break;
1880 case 2:
1881 fe_vector_scalar_error_switch(2, shape(elem,o,i,p), phi = , ; break;);
1882 break;
1883 case 3:
1884 fe_vector_scalar_error_switch(3, shape(elem,o,i,p), phi = , ; break;);
1885 break;
1886 default:
1887 libmesh_error_msg("Invalid dimension = " << dim);
1888 }
1889
1890 return;
1891}
1892#endif // LIBMESH_ENABLE_DEPRECATED
1893
1894
1895void FEInterface::compute_data(const unsigned int dim,
1896 const FEType & fe_t,
1897 const Elem * elem,
1898 FEComputeData & data)
1899{
1900#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1901
1902 if (elem && is_InfFE_elem(elem->type()))
1903 {
1904 data.init();
1905 ifem_compute_data(dim, fe_t, elem, data);
1906 return;
1907 }
1908
1909#endif
1910
1911 const unsigned int n_dof = n_dofs (fe_t, elem);
1912 const Point & p = data.p;
1913 data.shape.resize(n_dof);
1914
1915 if (data.need_derivative())
1916 {
1917 data.dshape.resize(n_dof);
1918 data.local_transform.resize(dim);
1919
1920 for (unsigned int d=0; d<dim; d++)
1921 data.local_transform[d].resize(dim);
1922
1923 auto fe = FEBase::build(dim, fe_t);
1924 std::vector<Point> pt = {p};
1925 fe->get_dphideta(); // to compute the map
1926 fe->reinit(elem, &pt);
1927
1928 // compute the reference->physical map.
1929 data.local_transform[0][0] = fe->get_dxidx()[0];
1930 if (dim > 1)
1931 {
1932 data.local_transform[1][0] = fe->get_detadx()[0];
1933 data.local_transform[1][1] = fe->get_detady()[0];
1934 data.local_transform[0][1] = fe->get_dxidy()[0];
1935 if (dim > 2)
1936 {
1937 data.local_transform[2][0] = fe->get_dzetadx()[0];
1938 data.local_transform[2][1] = fe->get_dzetady()[0];
1939 data.local_transform[2][2] = fe->get_dzetadz()[0];
1940 data.local_transform[1][2] = fe->get_detadz()[0];
1941 data.local_transform[0][2] = fe->get_dxidz()[0];
1942 }
1943 }
1944 }
1945
1946 // set default values for all the output fields
1947 data.init();
1948
1949 for (unsigned int n=0; n<n_dof; n++)
1950 {
1951 // Here we pass the original fe_t object. Additional p-levels
1952 // (if any) are handled internally by the shape() and
1953 // shape_deriv() functions since they have access to the elem
1954 // pointer. Note that we are already using the n_dof value
1955 // appropriate to the elevated p-level.
1956 data.shape[n] = shape(fe_t, elem, n, p);
1957 if (data.need_derivative())
1958 {
1959 for (unsigned int j=0; j<dim; j++)
1960 data.dshape[n](j) = shape_deriv(fe_t, elem, n, j, p);
1961 }
1962 }
1963}
1964
1965
1966
1967#ifdef LIBMESH_ENABLE_AMR
1968
1970 DofMap & dof_map,
1971 const unsigned int variable_number,
1972 const Elem * elem)
1973{
1974 libmesh_assert(elem);
1975
1976 const FEType & fe_t = dof_map.variable_type(variable_number);
1977
1978 switch (elem->dim())
1979 {
1980 case 0:
1981 case 1:
1982 {
1983 // No constraints in 0D/1D.
1984 return;
1985 }
1986
1987
1988 case 2:
1989 {
1990 switch (fe_t.family)
1991 {
1992 case CLOUGH:
1994 dof_map,
1995 variable_number,
1996 elem); return;
1997
1998 case HERMITE:
2000 dof_map,
2001 variable_number,
2002 elem); return;
2003
2004 case LAGRANGE:
2006 dof_map,
2007 variable_number,
2008 elem); return;
2009
2010 case HIERARCHIC:
2012 dof_map,
2013 variable_number,
2014 elem); return;
2015
2016 case HIERARCHIC_VEC:
2018 dof_map,
2019 variable_number,
2020 elem); return;
2021
2022 case SIDE_HIERARCHIC:
2024 dof_map,
2025 variable_number,
2026 elem); return;
2027
2028 case LAGRANGE_VEC:
2030 dof_map,
2031 variable_number,
2032 elem); return;
2033
2034 fe_family_horder_case_func(2, compute_constraints (constraints,
2035 dof_map,
2036 variable_number,
2037 elem), , ; return;)
2038 default:
2039 return;
2040 }
2041 }
2042
2043
2044 case 3:
2045 {
2046 switch (fe_t.family)
2047 {
2048 case HERMITE:
2050 dof_map,
2051 variable_number,
2052 elem); return;
2053
2054 case LAGRANGE:
2056 dof_map,
2057 variable_number,
2058 elem); return;
2059
2060 case HIERARCHIC:
2062 dof_map,
2063 variable_number,
2064 elem); return;
2065
2066 case SIDE_HIERARCHIC:
2068 dof_map,
2069 variable_number,
2070 elem); return;
2071
2072 case LAGRANGE_VEC:
2074 dof_map,
2075 variable_number,
2076 elem); return;
2077
2078 case HIERARCHIC_VEC:
2080 dof_map,
2081 variable_number,
2082 elem); return;
2083
2084 fe_family_horder_case_func(3, compute_constraints (constraints,
2085 dof_map,
2086 variable_number,
2087 elem), , ; return;)
2088 default:
2089 return;
2090 }
2091 }
2092
2093
2094 default:
2095 libmesh_error_msg("Invalid dimension = " << elem->dim());
2096 }
2097}
2098
2099#endif // #ifdef LIBMESH_ENABLE_AMR
2100
2101
2102
2103#ifdef LIBMESH_ENABLE_PERIODIC
2104
2106 DofMap & dof_map,
2107 const PeriodicBoundaries & boundaries,
2108 const MeshBase & mesh,
2109 const PointLocatorBase * point_locator,
2110 const unsigned int variable_number,
2111 const Elem * elem)
2112{
2113 const FEType & fe_t = dof_map.variable_type(variable_number);
2114 // No element-specific optimizations currently exist, although
2115 // we do have to select the right compute_periodic_constraints
2116 // for the OutputType of this FEType.
2117 switch (field_type(fe_t))
2118 {
2119 case TYPE_SCALAR:
2121 constraints, dof_map, boundaries, mesh, point_locator, variable_number, elem);
2122 break;
2123 case TYPE_VECTOR:
2125 constraints, dof_map, boundaries, mesh, point_locator, variable_number, elem);
2126 break;
2127 default:
2128 libmesh_error_msg(
2129 "compute_periodic_constraints only set up for vector or scalar FEFieldTypes");
2130 }
2131}
2132
2133#endif // #ifdef LIBMESH_ENABLE_PERIODIC
2134
2135
2136
2137unsigned int FEInterface::max_order(const FEType & fe_t,
2138 const ElemType & el_t)
2139{
2140 // Yeah, I know, infinity is much larger than 11, but our
2141 // solvers don't seem to like high degree polynomials, and our
2142 // quadrature rules and number_lookups tables
2143 // need to go up higher.
2144 const unsigned int unlimited = 11;
2145
2146 // If we used 0 as a default, then elements missing from this
2147 // table (e.g. infinite elements) would be considered broken.
2148 const unsigned int unknown = unlimited;
2149
2150 switch (fe_t.family)
2151 {
2152 case LAGRANGE:
2153 case LAGRANGE_VEC:
2154 switch (el_t)
2155 {
2156 case EDGE2:
2157 case EDGE3:
2158 case EDGE4:
2159 return 3;
2160 case TRI3:
2161 case TRISHELL3:
2162 case C0POLYGON:
2163 return 1;
2164 case TRI6:
2165 return 2;
2166 case TRI7:
2167 return 3;
2168 case QUAD4:
2169 case QUADSHELL4:
2170 return 1;
2171 case QUAD8:
2172 case QUADSHELL8:
2173 case QUAD9:
2174 case QUADSHELL9:
2175 return 2;
2176 case TET4:
2177 return 1;
2178 case TET10:
2179 return 2;
2180 case TET14:
2181 return 3;
2182 case HEX8:
2183 return 1;
2184 case HEX20:
2185 case HEX27:
2186 return 2;
2187 case PRISM6:
2188 return 1;
2189 case PRISM15:
2190 case PRISM18:
2191 return 2;
2192 case PRISM20:
2193 case PRISM21:
2194 return 3;
2195 case PYRAMID5:
2196 return 1;
2197 case PYRAMID13:
2198 case PYRAMID14:
2199 return 2;
2200 case PYRAMID18:
2201 return 3;
2202 case C0POLYHEDRON:
2203 return 1;
2204 default:
2205 return unknown;
2206 }
2207 break;
2208 case L2_LAGRANGE_GLL:
2209 case LAGRANGE_GLL:
2210 switch (el_t)
2211 {
2212 case EDGE2:
2213 case EDGE3:
2214 case EDGE4:
2215 case QUAD4:
2216 case QUADSHELL4:
2217 case QUAD8:
2218 case QUADSHELL8:
2219 case QUAD9:
2220 case QUADSHELL9:
2221 case HEX8:
2222 case HEX20:
2223 case HEX27:
2224 // A basis of degree p needs p+1 Gauss-Lobatto points, and QGaussLobatto tabulates
2225 // at most fe_lagrange_gll_max_points_1D
2227 default:
2228 return unknown;
2229 }
2230 break;
2231 case MONOMIAL:
2232 case L2_LAGRANGE:
2233 case L2_LAGRANGE_VEC:
2234 case L2_HIERARCHIC:
2235 case L2_HIERARCHIC_VEC:
2236 case MONOMIAL_VEC:
2237 switch (el_t)
2238 {
2239 case EDGE2:
2240 case EDGE3:
2241 case EDGE4:
2242 case C0POLYGON:
2243 case TRI3:
2244 case TRISHELL3:
2245 case TRI6:
2246 case TRI7:
2247 case QUAD4:
2248 case QUADSHELL4:
2249 case QUAD8:
2250 case QUADSHELL8:
2251 case QUAD9:
2252 case QUADSHELL9:
2253 case TET4:
2254 case TET10:
2255 case TET14:
2256 case HEX8:
2257 case HEX20:
2258 case HEX27:
2259 case PRISM6:
2260 case PRISM15:
2261 case PRISM18:
2262 case PRISM20:
2263 case PRISM21:
2264 case PYRAMID5:
2265 case PYRAMID13:
2266 case PYRAMID14:
2267 case PYRAMID18:
2268 case C0POLYHEDRON:
2269 return unlimited;
2270 default:
2271 return unknown;
2272 }
2273 break;
2274#ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
2275 case BERNSTEIN:
2276 case RATIONAL_BERNSTEIN:
2277 switch (el_t)
2278 {
2279 case EDGE2:
2280 case EDGE3:
2281 case EDGE4:
2282 return unlimited;
2283 case TRI3:
2284 case TRISHELL3:
2285 return 1;
2286 case TRI6:
2287 case TRI7:
2288 return 6;
2289 case QUAD4:
2290 case QUADSHELL4:
2291 return 1;
2292 case QUAD8:
2293 case QUADSHELL8:
2294 case QUAD9:
2295 case QUADSHELL9:
2296 return unlimited;
2297 case TET4:
2298 return 1;
2299 case TET10:
2300 case TET14:
2301 return 2;
2302 case HEX8:
2303 return 1;
2304 case HEX20:
2305 return 2;
2306 case HEX27:
2307 return 4;
2308 case C0POLYGON:
2309 case PRISM6:
2310 case PRISM15:
2311 case PRISM18:
2312 case PRISM20:
2313 case PRISM21:
2314 case PYRAMID5:
2315 case PYRAMID13:
2316 case PYRAMID14:
2317 case PYRAMID18:
2318 case C0POLYHEDRON:
2319 return 0;
2320 default:
2321 return unknown;
2322 }
2323 break;
2324 case SZABAB:
2325 switch (el_t)
2326 {
2327 case EDGE2:
2328 return 1;
2329 case EDGE3:
2330 case EDGE4:
2331 return 7;
2332 case TRI3:
2333 case TRISHELL3:
2334 return 1;
2335 case TRI6:
2336 case TRI7:
2337 return 7;
2338 case QUAD4:
2339 case QUADSHELL4:
2340 return 1;
2341 case QUAD8:
2342 case QUADSHELL8:
2343 case QUAD9:
2344 case QUADSHELL9:
2345 return 7;
2346 case C0POLYGON:
2347 case TET4:
2348 case TET10:
2349 case TET14:
2350 case HEX8:
2351 case HEX20:
2352 case HEX27:
2353 case PRISM6:
2354 case PRISM15:
2355 case PRISM18:
2356 case PRISM20:
2357 case PRISM21:
2358 case PYRAMID5:
2359 case PYRAMID13:
2360 case PYRAMID14:
2361 case PYRAMID18:
2362 case C0POLYHEDRON:
2363 return 0;
2364 default:
2365 return unknown;
2366 }
2367 break;
2368#endif
2369 case XYZ:
2370 switch (el_t)
2371 {
2372 case EDGE2:
2373 case EDGE3:
2374 case EDGE4:
2375 case C0POLYGON:
2376 case TRI3:
2377 case TRISHELL3:
2378 case TRI6:
2379 case TRI7:
2380 case QUAD4:
2381 case QUADSHELL4:
2382 case QUAD8:
2383 case QUADSHELL8:
2384 case QUAD9:
2385 case QUADSHELL9:
2386 case TET4:
2387 case TET10:
2388 case TET14:
2389 case HEX8:
2390 case HEX20:
2391 case HEX27:
2392 case PRISM6:
2393 case PRISM15:
2394 case PRISM18:
2395 case PRISM20:
2396 case PRISM21:
2397 case PYRAMID5:
2398 case PYRAMID13:
2399 case PYRAMID14:
2400 case PYRAMID18:
2401 case C0POLYHEDRON:
2402 return unlimited;
2403 default:
2404 return unknown;
2405 }
2406 break;
2407 case CLOUGH:
2408 switch (el_t)
2409 {
2410 case EDGE2:
2411 case EDGE3:
2412 return 3;
2413 case EDGE4:
2414 case TRI3:
2415 case TRISHELL3:
2416 return 0;
2417 case TRI6:
2418 case TRI7:
2419 return 3;
2420 case C0POLYGON:
2421 case QUAD4:
2422 case QUADSHELL4:
2423 case QUAD8:
2424 case QUADSHELL8:
2425 case QUAD9:
2426 case QUADSHELL9:
2427 case TET4:
2428 case TET10:
2429 case TET14:
2430 case HEX8:
2431 case HEX20:
2432 case HEX27:
2433 case PRISM6:
2434 case PRISM15:
2435 case PRISM18:
2436 case PRISM20:
2437 case PRISM21:
2438 case PYRAMID5:
2439 case PYRAMID13:
2440 case PYRAMID14:
2441 case PYRAMID18:
2442 case C0POLYHEDRON:
2443 return 0;
2444 default:
2445 return unknown;
2446 }
2447 break;
2448 case HERMITE:
2449 switch (el_t)
2450 {
2451 case EDGE2:
2452 case EDGE3:
2453 return unlimited;
2454 case EDGE4:
2455 case TRI3:
2456 case TRISHELL3:
2457 case TRI6:
2458 case TRI7:
2459 return 0;
2460 case QUAD4:
2461 case QUADSHELL4:
2462 return 3;
2463 case QUAD8:
2464 case QUADSHELL8:
2465 case QUAD9:
2466 case QUADSHELL9:
2467 return unlimited;
2468 case TET4:
2469 case TET10:
2470 case TET14:
2471 return 0;
2472 case HEX8:
2473 return 3;
2474 case HEX20:
2475 case HEX27:
2476 return unlimited;
2477 case C0POLYGON:
2478 case PRISM6:
2479 case PRISM15:
2480 case PRISM18:
2481 case PRISM20:
2482 case PRISM21:
2483 case PYRAMID5:
2484 case PYRAMID13:
2485 case PYRAMID14:
2486 case PYRAMID18:
2487 case C0POLYHEDRON:
2488 return 0;
2489 default:
2490 return unknown;
2491 }
2492 break;
2493 case HIERARCHIC:
2494 case HIERARCHIC_VEC:
2495 switch (el_t)
2496 {
2497 case EDGE2:
2498 case EDGE3:
2499 case EDGE4:
2500 return unlimited;
2501 case TRI3:
2502 case TRISHELL3:
2503 return 1;
2504 case TRI6:
2505 case TRI7:
2506 return unlimited;
2507 case QUAD4:
2508 case QUADSHELL4:
2509 return 1;
2510 case QUAD8:
2511 case QUADSHELL8:
2512 case QUAD9:
2513 case QUADSHELL9:
2514 return unlimited;
2515 case TET4:
2516 return 1;
2517 case TET10:
2518 return 2;
2519 case TET14:
2520 return unlimited;
2521 case HEX8:
2522 case HEX20:
2523 return 1;
2524 case HEX27:
2525 return unlimited;
2526 case PRISM6:
2527 case PRISM15:
2528 case PRISM18:
2529 case PRISM20:
2530 case PRISM21:
2531 return unlimited;
2532 case C0POLYGON:
2533 case PYRAMID5:
2534 case PYRAMID13:
2535 case PYRAMID14:
2536 case PYRAMID18:
2537 case C0POLYHEDRON:
2538 return 0;
2539 default:
2540 return unknown;
2541 }
2542 break;
2543 case SIDE_HIERARCHIC:
2544 switch (el_t)
2545 {
2546 case EDGE2:
2547 case EDGE3:
2548 case EDGE4:
2549 return unlimited; // although it's all the same as 0...
2550 case TRI3:
2551 case TRISHELL3:
2552 return 0;
2553 case TRI6:
2554 case TRI7:
2555 return unlimited;
2556 case C0POLYGON:
2557 case QUAD4:
2558 case QUADSHELL4:
2559 return 0;
2560 case QUAD8:
2561 case QUADSHELL8:
2562 case QUAD9:
2563 case QUADSHELL9:
2564 return unlimited;
2565 case TET4:
2566 case TET10:
2567 return 0;
2568 case TET14:
2569 return unlimited;
2570 case HEX8:
2571 case HEX20:
2572 return 0;
2573 case HEX27:
2574 return unlimited;
2575 case PRISM6:
2576 case PRISM15:
2577 case PRISM18:
2578 return 0;
2579 case PRISM20:
2580 case PRISM21:
2581 return unlimited;
2582 case PYRAMID5:
2583 case PYRAMID13:
2584 case PYRAMID14:
2585 case PYRAMID18:
2586 case C0POLYHEDRON:
2587 return 0;
2588 default:
2589 return unknown;
2590 }
2591 break;
2592 case SUBDIVISION:
2593 switch (el_t)
2594 {
2595 case TRI3SUBDIVISION:
2596 return unlimited;
2597 default:
2598 return unknown;
2599 }
2600 break;
2601 case NEDELEC_ONE:
2602 switch (el_t)
2603 {
2604 case TRI6:
2605 case TRI7:
2606 case QUAD8:
2607 case QUAD9:
2608 return 5;
2609 case TET10:
2610 case TET14:
2611 case HEX20:
2612 case HEX27:
2613 return 1;
2614 default:
2615 return 0;
2616 }
2617 break;
2618 case RAVIART_THOMAS:
2619 case L2_RAVIART_THOMAS:
2620 switch (el_t)
2621 {
2622 case TRI6:
2623 case TRI7:
2624 case QUAD8:
2625 case QUAD9:
2626 return 5;
2627 case TET14:
2628 case HEX27:
2629 return 1;
2630 default:
2631 return 0;
2632 }
2633 break;
2634 default:
2635 return 0;
2636 break;
2637 }
2638}
2639
2640
2641
2643{
2644 switch (fe_t.family)
2645 {
2646 case LAGRANGE:
2647 case L2_LAGRANGE:
2648 case L2_LAGRANGE_GLL:
2649 case MONOMIAL:
2650 case MONOMIAL_VEC:
2651 case L2_HIERARCHIC:
2652 case SIDE_HIERARCHIC:
2653 case XYZ:
2654 case SUBDIVISION:
2655 case LAGRANGE_VEC:
2656 case L2_LAGRANGE_VEC:
2657 case NEDELEC_ONE:
2658 case RAVIART_THOMAS:
2659 case L2_RAVIART_THOMAS:
2660 return false;
2661 case CLOUGH:
2662 case HERMITE:
2663 case HIERARCHIC:
2664 case HIERARCHIC_VEC:
2665 case L2_HIERARCHIC_VEC:
2666 // A mid-edge or mid-face node of this family owns the interpolation points inside its
2667 // entity. Above order two, none of these points is at the node itself. At a refinement
2668 // interface, the node is a vertex of the fine elements, so it needs a separate degree of
2669 // freedom for that role.
2670 case LAGRANGE_GLL:
2671 fe_family_horder_case()
2672 default:
2673 return true;
2674 }
2675}
2676
2678{
2679 return FEInterface::field_type(fe_type.family);
2680}
2681
2683{
2684 switch (fe_family)
2685 {
2686 fe_family_vector_case()
2687 return TYPE_VECTOR;
2688 default:
2689 return TYPE_SCALAR;
2690 }
2691}
2692
2694{
2695 switch (fe_family)
2696 {
2697 case HIERARCHIC:
2698 case L2_HIERARCHIC:
2699 case HIERARCHIC_VEC:
2700 case LAGRANGE_GLL:
2701 case L2_HIERARCHIC_VEC:
2702 case BERNSTEIN:
2703 case RATIONAL_BERNSTEIN:
2704 case SZABAB:
2705 case NEDELEC_ONE:
2706 case RAVIART_THOMAS:
2707 return true;
2708 default:
2709 return false;
2710 }
2711}
2712
2714 const FEType & fe_type)
2715{
2716 // We assume the number of vector components is the mesh spatial dimension.
2717 return field_type(fe_type.family) == TYPE_VECTOR ? mesh.spatial_dimension() : 1;
2718}
2719
2720
2721
2722
2723bool
2725{
2726 switch (fe_type.family)
2727 {
2728 case HERMITE:
2729 case HIERARCHIC:
2730 case HIERARCHIC_VEC:
2731 case L2_HIERARCHIC:
2732 case L2_HIERARCHIC_VEC:
2733 case MONOMIAL:
2734 case MONOMIAL_VEC:
2735 case SIDE_HIERARCHIC:
2736 case SZABAB:
2737 case XYZ:
2738 return true;
2739
2740 case BERNSTEIN:
2741 case CLOUGH: // maybe some day?
2742 case LAGRANGE:
2743 case LAGRANGE_VEC:
2744 case LAGRANGE_GLL:
2745 case L2_LAGRANGE:
2746 case L2_LAGRANGE_GLL:
2747 case L2_LAGRANGE_VEC:
2748 case NEDELEC_ONE:
2749 case RATIONAL_BERNSTEIN:
2750 case RAVIART_THOMAS:
2751 case L2_RAVIART_THOMAS:
2752 case SCALAR:
2753 case SUBDIVISION:
2754 return false;
2755
2756 default:
2757 libmesh_error_msg("Unknown FE Family " << Utility::enum_to_string(fe_type.family));
2758 }
2759}
2760
2761
2762
2764{
2765 switch (fe_type.family)
2766 {
2767 // Discontinuous elements
2768 case MONOMIAL:
2769 case MONOMIAL_VEC:
2770 case L2_HIERARCHIC:
2771 case L2_LAGRANGE:
2772 case L2_LAGRANGE_GLL:
2773 case XYZ:
2774 case SCALAR:
2775 case L2_RAVIART_THOMAS:
2776 case L2_HIERARCHIC_VEC:
2777 case L2_LAGRANGE_VEC:
2778 return DISCONTINUOUS;
2779
2780 // C0 elements
2781 case LAGRANGE:
2782 case LAGRANGE_GLL:
2783 case HIERARCHIC:
2784 case BERNSTEIN:
2785 case SZABAB:
2786 case RATIONAL_BERNSTEIN:
2787 case INFINITE_MAP:
2788 case JACOBI_20_00:
2789 case JACOBI_30_00:
2790 case LEGENDRE:
2791 case LAGRANGE_VEC:
2792 case HIERARCHIC_VEC:
2793 return C_ZERO;
2794
2795 // C1 elements
2796 case CLOUGH:
2797 case HERMITE:
2798 case SUBDIVISION:
2799 return C_ONE;
2800
2801 case NEDELEC_ONE:
2802 return H_CURL;
2803
2804 case RAVIART_THOMAS:
2805 return H_DIV;
2806
2807 // Side elements
2808 case SIDE_HIERARCHIC:
2809 return SIDE_DISCONTINUOUS;
2810
2811 default:
2812 libmesh_error_msg("Unknown FE Family " << Utility::enum_to_string(fe_type.family));
2813 }
2814}
2815
2816
2817} // namespace libMesh
unsigned int dim
The constraint matrix storage format.
Definition dof_map.h:112
This class handles the numbering of degrees of freedom on a mesh.
Definition dof_map.h:181
const FEType & variable_type(const unsigned int i) const
Definition dof_map.h:2472
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual unsigned short dim() const =0
virtual ElemType type() const =0
unsigned int p_level() const
Definition elem.h:3246
virtual bool infinite() const =0
static bool on_reference_element(const Point &p, const ElemType t, const Real eps=TOLERANCE)
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
const Point & p
Holds the point where the data are to be computed.
std::vector< Gradient > dshape
Storage for the computed shape derivative values.
bool need_derivative()
Check whether derivatives should be computed or not.
std::vector< std::vector< Real > > local_transform
Storage for local to global mapping at p.
std::vector< Number > shape
Storage for the computed shape function values.
void init()
Inits the output data to default values, provided the fields are correctly resized.
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
static void compute_periodic_constraints(DofConstraints &constraints, DofMap &dof_map, const PeriodicBoundaries &boundaries, const MeshBase &mesh, const PointLocatorBase *point_locator, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for meshes with periodic boundary conditions) correspon...
Definition fe_base.C:1892
static Real ifem_shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
static void dofs_on_side(const Elem *const elem, const unsigned int dim, const FEType &fe_t, unsigned int s, std::vector< unsigned int > &di, const bool add_p_level=true)
Fills the vector di with the local degree of freedom indices associated with side s of element elem A...
static void ifem_nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln)
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
static bool is_InfFE_elem(const ElemType et)
static Real shape_second_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
static void all_shape_derivs(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Point > &p, std::vector< std::vector< OutputType > > *comps[3], const bool add_p_level=true)
Real(* shape_second_deriv_ptr)(const FEType fet, const Elem *elem, const unsigned int i, const unsigned int j, const Point &p, const bool add_p_level)
Typedef for pointer to a function that returns FE shape function second derivative values.
static bool is_hierarchic(const FEType &fe_type)
Returns whether or not the input FEType's higher-order shape functions are always hierarchic.
FEInterface()
Empty constructor.
static shape_deriv_ptr shape_deriv_function(const unsigned int dim, const FEType &fe_t, const ElemType t)
Real(* shape_deriv_ptr)(const FEType fet, const Elem *elem, const unsigned int i, const unsigned int j, const Point &p, const bool add_p_level)
Typedef for pointer to a function that returns FE shape function derivative values.
static Real shape_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
static n_dofs_at_node_ptr n_dofs_at_node_function(const unsigned int dim, const FEType &fe_t)
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order,...
static void ifem_compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
static bool on_reference_element(const Point &p, const ElemType t, const Real eps=TOLERANCE)
static FEFieldType field_type(const FEType &fe_type)
static Real ifem_shape_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
static Point ifem_inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
static void shape_derivs(const FEType &fe_t, const Elem *elem, const unsigned int i, const unsigned int j, const std::vector< Point > &p, std::vector< OutputType > &dphi, const bool add_p_level=true)
Fills dphi with the derivatives of the shape function at point p in direction j.
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
unsigned int(* n_dofs_at_node_ptr)(const ElemType, const Order, const unsigned int)
static shape_second_deriv_ptr shape_second_deriv_function(const unsigned int dim, const FEType &fe_t, const ElemType t)
static unsigned int ifem_n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
static void compute_periodic_constraints(DofConstraints &constraints, DofMap &dof_map, const PeriodicBoundaries &boundaries, const MeshBase &mesh, const PointLocatorBase *point_locator, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for periodic boundary conditions) corresponding to vari...
static void all_shapes(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Point > &p, std::vector< std::vector< OutputType > > &phi, const bool add_p_level=true)
static unsigned int ifem_n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
static unsigned int ifem_n_shape_functions(const FEType &fe_t, const Elem *elem)
Real(* shape_ptr)(const FEType fe_t, const Elem *elem, const unsigned int i, const Point &p, const bool add_p_level)
Typedef for pointer to a function that returns FE shape function values.
static Point ifem_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
static unsigned int n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
static void shapes(const unsigned int dim, const FEType &fe_t, const Elem *elem, const unsigned int i, const std::vector< Point > &p, std::vector< OutputType > &phi, const bool add_p_level=true)
Fills phi with the values of the shape function at point p.
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
This is now deprecated; use FEMap::inverse_map instead.
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln from the element soln.
static unsigned int max_order(const FEType &fe_t, const ElemType &el_t)
static unsigned int ifem_n_dofs(const FEType &fe_t, const Elem *elem)
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
static shape_ptr shape_function(const unsigned int dim, const FEType &fe_t, const ElemType t)
static bool orientation_dependent(const FEFamily &fe_family)
static bool extra_hanging_dofs(const FEType &fe_t)
static void side_nodal_soln(const FEType &fe_t, const Elem *elem, const unsigned int side, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln on one side from the (full) element soln.
static void dofs_on_edge(const Elem *const elem, const unsigned int dim, const FEType &fe_t, unsigned int e, std::vector< unsigned int > &di, const bool add_p_level=true)
Fills the vector di with the local degree of freedom indices associated with edge e of element elem A...
static void compute_constraints(DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for non-conforming adapted meshes) corresponding to var...
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
static Point map(unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
This is now deprecated; use FEMap::map instead.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
FEFamily family
The type of finite element.
Definition fe_type.h:228
static void compute_constraints(DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for non-conforming adapted meshes) corresponding to var...
This is the MeshBase class.
Definition mesh_base.h:81
We're using a class instead of a typedef to allow forward declarations and future flexibility.
This is the base class for point locators.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
MeshBase & mesh
std::string enum_to_string(const T e)
The libMesh namespace provides an interface to certain functionality in the library.
@ SIDE_DISCONTINUOUS
OStreamProxy err
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
ElemType
Defines an enum for geometric element types.
libmesh_assert(ctx)
constexpr unsigned int fe_lagrange_gll_max_points_1D
The number of points in the largest Gauss-Lobatto rule that QGaussLobatto tabulates,...
@ L2_RAVIART_THOMAS
@ L2_HIERARCHIC_VEC
@ RATIONAL_BERNSTEIN
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176