21 #include "libmesh/fe.h"
22 #include "libmesh/libmesh_logging.h"
23 #include "libmesh/enum_elem_type.h"
26 #include "libmesh/boundary_info.h"
27 #include "libmesh/mesh_base.h"
28 #include "libmesh/dense_matrix.h"
29 #include "libmesh/dense_vector.h"
30 #include "libmesh/dof_map.h"
31 #include "libmesh/elem.h"
32 #include "libmesh/fe_interface.h"
33 #include "libmesh/numeric_vector.h"
34 #include "libmesh/periodic_boundaries.h"
35 #include "libmesh/periodic_boundary.h"
36 #include "libmesh/quadrature.h"
37 #include "libmesh/quadrature_gauss.h"
38 #include "libmesh/remote_elem.h"
39 #include "libmesh/tensor_value.h"
40 #include "libmesh/threads.h"
41 #include "libmesh/enum_elem_type.h"
48 _fe_map(
FEMap::build(fet) ),
50 calculations_started(false),
53 calculate_dphi(false),
54 calculate_d2phi(false),
55 calculate_curl_phi(false),
56 calculate_div_phi(false),
57 calculate_dphiref(false),
62 shapes_on_quadrature(false)
83 return libmesh_make_unique<FE<0,CLOUGH>>(fet);
86 return libmesh_make_unique<FE<0,HERMITE>>(fet);
89 return libmesh_make_unique<FE<0,LAGRANGE>>(fet);
92 return libmesh_make_unique<FE<0,LAGRANGE_VEC>>(fet);
95 return libmesh_make_unique<FE<0,L2_LAGRANGE>>(fet);
98 return libmesh_make_unique<FE<0,HIERARCHIC>>(fet);
101 return libmesh_make_unique<FE<0,L2_HIERARCHIC>>(fet);
104 return libmesh_make_unique<FE<0,MONOMIAL>>(fet);
107 return libmesh_make_unique<FE<0,MONOMIAL_VEC>>(fet);
109 #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
111 return libmesh_make_unique<FE<0,SZABAB>>(fet);
114 return libmesh_make_unique<FE<0,BERNSTEIN>>(fet);
117 return libmesh_make_unique<FE<0,RATIONAL_BERNSTEIN>>(fet);
121 return libmesh_make_unique<FEXYZ<0>>(fet);
124 return libmesh_make_unique<FEScalar<0>>(fet);
127 libmesh_error_msg(
"ERROR: Bad FEType.family= " << fet.
family);
136 return libmesh_make_unique<FE<1,CLOUGH>>(fet);
139 return libmesh_make_unique<FE<1,HERMITE>>(fet);
142 return libmesh_make_unique<FE<1,LAGRANGE>>(fet);
145 return libmesh_make_unique<FE<1,LAGRANGE_VEC>>(fet);
148 return libmesh_make_unique<FE<1,L2_LAGRANGE>>(fet);
151 return libmesh_make_unique<FE<1,HIERARCHIC>>(fet);
154 return libmesh_make_unique<FE<1,L2_HIERARCHIC>>(fet);
157 return libmesh_make_unique<FE<1,MONOMIAL>>(fet);
160 return libmesh_make_unique<FE<1,MONOMIAL_VEC>>(fet);
162 #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
164 return libmesh_make_unique<FE<1,SZABAB>>(fet);
167 return libmesh_make_unique<FE<1,BERNSTEIN>>(fet);
170 return libmesh_make_unique<FE<1,RATIONAL_BERNSTEIN>>(fet);
174 return libmesh_make_unique<FEXYZ<1>>(fet);
177 return libmesh_make_unique<FEScalar<1>>(fet);
180 libmesh_error_msg(
"ERROR: Bad FEType.family= " << fet.
family);
191 return libmesh_make_unique<FE<2,CLOUGH>>(fet);
194 return libmesh_make_unique<FE<2,HERMITE>>(fet);
197 return libmesh_make_unique<FE<2,LAGRANGE>>(fet);
200 return libmesh_make_unique<FE<2,LAGRANGE_VEC>>(fet);
203 return libmesh_make_unique<FE<2,L2_LAGRANGE>>(fet);
206 return libmesh_make_unique<FE<2,HIERARCHIC>>(fet);
209 return libmesh_make_unique<FE<2,L2_HIERARCHIC>>(fet);
212 return libmesh_make_unique<FE<2,MONOMIAL>>(fet);
215 return libmesh_make_unique<FE<2,MONOMIAL_VEC>>(fet);
217 #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
219 return libmesh_make_unique<FE<2,SZABAB>>(fet);
222 return libmesh_make_unique<FE<2,BERNSTEIN>>(fet);
225 return libmesh_make_unique<FE<2,RATIONAL_BERNSTEIN>>(fet);
229 return libmesh_make_unique<FEXYZ<2>>(fet);
232 return libmesh_make_unique<FEScalar<2>>(fet);
235 return libmesh_make_unique<FENedelecOne<2>>(fet);
238 return libmesh_make_unique<FESubdivision>(fet);
241 libmesh_error_msg(
"ERROR: Bad FEType.family= " << fet.
family);
252 libmesh_error_msg(
"ERROR: Clough-Tocher elements currently only support 1D and 2D");
255 return libmesh_make_unique<FE<3,HERMITE>>(fet);
258 return libmesh_make_unique<FE<3,LAGRANGE>>(fet);
261 return libmesh_make_unique<FE<3,LAGRANGE_VEC>>(fet);
264 return libmesh_make_unique<FE<3,L2_LAGRANGE>>(fet);
267 return libmesh_make_unique<FE<3,HIERARCHIC>>(fet);
270 return libmesh_make_unique<FE<3,L2_HIERARCHIC>>(fet);
273 return libmesh_make_unique<FE<3,MONOMIAL>>(fet);
276 return libmesh_make_unique<FE<3,MONOMIAL_VEC>>(fet);
278 #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
280 return libmesh_make_unique<FE<3,SZABAB>>(fet);
283 return libmesh_make_unique<FE<3,BERNSTEIN>>(fet);
286 return libmesh_make_unique<FE<3,RATIONAL_BERNSTEIN>>(fet);
290 return libmesh_make_unique<FEXYZ<3>>(fet);
293 return libmesh_make_unique<FEScalar<3>>(fet);
296 return libmesh_make_unique<FENedelecOne<3>>(fet);
299 libmesh_error_msg(
"ERROR: Bad FEType.family= " << fet.
family);
304 libmesh_error_msg(
"Invalid dimension dim = " <<
dim);
315 nodes[0] =
Point (-1.,0.,0.);
316 nodes[1] =
Point (1.,0.,0.);
322 nodes[0] =
Point (-1.,0.,0.);
323 nodes[1] =
Point (1.,0.,0.);
324 nodes[2] =
Point (0.,0.,0.);
331 nodes[0] =
Point (0.,0.,0.);
332 nodes[1] =
Point (1.,0.,0.);
333 nodes[2] =
Point (0.,1.,0.);
339 nodes[0] =
Point (0.,0.,0.);
340 nodes[1] =
Point (1.,0.,0.);
341 nodes[2] =
Point (0.,1.,0.);
342 nodes[3] =
Point (.5,0.,0.);
343 nodes[4] =
Point (.5,.5,0.);
344 nodes[5] =
Point (0.,.5,0.);
351 nodes[0] =
Point (-1.,-1.,0.);
352 nodes[1] =
Point (1.,-1.,0.);
353 nodes[2] =
Point (1.,1.,0.);
354 nodes[3] =
Point (-1.,1.,0.);
361 nodes[0] =
Point (-1.,-1.,0.);
362 nodes[1] =
Point (1.,-1.,0.);
363 nodes[2] =
Point (1.,1.,0.);
364 nodes[3] =
Point (-1.,1.,0.);
365 nodes[4] =
Point (0.,-1.,0.);
366 nodes[5] =
Point (1.,0.,0.);
367 nodes[6] =
Point (0.,1.,0.);
368 nodes[7] =
Point (-1.,0.,0.);
374 nodes[0] =
Point (-1.,-1.,0.);
375 nodes[1] =
Point (1.,-1.,0.);
376 nodes[2] =
Point (1.,1.,0.);
377 nodes[3] =
Point (-1.,1.,0.);
378 nodes[4] =
Point (0.,-1.,0.);
379 nodes[5] =
Point (1.,0.,0.);
380 nodes[6] =
Point (0.,1.,0.);
381 nodes[7] =
Point (-1.,0.,0.);
382 nodes[8] =
Point (0.,0.,0.);
388 nodes[0] =
Point (0.,0.,0.);
389 nodes[1] =
Point (1.,0.,0.);
390 nodes[2] =
Point (0.,1.,0.);
391 nodes[3] =
Point (0.,0.,1.);
397 nodes[0] =
Point (0.,0.,0.);
398 nodes[1] =
Point (1.,0.,0.);
399 nodes[2] =
Point (0.,1.,0.);
400 nodes[3] =
Point (0.,0.,1.);
401 nodes[4] =
Point (.5,0.,0.);
402 nodes[5] =
Point (.5,.5,0.);
403 nodes[6] =
Point (0.,.5,0.);
404 nodes[7] =
Point (0.,0.,.5);
405 nodes[8] =
Point (.5,0.,.5);
406 nodes[9] =
Point (0.,.5,.5);
412 nodes[0] =
Point (-1.,-1.,-1.);
413 nodes[1] =
Point (1.,-1.,-1.);
414 nodes[2] =
Point (1.,1.,-1.);
415 nodes[3] =
Point (-1.,1.,-1.);
416 nodes[4] =
Point (-1.,-1.,1.);
417 nodes[5] =
Point (1.,-1.,1.);
418 nodes[6] =
Point (1.,1.,1.);
419 nodes[7] =
Point (-1.,1.,1.);
425 nodes[0] =
Point (-1.,-1.,-1.);
426 nodes[1] =
Point (1.,-1.,-1.);
427 nodes[2] =
Point (1.,1.,-1.);
428 nodes[3] =
Point (-1.,1.,-1.);
429 nodes[4] =
Point (-1.,-1.,1.);
430 nodes[5] =
Point (1.,-1.,1.);
431 nodes[6] =
Point (1.,1.,1.);
432 nodes[7] =
Point (-1.,1.,1.);
433 nodes[8] =
Point (0.,-1.,-1.);
434 nodes[9] =
Point (1.,0.,-1.);
435 nodes[10] =
Point (0.,1.,-1.);
436 nodes[11] =
Point (-1.,0.,-1.);
437 nodes[12] =
Point (-1.,-1.,0.);
438 nodes[13] =
Point (1.,-1.,0.);
439 nodes[14] =
Point (1.,1.,0.);
440 nodes[15] =
Point (-1.,1.,0.);
441 nodes[16] =
Point (0.,-1.,1.);
442 nodes[17] =
Point (1.,0.,1.);
443 nodes[18] =
Point (0.,1.,1.);
444 nodes[19] =
Point (-1.,0.,1.);
450 nodes[0] =
Point (-1.,-1.,-1.);
451 nodes[1] =
Point (1.,-1.,-1.);
452 nodes[2] =
Point (1.,1.,-1.);
453 nodes[3] =
Point (-1.,1.,-1.);
454 nodes[4] =
Point (-1.,-1.,1.);
455 nodes[5] =
Point (1.,-1.,1.);
456 nodes[6] =
Point (1.,1.,1.);
457 nodes[7] =
Point (-1.,1.,1.);
458 nodes[8] =
Point (0.,-1.,-1.);
459 nodes[9] =
Point (1.,0.,-1.);
460 nodes[10] =
Point (0.,1.,-1.);
461 nodes[11] =
Point (-1.,0.,-1.);
462 nodes[12] =
Point (-1.,-1.,0.);
463 nodes[13] =
Point (1.,-1.,0.);
464 nodes[14] =
Point (1.,1.,0.);
465 nodes[15] =
Point (-1.,1.,0.);
466 nodes[16] =
Point (0.,-1.,1.);
467 nodes[17] =
Point (1.,0.,1.);
468 nodes[18] =
Point (0.,1.,1.);
469 nodes[19] =
Point (-1.,0.,1.);
470 nodes[20] =
Point (0.,0.,-1.);
471 nodes[21] =
Point (0.,-1.,0.);
472 nodes[22] =
Point (1.,0.,0.);
473 nodes[23] =
Point (0.,1.,0.);
474 nodes[24] =
Point (-1.,0.,0.);
475 nodes[25] =
Point (0.,0.,1.);
476 nodes[26] =
Point (0.,0.,0.);
482 nodes[0] =
Point (0.,0.,-1.);
483 nodes[1] =
Point (1.,0.,-1.);
484 nodes[2] =
Point (0.,1.,-1.);
485 nodes[3] =
Point (0.,0.,1.);
486 nodes[4] =
Point (1.,0.,1.);
487 nodes[5] =
Point (0.,1.,1.);
493 nodes[0] =
Point (0.,0.,-1.);
494 nodes[1] =
Point (1.,0.,-1.);
495 nodes[2] =
Point (0.,1.,-1.);
496 nodes[3] =
Point (0.,0.,1.);
497 nodes[4] =
Point (1.,0.,1.);
498 nodes[5] =
Point (0.,1.,1.);
499 nodes[6] =
Point (.5,0.,-1.);
500 nodes[7] =
Point (.5,.5,-1.);
501 nodes[8] =
Point (0.,.5,-1.);
502 nodes[9] =
Point (0.,0.,0.);
503 nodes[10] =
Point (1.,0.,0.);
504 nodes[11] =
Point (0.,1.,0.);
505 nodes[12] =
Point (.5,0.,1.);
506 nodes[13] =
Point (.5,.5,1.);
507 nodes[14] =
Point (0.,.5,1.);
513 nodes[0] =
Point (0.,0.,-1.);
514 nodes[1] =
Point (1.,0.,-1.);
515 nodes[2] =
Point (0.,1.,-1.);
516 nodes[3] =
Point (0.,0.,1.);
517 nodes[4] =
Point (1.,0.,1.);
518 nodes[5] =
Point (0.,1.,1.);
519 nodes[6] =
Point (.5,0.,-1.);
520 nodes[7] =
Point (.5,.5,-1.);
521 nodes[8] =
Point (0.,.5,-1.);
522 nodes[9] =
Point (0.,0.,0.);
523 nodes[10] =
Point (1.,0.,0.);
524 nodes[11] =
Point (0.,1.,0.);
525 nodes[12] =
Point (.5,0.,1.);
526 nodes[13] =
Point (.5,.5,1.);
527 nodes[14] =
Point (0.,.5,1.);
528 nodes[15] =
Point (.5,0.,0.);
529 nodes[16] =
Point (.5,.5,0.);
530 nodes[17] =
Point (0.,.5,0.);
536 nodes[0] =
Point (-1.,-1.,0.);
537 nodes[1] =
Point (1.,-1.,0.);
538 nodes[2] =
Point (1.,1.,0.);
539 nodes[3] =
Point (-1.,1.,0.);
540 nodes[4] =
Point (0.,0.,1.);
548 nodes[0] =
Point (-1.,-1.,0.);
549 nodes[1] =
Point (1.,-1.,0.);
550 nodes[2] =
Point (1.,1.,0.);
551 nodes[3] =
Point (-1.,1.,0.);
554 nodes[4] =
Point (0.,0.,1.);
557 nodes[5] =
Point (0.,-1.,0.);
558 nodes[6] =
Point (1.,0.,0.);
559 nodes[7] =
Point (0.,1.,0.);
560 nodes[8] =
Point (-1,0.,0.);
563 nodes[9] =
Point (-.5,-.5,.5);
564 nodes[10] =
Point (.5,-.5,.5);
565 nodes[11] =
Point (.5,.5,.5);
566 nodes[12] =
Point (-.5,.5,.5);
575 nodes[0] =
Point (-1.,-1.,0.);
576 nodes[1] =
Point (1.,-1.,0.);
577 nodes[2] =
Point (1.,1.,0.);
578 nodes[3] =
Point (-1.,1.,0.);
581 nodes[4] =
Point (0.,0.,1.);
584 nodes[5] =
Point (0.,-1.,0.);
585 nodes[6] =
Point (1.,0.,0.);
586 nodes[7] =
Point (0.,1.,0.);
587 nodes[8] =
Point (-1,0.,0.);
590 nodes[9] =
Point (-.5,-.5,.5);
591 nodes[10] =
Point (.5,-.5,.5);
592 nodes[11] =
Point (.5,.5,.5);
593 nodes[12] =
Point (-.5,.5,.5);
596 nodes[13] =
Point (0.,0.,0.);
602 libmesh_error_msg(
"ERROR: Unknown element type " << itemType);
608 libmesh_assert_greater_equal (eps, 0.);
610 const Real xi = p(0);
612 const Real eta = p(1);
617 const Real zeta = p(2);
619 const Real zeta = 0.;
626 return (!xi && !eta && !zeta);
633 if ((xi >= -1.-eps) &&
647 if ((xi >= 0.-eps) &&
649 ((xi + eta) <= 1.+eps))
663 if ((xi >= -1.-eps) &&
679 if ((xi >= 0.-eps) &&
682 ((xi + eta + zeta) <= 1.+eps))
704 if ((xi >= -1.-eps) &&
725 if ((xi >= 0.-eps) &&
729 ((xi + eta) <= 1.+eps))
748 if ((-eta - 1. + zeta <= 0.+eps) &&
749 ( xi - 1. + zeta <= 0.+eps) &&
750 ( eta - 1. + zeta <= 0.+eps) &&
751 ( -xi - 1. + zeta <= 0.+eps) &&
758 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
764 if ((xi >= -1.-eps) &&
780 if ((xi >= 0.-eps) &&
784 ((xi + eta) <= 1.+eps))
794 libmesh_error_msg(
"ERROR: Unknown element type " << t);
820 os <<
"phi[i][j]: Shape function i at quadrature pt. j" << std::endl;
823 os <<
"dphi[i][j]: Shape function i's gradient at quadrature pt. j" << std::endl;
826 os <<
"XYZ locations of the quadrature pts." << std::endl;
829 os <<
"Values of JxW at the quadrature pts." << std::endl;
842 #ifdef LIBMESH_ENABLE_AMR
844 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
850 const unsigned int Dim = elem->
dim();
864 std::vector<const Node *> my_nodes, parent_nodes;
865 std::unique_ptr<const Elem> my_side, parent_side;
886 const unsigned int n_side_nodes = my_side->n_nodes();
889 my_nodes.reserve (n_side_nodes);
890 parent_nodes.clear();
891 parent_nodes.reserve (n_side_nodes);
893 for (
unsigned int n=0; n != n_side_nodes; ++n)
894 my_nodes.push_back(my_side->node_ptr(n));
896 for (
unsigned int n=0; n != n_side_nodes; ++n)
897 parent_nodes.push_back(parent_side->node_ptr(n));
899 for (
unsigned int my_side_n=0;
900 my_side_n < n_side_nodes;
905 const Node * my_node = my_nodes[my_side_n];
908 const Point & support_point = *my_node;
916 for (
unsigned int their_side_n=0;
917 their_side_n < n_side_nodes;
922 const Node * their_node = parent_nodes[their_side_n];
935 if (their_mag > 0.999)
937 libmesh_assert_equal_to (my_node, their_node);
938 libmesh_assert_less (
std::abs(their_value - 1.), 0.001);
947 if (their_mag < 1.e-5)
957 constraint_row.insert(std::make_pair (their_node,
973 constraint_row.insert(std::make_pair (their_node,
981 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
983 #endif // #ifdef LIBMESH_ENABLE_AMR
987 #ifdef LIBMESH_ENABLE_PERIODIC
989 #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
997 if (boundaries.empty())
1006 const unsigned int Dim = elem->
dim();
1012 std::vector<const Node *> my_nodes, neigh_nodes;
1013 std::unique_ptr<const Elem> my_side, neigh_side;
1017 std::vector<boundary_id_type> bc_ids;
1023 mesh.get_boundary_info().boundary_ids (elem, s, bc_ids);
1024 for (
const auto & boundary_id : bc_ids)
1032 const Elem * neigh = boundaries.
neighbor(boundary_id, *point_locator, elem, s);
1040 unsigned int s_neigh =
1044 #ifdef LIBMESH_ENABLE_AMR
1046 #endif // #ifdef LIBMESH_ENABLE_AMR
1051 const unsigned int n_side_nodes = my_side->n_nodes();
1054 my_nodes.reserve (n_side_nodes);
1055 neigh_nodes.clear();
1056 neigh_nodes.reserve (n_side_nodes);
1058 for (
unsigned int n=0; n != n_side_nodes; ++n)
1059 my_nodes.push_back(my_side->node_ptr(n));
1061 for (
unsigned int n=0; n != n_side_nodes; ++n)
1062 neigh_nodes.push_back(neigh_side->node_ptr(n));
1068 std::vector<bool> skip_constraint(n_side_nodes,
false);
1070 for (
unsigned int my_side_n=0;
1071 my_side_n < n_side_nodes;
1076 const Node * my_node = my_nodes[my_side_n];
1081 const Point mapped_point =
1091 if (constraints.count(my_node))
1093 skip_constraint[my_side_n] =
true;
1099 for (
unsigned int their_side_n=0;
1100 their_side_n < n_side_nodes;
1105 const Node * their_node = neigh_nodes[their_side_n];
1114 if (!constraints.count(their_node))
1118 constraints[their_node].first;
1120 for (
unsigned int orig_side_n=0;
1121 orig_side_n < n_side_nodes;
1126 const Node * orig_node = my_nodes[orig_side_n];
1128 if (their_constraint_row.count(orig_node))
1129 skip_constraint[orig_side_n] =
true;
1134 for (
unsigned int my_side_n=0;
1135 my_side_n < n_side_nodes;
1140 if (skip_constraint[my_side_n])
1143 const Node * my_node = my_nodes[my_side_n];
1149 const Point mapped_point =
1153 for (
unsigned int their_side_n=0;
1154 their_side_n < n_side_nodes;
1159 const Node * their_node = neigh_nodes[their_side_n];
1175 constraints[my_node].first;
1177 constraint_row.insert(std::make_pair(their_node,
1187 #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1189 #endif // LIBMESH_ENABLE_PERIODIC