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 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 655 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 990 of file fe_test.h.

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 }
static RealGradient true_gradient(Point p)
Definition fe_test.h:300
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:1667
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 932 of file fe_test.h.

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 }
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
Number fe_quartic_test(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition fe_test.h:169
@ 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 367 of file fe_test.h.

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
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 }
Real _past_vertex_tol_factor
The factor by which the tolerances grow at the points past the vertices.
Definition fe_test.h:297
std::string _case_name
Name of the case, can be used in the test to switch cases.
Definition fe_test.h:280
std::unique_ptr< EquationSystems > _es
Definition fe_test.h:287
Real _past_vertex_offset
The offset, as a fraction of an edge, of the points past the vertices.
Definition fe_test.h:294
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
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: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
static const Real rational_w
Definition fe_test.h:205
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
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).
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 649 of file fe_test.h.

649{}

◆ testCustomReinit()

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

Definition at line 1169 of file fe_test.h.

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 }
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 972 of file fe_test.h.

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 }

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 885 of file fe_test.h.

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 }
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 1025 of file fe_test.h.

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 }

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 1061 of file fe_test.h.

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 }
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 1112 of file fe_test.h.

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 }

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 660 of file fe_test.h.

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 }
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 770 of file fe_test.h.

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 }
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 806 of file fe_test.h.

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 }

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::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 707 of file fe_test.h.

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 }
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 747 of file fe_test.h.

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 }

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

◆ true_gradient()

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

Definition at line 300 of file fe_test.h.

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 }
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 338 of file fe_test.h.

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 }

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 280 of file fe_test.h.

◆ _dim

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

Definition at line 282 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 284 of file fe_test.h.

◆ _elem

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

Definition at line 283 of file fe_test.h.

◆ _es

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

Definition at line 287 of file fe_test.h.

◆ _fe

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

Definition at line 288 of file fe_test.h.

◆ _grad_tol

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

Definition at line 291 of file fe_test.h.

◆ _hess_tol

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

Definition at line 291 of file fe_test.h.

◆ _mesh

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

Definition at line 286 of file fe_test.h.

◆ _nx

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

Definition at line 282 of file fe_test.h.

◆ _ny

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

Definition at line 282 of file fe_test.h.

◆ _nz

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

Definition at line 282 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 294 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 297 of file fe_test.h.

◆ _qrule

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

Definition at line 289 of file fe_test.h.

◆ _sys

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

Definition at line 285 of file fe_test.h.

◆ _value_tol

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

Definition at line 291 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 277 of file fe_test.h.


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