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