libMesh
Loading...
Searching...
No Matches
Public Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
FETest< order, family, elem_type, CaseName > Class Template Reference

#include <fe_test.h>

Inheritance diagram for FETest< order, family, elem_type, CaseName >:
[legend]

Public Member Functions

template<typename Functor >
void testLoop (Functor f)
 
template<typename Functor >
void testPastVerticesLoop (Functor f)
 
void testRefspaceNodes ()
 
void testNodalSoln ()
 
void testVectorNodalSoln ()
 
void testPartitionOfUnity ()
 
void testFEInterface ()
 
auto checkU (const Real tol)
 
void testU ()
 
void testUPastVertices ()
 
void testDualDoesntScreamAndDie ()
 
auto checkGradU (const Real tol)
 
void testGradU ()
 
void testGradUPastVertices ()
 
void testGradUComp ()
 
void testHessU ()
 
void testHessUComp ()
 
void testCustomReinit ()
 
void setUp ()
 
void tearDown ()
 

Static Protected Member Functions

static RealGradient true_gradient (Point p)
 
static RealTensor true_hessian (Point p)
 

Protected Attributes

std::string libmesh_suite_name
 
std::string _case_name
 Name of the case, can be used in the test to switch cases.
 
unsigned int _dim
 
unsigned int _nx
 
unsigned int _ny
 
unsigned int _nz
 
Elem * _elem
 
std::vector< dof_id_type > _dof_indices
 
System * _sys
 
std::unique_ptr< Mesh > _mesh
 
std::unique_ptr< EquationSystems > _es
 
std::unique_ptr< FEBase > _fe
 
std::unique_ptr< QGauss > _qrule
 
Real _value_tol
 
Real _grad_tol
 
Real _hess_tol
 
Real _past_vertex_offset
 The offset, as a fraction of an edge, of the points past the vertices.
 
Real _past_vertex_tol_factor
 The factor by which the tolerances grow at the points past the vertices.
 

Detailed Description

template<Order order, FEFamily family, ElemType elem_type, typename CaseName>
class FETest< order, family, elem_type, CaseName >

Definition at line 656 of file fe_test.h.

Member Function Documentation

◆ checkGradU()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
auto FETest< order, family, elem_type, CaseName >::checkGradU ( const Real  tol)
inline

Definition at line 1047 of file fe_test.h.

1048 {
1049 return [this, tol](Point p)
1050 {
1051 Parameters dummy;
1052
1053 Gradient grad_u = 0;
1054 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1055 grad_u += this->_fe->get_dphi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1056
1057 RealGradient true_grad = this->true_gradient(p);
1058
1059 LIBMESH_ASSERT_NUMBERS_EQUAL
1060 (grad_u(0), true_grad(0), tol);
1061 if (this->_dim > 1)
1062 LIBMESH_ASSERT_NUMBERS_EQUAL
1063 (grad_u(1), true_grad(1), tol);
1064 if (this->_dim > 2)
1065 LIBMESH_ASSERT_NUMBERS_EQUAL
1066 (grad_u(2), true_grad(2), tol);
1067 };
1068 }
static RealGradient true_gradient(Point p)
Definition fe_test.h:301
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
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:1679
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::System::current_local_solution, and FETestBase< order, family, elem_type, 1, CaseName >::true_gradient().

Referenced by FETest< order, family, elem_type, CaseName >::testGradU(), and FETest< order, family, elem_type, CaseName >::testGradUPastVertices().

◆ checkU()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
auto FETest< order, family, elem_type, CaseName >::checkU ( const Real  tol)
inline

Definition at line 989 of file fe_test.h.

990 {
991 return [this, tol](Point p)
992 {
993 Parameters dummy;
994
995 Number u = 0;
996 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
997 u += this->_fe->get_phi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
998
999 Number true_u;
1000
1001 if (family == RATIONAL_BERNSTEIN && order > 1)
1002 true_u = rational_test(p, dummy, "", "");
1003 else if (order > 3)
1004 true_u = fe_quartic_test(p, dummy, "", "");
1005 else if (FE_CAN_TEST_CUBIC)
1006 true_u = fe_cubic_test(p, dummy, "", "");
1007 else if (order > 1)
1008 true_u = p(0)*p(0) + 0.5*p(1)*p(1) + 0.25*p(2)*p(2) +
1009 0.125*p(0)*p(1) + 0.0625*p(0)*p(2) + 0.03125*p(1)*p(2);
1010 else
1011 true_u = p(0) + 0.25*p(1) + 0.0625*p(2);
1012
1013 LIBMESH_ASSERT_NUMBERS_EQUAL (true_u, u, tol);
1014 };
1015 }
Number fe_cubic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:137
Number rational_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:209
Number fe_quartic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:170
@ RATIONAL_BERNSTEIN

References FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::System::current_local_solution, fe_cubic_test(), fe_quartic_test(), libMesh::RATIONAL_BERNSTEIN, and rational_test().

Referenced by FETest< order, family, elem_type, CaseName >::testU(), and FETest< order, family, elem_type, CaseName >::testUPastVertices().

◆ setUp()

void FETestBase< order, family, elem_type, build_nx, CaseName >::setUp ( )
inlineinherited

Definition at line 368 of file fe_test.h.

369 {
370 _mesh = std::make_unique<Mesh>(*TestCommWorld);
371 _dim = Elem::type_to_dim_map[elem_type];
372 const unsigned int build_ny = (_dim > 1) * build_nx;
373 const unsigned int build_nz = (_dim > 2) * build_nx;
374
375 unsigned char weight_index = 0;
376
377 if (family == RATIONAL_BERNSTEIN)
378 {
379 // Make sure we can handle non-zero weight indices
380 _mesh->add_node_integer("buffer integer");
381
382 // Default weight to 1.0 so we don't get NaN from contains_point
383 // checks with a default GhostPointNeighbors ghosting
384 const Real default_weight = 1.0;
385 weight_index = cast_int<unsigned char>
386 (_mesh->add_node_datum<Real>("rational_weight", true,
387 &default_weight));
388 libmesh_assert_not_equal_to(weight_index, 0);
389
390 // Set mapping data but not type, since here we're testing
391 // rational basis functions in the FE space but testing then
392 // with Lagrange bases for the mapping space.
393 _mesh->set_default_mapping_data(weight_index);
394 }
395
396 if (elem_type == C0POLYGON)
397 {
398 // Build a pentagon by hand for testing purposes. Make this
399 // one non-skewed so a MONOMIAL basis will be able to exactly
400 // represent the polynomials we're projecting.
401
402 _mesh->add_point(Point(0, 0), 0);
403 _mesh->add_point(Point(1, 0), 1);
404 _mesh->add_point(Point(1+cos(2*libMesh::pi/5), sin(2*libMesh::pi/5)), 2);
405 _mesh->add_point(Point(0.5, sin(2*libMesh::pi/5)+sin(libMesh::pi/5)), 3);
406 _mesh->add_point(Point(-cos(2*libMesh::pi/5), sin(2*libMesh::pi/5)), 4);
407
408 std::unique_ptr<Elem> polygon = std::make_unique<C0Polygon>(5);
409 for (auto i : make_range(5))
410 polygon->set_node(i, _mesh->node_ptr(i));
411 polygon->set_id() = 0;
412
413 _mesh->add_elem(std::move(polygon));
414 _mesh->prepare_for_use();
415 }
416 else if (elem_type == C0POLYHEDRON)
417 {
418 // Build a plain cube by hand for testing purposes. We could
419 // upgrade this, but it should be to something non-skewed so a
420 // MONOMIAL basis will be able to exactly represent the
421 // polynomials we're projecting.
422 //
423 // See elem_test.h for the limitations here.
424
425 _mesh->add_point(Point(0, 0, 0), 0);
426 _mesh->add_point(Point(1, 0, 0), 1);
427 _mesh->add_point(Point(1, 1, 0), 2);
428 _mesh->add_point(Point(0, 1, 0), 3);
429 _mesh->add_point(Point(0, 0, 1), 4);
430 _mesh->add_point(Point(1, 0, 1), 5);
431 _mesh->add_point(Point(1, 1, 1), 6);
432 _mesh->add_point(Point(0, 1, 1), 7);
433
434 // Pick case
435 std::vector<std::vector<unsigned int>> nodes_on_side;
436 if (_case_name == "Default")
437 nodes_on_side = { {0, 1, 2, 3}, // min z
438 {0, 1, 5, 4}, // min y
439 {2, 6, 5, 1}, // max x
440 {2, 3, 7, 6}, // max y
441 {0, 4, 7, 3}, // min x
442 {5, 6, 7, 4} }; // max z
443 else if (_case_name == "MidNode")
444 nodes_on_side = { {0, 1, 2, 3}, // min z
445 {0, 1, 5, 4}, // min y
446 {1, 2, 6, 5}, // max x
447 {2, 3, 7, 6}, // max y
448 {3, 0, 4, 7}, // min x
449 {4, 5, 6, 7} }; // max z
450 else
451 libmesh_error_msg("Unknown case name: " + _case_name);
452
453 // Build all the sides.
454 std::vector<std::shared_ptr<Polygon>> sides(nodes_on_side.size());
455
456 for (auto s : index_range(nodes_on_side))
457 {
458 const auto & nodes_on_s = nodes_on_side[s];
459 sides[s] = std::make_shared<C0Polygon>(nodes_on_s.size());
460 for (auto i : index_range(nodes_on_s))
461 sides[s]->set_node(i, _mesh->node_ptr(nodes_on_s[i]));
462 }
463
464 std::unique_ptr<libMesh::Node> mid_elem_node;
465 std::unique_ptr<Elem> polyhedron = std::make_unique<C0Polyhedron>(sides, mid_elem_node);
466 _mesh->add_elem(std::move(polyhedron));
467 if (mid_elem_node)
468 _mesh->add_node(std::move(mid_elem_node));
469 _mesh->prepare_for_use();
470 }
471 else
472 {
474 build_nx, build_ny, build_nz,
475 0., 1., 0., 1., 0., 1.,
476 elem_type);
477 }
478
479 // For debugging purposes it can be helpful to only consider one
480 // element even when we're using an element type that requires
481 // more than one element to fill out a square or cube.
482#if 0
483 for (dof_id_type i = 0; i != _mesh->max_elem_id(); ++i)
484 {
485 Elem * elem = _mesh->query_elem_ptr(i);
486 if (elem && elem->id())
487 _mesh->delete_elem(elem);
488 }
489 _mesh->prepare_for_use();
490 CPPUNIT_ASSERT_EQUAL(_mesh->n_elem(), dof_id_type(1));
491#endif
492
493 // Permute our elements randomly and rotate and skew our mesh so
494 // we test all sorts of orientations ... except with Hermite
495 // elements, which are only designed to support meshes with a
496 // single orientation shared by all elements. We're also not
497 // rotating and/or skewing the rational elements, since our test
498 // solution was designed for a specific weighted mesh.
499 if (family != HERMITE &&
500 family != RATIONAL_BERNSTEIN)
501 {
503
504 // Not yet testing manifolds embedded in higher-D space
505 if (_dim > 1)
507 8*(_dim>2), 16*(_dim>2));
508
509 SkewFunc skew_func;
511 }
512
513 // Set rational weights so we can exactly match our test solution
514 if (family == RATIONAL_BERNSTEIN)
515 {
516 for (auto elem : _mesh->active_element_ptr_range())
517 {
518 // Workaround for nvc++ bug
519 Elem & e = *elem;
520
521 const unsigned int nv = elem->n_vertices();
522 const unsigned int nn = elem->n_nodes();
523 // We want interiors in lower dimensional elements treated
524 // like edges or faces as appropriate.
525 const unsigned int n_edges =
526 (elem->type() == EDGE3) ? 1 : elem->n_edges();
527 const unsigned int n_faces =
528 (elem->type() == QUAD9) ? 1 : elem->n_faces();
529 const unsigned int nve = std::min(nv + n_edges, nn);
530 const unsigned int nvef = std::min(nve + n_faces, nn);
531
532 for (unsigned int i = 0; i != nv; ++i)
533 e.node_ref(i).set_extra_datum<Real>(weight_index, 1.);
534 for (unsigned int i = nv; i != nve; ++i)
535 e.node_ref(i).set_extra_datum<Real>(weight_index, rational_w);
536 const Real w2 = rational_w * rational_w;
537 for (unsigned int i = nve; i != nvef; ++i)
538 e.node_ref(i).set_extra_datum<Real>(weight_index, w2);
539 const Real w3 = rational_w * w2;
540 for (unsigned int i = nvef; i != nn; ++i)
541 e.node_ref(i).set_extra_datum<Real>(weight_index, w3);
542 }
543 }
544
545 _mesh->complete_preparation();
546 _es = std::make_unique<EquationSystems>(*_mesh);
547 _sys = &(_es->add_system<System> ("SimpleSystem"));
548 _sys->add_variable("u", order, family);
549 _es->init();
550
551 if (family == RATIONAL_BERNSTEIN && order > 1)
552 {
554 }
555 else if (order > 3)
556 {
558 }
559 // Lagrange "cubic" on Tet7 only supports a bubble function, not
560 // all of P^3
561 else if (FE_CAN_TEST_CUBIC)
562 {
564 }
565 else if (order > 1)
566 {
568 }
569 else
570 {
572 }
573
574 FEType fe_type = _sys->variable_type(0);
575 _fe = FEBase::build(_dim, fe_type);
576
577 // Create quadrature rule for use in computing dual shape coefficients
578 _qrule = std::make_unique<QGauss>(_dim, fe_type.default_quadrature_order());
579 _fe->attach_quadrature_rule(_qrule.get());
580
581 auto rng = _mesh->active_local_element_ptr_range();
582 this->_elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
583
585
586 _nx = 10;
587 _ny = (_dim > 1) ? _nx : 1;
588 _nz = (_dim > 2) ? _nx : 1;
589
590 this->_value_tol = TOLERANCE * sqrt(TOLERANCE);
591
592 // We see 6.5*tol*sqrt(tol) errors on cubic Hermites with the fe_cubic
593 // hermite test function
594 // On Tri7 we see 10*tol*sqrt(tol) errors, even!
595 // On Tet14 Monomial gives us at least 13*tol*sqrt(tol) in some
596 // cases
597 this->_grad_tol = 15 * TOLERANCE * sqrt(TOLERANCE);
598
599 this->_hess_tol = sqrt(TOLERANCE); // FIXME: we see some ~1e-5 errors?!?
600
601 // Reference vertices have coordinates of 0 and +/-1, so with a power of two offset the
602 // barycentric coordinates of each point, and their sums and differences, are computed
603 // exactly. A combination which vanishes on a point is then evaluated as exactly zero.
604 this->_past_vertex_offset = 0.25;
605
606 // Shape functions grow outside the element, and with them the rounding error in the
607 // solution there, so evaluations past the vertices get looser tolerances. Along the line
608 // through an edge the error is a polynomial of degree at most p, so an error within a
609 // tolerance on the edge is within T_p(1 + 2*offset) times that tolerance at offset past
610 // the edge's end, where T_p is the Chebyshev polynomial. Gradient errors have lower degree
611 // and grow more slowly.
612 const Real x = 1 + 2 * this->_past_vertex_offset;
613 Real t_prev = 1, t = x;
614 for (unsigned int k = 1; k < static_cast<unsigned int>(order); ++k)
615 t_prev = std::exchange(t, 2 * x * t - t_prev);
616 this->_past_vertex_tol_factor = (order == CONSTANT) ? 1 : t;
617
618 // Prerequest everything we'll want to calculate later.
619 _fe->get_phi();
620 _fe->get_dphi();
621 _fe->get_dphidx();
622#if LIBMESH_DIM > 1
623 _fe->get_dphidy();
624#endif
625#if LIBMESH_DIM > 2
626 _fe->get_dphidz();
627#endif
628
629#if LIBMESH_ENABLE_SECOND_DERIVATIVES
630
631 // Szabab elements don't have second derivatives yet
632 if (family == SZABAB)
633 return;
634
635 _fe->get_d2phi();
636 _fe->get_d2phidx2();
637#if LIBMESH_DIM > 1
638 _fe->get_d2phidxdy();
639 _fe->get_d2phidy2();
640#endif
641#if LIBMESH_DIM > 2
642 _fe->get_d2phidxdz();
643 _fe->get_d2phidydz();
644 _fe->get_d2phidz2();
645#endif
646
647#endif
648 }
Real _past_vertex_tol_factor
The factor by which the tolerances grow at the points past the vertices.
Definition fe_test.h:298
std::string _case_name
Name of the case, can be used in the test to switch cases.
Definition fe_test.h:281
std::unique_ptr< EquationSystems > _es
Definition fe_test.h:288
Real _past_vertex_offset
The offset, as a fraction of an edge, of the points past the vertices.
Definition fe_test.h:295
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition dof_map.C:2231
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
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 ElemType type() const =0
static std::unique_ptr< FEGenericBase > build(const unsigned int dim, const FEType &type)
Builds a specific finite element type.
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
Order default_quadrature_order() const
Definition fe_type.h:415
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.
const FEType & variable_type(const unsigned int i) const
Definition system.C:2776
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:1400
const DofMap & get_dof_map() const
Definition system.h:2448
static const Real rational_w
Definition fe_test.h:206
Gradient quadratic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:117
Number quadratic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:104
Gradient fe_quartic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:183
Gradient linear_test_grad(const Point &, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:88
Gradient rational_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:226
Gradient fe_cubic_test_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:150
Number linear_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:75
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).
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
const Real pi
.
Definition libmesh.h:292
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
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

◆ tearDown()

void FETestBase< order, family, elem_type, build_nx, CaseName >::tearDown ( )
inlineinherited

Definition at line 650 of file fe_test.h.

650{}

◆ testCustomReinit()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testCustomReinit ( )
inline

Definition at line 1226 of file fe_test.h.

1227 {
1228 LOG_UNIT_TEST;
1229
1230 std::vector<Point> q_points;
1231 std::vector<Real> weights;
1232 q_points.resize(3); weights.resize(3);
1233 q_points[0](0) = 0.0; q_points[0](1) = 0.0; weights[0] = Real(1)/6;
1234 q_points[1](0) = 1.0; q_points[1](1) = 0.0; weights[1] = weights[0];
1235 q_points[2](0) = 0.0; q_points[2](1) = 1.0; weights[2] = weights[0];
1236
1237 FEType fe_type = this->_sys->variable_type(0);
1238 std::unique_ptr<FEBase> fe (FEBase::build(this->_dim, fe_type));
1239 const int extraorder = 3;
1240 std::unique_ptr<QBase> qrule (fe_type.default_quadrature_rule (this->_dim, extraorder));
1241 fe->attach_quadrature_rule (qrule.get());
1242
1243 const std::vector<Point> & q_pos = fe->get_xyz();
1244
1245 for (const auto & elem : this->_mesh->active_local_element_ptr_range()) {
1246 fe->reinit (elem, &q_points, &weights);
1247 CPPUNIT_ASSERT_EQUAL(q_points.size(), std::size_t(3));
1248 CPPUNIT_ASSERT_EQUAL(q_pos.size(), std::size_t(3)); // 6? bug?
1249 }
1250 }
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition fe_type.C:35

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_mesh, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::FEGenericBase< OutputType >::build(), libMesh::FEType::default_quadrature_rule(), libMesh::Real, and libMesh::System::variable_type().

◆ testDualDoesntScreamAndDie()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testDualDoesntScreamAndDie ( )
inline

Definition at line 1029 of file fe_test.h.

1030 {
1031 LOG_UNIT_TEST;
1032
1033 // Handle the "more processors than elements" case
1034 if (!this->_elem)
1035 return;
1036
1037 // Request dual calculations
1038 this->_fe->get_dual_phi();
1039
1040 // reinit using the default quadrature rule in order to calculate the dual coefficients
1041 this->_fe->reinit(this->_elem);
1042 }

References FETestBase< order, family, elem_type, 1, CaseName >::_elem, and FETestBase< order, family, elem_type, 1, CaseName >::_fe.

◆ testFEInterface()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testFEInterface ( )
inline

Definition at line 942 of file fe_test.h.

943 {
944 LOG_UNIT_TEST;
945
946 // Handle the "more processors than elements" case
947 if (!this->_elem)
948 return;
949
950 this->_fe->reinit(this->_elem);
951
952 const FEType fe_type = this->_sys->variable_type(0);
953
954 unsigned int my_n_dofs = 0;
955
956 switch (this->_elem->dim())
957 {
958 case 0:
959 my_n_dofs = FE<0,family>::n_dofs(this->_elem, order);
960 break;
961 case 1:
962 my_n_dofs = FE<1,family>::n_dofs(this->_elem, order);
963 break;
964 case 2:
965 my_n_dofs = FE<2,family>::n_dofs(this->_elem, order);
966 break;
967 case 3:
968 my_n_dofs = FE<3,family>::n_dofs(this->_elem, order);
969 break;
970 default:
971 libmesh_error();
972 }
973
974 CPPUNIT_ASSERT_EQUAL(
976 my_n_dofs);
977
978 CPPUNIT_ASSERT_EQUAL(
980 this->_fe->get_continuity());
981
982 CPPUNIT_ASSERT_EQUAL(
984 this->_fe->is_hierarchic());
985 }
virtual unsigned short dim() const =0
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_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
static unsigned int n_dofs(const ElemType t, const Order o)

References FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::Elem::dim(), libMesh::FEInterface::get_continuity(), libMesh::FEInterface::is_hierarchic(), libMesh::FE< Dim, T >::n_dofs(), libMesh::FEInterface::n_shape_functions(), and libMesh::System::variable_type().

◆ testGradU()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testGradU ( )
inline

◆ testGradUComp()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testGradUComp ( )
inline

Definition at line 1082 of file fe_test.h.

1083 {
1084 LOG_UNIT_TEST;
1085
1086 auto f = [this](Point p)
1087 {
1088 Parameters dummy;
1089
1090 Number grad_u_x = 0, grad_u_y = 0, grad_u_z = 0;
1091 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1092 {
1093 grad_u_x += this->_fe->get_dphidx()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1094#if LIBMESH_DIM > 1
1095 grad_u_y += this->_fe->get_dphidy()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1096#endif
1097#if LIBMESH_DIM > 2
1098 grad_u_z += this->_fe->get_dphidz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1099#endif
1100 }
1101
1102 RealGradient true_grad = this->true_gradient(p);
1103
1104 LIBMESH_ASSERT_NUMBERS_EQUAL(grad_u_x,
1105 true_grad(0), this->_grad_tol);
1106 if (this->_dim > 1)
1107 LIBMESH_ASSERT_NUMBERS_EQUAL
1108 (grad_u_y, true_grad(1), this->_grad_tol);
1109 if (this->_dim > 2)
1110 LIBMESH_ASSERT_NUMBERS_EQUAL
1111 (grad_u_z, true_grad(2), this->_grad_tol);
1112 };
1113
1114 testLoop(f);
1115 }

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_grad_tol, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::System::current_local_solution, FETest< order, family, elem_type, CaseName >::testLoop(), and FETestBase< order, family, elem_type, 1, CaseName >::true_gradient().

◆ testGradUPastVertices()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testGradUPastVertices ( )
inline

◆ testHessU()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testHessU ( )
inline

Definition at line 1118 of file fe_test.h.

1119 {
1120 LOG_UNIT_TEST;
1121
1122 // Szabab elements don't have second derivatives yet
1123 if (family == SZABAB)
1124 return;
1125
1126#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1127 auto f = [this](Point p)
1128 {
1129 Tensor hess_u;
1130 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1131 hess_u += this->_fe->get_d2phi()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1132
1133 // TODO: Yeah we'll test the ugly expressions later.
1134 if (family == RATIONAL_BERNSTEIN && order > 1)
1135 return;
1136
1137 RealTensor true_hess = this->true_hessian(p);
1138
1139 LIBMESH_ASSERT_NUMBERS_EQUAL
1140 (true_hess(0,0), hess_u(0,0), this->_hess_tol);
1141 if (this->_dim > 1)
1142 {
1143 LIBMESH_ASSERT_NUMBERS_EQUAL
1144 (hess_u(0,1), hess_u(1,0), this->_hess_tol);
1145 LIBMESH_ASSERT_NUMBERS_EQUAL
1146 (true_hess(0,1), hess_u(0,1), this->_hess_tol);
1147 LIBMESH_ASSERT_NUMBERS_EQUAL
1148 (true_hess(1,1), hess_u(1,1), this->_hess_tol);
1149 }
1150 if (this->_dim > 2)
1151 {
1152 LIBMESH_ASSERT_NUMBERS_EQUAL
1153 (hess_u(0,2), hess_u(2,0), this->_hess_tol);
1154 LIBMESH_ASSERT_NUMBERS_EQUAL
1155 (hess_u(1,2), hess_u(2,1), this->_hess_tol);
1156 LIBMESH_ASSERT_NUMBERS_EQUAL
1157 (true_hess(0,2), hess_u(0,2), this->_hess_tol);
1158 LIBMESH_ASSERT_NUMBERS_EQUAL
1159 (true_hess(1,2), hess_u(1,2), this->_hess_tol);
1160 LIBMESH_ASSERT_NUMBERS_EQUAL
1161 (true_hess(2,2), hess_u(2,2), this->_hess_tol);
1162 }
1163 };
1164
1165 testLoop(f);
1166#endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
1167 }
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_hess_tol, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::System::current_local_solution, libMesh::RATIONAL_BERNSTEIN, libMesh::SZABAB, FETest< order, family, elem_type, CaseName >::testLoop(), and FETestBase< order, family, elem_type, 1, CaseName >::true_hessian().

◆ testHessUComp()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testHessUComp ( )
inline

Definition at line 1169 of file fe_test.h.

1170 {
1171#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1172 LOG_UNIT_TEST;
1173
1174 // Szabab elements don't have second derivatives yet
1175 if (family == SZABAB)
1176 return;
1177
1178 auto f = [this](Point p)
1179 {
1180 Number hess_u_xx = 0, hess_u_xy = 0, hess_u_yy = 0,
1181 hess_u_xz = 0, hess_u_yz = 0, hess_u_zz = 0;
1182 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
1183 {
1184 hess_u_xx += this->_fe->get_d2phidx2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1185#if LIBMESH_DIM > 1
1186 hess_u_xy += this->_fe->get_d2phidxdy()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1187 hess_u_yy += this->_fe->get_d2phidy2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1188#endif
1189#if LIBMESH_DIM > 2
1190 hess_u_xz += this->_fe->get_d2phidxdz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1191 hess_u_yz += this->_fe->get_d2phidydz()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1192 hess_u_zz += this->_fe->get_d2phidz2()[d][0] * (*this->_sys->current_local_solution)(this->_dof_indices[d]);
1193#endif
1194 }
1195
1196 // TODO: Yeah we'll test the ugly expressions later.
1197 if (family == RATIONAL_BERNSTEIN && order > 1)
1198 return;
1199
1200 RealTensor true_hess = this->true_hessian(p);
1201
1202 LIBMESH_ASSERT_NUMBERS_EQUAL
1203 (true_hess(0,0), hess_u_xx, this->_hess_tol);
1204 if (this->_dim > 1)
1205 {
1206 LIBMESH_ASSERT_NUMBERS_EQUAL
1207 (true_hess(0,1), hess_u_xy, this->_hess_tol);
1208 LIBMESH_ASSERT_NUMBERS_EQUAL
1209 (true_hess(1,1), hess_u_yy, this->_hess_tol);
1210 }
1211 if (this->_dim > 2)
1212 {
1213 LIBMESH_ASSERT_NUMBERS_EQUAL
1214 (true_hess(0,2), hess_u_xz, this->_hess_tol);
1215 LIBMESH_ASSERT_NUMBERS_EQUAL
1216 (true_hess(1,2), hess_u_yz, this->_hess_tol);
1217 LIBMESH_ASSERT_NUMBERS_EQUAL
1218 (true_hess(2,2), hess_u_zz, this->_hess_tol);
1219 }
1220 };
1221
1222 testLoop(f);
1223#endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
1224 }

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_hess_tol, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::System::current_local_solution, libMesh::RATIONAL_BERNSTEIN, libMesh::SZABAB, FETest< order, family, elem_type, CaseName >::testLoop(), and FETestBase< order, family, elem_type, 1, CaseName >::true_hessian().

◆ testLoop()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
template<typename Functor >
void FETest< order, family, elem_type, CaseName >::testLoop ( Functor  f)
inline

Definition at line 661 of file fe_test.h.

662 {
663 // Handle the "more processors than elements" case
664 if (!this->_elem)
665 return;
666
667 // These tests require exceptions to be enabled because a
668 // TypeTensor::solve() call down in Elem::contains_point()
669 // actually throws a non-fatal exception for a certain Point which
670 // is not in the Elem. When exceptions are not enabled, this test
671 // simply aborts.
672#ifdef LIBMESH_ENABLE_EXCEPTIONS
673 for (unsigned int i=0; i != this->_nx; ++i)
674 for (unsigned int j=0; j != this->_ny; ++j)
675 for (unsigned int k=0; k != this->_nz; ++k)
676 {
677 Point p = Real(i)/this->_nx;
678 if (j > 0)
679 p(1) = Real(j)/this->_ny;
680 if (k > 0)
681 p(2) = Real(k)/this->_nz;
682 if (!this->_elem->contains_point(p))
683 continue;
684
685 // If at a singular node, cannot use FEMap::map
686 if (this->_elem->local_singular_node(p) != invalid_uint)
687 continue;
688
689 std::vector<Point> master_points
690 (1, FEMap::inverse_map(this->_dim, this->_elem, p));
691
692 // Reinit at point to test against analytic solution
693 this->_fe->reinit(this->_elem, &master_points);
694
695 f(p);
696 }
697#endif // LIBMESH_ENABLE_EXCEPTIONS
698 }
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition elem.C:2886
virtual unsigned int local_singular_node(const Point &, const Real=TOLERANCE *TOLERANCE) const
Definition elem.h:1961
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
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

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_nx, FETestBase< order, family, elem_type, 1, CaseName >::_ny, FETestBase< order, family, elem_type, 1, CaseName >::_nz, libMesh::Elem::contains_point(), libMesh::invalid_uint, libMesh::FEMap::inverse_map(), libMesh::Elem::local_singular_node(), and libMesh::Real.

Referenced by FETest< order, family, elem_type, CaseName >::testGradU(), FETest< order, family, elem_type, CaseName >::testGradUComp(), FETest< order, family, elem_type, CaseName >::testHessU(), FETest< order, family, elem_type, CaseName >::testHessUComp(), and FETest< order, family, elem_type, CaseName >::testU().

◆ testNodalSoln()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testNodalSoln ( )
inline

Definition at line 771 of file fe_test.h.

772 {
773 LOG_UNIT_TEST;
774
775 if (!this->_elem)
776 return;
777
778 // The Lagrange nodal solution is the interpolant evaluated at
779 // each node, including nodes which carry no degree of freedom
780 if (family != LAGRANGE && family != L2_LAGRANGE)
781 return;
782
783 if (this->_elem->runtime_topology())
784 return;
785
786 const FEType fe_type = this->_sys->variable_type(0);
787 const unsigned int n_dofs = FEInterface::n_dofs(fe_type, this->_elem);
788
789 std::vector<Number> elem_soln(n_dofs, 0), nodal_soln;
790 for (auto i : make_range(n_dofs))
791 {
792 elem_soln[i] = 1;
793 FEInterface::nodal_soln(this->_dim, fe_type, this->_elem,
794 elem_soln, nodal_soln);
795 elem_soln[i] = 0;
796
797 CPPUNIT_ASSERT_EQUAL(std::size_t(this->_elem->n_nodes()),
798 nodal_soln.size());
799 for (auto n : this->_elem->node_index_range())
800 LIBMESH_ASSERT_NUMBERS_EQUAL
801 (FEInterface::shape(fe_type, this->_elem, i,
802 this->_elem->master_point(n)),
803 nodal_soln[n], TOLERANCE*TOLERANCE);
804 }
805 }
virtual bool runtime_topology() const
Definition elem.h:254
This class provides an encapsulated access to all static public member functions of finite element cl...
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.

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_sys, libMesh::L2_LAGRANGE, libMesh::LAGRANGE, libMesh::make_range(), libMesh::Elem::master_point(), libMesh::FEInterface::n_dofs(), libMesh::Elem::n_nodes(), libMesh::FEInterface::nodal_soln(), libMesh::Elem::node_index_range(), libMesh::Elem::runtime_topology(), libMesh::FEInterface::shape(), libMesh::TOLERANCE, and libMesh::System::variable_type().

◆ testPartitionOfUnity()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testPartitionOfUnity ( )
inline

Definition at line 862 of file fe_test.h.

863 {
864 LOG_UNIT_TEST;
865
866 if (!this->_elem)
867 return;
868
869 this->_fe->reinit(this->_elem);
870
871 bool satisfies_partition_of_unity = true;
872 for (const auto qp : make_range(this->_qrule->n_points()))
873 {
874 Real phi_sum = 0;
875 for (std::size_t d = 0; d != this->_dof_indices.size(); ++d)
876 phi_sum += this->_fe->get_phi()[d][qp];
877 if (phi_sum < (1 - TOLERANCE) || phi_sum > (1 + TOLERANCE))
878 {
879 satisfies_partition_of_unity = false;
880 break;
881 }
882 }
883
884 switch (this->_fe->get_family())
885 {
886 case MONOMIAL:
887 {
888 switch (this->_fe->get_order())
889 {
890 case CONSTANT:
891 CPPUNIT_ASSERT(satisfies_partition_of_unity);
892 break;
893
894 default:
895 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
896 break;
897 }
898 break;
899 }
900 case SZABAB:
901 case HIERARCHIC:
902 case L2_HIERARCHIC:
903 {
904 switch (this->_fe->get_order())
905 {
906 case FIRST:
907 CPPUNIT_ASSERT(satisfies_partition_of_unity);
908 break;
909
910 default:
911 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
912 break;
913 }
914 break;
915 }
916
917 case XYZ:
918 case CLOUGH:
919 case HERMITE:
920 {
921 CPPUNIT_ASSERT(!satisfies_partition_of_unity);
922 break;
923 }
924
925 case LAGRANGE:
926 case L2_LAGRANGE:
927 case LAGRANGE_GLL:
928 case L2_LAGRANGE_GLL:
929 case BERNSTEIN:
931 {
932 CPPUNIT_ASSERT(satisfies_partition_of_unity);
933 break;
934 }
935
936 default:
937 CPPUNIT_FAIL("Uncovered FEFamily");
938 }
939 }

References FETestBase< order, family, elem_type, 1, CaseName >::_dof_indices, FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_qrule, libMesh::BERNSTEIN, libMesh::CLOUGH, libMesh::CONSTANT, libMesh::FIRST, libMesh::HERMITE, libMesh::HIERARCHIC, libMesh::L2_HIERARCHIC, libMesh::L2_LAGRANGE, libMesh::L2_LAGRANGE_GLL, libMesh::LAGRANGE, libMesh::LAGRANGE_GLL, libMesh::make_range(), libMesh::MONOMIAL, libMesh::RATIONAL_BERNSTEIN, libMesh::Real, libMesh::SZABAB, libMesh::TOLERANCE, and libMesh::XYZ.

◆ testPastVerticesLoop()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
template<typename Functor >
void FETest< order, family, elem_type, CaseName >::testPastVerticesLoop ( Functor  f)
inline

Definition at line 708 of file fe_test.h.

709 {
710 // Handle the "more processors than elements" case
711 if (!this->_elem)
712 return;
713
714 // We don't have reference elements for these
715 if (this->_elem->infinite() || this->_elem->runtime_topology())
716 return;
717
718 const Real delta = this->_past_vertex_offset;
719
720 // An edge element is its own edge
721 std::vector<std::pair<unsigned int, unsigned int>> edges;
722 if (this->_dim == 1)
723 edges.emplace_back(0, 1);
724 for (const auto e : this->_elem->edge_index_range())
725 edges.emplace_back(this->_elem->local_edge_node(e, 0),
726 this->_elem->local_edge_node(e, 1));
727
728 for (const auto v : make_range(this->_elem->n_vertices()))
729 {
730 // Shape functions are singular at, and on a plane through, a singular node
731 if (this->_elem->is_singular_node(v))
732 continue;
733
734 for (const auto & [a, b] : edges)
735 for (const Real sign : {Real(-1), Real(1)})
736 {
737 const Point master_p = this->_elem->master_point(v) + sign * delta *
738 (this->_elem->master_point(b) - this->_elem->master_point(a));
739
740 std::vector<Point> master_points(1, master_p);
741 this->_fe->reinit(this->_elem, &master_points);
742
743 f(FEMap::map(this->_dim, this->_elem, master_p));
744 }
745 }
746 }
virtual bool is_singular_node(unsigned int) const
Definition elem.h:1968
virtual Point master_point(const unsigned int i) const =0
virtual bool infinite() const =0
static Point map(const unsigned int dim, const Elem *elem, const Point &reference_point)
Definition fe_map.C:1954
static const Real b

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_fe, FETestBase< order, family, elem_type, 1, CaseName >::_past_vertex_offset, b, libMesh::Elem::edge_index_range(), libMesh::Elem::infinite(), libMesh::Elem::is_singular_node(), libMesh::Elem::local_edge_node(), libMesh::make_range(), libMesh::FEMap::map(), libMesh::Elem::master_point(), libMesh::Elem::n_vertices(), and libMesh::Real.

Referenced by FETest< order, family, elem_type, CaseName >::testGradUPastVertices(), and FETest< order, family, elem_type, CaseName >::testUPastVertices().

◆ testRefspaceNodes()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testRefspaceNodes ( )
inline

Definition at line 748 of file fe_test.h.

749 {
750 LOG_UNIT_TEST;
751
752 if (!this->_elem)
753 return;
754
755 // We don't currently support reference infinite elements
756 if (this->_elem->infinite())
757 return;
758
759 // We'll probably never support reference polytopes
760 if (this->_elem->runtime_topology())
761 return;
762
763 std::vector<Point> nodes;
764 this->_fe->get_refspace_nodes(this->_elem->type(), nodes);
765 for (auto n : index_range(nodes))
766 LIBMESH_ASSERT_REALVEC_EQUAL(nodes[n],
767 this->_elem->master_point(n),
769 }

References FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_fe, libMesh::index_range(), libMesh::Elem::infinite(), libMesh::Elem::master_point(), libMesh::Elem::runtime_topology(), libMesh::TOLERANCE, and libMesh::Elem::type().

◆ testU()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testU ( )
inline

◆ testUPastVertices()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testUPastVertices ( )
inline

◆ testVectorNodalSoln()

template<Order order, FEFamily family, ElemType elem_type, typename CaseName >
void FETest< order, family, elem_type, CaseName >::testVectorNodalSoln ( )
inline

Definition at line 807 of file fe_test.h.

808 {
809 LOG_UNIT_TEST;
810
811 if (!this->_elem)
812 return;
813
814 // LAGRANGE_VEC has its own nodal_soln for 2D and 3D elements; each
815 // component must match the LAGRANGE nodal_soln
816 if (family != LAGRANGE || this->_dim < 2)
817 return;
818
819 if (this->_elem->runtime_topology())
820 return;
821
822 // LAGRANGE_VEC nodal_soln is wrong on these, see libMesh/libmesh#4665
823 if ((order == SECOND && (elem_type == TET14 || elem_type == PRISM20 ||
824 elem_type == PRISM21 || elem_type == PYRAMID18)) ||
825 (order == FIRST && (elem_type == PYRAMID13 || elem_type == PYRAMID14 ||
826 elem_type == PYRAMID18)))
827 return;
828
829 const FEType fe_type = this->_sys->variable_type(0);
830 const FEType vec_fe_type(fe_type.order, LAGRANGE_VEC);
831 const unsigned int dim = this->_dim;
832 const unsigned int n_dofs = FEInterface::n_dofs(fe_type, this->_elem);
833 const unsigned int n_nodes = this->_elem->n_nodes();
834
835 std::vector<Number> elem_soln(n_dofs, 0), nodal_soln,
836 vec_elem_soln(dim*n_dofs, 0), vec_nodal_soln;
837 for (auto i : make_range(n_dofs))
838 {
839 elem_soln[i] = 1;
840 FEInterface::nodal_soln(dim, fe_type, this->_elem,
841 elem_soln, nodal_soln);
842 elem_soln[i] = 0;
843
844 for (auto d : make_range(dim))
845 {
846 vec_elem_soln[dim*i + d] = 1;
847 FEInterface::nodal_soln(dim, vec_fe_type, this->_elem,
848 vec_elem_soln, vec_nodal_soln);
849 vec_elem_soln[dim*i + d] = 0;
850
851 CPPUNIT_ASSERT_EQUAL(std::size_t(dim*n_nodes),
852 vec_nodal_soln.size());
853 for (auto n : make_range(n_nodes))
854 for (auto c : make_range(dim))
855 LIBMESH_ASSERT_NUMBERS_EQUAL
856 (c == d ? nodal_soln[n] : Number(0),
857 vec_nodal_soln[dim*n + c], TOLERANCE*TOLERANCE);
858 }
859 }
860 }
unsigned int dim
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
const dof_id_type n_nodes
Definition tecplot_io.C:67

References FETestBase< order, family, elem_type, 1, CaseName >::_dim, FETestBase< order, family, elem_type, 1, CaseName >::_elem, FETestBase< order, family, elem_type, 1, CaseName >::_sys, dim, libMesh::FIRST, libMesh::LAGRANGE, libMesh::LAGRANGE_VEC, libMesh::make_range(), libMesh::FEInterface::n_dofs(), libMesh::Elem::n_nodes(), n_nodes, libMesh::FEInterface::nodal_soln(), libMesh::FEType::order, libMesh::PRISM20, libMesh::PRISM21, libMesh::PYRAMID13, libMesh::PYRAMID14, libMesh::PYRAMID18, libMesh::Elem::runtime_topology(), libMesh::SECOND, libMesh::TET14, libMesh::TOLERANCE, and libMesh::System::variable_type().

◆ true_gradient()

static RealGradient FETestBase< order, family, elem_type, build_nx, CaseName >::true_gradient ( Point  p)
inlinestaticprotectedinherited

Definition at line 301 of file fe_test.h.

302 {
303 Parameters dummy;
304
305 Gradient true_grad;
306 RealGradient returnval;
307
308 if (family == RATIONAL_BERNSTEIN && order > 1)
309 true_grad = rational_test_grad(p, dummy, "", "");
310 else if (order > 3)
311 true_grad = fe_quartic_test_grad(p, dummy, "", "");
312 else if (FE_CAN_TEST_CUBIC)
313 true_grad = fe_cubic_test_grad(p, dummy, "", "");
314 else if (order > 1)
315 {
316 const Real & x = p(0);
317 const Real & y = (LIBMESH_DIM > 1) ? p(1) : 0;
318 const Real & z = (LIBMESH_DIM > 2) ? p(2) : 0;
319
320 true_grad = Gradient(2*x+0.125*y+0.0625*z,
321 y+0.125*x+0.03125*z,
322 0.5*z+0.0625*x+0.03125*y);
323 }
324 else
325 true_grad = Gradient(1.0, 0.25, 0.0625);
326
327 for (unsigned int d=0; d != LIBMESH_DIM; ++d)
328 {
329 CPPUNIT_ASSERT(true_grad(d) ==
330 Number(libmesh_real(true_grad(d))));
331
332 returnval(d) = libmesh_real(true_grad(d));
333 }
334
335 return returnval;
336 }
NumberVectorValue Gradient
LIBMESH_DEVICE_INLINE T libmesh_real(T a)

◆ true_hessian()

static RealTensor FETestBase< order, family, elem_type, build_nx, CaseName >::true_hessian ( Point  p)
inlinestaticprotectedinherited

Definition at line 339 of file fe_test.h.

340 {
341 const Real & x = p(0);
342 const Real & y = LIBMESH_DIM > 1 ? p(1) : 0;
343 const Real & z = LIBMESH_DIM > 2 ? p(2) : 0;
344
345 if (order > 3)
346 return RealTensor
347 { 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),
348 -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),
349 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 };
350 else if (FE_CAN_TEST_CUBIC)
351 return RealTensor
352 { 6*x-4+2*(1-y), -2*x+z-1, y-1,
353 -2*x+z-1, -2*z, x+1-2*y,
354 y-1, x+1-2*y, 6*z-4 };
355 else if (order > 1)
356 return RealTensor
357 { 2, 0.125, 0.0625,
358 0.125, 1, 0.03125,
359 0.0625, 0.03125, 0.5 };
360
361 return RealTensor
362 { 0, 0, 0,
363 0, 0, 0,
364 0, 0, 0 };
365 }

Member Data Documentation

◆ _case_name

std::string FETestBase< order, family, elem_type, build_nx, CaseName >::_case_name
protectedinherited

Name of the case, can be used in the test to switch cases.

Definition at line 281 of file fe_test.h.

◆ _dim

unsigned int FETestBase< order, family, elem_type, build_nx, CaseName >::_dim
protectedinherited

Definition at line 283 of file fe_test.h.

◆ _dof_indices

std::vector<dof_id_type> FETestBase< order, family, elem_type, build_nx, CaseName >::_dof_indices
protectedinherited

Definition at line 285 of file fe_test.h.

◆ _elem

Elem* FETestBase< order, family, elem_type, build_nx, CaseName >::_elem
protectedinherited

Definition at line 284 of file fe_test.h.

◆ _es

std::unique_ptr<EquationSystems> FETestBase< order, family, elem_type, build_nx, CaseName >::_es
protectedinherited

Definition at line 288 of file fe_test.h.

◆ _fe

std::unique_ptr<FEBase> FETestBase< order, family, elem_type, build_nx, CaseName >::_fe
protectedinherited

Definition at line 289 of file fe_test.h.

◆ _grad_tol

Real FETestBase< order, family, elem_type, build_nx, CaseName >::_grad_tol
protectedinherited

Definition at line 292 of file fe_test.h.

◆ _hess_tol

Real FETestBase< order, family, elem_type, build_nx, CaseName >::_hess_tol
protectedinherited

Definition at line 292 of file fe_test.h.

◆ _mesh

std::unique_ptr<Mesh> FETestBase< order, family, elem_type, build_nx, CaseName >::_mesh
protectedinherited

Definition at line 287 of file fe_test.h.

◆ _nx

unsigned int FETestBase< order, family, elem_type, build_nx, CaseName >::_nx
protectedinherited

Definition at line 283 of file fe_test.h.

◆ _ny

unsigned int FETestBase< order, family, elem_type, build_nx, CaseName >::_ny
protectedinherited

Definition at line 283 of file fe_test.h.

◆ _nz

unsigned int FETestBase< order, family, elem_type, build_nx, CaseName >::_nz
protectedinherited

Definition at line 283 of file fe_test.h.

◆ _past_vertex_offset

Real FETestBase< order, family, elem_type, build_nx, CaseName >::_past_vertex_offset
protectedinherited

The offset, as a fraction of an edge, of the points past the vertices.

Definition at line 295 of file fe_test.h.

◆ _past_vertex_tol_factor

Real FETestBase< order, family, elem_type, build_nx, CaseName >::_past_vertex_tol_factor
protectedinherited

The factor by which the tolerances grow at the points past the vertices.

Definition at line 298 of file fe_test.h.

◆ _qrule

std::unique_ptr<QGauss> FETestBase< order, family, elem_type, build_nx, CaseName >::_qrule
protectedinherited

Definition at line 290 of file fe_test.h.

◆ _sys

System* FETestBase< order, family, elem_type, build_nx, CaseName >::_sys
protectedinherited

Definition at line 286 of file fe_test.h.

◆ _value_tol

Real FETestBase< order, family, elem_type, build_nx, CaseName >::_value_tol
protectedinherited

Definition at line 292 of file fe_test.h.

◆ libmesh_suite_name

std::string FETestBase< order, family, elem_type, build_nx, CaseName >::libmesh_suite_name
protectedinherited

Definition at line 278 of file fe_test.h.


The documentation for this class was generated from the following file: