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 : // libmesh includes
19 : #include "libmesh/fe.h"
20 : #include "libmesh/libmesh_logging.h"
21 : #include "libmesh/enum_elem_type.h"
22 : #include "libmesh/boundary_info.h"
23 : #include "libmesh/mesh_base.h"
24 : #include "libmesh/dense_matrix.h"
25 : #include "libmesh/dense_vector.h"
26 : #include "libmesh/dof_map.h"
27 : #include "libmesh/elem.h"
28 : #include "libmesh/fe_interface.h"
29 : #include "libmesh/numeric_vector.h"
30 : #include "libmesh/periodic_boundaries.h"
31 : #include "libmesh/periodic_boundary.h"
32 : #include "libmesh/quadrature.h"
33 : #include "libmesh/quadrature_gauss.h"
34 : #include "libmesh/remote_elem.h"
35 : #include "libmesh/tensor_value.h"
36 : #include "libmesh/threads.h"
37 : #include "libmesh/enum_to_string.h"
38 :
39 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
40 : #include "libmesh/inf_fe.h"
41 : #include "libmesh/fe_interface_macros.h"
42 : #endif
43 :
44 : namespace libMesh
45 : {
46 :
47 13066292 : FEAbstract::FEAbstract(const unsigned int d,
48 13066292 : const FEType & fet) :
49 11607919 : _fe_map( FEMap::build(fet) ),
50 11607919 : dim(d),
51 11607919 : calculations_started(false),
52 11607919 : calculate_dual(false),
53 11607919 : calculate_default_dual_coeff(true),
54 11607919 : calculate_nothing(false),
55 11607919 : calculate_map(false),
56 11607919 : calculate_phi(false),
57 11607919 : calculate_dphi(false),
58 11607919 : calculate_d2phi(false),
59 11607919 : calculate_curl_phi(false),
60 11607919 : calculate_div_phi(false),
61 11607919 : calculate_dphiref(false),
62 11607919 : fe_type(fet),
63 11607919 : _elem_type(INVALID_ELEM),
64 11607919 : _elem(nullptr),
65 11607919 : _elem_p_level(0),
66 11607919 : _p_level(0),
67 11607919 : qrule(nullptr),
68 11607919 : shapes_on_quadrature(false),
69 11607919 : _n_total_qp(0),
70 13066292 : _add_p_level_in_reinit(fet.p_refinement)
71 : {
72 13066292 : }
73 :
74 :
75 11607919 : FEAbstract::~FEAbstract() = default;
76 :
77 :
78 6927245 : std::unique_ptr<FEAbstract> FEAbstract::build(const unsigned int dim,
79 : const FEType & fet)
80 : {
81 6927245 : switch (dim)
82 : {
83 : // 0D
84 63286 : case 0:
85 : {
86 63286 : switch (fet.family)
87 : {
88 0 : case CLOUGH:
89 0 : return std::make_unique<FE<0,CLOUGH>>(fet);
90 :
91 0 : case HERMITE:
92 0 : return std::make_unique<FE<0,HERMITE>>(fet);
93 :
94 38334 : case LAGRANGE:
95 38334 : return std::make_unique<FE<0,LAGRANGE>>(fet);
96 :
97 0 : case LAGRANGE_VEC:
98 0 : return std::make_unique<FE<0,LAGRANGE_VEC>>(fet);
99 :
100 840 : case L2_LAGRANGE:
101 840 : return std::make_unique<FE<0,L2_LAGRANGE>>(fet);
102 :
103 0 : case L2_LAGRANGE_GLL:
104 0 : return std::make_unique<FE<0,L2_LAGRANGE_GLL>>(fet);
105 :
106 0 : case LAGRANGE_GLL:
107 0 : return std::make_unique<FE<0,LAGRANGE_GLL>>(fet);
108 :
109 840 : case L2_LAGRANGE_VEC:
110 840 : return std::make_unique<FE<0,L2_LAGRANGE_VEC>>(fet);
111 :
112 0 : case HIERARCHIC_VEC:
113 0 : return std::make_unique<FE<0,HIERARCHIC_VEC>>(fet);
114 :
115 0 : case HIERARCHIC:
116 0 : return std::make_unique<FE<0,HIERARCHIC>>(fet);
117 :
118 1136 : case L2_HIERARCHIC:
119 1136 : return std::make_unique<FE<0,L2_HIERARCHIC>>(fet);
120 :
121 0 : case L2_HIERARCHIC_VEC:
122 0 : return std::make_unique<FE<0,L2_HIERARCHIC_VEC>>(fet);
123 :
124 840 : case SIDE_HIERARCHIC:
125 840 : return std::make_unique<FE<0,SIDE_HIERARCHIC>>(fet);
126 :
127 3432 : case MONOMIAL:
128 3432 : return std::make_unique<FE<0,MONOMIAL>>(fet);
129 :
130 0 : case MONOMIAL_VEC:
131 0 : return std::make_unique<FE<0,MONOMIAL_VEC>>(fet);
132 :
133 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
134 0 : case SZABAB:
135 0 : return std::make_unique<FE<0,SZABAB>>(fet);
136 :
137 0 : case BERNSTEIN:
138 0 : return std::make_unique<FE<0,BERNSTEIN>>(fet);
139 :
140 11012 : case RATIONAL_BERNSTEIN:
141 11012 : return std::make_unique<FE<0,RATIONAL_BERNSTEIN>>(fet);
142 : #endif
143 :
144 0 : case XYZ:
145 0 : return std::make_unique<FEXYZ<0>>(fet);
146 :
147 3988 : case SCALAR:
148 3988 : return std::make_unique<FEScalar<0>>(fet);
149 :
150 0 : case NEDELEC_ONE:
151 0 : return std::make_unique<FENedelecOne<0>>(fet);
152 :
153 2864 : case RAVIART_THOMAS:
154 2864 : return std::make_unique<FERaviartThomas<0>>(fet);
155 :
156 0 : case L2_RAVIART_THOMAS:
157 0 : return std::make_unique<FEL2RaviartThomas<0>>(fet);
158 :
159 0 : case SUBDIVISION:
160 0 : return std::make_unique<FESubdivision>(fet);
161 :
162 0 : default:
163 0 : libmesh_error_msg("ERROR: Bad FEType.family= " << Utility::enum_to_string(fet.family));
164 : }
165 : }
166 : // 1D
167 811314 : case 1:
168 : {
169 811314 : switch (fet.family)
170 : {
171 0 : case CLOUGH:
172 0 : return std::make_unique<FE<1,CLOUGH>>(fet);
173 :
174 141252 : case HERMITE:
175 141252 : return std::make_unique<FE<1,HERMITE>>(fet);
176 :
177 84370 : case LAGRANGE:
178 84370 : return std::make_unique<FE<1,LAGRANGE>>(fet);
179 :
180 0 : case LAGRANGE_VEC:
181 0 : return std::make_unique<FE<1,LAGRANGE_VEC>>(fet);
182 :
183 28626 : case L2_LAGRANGE:
184 28626 : return std::make_unique<FE<1,L2_LAGRANGE>>(fet);
185 :
186 114504 : case L2_LAGRANGE_GLL:
187 114504 : return std::make_unique<FE<1,L2_LAGRANGE_GLL>>(fet);
188 :
189 47710 : case LAGRANGE_GLL:
190 47710 : return std::make_unique<FE<1,LAGRANGE_GLL>>(fet);
191 :
192 0 : case L2_LAGRANGE_VEC:
193 0 : return std::make_unique<FE<1,L2_LAGRANGE_VEC>>(fet);
194 :
195 0 : case HIERARCHIC_VEC:
196 0 : return std::make_unique<FE<1,HIERARCHIC_VEC>>(fet);
197 :
198 116246 : case HIERARCHIC:
199 116246 : return std::make_unique<FE<1,HIERARCHIC>>(fet);
200 :
201 47710 : case L2_HIERARCHIC:
202 47710 : return std::make_unique<FE<1,L2_HIERARCHIC>>(fet);
203 :
204 0 : case L2_HIERARCHIC_VEC:
205 0 : return std::make_unique<FE<1,L2_HIERARCHIC_VEC>>(fet);
206 :
207 24222 : case SIDE_HIERARCHIC:
208 24222 : return std::make_unique<FE<1,SIDE_HIERARCHIC>>(fet);
209 :
210 63544 : case MONOMIAL:
211 63544 : return std::make_unique<FE<1,MONOMIAL>>(fet);
212 :
213 0 : case MONOMIAL_VEC:
214 0 : return std::make_unique<FE<1,MONOMIAL_VEC>>(fet);
215 :
216 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
217 38168 : case SZABAB:
218 38168 : return std::make_unique<FE<1,SZABAB>>(fet);
219 :
220 47710 : case BERNSTEIN:
221 47710 : return std::make_unique<FE<1,BERNSTEIN>>(fet);
222 :
223 19084 : case RATIONAL_BERNSTEIN:
224 19084 : return std::make_unique<FE<1,RATIONAL_BERNSTEIN>>(fet);
225 : #endif
226 :
227 38168 : case XYZ:
228 38168 : return std::make_unique<FEXYZ<1>>(fet);
229 :
230 0 : case SCALAR:
231 0 : return std::make_unique<FEScalar<1>>(fet);
232 :
233 0 : case NEDELEC_ONE:
234 0 : return std::make_unique<FENedelecOne<1>>(fet);
235 :
236 0 : case RAVIART_THOMAS:
237 0 : return std::make_unique<FERaviartThomas<1>>(fet);
238 :
239 0 : case L2_RAVIART_THOMAS:
240 0 : return std::make_unique<FEL2RaviartThomas<1>>(fet);
241 :
242 0 : case SUBDIVISION:
243 0 : return std::make_unique<FESubdivision>(fet);
244 :
245 0 : default:
246 0 : libmesh_error_msg("ERROR: Bad FEType.family= " << Utility::enum_to_string(fet.family));
247 : }
248 : }
249 :
250 :
251 : // 2D
252 3314195 : case 2:
253 : {
254 3314195 : switch (fet.family)
255 : {
256 67506 : case CLOUGH:
257 67506 : return std::make_unique<FE<2,CLOUGH>>(fet);
258 :
259 60548 : case HERMITE:
260 60548 : return std::make_unique<FE<2,HERMITE>>(fet);
261 :
262 1491223 : case LAGRANGE:
263 1491223 : return std::make_unique<FE<2,LAGRANGE>>(fet);
264 :
265 61344 : case LAGRANGE_VEC:
266 61344 : return std::make_unique<FE<2,LAGRANGE_VEC>>(fet);
267 :
268 100508 : case L2_LAGRANGE:
269 100508 : return std::make_unique<FE<2,L2_LAGRANGE>>(fet);
270 :
271 114504 : case L2_LAGRANGE_GLL:
272 114504 : return std::make_unique<FE<2,L2_LAGRANGE_GLL>>(fet);
273 :
274 49912 : case LAGRANGE_GLL:
275 49912 : return std::make_unique<FE<2,LAGRANGE_GLL>>(fet);
276 :
277 4236 : case L2_LAGRANGE_VEC:
278 4236 : return std::make_unique<FE<2,L2_LAGRANGE_VEC>>(fet);
279 :
280 0 : case HIERARCHIC_VEC:
281 0 : return std::make_unique<FE<2,HIERARCHIC_VEC>>(fet);
282 :
283 477054 : case HIERARCHIC:
284 477054 : return std::make_unique<FE<2,HIERARCHIC>>(fet);
285 :
286 133134 : case L2_HIERARCHIC:
287 133134 : return std::make_unique<FE<2,L2_HIERARCHIC>>(fet);
288 :
289 3408 : case L2_HIERARCHIC_VEC:
290 3408 : return std::make_unique<FE<2,L2_HIERARCHIC_VEC>>(fet);
291 :
292 86824 : case SIDE_HIERARCHIC:
293 86824 : return std::make_unique<FE<2,SIDE_HIERARCHIC>>(fet);
294 :
295 241010 : case MONOMIAL:
296 241010 : return std::make_unique<FE<2,MONOMIAL>>(fet);
297 :
298 1704 : case MONOMIAL_VEC:
299 1704 : return std::make_unique<FE<2,MONOMIAL_VEC>>(fet);
300 :
301 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
302 106430 : case SZABAB:
303 106430 : return std::make_unique<FE<2,SZABAB>>(fet);
304 :
305 104962 : case BERNSTEIN:
306 104962 : return std::make_unique<FE<2,BERNSTEIN>>(fet);
307 :
308 38126 : case RATIONAL_BERNSTEIN:
309 38126 : return std::make_unique<FE<2,RATIONAL_BERNSTEIN>>(fet);
310 : #endif
311 :
312 157312 : case XYZ:
313 157312 : return std::make_unique<FEXYZ<2>>(fet);
314 :
315 3396 : case SCALAR:
316 3396 : return std::make_unique<FEScalar<2>>(fet);
317 :
318 3714 : case NEDELEC_ONE:
319 3714 : return std::make_unique<FENedelecOne<2>>(fet);
320 :
321 5640 : case RAVIART_THOMAS:
322 5640 : return std::make_unique<FERaviartThomas<2>>(fet);
323 :
324 1700 : case L2_RAVIART_THOMAS:
325 1700 : return std::make_unique<FEL2RaviartThomas<2>>(fet);
326 :
327 0 : case SUBDIVISION:
328 0 : return std::make_unique<FESubdivision>(fet);
329 :
330 0 : default:
331 0 : libmesh_error_msg("ERROR: Bad FEType.family= " << Utility::enum_to_string(fet.family));
332 : }
333 : }
334 :
335 :
336 : // 3D
337 2738450 : case 3:
338 : {
339 2738450 : switch (fet.family)
340 : {
341 0 : case CLOUGH:
342 0 : libmesh_error_msg("ERROR: Clough-Tocher elements currently only support 1D and 2D");
343 :
344 14313 : case HERMITE:
345 14313 : return std::make_unique<FE<3,HERMITE>>(fet);
346 :
347 556054 : case LAGRANGE:
348 556054 : return std::make_unique<FE<3,LAGRANGE>>(fet);
349 :
350 92868 : case LAGRANGE_VEC:
351 92868 : return std::make_unique<FE<3,LAGRANGE_VEC>>(fet);
352 :
353 206914 : case L2_LAGRANGE:
354 206914 : return std::make_unique<FE<3,L2_LAGRANGE>>(fet);
355 :
356 171756 : case L2_LAGRANGE_GLL:
357 171756 : return std::make_unique<FE<3,L2_LAGRANGE_GLL>>(fet);
358 :
359 60555 : case LAGRANGE_GLL:
360 60555 : return std::make_unique<FE<3,LAGRANGE_GLL>>(fet);
361 :
362 2556 : case L2_LAGRANGE_VEC:
363 2556 : return std::make_unique<FE<3,L2_LAGRANGE_VEC>>(fet);
364 :
365 0 : case HIERARCHIC_VEC:
366 0 : return std::make_unique<FE<3,HIERARCHIC_VEC>>(fet);
367 :
368 270768 : case HIERARCHIC:
369 270768 : return std::make_unique<FE<3,HIERARCHIC>>(fet);
370 :
371 281106 : case L2_HIERARCHIC:
372 281106 : return std::make_unique<FE<3,L2_HIERARCHIC>>(fet);
373 :
374 1278 : case L2_HIERARCHIC_VEC:
375 1278 : return std::make_unique<FE<3,L2_HIERARCHIC_VEC>>(fet);
376 :
377 121110 : case SIDE_HIERARCHIC:
378 121110 : return std::make_unique<FE<3,SIDE_HIERARCHIC>>(fet);
379 :
380 445746 : case MONOMIAL:
381 445746 : return std::make_unique<FE<3,MONOMIAL>>(fet);
382 :
383 0 : case MONOMIAL_VEC:
384 0 : return std::make_unique<FE<3,MONOMIAL_VEC>>(fet);
385 :
386 : #ifdef LIBMESH_ENABLE_HIGHER_ORDER_SHAPES
387 0 : case SZABAB:
388 0 : return std::make_unique<FE<3,SZABAB>>(fet);
389 :
390 100191 : case BERNSTEIN:
391 100191 : return std::make_unique<FE<3,BERNSTEIN>>(fet);
392 :
393 45207 : case RATIONAL_BERNSTEIN:
394 45207 : return std::make_unique<FE<3,RATIONAL_BERNSTEIN>>(fet);
395 : #endif
396 :
397 360381 : case XYZ:
398 360381 : return std::make_unique<FEXYZ<3>>(fet);
399 :
400 888 : case SCALAR:
401 888 : return std::make_unique<FEScalar<3>>(fet);
402 :
403 3306 : case NEDELEC_ONE:
404 3306 : return std::make_unique<FENedelecOne<3>>(fet);
405 :
406 2178 : case RAVIART_THOMAS:
407 2178 : return std::make_unique<FERaviartThomas<3>>(fet);
408 :
409 1275 : case L2_RAVIART_THOMAS:
410 1275 : return std::make_unique<FEL2RaviartThomas<3>>(fet);
411 :
412 0 : default:
413 0 : libmesh_error_msg("ERROR: Bad FEType.family= " << Utility::enum_to_string(fet.family));
414 : }
415 : }
416 :
417 0 : default:
418 0 : libmesh_error_msg("Invalid dimension dim = " << dim);
419 : }
420 : }
421 :
422 :
423 :
424 34127932 : void FEAbstract::get_refspace_nodes(const ElemType itemType, std::vector<Point> & nodes)
425 : {
426 34127932 : const unsigned int n_nodes = Elem::type_to_n_nodes_map[itemType];
427 34127932 : if (n_nodes == invalid_uint)
428 0 : libmesh_error_msg("Number of nodes is not well-defined for " <<
429 : Utility::enum_to_string(itemType));
430 :
431 34127932 : nodes.resize(n_nodes);
432 34127932 : switch(itemType)
433 : {
434 28512 : case NODEELEM:
435 : {
436 114048 : nodes[0] = Point (0.,0.,0.);
437 114048 : return;
438 : }
439 6676 : case EDGE3:
440 : {
441 80410 : nodes[2] = Point (0.,0.,0.);
442 : libmesh_fallthrough();
443 : }
444 6996820 : case EDGE2:
445 : {
446 6996820 : nodes[0] = Point (-1.,0.,0.);
447 6996820 : nodes[1] = Point (1.,0.,0.);
448 6996820 : return;
449 : }
450 6 : case EDGE4: // not nested with EDGE3
451 : {
452 72 : nodes[0] = Point (-1.,0.,0.);
453 72 : nodes[1] = Point (1.,0.,0.);
454 72 : nodes[2] = Point (-1./3.,0.,0.);
455 72 : nodes[3] = Point (1./3.,0.,0.);
456 72 : return;
457 : }
458 124229 : case TRI7:
459 : {
460 1505032 : nodes[6] = Point (1./3.,1./3.,0.);
461 : libmesh_fallthrough();
462 : }
463 5887195 : case TRI6:
464 : {
465 5887195 : nodes[3] = Point (.5,0.,0.);
466 5887195 : nodes[4] = Point (.5,.5,0.);
467 5887195 : nodes[5] = Point (0.,.5,0.);
468 : libmesh_fallthrough();
469 : }
470 8224227 : case TRI3:
471 : case TRISHELL3:
472 : {
473 8224227 : nodes[0] = Point (0.,0.,0.);
474 8224227 : nodes[1] = Point (1.,0.,0.);
475 8224227 : nodes[2] = Point (0.,1.,0.);
476 8224227 : return;
477 : }
478 195201 : case QUAD9:
479 : case QUADSHELL9:
480 : {
481 2056593 : nodes[8] = Point (0.,0.,0.);
482 : libmesh_fallthrough();
483 : }
484 2182007 : case QUAD8:
485 : case QUADSHELL8:
486 : {
487 2182007 : nodes[4] = Point (0.,-1.,0.);
488 2182007 : nodes[5] = Point (1.,0.,0.);
489 2182007 : nodes[6] = Point (0.,1.,0.);
490 2182007 : nodes[7] = Point (-1.,0.,0.);
491 : libmesh_fallthrough();
492 : }
493 4859435 : case QUAD4:
494 : case QUADSHELL4:
495 : {
496 4859435 : nodes[0] = Point (-1.,-1.,0.);
497 4859435 : nodes[1] = Point (1.,-1.,0.);
498 4859435 : nodes[2] = Point (1.,1.,0.);
499 4859435 : nodes[3] = Point (-1.,1.,0.);
500 4859435 : return;
501 : }
502 997830 : case TET14:
503 : {
504 12069846 : nodes[10] = Point (1/Real(3),1/Real(3),0.);
505 12069846 : nodes[11] = Point (1/Real(3),0.,1/Real(3));
506 12069846 : nodes[12] = Point (1/Real(3),1/Real(3),1/Real(3));
507 12069846 : nodes[13] = Point (0.,1/Real(3),1/Real(3));
508 : libmesh_fallthrough();
509 : }
510 12131450 : case TET10:
511 : {
512 12131450 : nodes[4] = Point (.5,0.,0.);
513 12131450 : nodes[5] = Point (.5,.5,0.);
514 12131450 : nodes[6] = Point (0.,.5,0.);
515 12131450 : nodes[7] = Point (0.,0.,.5);
516 12131450 : nodes[8] = Point (.5,0.,.5);
517 12131450 : nodes[9] = Point (0.,.5,.5);
518 : libmesh_fallthrough();
519 : }
520 12133694 : case TET4:
521 : {
522 12133694 : nodes[0] = Point (0.,0.,0.);
523 12133694 : nodes[1] = Point (1.,0.,0.);
524 12133694 : nodes[2] = Point (0.,1.,0.);
525 12133694 : nodes[3] = Point (0.,0.,1.);
526 12133694 : return;
527 : }
528 37389 : case HEX27:
529 : {
530 513077 : nodes[20] = Point (0.,0.,-1.);
531 513077 : nodes[21] = Point (0.,-1.,0.);
532 513077 : nodes[22] = Point (1.,0.,0.);
533 513077 : nodes[23] = Point (0.,1.,0.);
534 513077 : nodes[24] = Point (-1.,0.,0.);
535 513077 : nodes[25] = Point (0.,0.,1.);
536 513077 : nodes[26] = Point (0.,0.,0.);
537 : libmesh_fallthrough();
538 : }
539 518831 : case HEX20:
540 : {
541 518831 : nodes[8] = Point (0.,-1.,-1.);
542 518831 : nodes[9] = Point (1.,0.,-1.);
543 518831 : nodes[10] = Point (0.,1.,-1.);
544 518831 : nodes[11] = Point (-1.,0.,-1.);
545 518831 : nodes[12] = Point (-1.,-1.,0.);
546 518831 : nodes[13] = Point (1.,-1.,0.);
547 518831 : nodes[14] = Point (1.,1.,0.);
548 518831 : nodes[15] = Point (-1.,1.,0.);
549 518831 : nodes[16] = Point (0.,-1.,1.);
550 518831 : nodes[17] = Point (1.,0.,1.);
551 518831 : nodes[18] = Point (0.,1.,1.);
552 518831 : nodes[19] = Point (-1.,0.,1.);
553 : libmesh_fallthrough();
554 : }
555 1573645 : case HEX8:
556 : {
557 1573645 : nodes[0] = Point (-1.,-1.,-1.);
558 1573645 : nodes[1] = Point (1.,-1.,-1.);
559 1573645 : nodes[2] = Point (1.,1.,-1.);
560 1573645 : nodes[3] = Point (-1.,1.,-1.);
561 1573645 : nodes[4] = Point (-1.,-1.,1.);
562 1573645 : nodes[5] = Point (1.,-1.,1.);
563 1573645 : nodes[6] = Point (1.,1.,1.);
564 1573645 : nodes[7] = Point (-1.,1.,1.);
565 1573645 : return;
566 : }
567 7976 : case PRISM21:
568 : {
569 97556 : nodes[20] = Point (1/Real(3),1/Real(3),0);
570 : libmesh_fallthrough();
571 : }
572 154895 : case PRISM20:
573 : {
574 154895 : nodes[18] = Point (1/Real(3),1/Real(3),-1);
575 154895 : nodes[19] = Point (1/Real(3),1/Real(3),1);
576 : libmesh_fallthrough();
577 : }
578 198903 : case PRISM18:
579 : {
580 198903 : nodes[15] = Point (.5,0.,0.);
581 198903 : nodes[16] = Point (.5,.5,0.);
582 198903 : nodes[17] = Point (0.,.5,0.);
583 : libmesh_fallthrough();
584 : }
585 199478 : case PRISM15:
586 : {
587 199478 : nodes[6] = Point (.5,0.,-1.);
588 199478 : nodes[7] = Point (.5,.5,-1.);
589 199478 : nodes[8] = Point (0.,.5,-1.);
590 199478 : nodes[9] = Point (0.,0.,0.);
591 199478 : nodes[10] = Point (1.,0.,0.);
592 199478 : nodes[11] = Point (0.,1.,0.);
593 199478 : nodes[12] = Point (.5,0.,1.);
594 199478 : nodes[13] = Point (.5,.5,1.);
595 199478 : nodes[14] = Point (0.,.5,1.);
596 : libmesh_fallthrough();
597 : }
598 224696 : case PRISM6:
599 : {
600 224696 : nodes[0] = Point (0.,0.,-1.);
601 224696 : nodes[1] = Point (1.,0.,-1.);
602 224696 : nodes[2] = Point (0.,1.,-1.);
603 224696 : nodes[3] = Point (0.,0.,1.);
604 224696 : nodes[4] = Point (1.,0.,1.);
605 224696 : nodes[5] = Point (0.,1.,1.);
606 224696 : return;
607 : }
608 14 : case PYRAMID18:
609 : {
610 : // triangle centers
611 447 : nodes[14] = Point (0., -2/Real(3),1/Real(3));
612 447 : nodes[15] = Point (2/Real(3),0.,1/Real(3));
613 447 : nodes[16] = Point (0.,2/Real(3),1/Real(3));
614 447 : nodes[17] = Point (-2/Real(3),0.,1/Real(3));
615 :
616 : libmesh_fallthrough();
617 : }
618 848 : case PYRAMID14:
619 : {
620 : // base center
621 848 : nodes[13] = Point (0.,0.,0.);
622 :
623 : libmesh_fallthrough();
624 : }
625 1249 : case PYRAMID13:
626 : {
627 : // base midedge
628 1249 : nodes[5] = Point (0.,-1.,0.);
629 1249 : nodes[6] = Point (1.,0.,0.);
630 1249 : nodes[7] = Point (0.,1.,0.);
631 1249 : nodes[8] = Point (-1,0.,0.);
632 :
633 : // lateral midedge
634 1249 : nodes[9] = Point (-.5,-.5,.5);
635 1249 : nodes[10] = Point (.5,-.5,.5);
636 1249 : nodes[11] = Point (.5,.5,.5);
637 1249 : nodes[12] = Point (-.5,.5,.5);
638 :
639 : libmesh_fallthrough();
640 : }
641 1295 : case PYRAMID5:
642 : {
643 : // base corners
644 1295 : nodes[0] = Point (-1.,-1.,0.);
645 1295 : nodes[1] = Point (1.,-1.,0.);
646 1295 : nodes[2] = Point (1.,1.,0.);
647 1295 : nodes[3] = Point (-1.,1.,0.);
648 : // apex
649 1295 : nodes[4] = Point (0.,0.,1.);
650 1295 : return;
651 : }
652 :
653 0 : default:
654 0 : libmesh_error_msg("ERROR: Unknown element type " << Utility::enum_to_string(itemType));
655 : }
656 : }
657 :
658 :
659 :
660 : #ifdef LIBMESH_ENABLE_DEPRECATED
661 0 : bool FEAbstract::on_reference_element(const Point & p, const ElemType t, const Real eps)
662 : {
663 : // Use Elem::on_reference_element() instead
664 : libmesh_deprecated();
665 :
666 0 : libmesh_assert_greater_equal (eps, 0.);
667 :
668 0 : const Real xi = p(0);
669 : #if LIBMESH_DIM > 1
670 0 : const Real eta = p(1);
671 : #else
672 : const Real eta = 0.;
673 : #endif
674 : #if LIBMESH_DIM > 2
675 0 : const Real zeta = p(2);
676 : #else
677 : const Real zeta = 0.;
678 : #endif
679 :
680 0 : switch (t)
681 : {
682 0 : case NODEELEM:
683 : {
684 0 : return (!xi && !eta && !zeta);
685 : }
686 0 : case EDGE2:
687 : case EDGE3:
688 : case EDGE4:
689 : {
690 : // The reference 1D element is [-1,1].
691 0 : if ((xi >= -1.-eps) &&
692 0 : (xi <= 1.+eps))
693 0 : return true;
694 :
695 0 : return false;
696 : }
697 :
698 :
699 0 : case TRI3:
700 : case TRISHELL3:
701 : case TRI6:
702 : case TRI7:
703 : {
704 : // The reference triangle is isosceles
705 : // and is bound by xi=0, eta=0, and xi+eta=1.
706 0 : if ((xi >= 0.-eps) &&
707 0 : (eta >= 0.-eps) &&
708 0 : ((xi + eta) <= 1.+eps))
709 0 : return true;
710 :
711 0 : return false;
712 : }
713 :
714 :
715 0 : case QUAD4:
716 : case QUADSHELL4:
717 : case QUAD8:
718 : case QUADSHELL8:
719 : case QUAD9:
720 : case QUADSHELL9:
721 : {
722 : // The reference quadrilateral element is [-1,1]^2.
723 0 : if ((xi >= -1.-eps) &&
724 0 : (xi <= 1.+eps) &&
725 0 : (eta >= -1.-eps) &&
726 0 : (eta <= 1.+eps))
727 0 : return true;
728 :
729 0 : return false;
730 : }
731 :
732 :
733 0 : case TET4:
734 : case TET10:
735 : case TET14:
736 : {
737 : // The reference tetrahedral is isosceles
738 : // and is bound by xi=0, eta=0, zeta=0,
739 : // and xi+eta+zeta=1.
740 0 : if ((xi >= 0.-eps) &&
741 0 : (eta >= 0.-eps) &&
742 0 : (zeta >= 0.-eps) &&
743 0 : ((xi + eta + zeta) <= 1.+eps))
744 0 : return true;
745 :
746 0 : return false;
747 : }
748 :
749 :
750 0 : case HEX8:
751 : case HEX20:
752 : case HEX27:
753 : {
754 : /*
755 : if ((xi >= -1.) &&
756 : (xi <= 1.) &&
757 : (eta >= -1.) &&
758 : (eta <= 1.) &&
759 : (zeta >= -1.) &&
760 : (zeta <= 1.))
761 : return true;
762 : */
763 :
764 : // The reference hexahedral element is [-1,1]^3.
765 0 : if ((xi >= -1.-eps) &&
766 0 : (xi <= 1.+eps) &&
767 0 : (eta >= -1.-eps) &&
768 0 : (eta <= 1.+eps) &&
769 0 : (zeta >= -1.-eps) &&
770 0 : (zeta <= 1.+eps))
771 : {
772 : // libMesh::out << "Strange Point:\n";
773 : // p.print();
774 0 : return true;
775 : }
776 :
777 0 : return false;
778 : }
779 :
780 0 : case PRISM6:
781 : case PRISM15:
782 : case PRISM18:
783 : case PRISM20:
784 : case PRISM21:
785 : {
786 : // Figure this one out...
787 : // inside the reference triangle with zeta in [-1,1]
788 0 : if ((xi >= 0.-eps) &&
789 0 : (eta >= 0.-eps) &&
790 0 : (zeta >= -1.-eps) &&
791 0 : (zeta <= 1.+eps) &&
792 0 : ((xi + eta) <= 1.+eps))
793 0 : return true;
794 :
795 0 : return false;
796 : }
797 :
798 :
799 0 : case PYRAMID5:
800 : case PYRAMID13:
801 : case PYRAMID14:
802 : case PYRAMID18:
803 : {
804 : // Check that the point is on the same side of all the faces
805 : // by testing whether:
806 : //
807 : // n_i.(x - x_i) <= 0
808 : //
809 : // for each i, where:
810 : // n_i is the outward normal of face i,
811 : // x_i is a point on face i.
812 0 : if ((-eta - 1. + zeta <= 0.+eps) &&
813 0 : ( xi - 1. + zeta <= 0.+eps) &&
814 0 : ( eta - 1. + zeta <= 0.+eps) &&
815 0 : ( -xi - 1. + zeta <= 0.+eps) &&
816 0 : ( zeta >= 0.-eps))
817 0 : return true;
818 :
819 0 : return false;
820 : }
821 :
822 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
823 0 : case INFHEX8:
824 : case INFHEX16:
825 : case INFHEX18:
826 : {
827 : // The reference infhex8 is a [-1,1]^3.
828 0 : if ((xi >= -1.-eps) &&
829 0 : (xi <= 1.+eps) &&
830 0 : (eta >= -1.-eps) &&
831 0 : (eta <= 1.+eps) &&
832 0 : (zeta >= -1.-eps) &&
833 0 : (zeta <= 1.+eps))
834 : {
835 0 : return true;
836 : }
837 0 : return false;
838 : }
839 :
840 0 : case INFPRISM6:
841 : case INFPRISM12:
842 : {
843 : // inside the reference triangle with zeta in [-1,1]
844 0 : if ((xi >= 0.-eps) &&
845 0 : (eta >= 0.-eps) &&
846 0 : (zeta >= -1.-eps) &&
847 0 : (zeta <= 1.+eps) &&
848 0 : ((xi + eta) <= 1.+eps))
849 : {
850 0 : return true;
851 : }
852 :
853 0 : return false;
854 : }
855 : #endif
856 :
857 0 : default:
858 0 : libmesh_error_msg("ERROR: Unknown element type " << Utility::enum_to_string(t));
859 : }
860 :
861 : // If we get here then the point is _not_ in the
862 : // reference element. Better return false.
863 :
864 : return false;
865 : }
866 : #endif // LIBMESH_ENABLE_DEPRECATED
867 :
868 :
869 :
870 0 : void FEAbstract::print_JxW(std::ostream & os) const
871 : {
872 0 : this->_fe_map->print_JxW(os);
873 0 : }
874 :
875 :
876 :
877 0 : void FEAbstract::print_xyz(std::ostream & os) const
878 : {
879 0 : this->_fe_map->print_xyz(os);
880 0 : }
881 :
882 :
883 0 : void FEAbstract::print_info(std::ostream & os) const
884 : {
885 0 : os << "phi[i][j]: Shape function i at quadrature pt. j" << std::endl;
886 0 : this->print_phi(os);
887 :
888 0 : os << "dphi[i][j]: Shape function i's gradient at quadrature pt. j" << std::endl;
889 0 : this->print_dphi(os);
890 :
891 0 : os << "XYZ locations of the quadrature pts." << std::endl;
892 0 : this->print_xyz(os);
893 :
894 0 : os << "Values of JxW at the quadrature pts." << std::endl;
895 0 : this->print_JxW(os);
896 0 : }
897 :
898 :
899 0 : std::ostream & operator << (std::ostream & os, const FEAbstract & fe)
900 : {
901 0 : fe.print_info(os);
902 0 : return os;
903 : }
904 :
905 :
906 :
907 : #ifdef LIBMESH_ENABLE_AMR
908 :
909 : #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
910 1039956 : void FEAbstract::compute_node_constraints (NodeConstraints & constraints,
911 : const Elem * elem)
912 : {
913 519978 : libmesh_assert(elem);
914 :
915 1039956 : const unsigned int Dim = elem->dim();
916 :
917 : // Only constrain elements in 2,3D.
918 1039956 : if (Dim == 1)
919 96436 : return;
920 :
921 : // Only constrain active and ancestor elements
922 1025528 : if (elem->subactive())
923 39948 : return;
924 :
925 :
926 : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
927 945632 : if (elem->infinite())
928 : {
929 2112 : const FEType fe_t(elem->default_order(), FEMap::map_fe_type(*elem));
930 :
931 : // expand the infinite_compute_constraint in its template-arguments.
932 2112 : switch(Dim)
933 : {
934 0 : case 2:
935 : {
936 0 : inf_fe_family_mapping_switch(2, inf_compute_node_constraints (constraints, elem) , ,; break;);
937 0 : break;
938 : }
939 1056 : case 3:
940 : {
941 2112 : inf_fe_family_mapping_switch(3, inf_compute_node_constraints (constraints, elem) , ,; break;);
942 1056 : break;
943 : }
944 0 : default:
945 0 : libmesh_error_msg("Invalid dim = " << Dim);
946 : }
947 1056 : return;
948 : }
949 :
950 : #endif
951 943520 : const FEFamily mapping_family = FEMap::map_fe_type(*elem);
952 943520 : const FEType fe_type(elem->default_side_order(), mapping_family);
953 :
954 : // Pull objects out of the loop to reduce heap operations
955 943520 : std::vector<const Node *> my_nodes, parent_nodes;
956 943520 : std::unique_ptr<const Elem> my_side, parent_side;
957 :
958 : // Look at the element faces. Check to see if we need to
959 : // build constraints.
960 4695142 : for (auto s : elem->side_index_range())
961 7377291 : if (elem->neighbor_ptr(s) != nullptr &&
962 3499716 : elem->neighbor_ptr(s) != remote_elem)
963 3499716 : if (elem->neighbor_ptr(s)->level() < elem->level()) // constrain dofs shared between
964 : { // this element and ones coarser
965 : // than this element.
966 : // Get pointers to the elements of interest and its parent.
967 117176 : const Elem * parent = elem->parent();
968 :
969 : // This can't happen... Only level-0 elements have nullptr
970 : // parents, and no level-0 elements can be at a higher
971 : // level than their neighbors!
972 58588 : libmesh_assert(parent);
973 :
974 117176 : elem->build_side_ptr(my_side, s);
975 117176 : parent->build_side_ptr(parent_side, s);
976 :
977 117176 : const unsigned int n_side_nodes = my_side->n_nodes();
978 :
979 58588 : my_nodes.clear();
980 117176 : my_nodes.reserve (n_side_nodes);
981 58588 : parent_nodes.clear();
982 117176 : parent_nodes.reserve (n_side_nodes);
983 :
984 439428 : for (unsigned int n=0; n != n_side_nodes; ++n)
985 483378 : my_nodes.push_back(my_side->node_ptr(n));
986 :
987 439428 : for (unsigned int n=0; n != n_side_nodes; ++n)
988 483378 : parent_nodes.push_back(parent_side->node_ptr(n));
989 :
990 380840 : for (unsigned int my_side_n=0;
991 439428 : my_side_n < n_side_nodes;
992 : my_side_n++)
993 : {
994 : // We can have an FE type that supports an order
995 : // partially, such that sides do not support the same
996 : // order. E.g. we say that a LAGRANGE PRISM21 supports
997 : // "third" order to distinguish its shape functions from
998 : // a PRISM18, but the QUAD9 sides will still only
999 : // support second order.
1000 322252 : FEType side_fe_type = fe_type;
1001 : const int side_max_order =
1002 322252 : FEInterface::max_order(fe_type, my_side->type());
1003 :
1004 322252 : if ((int)fe_type.order > side_max_order)
1005 2736 : side_fe_type.order = side_max_order;
1006 :
1007 : // Do not use the p_level(), if any, that is inherited by the side.
1008 161126 : libmesh_assert_less
1009 : (my_side_n,
1010 : FEInterface::n_dofs(side_fe_type, /*extra_order=*/0,
1011 : my_side.get()));
1012 :
1013 322252 : const Node * my_node = my_nodes[my_side_n];
1014 :
1015 : // The support point of the DOF
1016 322252 : const Point & support_point = *my_node;
1017 :
1018 : // Figure out where my node lies on their reference element.
1019 : const Point mapped_point = FEMap::inverse_map(Dim-1,
1020 : parent_side.get(),
1021 322252 : support_point);
1022 :
1023 : // Compute the parent's side shape function values.
1024 1170914 : for (unsigned int their_side_n=0;
1025 1332040 : their_side_n < n_side_nodes;
1026 : their_side_n++)
1027 : {
1028 : // Do not use the p_level(), if any, that is inherited by the side.
1029 504894 : libmesh_assert_less
1030 : (their_side_n,
1031 : FEInterface::n_dofs(side_fe_type,
1032 : /*extra_order=*/0,
1033 : parent_side.get()));
1034 :
1035 1514682 : const Node * their_node = parent_nodes[their_side_n];
1036 504894 : libmesh_assert(their_node);
1037 :
1038 : // Do not use the p_level(), if any, that is inherited by the side.
1039 1009788 : const Real their_value = FEInterface::shape(side_fe_type,
1040 : /*extra_order=*/0,
1041 : parent_side.get(),
1042 : their_side_n,
1043 1009788 : mapped_point);
1044 :
1045 504894 : const Real their_mag = std::abs(their_value);
1046 : #ifdef DEBUG
1047 : // Protect for the case u_i ~= u_j,
1048 : // in which case i better equal j.
1049 504894 : if (their_mag > 0.999)
1050 : {
1051 82114 : libmesh_assert_equal_to (my_node, their_node);
1052 82114 : libmesh_assert_less (std::abs(their_value - 1.), 0.001);
1053 : }
1054 : else
1055 : #endif
1056 : // To make nodal constraints useful for constructing
1057 : // sparsity patterns faster, we need to get EVERY
1058 : // POSSIBLE constraint coupling identified, even if
1059 : // there is no coupling in the isoparametric
1060 : // Lagrange case.
1061 927674 : if (their_mag < 1.e-5)
1062 : {
1063 : // since we may be running this method concurrently
1064 : // on multiple threads we need to acquire a lock
1065 : // before modifying the shared constraint_row object.
1066 217162 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1067 :
1068 : // A reference to the constraint row.
1069 434324 : NodeConstraintRow & constraint_row = constraints[my_node].first;
1070 :
1071 434324 : constraint_row.emplace(their_node, 0.);
1072 : }
1073 : // To get nodal coordinate constraints right, only
1074 : // add non-zero and non-identity values for Lagrange
1075 : // basis functions.
1076 : else // (1.e-5 <= their_mag <= .999)
1077 : {
1078 : // since we may be running this method concurrently
1079 : // on multiple threads we need to acquire a lock
1080 : // before modifying the shared constraint_row object.
1081 411236 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1082 :
1083 : // A reference to the constraint row.
1084 493350 : NodeConstraintRow & constraint_row = constraints[my_node].first;
1085 :
1086 205618 : constraint_row.emplace(their_node, their_value);
1087 : }
1088 : }
1089 : }
1090 : }
1091 : }
1092 :
1093 : #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1094 :
1095 : #endif // #ifdef LIBMESH_ENABLE_AMR
1096 :
1097 :
1098 :
1099 : #ifdef LIBMESH_ENABLE_PERIODIC
1100 :
1101 : #ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
1102 130172 : void FEAbstract::compute_periodic_node_constraints (NodeConstraints & constraints,
1103 : const PeriodicBoundaries & boundaries,
1104 : const MeshBase & mesh,
1105 : const PointLocatorBase * point_locator,
1106 : const Elem * elem)
1107 : {
1108 : // Only bother if we truly have periodic boundaries
1109 130172 : if (boundaries.empty())
1110 39030 : return;
1111 :
1112 65086 : libmesh_assert(elem);
1113 :
1114 : // Only constrain active elements with this method
1115 65086 : if (!elem->active())
1116 19515 : return;
1117 :
1118 91142 : const unsigned int Dim = elem->dim();
1119 :
1120 91142 : const FEFamily mapping_family = FEMap::map_fe_type(*elem);
1121 91142 : const FEType fe_type(elem->default_side_order(), mapping_family);
1122 :
1123 : // Pull objects out of the loop to reduce heap operations
1124 91142 : std::vector<const Node *> my_nodes, neigh_nodes;
1125 91142 : std::unique_ptr<const Elem> my_side, neigh_side;
1126 :
1127 : // Look at the element faces. Check to see if we need to
1128 : // build constraints.
1129 91142 : std::vector<boundary_id_type> bc_ids;
1130 443726 : for (auto s : elem->side_index_range())
1131 : {
1132 528876 : if (elem->neighbor_ptr(s))
1133 172806 : continue;
1134 :
1135 6972 : mesh.get_boundary_info().boundary_ids (elem, s, bc_ids);
1136 12896 : for (const auto & boundary_id : bc_ids)
1137 : {
1138 5924 : const PeriodicBoundaryBase * periodic = boundaries.boundary(boundary_id);
1139 5924 : if (periodic)
1140 : {
1141 2712 : libmesh_assert(point_locator);
1142 :
1143 : // Get pointers to the element's neighbor.
1144 : unsigned int s_neigh;
1145 5424 : const Elem * neigh = boundaries.neighbor(boundary_id, *point_locator, elem, s, &s_neigh);
1146 :
1147 5424 : libmesh_error_msg_if
1148 : (!neigh, "PeriodicBoundaries can't find a periodic neighbor for element " <<
1149 : elem->id() << " side " << s);
1150 :
1151 : // h refinement constraints:
1152 : // constrain dofs shared between
1153 : // this element and ones as coarse
1154 : // as or coarser than this element.
1155 5424 : if (neigh->level() <= elem->level())
1156 : {
1157 : #ifdef LIBMESH_ENABLE_AMR
1158 2264 : libmesh_assert(neigh->active());
1159 : #endif // #ifdef LIBMESH_ENABLE_AMR
1160 :
1161 4528 : elem->build_side_ptr(my_side, s);
1162 4528 : neigh->build_side_ptr(neigh_side, s_neigh);
1163 :
1164 4528 : const unsigned int n_side_nodes = my_side->n_nodes();
1165 :
1166 2264 : my_nodes.clear();
1167 4528 : my_nodes.reserve (n_side_nodes);
1168 2264 : neigh_nodes.clear();
1169 4528 : neigh_nodes.reserve (n_side_nodes);
1170 :
1171 14528 : for (unsigned int n=0; n != n_side_nodes; ++n)
1172 15000 : my_nodes.push_back(my_side->node_ptr(n));
1173 :
1174 14528 : for (unsigned int n=0; n != n_side_nodes; ++n)
1175 15000 : neigh_nodes.push_back(neigh_side->node_ptr(n));
1176 :
1177 : // Make sure we're not adding recursive constraints
1178 : // due to the redundancy in the way we add periodic
1179 : // boundary constraints, or adding constraints to
1180 : // nodes that already have AMR constraints
1181 6792 : std::vector<bool> skip_constraint(n_side_nodes, false);
1182 :
1183 12264 : for (unsigned int my_side_n=0;
1184 14528 : my_side_n < n_side_nodes;
1185 : my_side_n++)
1186 : {
1187 : // Do not use the p_level(), if any, that is inherited by the side.
1188 5000 : libmesh_assert_less (my_side_n, FEInterface::n_dofs(fe_type, /*extra_order=*/0, my_side.get()));
1189 :
1190 15000 : const Node * my_node = my_nodes[my_side_n];
1191 :
1192 : // If we've already got a constraint on this
1193 : // node, then the periodic constraint is
1194 : // redundant
1195 : {
1196 5000 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1197 :
1198 5000 : if (constraints.count(my_node))
1199 : {
1200 3998 : skip_constraint[my_side_n] = true;
1201 1999 : continue;
1202 : }
1203 : }
1204 :
1205 : // Compute the neighbors's side shape function values.
1206 17485 : for (unsigned int their_side_n=0;
1207 20486 : their_side_n < n_side_nodes;
1208 : their_side_n++)
1209 : {
1210 : // Do not use the p_level(), if any, that is inherited by the side.
1211 7242 : libmesh_assert_less (their_side_n, FEInterface::n_dofs(fe_type, /*extra_order=*/0, neigh_side.get()));
1212 :
1213 21726 : const Node * their_node = neigh_nodes[their_side_n];
1214 :
1215 : // If there's a constraint on an opposing node,
1216 : // we need to see if it's constrained by
1217 : // *our side* making any periodic constraint
1218 : // on us recursive
1219 : {
1220 7242 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1221 :
1222 7242 : if (!constraints.count(their_node))
1223 4558 : continue;
1224 :
1225 : const NodeConstraintRow & their_constraint_row =
1226 5368 : constraints[their_node].first;
1227 :
1228 19764 : for (unsigned int orig_side_n=0;
1229 22448 : orig_side_n < n_side_nodes;
1230 : orig_side_n++)
1231 : {
1232 : // Do not use the p_level(), if any, that is inherited by the side.
1233 8540 : libmesh_assert_less (orig_side_n, FEInterface::n_dofs(fe_type, /*extra_order=*/0, my_side.get()));
1234 :
1235 25620 : const Node * orig_node = my_nodes[orig_side_n];
1236 :
1237 8540 : if (their_constraint_row.count(orig_node))
1238 10784 : skip_constraint[orig_side_n] = true;
1239 : }
1240 : }
1241 : }
1242 : }
1243 12264 : for (unsigned int my_side_n=0;
1244 14528 : my_side_n < n_side_nodes;
1245 : my_side_n++)
1246 : {
1247 : // Do not use the p_level(), if any, that is inherited by the side.
1248 5000 : libmesh_assert_less (my_side_n, FEInterface::n_dofs(fe_type, /*extra_order=*/0, my_side.get()));
1249 :
1250 15000 : if (skip_constraint[my_side_n])
1251 5714 : continue;
1252 :
1253 4286 : const Node * my_node = my_nodes[my_side_n];
1254 :
1255 : // Figure out where my node lies on their reference element.
1256 4286 : const Point neigh_point = periodic->get_corresponding_pos(*my_node);
1257 :
1258 : // Figure out where my node lies on their reference element.
1259 : const Point mapped_point =
1260 : FEMap::inverse_map(Dim-1, neigh_side.get(),
1261 4286 : neigh_point);
1262 :
1263 11539 : for (unsigned int their_side_n=0;
1264 13682 : their_side_n < n_side_nodes;
1265 : their_side_n++)
1266 : {
1267 : // Do not use the p_level(), if any, that is inherited by the side.
1268 4698 : libmesh_assert_less (their_side_n, FEInterface::n_dofs(fe_type, /*extra_order=*/0, neigh_side.get()));
1269 :
1270 14094 : const Node * their_node = neigh_nodes[their_side_n];
1271 4698 : libmesh_assert(their_node);
1272 :
1273 : // Do not use the p_level(), if any, that is inherited by the side.
1274 9396 : const Real their_value = FEInterface::shape(fe_type,
1275 : /*extra_order=*/0,
1276 : neigh_side.get(),
1277 : their_side_n,
1278 9396 : mapped_point);
1279 :
1280 : // since we may be running this method concurrently
1281 : // on multiple threads we need to acquire a lock
1282 : // before modifying the shared constraint_row object.
1283 : {
1284 9396 : Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
1285 :
1286 : NodeConstraintRow & constraint_row =
1287 9396 : constraints[my_node].first;
1288 :
1289 4698 : constraint_row.emplace(their_node, their_value);
1290 : }
1291 : }
1292 : }
1293 : }
1294 : }
1295 : }
1296 : }
1297 : }
1298 : #endif // LIBMESH_ENABLE_NODE_CONSTRAINTS
1299 :
1300 : #endif // LIBMESH_ENABLE_PERIODIC
1301 :
1302 :
1303 2134576 : unsigned int FEAbstract::n_quadrature_points () const
1304 : {
1305 240186 : if (this->shapes_on_quadrature)
1306 : {
1307 240170 : libmesh_assert(this->qrule);
1308 240170 : libmesh_assert_equal_to(this->qrule->n_points(),
1309 : this->_n_total_qp);
1310 : }
1311 2134576 : return this->_n_total_qp;
1312 : }
1313 :
1314 : } // namespace libMesh
|