libMesh
Loading...
Searching...
No Matches
fe_test.h
Go to the documentation of this file.
1#ifndef FE_TEST_H
2#define FE_TEST_H
3
4#include "test_comm.h"
5
6#include <libmesh/cell_c0polyhedron.h>
7#include <libmesh/dof_map.h>
8#include <libmesh/elem.h>
9#include <libmesh/equation_systems.h>
10#include <libmesh/face_c0polygon.h>
11#include <libmesh/fe.h>
12#include <libmesh/fe_base.h>
13#include <libmesh/fe_interface.h>
14#include <libmesh/function_base.h>
15#include <libmesh/mesh.h>
16#include <libmesh/mesh_generation.h>
17#include <libmesh/mesh_modification.h>
18#include <libmesh/numeric_vector.h>
19#include <libmesh/system.h>
20#include <libmesh/quadrature_gauss.h>
21
22#include <utility>
23#include <vector>
24
25#include "libmesh_cppunit.h"
26
27#define FETEST \
28 CPPUNIT_TEST( testFEInterface ); \
29 CPPUNIT_TEST( testRefspaceNodes ); \
30 CPPUNIT_TEST( testNodalSoln ); \
31 CPPUNIT_TEST( testU ); \
32 CPPUNIT_TEST( testPartitionOfUnity ); \
33 CPPUNIT_TEST( testUPastVertices ); \
34 CPPUNIT_TEST( testGradU ); \
35 CPPUNIT_TEST( testGradUPastVertices ); \
36 CPPUNIT_TEST( testGradUComp ); \
37 CPPUNIT_TEST( testHessU ); \
38 CPPUNIT_TEST( testHessUComp ); \
39 CPPUNIT_TEST( testDualDoesntScreamAndDie ); \
40 CPPUNIT_TEST( testCustomReinit );
41
42using namespace libMesh;
43
44
45class SkewFunc : public FunctionBase<Real>
46{
47 std::unique_ptr<FunctionBase<Real>> clone () const override
48 { return std::make_unique<SkewFunc>(); }
49
51 const Real = 0.) override
52 { libmesh_not_implemented(); } // scalar-only API
53
54 // Skew in x based on y, y based on z
55 void operator() (const Point & p,
56 const Real,
57 DenseVector<Real> & output)
58 {
59 output.resize(3);
60 output(0) = p(0);
61#if LIBMESH_DIM > 0
62 output(0) += .1*p(1);
63 output(1) = p(1);
64#endif
65#if LIBMESH_DIM > 1
66 output(1) += .2*p(2);
67 output(2) = p(2);
68#endif
69 }
70};
71
72
73inline
75 const Parameters&,
76 const std::string&,
77 const std::string&)
78{
79 const Real & x = p(0);
80 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
81 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
82
83 return x + 0.25*y + 0.0625*z;
84}
85
86inline
88 const Parameters&,
89 const std::string&,
90 const std::string&)
91{
92 Gradient grad = 1;
93 if (LIBMESH_DIM > 1)
94 grad(1) = 0.25;
95 if (LIBMESH_DIM > 2)
96 grad(2) = 0.0625;
97
98 return grad;
99}
100
101
102inline
104 const Parameters&,
105 const std::string&,
106 const std::string&)
107{
108 const Real & x = p(0);
109 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
110 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
111
112 return x*x + 0.5*y*y + 0.25*z*z + 0.125*x*y + 0.0625*x*z + 0.03125*y*z;
113}
114
115inline
117 const Parameters&,
118 const std::string&,
119 const std::string&)
120{
121 const Real & x = p(0);
122 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
123 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
124
125 Gradient grad = 2*x + 0.125*y + 0.0625*z;
126 if (LIBMESH_DIM > 1)
127 grad(1) = y + 0.125*x + 0.03125*z;
128 if (LIBMESH_DIM > 2)
129 grad(2) = 0.5*z + 0.0625*x + 0.03125*y;
130
131 return grad;
132}
133
134
135inline
137 const Parameters&,
138 const std::string&,
139 const std::string&)
140{
141 const Real & x = p(0);
142 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
143 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
144
145 return x*(1-x)*(1-x) + x*x*(1-y) + x*(1-y)*(1-z) + y*(1-y)*z + z*(1-z)*(1-z);
146}
147
148inline
150 const Parameters&,
151 const std::string&,
152 const std::string&)
153{
154 const Real & x = p(0);
155 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
156 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
157
158 Gradient grad = 3*x*x-4*x+1 + 2*x*(1-y) + (1-y)*(1-z);
159 if (LIBMESH_DIM > 1)
160 grad(1) = -x*x - x*(1-z) + (1-2*y)*z;
161 if (LIBMESH_DIM > 2)
162 grad(2) = -x*(1-y) + y*(1-y) + 3*z*z-4*z+1;
163
164 return grad;
165}
166
167
168inline
170 const Parameters&,
171 const std::string&,
172 const std::string&)
173{
174 const Real & x = p(0);
175 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
176 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
177
178 return x*x*(1-x)*(1-x) + x*x*z*(1-y) + x*(1-x)*(1-y)*(1-z) + (1-x)*y*(1-y)*z + z*z*(1-z)*(1-z);
179}
180
181inline
183 const Parameters&,
184 const std::string&,
185 const std::string&)
186{
187 const Real & x = p(0);
188 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
189 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
190
191 Gradient grad = 4*x*x*x-6*x*x+2*x + 2*x*z*(1-y) + (1-2*x)*(1-y)*(1-z) - y*(1-y)*z;
192 if (LIBMESH_DIM > 1)
193 grad(1) = -x*x*z - x*(1-x)*(1-z) + (1-x)*(1-2*y)*z;
194 if (LIBMESH_DIM > 2)
195 grad(2) = x*x*(1-y) - x*(1-x)*(1-y) + (1-x)*y*(1-y) + 4*z*z*z-6*z*z+2*z;
196
197 return grad;
198}
199
200
201
202// Higher order rational bases need uniform weights to exactly
203// represent linears; we can easily try out other functions on
204// tensor product elements.
205static const Real rational_w = 0.75;
206
207inline
209 const Parameters&,
210 const std::string&,
211 const std::string&)
212{
213 const Real & x = p(0);
214 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
215 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
216
217 const Real denom = ((1-x)*(1-x)+x*x+2*rational_w*x*(1-x))*
218 ((1-y)*(1-y)+y*y+2*rational_w*y*(1-y))*
219 ((1-z)*(1-z)+z*z+2*rational_w*z*(1-z));
220
221 return (x + 0.25*y + 0.0625*z)/denom;
222}
223
224inline
226 const Parameters&,
227 const std::string&,
228 const std::string&)
229{
230 const Real & x = p(0);
231 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
232 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
233
234 const Real xpoly = (1-x)*(1-x)+x*x+2*rational_w*x*(1-x);
235 const Real xderiv = -2*(1-x)+2*x+2*rational_w*(1-2*x);
236 const Real ypoly = (1-y)*(1-y)+y*y+2*rational_w*y*(1-y);
237 const Real yderiv = -2*(1-y)+2*y+2*rational_w*(1-2*y);
238 const Real zpoly = (1-z)*(1-z)+z*z+2*rational_w*z*(1-z);
239 const Real zderiv = -2*(1-z)+2*z+2*rational_w*(1-2*z);
240
241 const Real denom = xpoly * ypoly * zpoly;
242
243 const Real numer = (x + 0.25*y + 0.0625*z);
244
245 Gradient grad_n = 1, grad_d = xderiv * ypoly * zpoly;
246 if (LIBMESH_DIM > 1)
247 {
248 grad_n(1) = 0.25;
249 grad_d(1) = xpoly * yderiv * zpoly;
250 }
251 if (LIBMESH_DIM > 2)
252 {
253 grad_n(2) = 0.0625;
254 grad_d(2) = xpoly * ypoly * zderiv;
255 }
256
257 Gradient grad = (grad_n - numer * grad_d / denom) / denom;
258
259 return grad;
260}
261
262
263#define FE_CAN_TEST_CUBIC \
264 (((family != LAGRANGE && family != L2_LAGRANGE) || \
265 (elem_type != TRI7 && elem_type != TET14 && \
266 elem_type != PRISM20 && elem_type != PRISM21 && \
267 elem_type != PYRAMID18)) && order > 2)
268
269
270// Note: type name is used to name the test
271struct Default { };
272
273template <Order order, FEFamily family, ElemType elem_type, unsigned int build_nx, typename CaseName = Default>
274class FETestBase : public CppUnit::TestCase {
275
276protected:
278
280 std::string _case_name;
281
282 unsigned int _dim, _nx, _ny, _nz;
284 std::vector<dof_id_type> _dof_indices;
286 std::unique_ptr<Mesh> _mesh;
287 std::unique_ptr<EquationSystems> _es;
288 std::unique_ptr<FEBase> _fe;
289 std::unique_ptr<QGauss> _qrule;
290
292
295
298
299
301 {
302 Parameters dummy;
303
304 Gradient true_grad;
305 RealGradient returnval;
306
307 if (family == RATIONAL_BERNSTEIN && order > 1)
308 true_grad = rational_test_grad(p, dummy, "", "");
309 else if (order > 3)
310 true_grad = fe_quartic_test_grad(p, dummy, "", "");
311 else if (FE_CAN_TEST_CUBIC)
312 true_grad = fe_cubic_test_grad(p, dummy, "", "");
313 else if (order > 1)
314 {
315 const Real & x = p(0);
316 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
317 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
318
319 true_grad = Gradient(2*x+0.125*y+0.0625*z,
320 y+0.125*x+0.03125*z,
321 0.5*z+0.0625*x+0.03125*y);
322 }
323 else
324 true_grad = Gradient(1.0, 0.25, 0.0625);
325
326 for (unsigned int d=0; d != LIBMESH_DIM; ++d)
327 {
328 CPPUNIT_ASSERT(true_grad(d) ==
329 Number(libmesh_real(true_grad(d))));
330
331 returnval(d) = libmesh_real(true_grad(d));
332 }
333
334 return returnval;
335 }
336
337
339 {
340 const Real & x = p(0);
341 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
342 const Real & z = LIBMESH_DIM > 2 ? p(2) : 0;
343
344 if (order > 3)
345 return RealTensor
346 { 12*x*x-12*x+2+2*z*(1-y)-2*(1-y)*(1-z), -2*x*z-(1-2*x)*(1-z)-(1-2*y)*z, 2*x*(1-y)-(1-2*x)*(1-y)-y*(1-y),
347 -2*x*z-(1-2*x)*(1-z)-(1-2*y)*z, -2*(1-x)*z, -x*x+x*(1-x)+(1-x)*(1-2*y),
348 2*x*(1-y)-(1-2*x)*(1-y)-y*(1-y), -x*x+x*(1-x)+(1-x)*(1-2*y), 12*z*z-12*z+2 };
349 else if (FE_CAN_TEST_CUBIC)
350 return RealTensor
351 { 6*x-4+2*(1-y), -2*x+z-1, y-1,
352 -2*x+z-1, -2*z, x+1-2*y,
353 y-1, x+1-2*y, 6*z-4 };
354 else if (order > 1)
355 return RealTensor
356 { 2, 0.125, 0.0625,
357 0.125, 1, 0.03125,
358 0.0625, 0.03125, 0.5 };
359
360 return RealTensor
361 { 0, 0, 0,
362 0, 0, 0,
363 0, 0, 0 };
364 }
365
366public:
367 void setUp()
368 {
369 _mesh = std::make_unique<Mesh>(*TestCommWorld);
370 _dim = Elem::type_to_dim_map[elem_type];
371 const unsigned int build_ny = (_dim > 1) * build_nx;
372 const unsigned int build_nz = (_dim > 2) * build_nx;
373
374 unsigned char weight_index = 0;
375
376 if (family == RATIONAL_BERNSTEIN)
377 {
378 // Make sure we can handle non-zero weight indices
379 _mesh->add_node_integer("buffer integer");
380
381 // Default weight to 1.0 so we don't get NaN from contains_point
382 // checks with a default GhostPointNeighbors ghosting
383 const Real default_weight = 1.0;
384 weight_index = cast_int<unsigned char>
385 (_mesh->add_node_datum<Real>("rational_weight", true,
386 &default_weight));
387 libmesh_assert_not_equal_to(weight_index, 0);
388
389 // Set mapping data but not type, since here we're testing
390 // rational basis functions in the FE space but testing then
391 // with Lagrange bases for the mapping space.
392 _mesh->set_default_mapping_data(weight_index);
393 }
394
395 if (elem_type == C0POLYGON)
396 {
397 // Build a pentagon by hand for testing purposes. Make this
398 // one non-skewed so a MONOMIAL basis will be able to exactly
399 // represent the polynomials we're projecting.
400
401 _mesh->add_point(Point(0, 0), 0);
402 _mesh->add_point(Point(1, 0), 1);
403 _mesh->add_point(Point(1+cos(2*libMesh::pi/5), sin(2*libMesh::pi/5)), 2);
404 _mesh->add_point(Point(0.5, sin(2*libMesh::pi/5)+sin(libMesh::pi/5)), 3);
405 _mesh->add_point(Point(-cos(2*libMesh::pi/5), sin(2*libMesh::pi/5)), 4);
406
407 std::unique_ptr<Elem> polygon = std::make_unique<C0Polygon>(5);
408 for (auto i : make_range(5))
409 polygon->set_node(i, _mesh->node_ptr(i));
410 polygon->set_id() = 0;
411
412 _mesh->add_elem(std::move(polygon));
413 _mesh->prepare_for_use();
414 }
415 else if (elem_type == C0POLYHEDRON)
416 {
417 // Build a plain cube by hand for testing purposes. We could
418 // upgrade this, but it should be to something non-skewed so a
419 // MONOMIAL basis will be able to exactly represent the
420 // polynomials we're projecting.
421 //
422 // See elem_test.h for the limitations here.
423
424 _mesh->add_point(Point(0, 0, 0), 0);
425 _mesh->add_point(Point(1, 0, 0), 1);
426 _mesh->add_point(Point(1, 1, 0), 2);
427 _mesh->add_point(Point(0, 1, 0), 3);
428 _mesh->add_point(Point(0, 0, 1), 4);
429 _mesh->add_point(Point(1, 0, 1), 5);
430 _mesh->add_point(Point(1, 1, 1), 6);
431 _mesh->add_point(Point(0, 1, 1), 7);
432
433 // Pick case
434 std::vector<std::vector<unsigned int>> nodes_on_side;
435 if (_case_name == "Default")
436 nodes_on_side = { {0, 1, 2, 3}, // min z
437 {0, 1, 5, 4}, // min y
438 {2, 6, 5, 1}, // max x
439 {2, 3, 7, 6}, // max y
440 {0, 4, 7, 3}, // min x
441 {5, 6, 7, 4} }; // max z
442 else if (_case_name == "MidNode")
443 nodes_on_side = { {0, 1, 2, 3}, // min z
444 {0, 1, 5, 4}, // min y
445 {1, 2, 6, 5}, // max x
446 {2, 3, 7, 6}, // max y
447 {3, 0, 4, 7}, // min x
448 {4, 5, 6, 7} }; // max z
449 else
450 libmesh_error_msg("Unknown case name: " + _case_name);
451
452 // Build all the sides.
453 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
454
455 for (auto s : index_range(nodes_on_side))
456 {
457 const auto & nodes_on_s = nodes_on_side[s];
458 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
459 for (auto i : index_range(nodes_on_s))
460 sides[s]->set_node(i, _mesh->node_ptr(nodes_on_s[i]));
461 }
462
463 std::unique_ptr<libMesh::Node> mid_elem_node;
464 std::unique_ptr<Elem> polyhedron = std::make_unique<C0Polyhedron>(sides, mid_elem_node);
465 _mesh->add_elem(std::move(polyhedron));
466 if (mid_elem_node)
467 _mesh->add_node(std::move(mid_elem_node));
468 _mesh->prepare_for_use();
469 }
470 else
471 {
473 build_nx, build_ny, build_nz,
474 0., 1., 0., 1., 0., 1.,
475 elem_type);
476 }
477
478 // For debugging purposes it can be helpful to only consider one
479 // element even when we're using an element type that requires
480 // more than one element to fill out a square or cube.
481#if 0
482 for (dof_id_type i = 0; i != _mesh->max_elem_id(); ++i)
483 {
484 Elem * elem = _mesh->query_elem_ptr(i);
485 if (elem && elem->id())
486 _mesh->delete_elem(elem);
487 }
488 _mesh->prepare_for_use();
489 CPPUNIT_ASSERT_EQUAL(_mesh->n_elem(), dof_id_type(1));
490#endif
491
492 // Permute our elements randomly and rotate and skew our mesh so
493 // we test all sorts of orientations ... except with Hermite
494 // elements, which are only designed to support meshes with a
495 // single orientation shared by all elements. We're also not
496 // rotating and/or skewing the rational elements, since our test
497 // solution was designed for a specific weighted mesh.
498 if (family != HERMITE &&
499 family != RATIONAL_BERNSTEIN)
500 {
502
503 // Not yet testing manifolds embedded in higher-D space
504 if (_dim > 1)
506 8*(_dim>2), 16*(_dim>2));
507
508 SkewFunc skew_func;
510 }
511
512 // Set rational weights so we can exactly match our test solution
513 if (family == RATIONAL_BERNSTEIN)
514 {
515 for (auto elem : _mesh->active_element_ptr_range())
516 {
517 // Workaround for nvc++ bug
518 Elem & e = *elem;
519
520 const unsigned int nv = elem->n_vertices();
521 const unsigned int nn = elem->n_nodes();
522 // We want interiors in lower dimensional elements treated
523 // like edges or faces as appropriate.
524 const unsigned int n_edges =
525 (elem->type() == EDGE3) ? 1 : elem->n_edges();
526 const unsigned int n_faces =
527 (elem->type() == QUAD9) ? 1 : elem->n_faces();
528 const unsigned int nve = std::min(nv + n_edges, nn);
529 const unsigned int nvef = std::min(nve + n_faces, nn);
530
531 for (unsigned int i = 0; i != nv; ++i)
532 e.node_ref(i).set_extra_datum<Real>(weight_index, 1.);
533 for (unsigned int i = nv; i != nve; ++i)
534 e.node_ref(i).set_extra_datum<Real>(weight_index, rational_w);
535 const Real w2 = rational_w * rational_w;
536 for (unsigned int i = nve; i != nvef; ++i)
537 e.node_ref(i).set_extra_datum<Real>(weight_index, w2);
538 const Real w3 = rational_w * w2;
539 for (unsigned int i = nvef; i != nn; ++i)
540 e.node_ref(i).set_extra_datum<Real>(weight_index, w3);
541 }
542 }
543
544 _mesh->complete_preparation();
545 _es = std::make_unique<EquationSystems>(*_mesh);
546 _sys = &(_es->add_system<System> ("SimpleSystem"));
547 _sys->add_variable("u", order, family);
548 _es->init();
549
550 if (family == RATIONAL_BERNSTEIN && order > 1)
551 {
553 }
554 else if (order > 3)
555 {
557 }
558 // Lagrange "cubic" on Tet7 only supports a bubble function, not
559 // all of P^3
560 else if (FE_CAN_TEST_CUBIC)
561 {
563 }
564 else if (order > 1)
565 {
567 }
568 else
569 {
571 }
572
573 FEType fe_type = _sys->variable_type(0);
574 _fe = FEBase::build(_dim, fe_type);
575
576 // Create quadrature rule for use in computing dual shape coefficients
577 _qrule = std::make_unique<QGauss>(_dim, fe_type.default_quadrature_order());
578 _fe->attach_quadrature_rule(_qrule.get());
579
580 auto rng = _mesh->active_local_element_ptr_range();
581 this->_elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
582
583 _sys->get_dof_map().dof_indices(this->_elem, _dof_indices);
584
585 _nx = 10;
586 _ny = (_dim > 1) ? _nx : 1;
587 _nz = (_dim > 2) ? _nx : 1;
588
589 this->_value_tol = TOLERANCE * sqrt(TOLERANCE);
590
591 // We see 6.5*tol*sqrt(tol) errors on cubic Hermites with the fe_cubic
592 // hermite test function
593 // On Tri7 we see 10*tol*sqrt(tol) errors, even!
594 // On Tet14 Monomial gives us at least 13*tol*sqrt(tol) in some
595 // cases
596 this->_grad_tol = 15 * TOLERANCE * sqrt(TOLERANCE);
597
598 this->_hess_tol = sqrt(TOLERANCE); // FIXME: we see some ~1e-5 errors?!?
599
600 // Reference vertices have coordinates of 0 and +/-1, so with a power of two offset the
601 // barycentric coordinates of each point, and their sums and differences, are computed
602 // exactly. A combination which vanishes on a point is then evaluated as exactly zero.
603 this->_past_vertex_offset = 0.25;
604
605 // Shape functions grow outside the element, and with them the rounding error in the
606 // solution there, so evaluations past the vertices get looser tolerances. Along the line
607 // through an edge the error is a polynomial of degree at most p, so an error within a
608 // tolerance on the edge is within T_p(1 + 2*offset) times that tolerance at offset past
609 // the edge's end, where T_p is the Chebyshev polynomial. Gradient errors have lower degree
610 // and grow more slowly.
611 const Real x = 1 + 2 * this->_past_vertex_offset;
612 Real t_prev = 1, t = x;
613 for (unsigned int k = 1; k < static_cast<unsigned int>(order); ++k)
614 t_prev = std::exchange(t, 2 * x * t - t_prev);
615 this->_past_vertex_tol_factor = (order == CONSTANT) ? 1 : t;
616
617 // Prerequest everything we'll want to calculate later.
618 _fe->get_phi();
619 _fe->get_dphi();
620 _fe->get_dphidx();
621#if LIBMESH_DIM > 1
622 _fe->get_dphidy();
623#endif
624#if LIBMESH_DIM > 2
625 _fe->get_dphidz();
626#endif
627
628#if LIBMESH_ENABLE_SECOND_DERIVATIVES
629
630 // Szabab elements don't have second derivatives yet
631 if (family == SZABAB)
632 return;
633
634 _fe->get_d2phi();
635 _fe->get_d2phidx2();
636#if LIBMESH_DIM > 1
637 _fe->get_d2phidxdy();
638 _fe->get_d2phidy2();
639#endif
640#if LIBMESH_DIM > 2
641 _fe->get_d2phidxdz();
642 _fe->get_d2phidydz();
643 _fe->get_d2phidz2();
644#endif
645
646#endif
647 }
648
649 void tearDown() {}
650};
651
652
653
654template <Order order, FEFamily family, ElemType elem_type, typename CaseName>
655class FETest : public FETestBase<order, family, elem_type, 1, CaseName> {
656
657public:
658
659 template <typename Functor>
660 void testLoop(Functor f)
661 {
662 // Handle the "more processors than elements" case
663 if (!this->_elem)
664 return;
665
666 // These tests require exceptions to be enabled because a
667 // TypeTensor::solve() call down in Elem::contains_point()
668 // actually throws a non-fatal exception for a certain Point which
669 // is not in the Elem. When exceptions are not enabled, this test
670 // simply aborts.
671#ifdef LIBMESH_ENABLE_EXCEPTIONS
672 for (unsigned int i=0; i != this->_nx; ++i)
673 for (unsigned int j=0; j != this->_ny; ++j)
674 for (unsigned int k=0; k != this->_nz; ++k)
675 {
676 Point p = Real(i)/this->_nx;
677 if (j > 0)
678 p(1) = Real(j)/this->_ny;
679 if (k > 0)
680 p(2) = Real(k)/this->_nz;
681 if (!this->_elem->contains_point(p))
682 continue;
683
684 // If at a singular node, cannot use FEMap::map
685 if (this->_elem->local_singular_node(p) != invalid_uint)
686 continue;
687
688 std::vector<Point> master_points
689 (1, FEMap::inverse_map(this->_dim, this->_elem, p));
690
691 // Reinit at point to test against analytic solution
692 this->_fe->reinit(this->_elem, &master_points);
693
694 f(p);
695 }
696#endif // LIBMESH_ENABLE_EXCEPTIONS
697 }
698
699 // Evaluates at points just past each vertex, offset from it in the direction of each edge.
700 // Most of these lie outside the element, where shape functions are still evaluated by
701 // imprecise point queries and finite-difference derivatives, so the polynomial extension of
702 // the solution must still match the exact solution there. Offsets along edges away from the
703 // vertex also reach the loci where simplex edge functions switch to a limiting expression:
704 // on a triangle, the line through a vertex parallel to the opposite edge, and on a
705 // tetrahedron, the plane through an edge parallel to the opposite edge.
706 template <typename Functor>
707 void testPastVerticesLoop(Functor f)
708 {
709 // Handle the "more processors than elements" case
710 if (!this->_elem)
711 return;
712
713 // We don't have reference elements for these
714 if (this->_elem->infinite() || this->_elem->runtime_topology())
715 return;
716
717 const Real delta = this->_past_vertex_offset;
718
719 // An edge element is its own edge
720 std::vector<std::pair<unsigned int, unsigned int>> edges;
721 if (this->_dim == 1)
722 edges.emplace_back(0, 1);
723 for (const auto e : this->_elem->edge_index_range())
724 edges.emplace_back(this->_elem->local_edge_node(e, 0),
725 this->_elem->local_edge_node(e, 1));
726
727 for (const auto v : make_range(this->_elem->n_vertices()))
728 {
729 // Shape functions are singular at, and on a plane through, a singular node
730 if (this->_elem->is_singular_node(v))
731 continue;
732
733 for (const auto & [a, b] : edges)
734 for (const Real sign : {Real(-1), Real(1)})
735 {
736 const Point master_p = this->_elem->master_point(v) + sign * delta *
737 (this->_elem->master_point(b) - this->_elem->master_point(a));
738
739 std::vector<Point> master_points(1, master_p);
740 this->_fe->reinit(this->_elem, &master_points);
741
742 f(FEMap::map(this->_dim, this->_elem, master_p));
743 }
744 }
745 }
746
748 {
749 LOG_UNIT_TEST;
750
751 if (!this->_elem)
752 return;
753
754 // We don't currently support reference infinite elements
755 if (this->_elem->infinite())
756 return;
757
758 // We'll probably never support reference polytopes
759 if (this->_elem->runtime_topology())
760 return;
761
762 std::vector<Point> nodes;
763 this->_fe->get_refspace_nodes(this->_elem->type(), nodes);
764 for (auto n : index_range(nodes))
765 LIBMESH_ASSERT_REALVEC_EQUAL(nodes[n],
766 this->_elem->master_point(n),
768 }
769
771 {
772 LOG_UNIT_TEST;
773
774 if (!this->_elem)
775 return;
776
777 // The Lagrange nodal solution is the interpolant evaluated at
778 // each node, including nodes which carry no degree of freedom
779 if (family != LAGRANGE && family != L2_LAGRANGE)
780 return;
781
782 if (this->_elem->runtime_topology())
783 return;
784
785 const FEType fe_type = this->_sys->variable_type(0);
786 const unsigned int n_dofs = FEInterface::n_dofs(fe_type, this->_elem);
787
788 std::vector<Number> elem_soln(n_dofs, 0), nodal_soln;
789 for (auto i : make_range(n_dofs))
790 {
791 elem_soln[i] = 1;
792 FEInterface::nodal_soln(this->_dim, fe_type, this->_elem,
793 elem_soln, nodal_soln);
794 elem_soln[i] = 0;
795
796 CPPUNIT_ASSERT_EQUAL(std::size_t(this->_elem->n_nodes()),
797 nodal_soln.size());
798 for (auto n : this->_elem->node_index_range())
799 LIBMESH_ASSERT_NUMBERS_EQUAL
800 (FEInterface::shape(fe_type, this->_elem, i,
801 this->_elem->master_point(n)),
802 nodal_soln[n], TOLERANCE*TOLERANCE);
803 }
804 }
805
807 {
808 LOG_UNIT_TEST;
809
810 if (!this->_elem)
811 return;
812
813 this->_fe->reinit(this->_elem);
814
815 bool satisfies_partition_of_unity = true;
816 for (const auto qp : make_range(this->_qrule->n_points()))
817 {
818 Real phi_sum = 0;
819 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
820 phi_sum += this->_fe->get_phi()[d][qp];
821 if (phi_sum < (1 - TOLERANCE) || phi_sum > (1 + TOLERANCE))
822 {
823 satisfies_partition_of_unity = false;
824 break;
825 }
826 }
827
828 switch (this->_fe->get_family())
829 {
830 case MONOMIAL:
831 {
832 switch (this->_fe->get_order())
833 {
834 case CONSTANT:
835 CPPUNIT_ASSERT(satisfies_partition_of_unity);
836 break;
837
838 default:
839 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
840 break;
841 }
842 break;
843 }
844 case SZABAB:
845 case HIERARCHIC:
846 case L2_HIERARCHIC:
847 {
848 switch (this->_fe->get_order())
849 {
850 case FIRST:
851 CPPUNIT_ASSERT(satisfies_partition_of_unity);
852 break;
853
854 default:
855 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
856 break;
857 }
858 break;
859 }
860
861 case XYZ:
862 case CLOUGH:
863 case HERMITE:
864 {
865 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
866 break;
867 }
868
869 case LAGRANGE:
870 case L2_LAGRANGE:
871 case L2_LAGRANGE_GLL:
872 case BERNSTEIN:
874 {
875 CPPUNIT_ASSERT(satisfies_partition_of_unity);
876 break;
877 }
878
879 default:
880 CPPUNIT_FAIL("Uncovered FEFamily");
881 }
882 }
883
884
886 {
887 LOG_UNIT_TEST;
888
889 // Handle the "more processors than elements" case
890 if (!this->_elem)
891 return;
892
893 this->_fe->reinit(this->_elem);
894
895 const FEType fe_type = this->_sys->variable_type(0);
896
897 unsigned int my_n_dofs = 0;
898
899 switch (this->_elem->dim())
900 {
901 case 0:
902 my_n_dofs = FE<0,family>::n_dofs(this->_elem, order);
903 break;
904 case 1:
905 my_n_dofs = FE<1,family>::n_dofs(this->_elem, order);
906 break;
907 case 2:
908 my_n_dofs = FE<2,family>::n_dofs(this->_elem, order);
909 break;
910 case 3:
911 my_n_dofs = FE<3,family>::n_dofs(this->_elem, order);
912 break;
913 default:
914 libmesh_error();
915 }
916
917 CPPUNIT_ASSERT_EQUAL(
919 my_n_dofs);
920
921 CPPUNIT_ASSERT_EQUAL(
923 this->_fe->get_continuity());
924
925 CPPUNIT_ASSERT_EQUAL(
927 this->_fe->is_hierarchic());
928 }
929
930 // Returns a functor which compares the solution value at the point reinit() was last called
931 // on with the exact value at p
932 auto checkU(const Real tol)
933 {
934 return [this, tol](Point p)
935 {
936 Parameters dummy;
937
938 Number u = 0;
939 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
940 u += this->_fe->get_phi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
941
942 Number true_u;
943
944 if (family == RATIONAL_BERNSTEIN && order > 1)
945 true_u = rational_test(p, dummy, "", "");
946 else if (order > 3)
947 true_u = fe_quartic_test(p, dummy, "", "");
948 else if (FE_CAN_TEST_CUBIC)
949 true_u = fe_cubic_test(p, dummy, "", "");
950 else if (order > 1)
951 true_u = p(0)*p(0) + 0.5*p(1)*p(1) + 0.25*p(2)*p(2) +
952 0.125*p(0)*p(1) + 0.0625*p(0)*p(2) + 0.03125*p(1)*p(2);
953 else
954 true_u = p(0) + 0.25*p(1) + 0.0625*p(2);
955
956 LIBMESH_ASSERT_NUMBERS_EQUAL (true_u, u, tol);
957 };
958 }
959
960 void testU()
961 {
962 LOG_UNIT_TEST;
963 testLoop(checkU(this->_value_tol));
964 }
965
967 {
968 LOG_UNIT_TEST;
970 }
971
973 {
974 LOG_UNIT_TEST;
975
976 // Handle the "more processors than elements" case
977 if (!this->_elem)
978 return;
979
980 // Request dual calculations
981 this->_fe->get_dual_phi();
982
983 // reinit using the default quadrature rule in order to calculate the dual coefficients
984 this->_fe->reinit(this->_elem);
985 }
986
987
988 // Returns a functor which compares the solution gradient at the point reinit() was last called
989 // on with the exact gradient at p
990 auto checkGradU(const Real tol)
991 {
992 return [this, tol](Point p)
993 {
994 Parameters dummy;
995
996 Gradient grad_u = 0;
997 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
998 grad_u += this->_fe->get_dphi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
999
1000 RealGradient true_grad = this->true_gradient(p);
1001
1002 LIBMESH_ASSERT_NUMBERS_EQUAL
1003 (grad_u(0), true_grad(0), tol);
1004 if (this->_dim > 1)
1005 LIBMESH_ASSERT_NUMBERS_EQUAL
1006 (grad_u(1), true_grad(1), tol);
1007 if (this->_dim > 2)
1008 LIBMESH_ASSERT_NUMBERS_EQUAL
1009 (grad_u(2), true_grad(2), tol);
1010 };
1011 }
1012
1014 {
1015 LOG_UNIT_TEST;
1017 }
1018
1020 {
1021 LOG_UNIT_TEST;
1023 }
1024
1026 {
1027 LOG_UNIT_TEST;
1028
1029 auto f = [this](Point p)
1030 {
1031 Parameters dummy;
1032
1033 Number grad_u_x = 0, grad_u_y = 0, grad_u_z = 0;
1034 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1035 {
1036 grad_u_x += this->_fe->get_dphidx()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1037#if LIBMESH_DIM > 1
1038 grad_u_y += this->_fe->get_dphidy()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1039#endif
1040#if LIBMESH_DIM > 2
1041 grad_u_z += this->_fe->get_dphidz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1042#endif
1043 }
1044
1045 RealGradient true_grad = this->true_gradient(p);
1046
1047 LIBMESH_ASSERT_NUMBERS_EQUAL(grad_u_x,
1048 true_grad(0), this->_grad_tol);
1049 if (this->_dim > 1)
1050 LIBMESH_ASSERT_NUMBERS_EQUAL
1051 (grad_u_y, true_grad(1), this->_grad_tol);
1052 if (this->_dim > 2)
1053 LIBMESH_ASSERT_NUMBERS_EQUAL
1054 (grad_u_z, true_grad(2), this->_grad_tol);
1055 };
1056
1057 testLoop(f);
1058 }
1059
1060
1062 {
1063 LOG_UNIT_TEST;
1064
1065 // Szabab elements don't have second derivatives yet
1066 if (family == SZABAB)
1067 return;
1068
1069#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1070 auto f = [this](Point p)
1071 {
1072 Tensor hess_u;
1073 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1074 hess_u += this->_fe->get_d2phi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1075
1076 // TODO: Yeah we'll test the ugly expressions later.
1077 if (family == RATIONAL_BERNSTEIN && order > 1)
1078 return;
1079
1080 RealTensor true_hess = this->true_hessian(p);
1081
1082 LIBMESH_ASSERT_NUMBERS_EQUAL
1083 (true_hess(0,0), hess_u(0,0), this->_hess_tol);
1084 if (this->_dim > 1)
1085 {
1086 LIBMESH_ASSERT_NUMBERS_EQUAL
1087 (hess_u(0,1), hess_u(1,0), this->_hess_tol);
1088 LIBMESH_ASSERT_NUMBERS_EQUAL
1089 (true_hess(0,1), hess_u(0,1), this->_hess_tol);
1090 LIBMESH_ASSERT_NUMBERS_EQUAL
1091 (true_hess(1,1), hess_u(1,1), this->_hess_tol);
1092 }
1093 if (this->_dim > 2)
1094 {
1095 LIBMESH_ASSERT_NUMBERS_EQUAL
1096 (hess_u(0,2), hess_u(2,0), this->_hess_tol);
1097 LIBMESH_ASSERT_NUMBERS_EQUAL
1098 (hess_u(1,2), hess_u(2,1), this->_hess_tol);
1099 LIBMESH_ASSERT_NUMBERS_EQUAL
1100 (true_hess(0,2), hess_u(0,2), this->_hess_tol);
1101 LIBMESH_ASSERT_NUMBERS_EQUAL
1102 (true_hess(1,2), hess_u(1,2), this->_hess_tol);
1103 LIBMESH_ASSERT_NUMBERS_EQUAL
1104 (true_hess(2,2), hess_u(2,2), this->_hess_tol);
1105 }
1106 };
1107
1108 testLoop(f);
1109#endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
1110 }
1111
1113 {
1114#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1115 LOG_UNIT_TEST;
1116
1117 // Szabab elements don't have second derivatives yet
1118 if (family == SZABAB)
1119 return;
1120
1121 auto f = [this](Point p)
1122 {
1123 Number hess_u_xx = 0, hess_u_xy = 0, hess_u_yy = 0,
1124 hess_u_xz = 0, hess_u_yz = 0, hess_u_zz = 0;
1125 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1126 {
1127 hess_u_xx += this->_fe->get_d2phidx2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1128#if LIBMESH_DIM > 1
1129 hess_u_xy += this->_fe->get_d2phidxdy()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1130 hess_u_yy += this->_fe->get_d2phidy2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1131#endif
1132#if LIBMESH_DIM > 2
1133 hess_u_xz += this->_fe->get_d2phidxdz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1134 hess_u_yz += this->_fe->get_d2phidydz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1135 hess_u_zz += this->_fe->get_d2phidz2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1136#endif
1137 }
1138
1139 // TODO: Yeah we'll test the ugly expressions later.
1140 if (family == RATIONAL_BERNSTEIN && order > 1)
1141 return;
1142
1143 RealTensor true_hess = this->true_hessian(p);
1144
1145 LIBMESH_ASSERT_NUMBERS_EQUAL
1146 (true_hess(0,0), hess_u_xx, this->_hess_tol);
1147 if (this->_dim > 1)
1148 {
1149 LIBMESH_ASSERT_NUMBERS_EQUAL
1150 (true_hess(0,1), hess_u_xy, this->_hess_tol);
1151 LIBMESH_ASSERT_NUMBERS_EQUAL
1152 (true_hess(1,1), hess_u_yy, this->_hess_tol);
1153 }
1154 if (this->_dim > 2)
1155 {
1156 LIBMESH_ASSERT_NUMBERS_EQUAL
1157 (true_hess(0,2), hess_u_xz, this->_hess_tol);
1158 LIBMESH_ASSERT_NUMBERS_EQUAL
1159 (true_hess(1,2), hess_u_yz, this->_hess_tol);
1160 LIBMESH_ASSERT_NUMBERS_EQUAL
1161 (true_hess(2,2), hess_u_zz, this->_hess_tol);
1162 }
1163 };
1164
1165 testLoop(f);
1166#endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
1167 }
1168
1170 {
1171 LOG_UNIT_TEST;
1172
1173 std::vector<Point> q_points;
1174 std::vector<Real> weights;
1175 q_points.resize(3); weights.resize(3);
1176 q_points[0](0) = 0.0; q_points[0](1) = 0.0; weights[0] = Real(1)/6;
1177 q_points[1](0) = 1.0; q_points[1](1) = 0.0; weights[1] = weights[0];
1178 q_points[2](0) = 0.0; q_points[2](1) = 1.0; weights[2] = weights[0];
1179
1180 FEType fe_type = this->_sys->variable_type(0);
1181 std::unique_ptr<FEBase> fe (FEBase::build(this->_dim, fe_type));
1182 const int extraorder = 3;
1183 std::unique_ptr<QBase> qrule (fe_type.default_quadrature_rule (this->_dim, extraorder));
1184 fe->attach_quadrature_rule (qrule.get());
1185
1186 const std::vector<Point> & q_pos = fe->get_xyz();
1187
1188 for (const auto & elem : this->_mesh->active_local_element_ptr_range()) {
1189 fe->reinit (elem, &q_points, &weights);
1190 CPPUNIT_ASSERT_EQUAL(q_points.size(), std::size_t(3));
1191 CPPUNIT_ASSERT_EQUAL(q_pos.size(), std::size_t(3)); // 6? bug?
1192 }
1193 }
1194
1195};
1196
1197
1198#define INSTANTIATE_FETEST_CASE(order, family, elemtype, case_name) \
1199 class FETest_##order##_##family##_##elemtype##_##case_name : public FETest<order, family, elemtype, case_name> { \
1200 public: \
1201 FETest_##order##_##family##_##elemtype##_##case_name() : \
1202 FETest<order,family,elemtype,case_name>() { \
1203 if (unitlog->summarized_logs_enabled()) \
1204 this->libmesh_suite_name = "FETest"; \
1205 else \
1206 this->libmesh_suite_name = "FETest_" #order "_" #family "_" #elemtype "_" #case_name; \
1207 this->_case_name = #case_name; \
1208 } \
1209 CPPUNIT_TEST_SUITE( FETest_##order##_##family##_##elemtype##_##case_name ); \
1210 FETEST \
1211 CPPUNIT_TEST_SUITE_END(); \
1212 }; \
1213 \
1214 CPPUNIT_TEST_SUITE_REGISTRATION( FETest_##order##_##family##_##elemtype##_##case_name );
1215
1216#define INSTANTIATE_FETEST(order, family, elemtype) \
1217 INSTANTIATE_FETEST_CASE(order, family, elemtype, Default)
1218
1219#endif
unsigned int _ny
Definition fe_test.h:282
unsigned int _dim
Definition fe_test.h:282
Real _past_vertex_tol_factor
The factor by which the tolerances grow at the points past the vertices.
Definition fe_test.h:297
Real _hess_tol
Definition fe_test.h:291
std::string _case_name
Name of the case, can be used in the test to switch cases.
Definition fe_test.h:280
std::string libmesh_suite_name
Definition fe_test.h:277
std::unique_ptr< EquationSystems > _es
Definition fe_test.h:287
std::unique_ptr< FEBase > _fe
Definition fe_test.h:288
unsigned int _nz
Definition fe_test.h:282
std::unique_ptr< Mesh > _mesh
Definition fe_test.h:286
void tearDown()
Definition fe_test.h:649
std::vector< dof_id_type > _dof_indices
Definition fe_test.h:284
Real _grad_tol
Definition fe_test.h:291
std::unique_ptr< QGauss > _qrule
Definition fe_test.h:289
void setUp()
Definition fe_test.h:367
static RealTensor true_hessian(Point p)
Definition fe_test.h:338
System * _sys
Definition fe_test.h:285
Elem * _elem
Definition fe_test.h:283
Real _value_tol
Definition fe_test.h:291
unsigned int _nx
Definition fe_test.h:282
Real _past_vertex_offset
The offset, as a fraction of an edge, of the points past the vertices.
Definition fe_test.h:294
static RealGradient true_gradient(Point p)
Definition fe_test.h:300
void testGradUPastVertices()
Definition fe_test.h:1019
void testPartitionOfUnity()
Definition fe_test.h:806
void testGradU()
Definition fe_test.h:1013
void testLoop(Functor f)
Definition fe_test.h:660
void testRefspaceNodes()
Definition fe_test.h:747
void testHessUComp()
Definition fe_test.h:1112
void testCustomReinit()
Definition fe_test.h:1169
void testUPastVertices()
Definition fe_test.h:966
void testFEInterface()
Definition fe_test.h:885
void testGradUComp()
Definition fe_test.h:1025
void testDualDoesntScreamAndDie()
Definition fe_test.h:972
auto checkU(const Real tol)
Definition fe_test.h:932
void testHessU()
Definition fe_test.h:1061
auto checkGradU(const Real tol)
Definition fe_test.h:990
void testPastVerticesLoop(Functor f)
Definition fe_test.h:707
void testNodalSoln()
Definition fe_test.h:770
void testU()
Definition fe_test.h:960
Real operator()(const Point &, const Real=0.) override
Definition fe_test.h:50
std::unique_ptr< FunctionBase< Real > > clone() const override
Definition fe_test.h:47
Defines a dense vector for use in Finite Element-type computations.
void resize(const unsigned int n)
Resize the vector.
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2203
void set_extra_datum(const unsigned int index, const T value)
Sets the value on this object of the extra datum associated with index, which should have been obtain...
dof_id_type id() const
Definition dof_object.h:833
This is the base class from which all geometric element types are derived.
Definition elem.h:96
virtual unsigned int n_vertices() const =0
const Node & node_ref(const unsigned int i) const
Definition elem.h:2659
virtual unsigned int n_nodes() const =0
virtual bool is_singular_node(unsigned int) const
Definition elem.h:1968
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition elem.C:2886
virtual unsigned short dim() const =0
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const =0
Similar to Elem::local_side_node(), but instead of a side id, takes an edge id and a node id on that ...
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
Definition elem.h:649
virtual bool runtime_topology() const
Definition elem.h:254
IntRange< unsigned short > edge_index_range() const
Definition elem.h:2830
virtual ElemType type() const =0
IntRange< unsigned short > node_index_range() const
Definition elem.h:2821
virtual Point master_point(const unsigned int i) const =0
virtual unsigned int local_singular_node(const Point &, const Real=TOLERANCE *TOLERANCE) const
Definition elem.h:1961
virtual bool infinite() const =0
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
static bool is_hierarchic(const FEType &fe_type)
Returns whether or not the input FEType's higher-order shape functions are always hierarchic.
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order,...
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln, const bool add_p_level=true, const unsigned int vdim=1)
Build the nodal soln from the element soln.
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
Definition fe_map.C:1954
static Point inverse_map(const unsigned int dim, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true, const bool extra_checks=true)
Definition fe_map.C:1512
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition fe_type.C:35
Order default_quadrature_order() const
Definition fe_type.h:415
static unsigned int n_dofs(const ElemType t, const Order o)
Base class for functors that can be evaluated at a point and (optionally) time.
This class provides the ability to map between arbitrary, user-defined strings and several data types...
Definition parameters.h:75
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition system.h:100
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, std::optional< ConstElemRange > active_local_range=std::nullopt, std::optional< std::vector< unsigned int > > variable_numbers=std::nullopt) const
Projects arbitrary functions onto the current solution.
std::unique_ptr< NumericVector< Number > > current_local_solution
All the values I need to compute my contribution to the simulation at hand.
Definition system.h:1667
const FEType & variable_type(const unsigned int i) const
Definition system.C:2721
unsigned int add_variable(std::string_view var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=nullptr)
Adds the variable var to the list of variables for this system.
Definition system.C:1344
const DofMap & get_dof_map() const
Definition system.h:2417
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
static const Real b
Communicator * TestCommWorld
static const Real rational_w
Definition fe_test.h:205
Number fe_cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:136
Number rational_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:208
Gradient quadratic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:116
Number quadratic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:103
Gradient fe_quartic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:182
Gradient linear_test_grad(const Point &, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:87
Number fe_quartic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:169
Gradient rational_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:225
Gradient fe_cubic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:149
Number linear_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:74
void build_cube(UnstructuredMesh &mesh, const unsigned int nx=0, const unsigned int ny=0, const unsigned int nz=0, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const Real zmin=0., const Real zmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
Builds a (elements) cube.
void redistribute(MeshBase &mesh, const FunctionBase< Real > &mapfunc)
Deterministically perturb the nodal locations.
RealTensorValue rotate(MeshBase &mesh, const Real phi, const Real theta=0., const Real psi=0.)
Rotates the mesh in 3D space.
void permute_elements(MeshBase &mesh)
Randomly permute the nodal ordering of each element (without twisting the element mapping).
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
NumberVectorValue Gradient
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
const Real pi
.
Definition libmesh.h:292
LIBMESH_DEVICE_INLINE T libmesh_real(T a)
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
@ RATIONAL_BERNSTEIN
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176