libMesh
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
FEGLLLagrangeAgreementTest< elem_type, order > Class Template Reference
Inheritance diagram for FEGLLLagrangeAgreementTest< elem_type, order >:
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
Point gll_point (const unsigned int i, const unsigned int dim)
 The interpolation point of Gauss-Lobatto shape function i.
 
unsigned int node_at (const Elem &elem, const Point &q)
 The node of elem whose reference position is q, or invalid_uint if it has none.
 
void testAgreesWithLagrange ()
 

Protected Attributes

std::unique_ptr< Mesh > _mesh
 
std::string libmesh_suite_name
 

Detailed Description

template<ElemType elem_type, Order order>
class FEGLLLagrangeAgreementTest< elem_type, order >

Definition at line 32 of file fe_gll_lagrange_agreement_test.C.

Member Function Documentation

◆ gll_point()

template<ElemType elem_type, Order order>
Point FEGLLLagrangeAgreementTest< elem_type, order >::gll_point ( const unsigned int  i,
const unsigned int  dim 
)
inline

The interpolation point of Gauss-Lobatto shape function i.

Definition at line 56 of file fe_gll_lagrange_agreement_test.C.

57 {
58 const unsigned int n = static_cast<unsigned int>(order) + 1;
59
60 // QGaussLobatto chooses n points for order 2n-3
61 QGaussLobatto rule(1, static_cast<Order>(2*n - 3));
62 rule.init(EDGE2);
63
64 Point q;
65 unsigned int stride = 1;
66
67 for (const auto d : make_range(dim))
68 {
69 q(d) = rule.qp((i / stride) % n)(0);
70 stride *= n;
71 }
72
73 return q;
74 }
unsigned int dim
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
This class implements Gauss-Lobatto quadrature for 1D elements and 2D/3D tensor product elements.
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

References dim, libMesh::EDGE2, libMesh::QBase::init(), libMesh::make_range(), and libMesh::QBase::qp().

Referenced by FEGLLLagrangeAgreementTest< elem_type, order >::testAgreesWithLagrange().

◆ node_at()

template<ElemType elem_type, Order order>
unsigned int FEGLLLagrangeAgreementTest< elem_type, order >::node_at ( const Elem &  elem,
const Point &  q 
)
inline

The node of elem whose reference position is q, or invalid_uint if it has none.

Definition at line 77 of file fe_gll_lagrange_agreement_test.C.

78 {
79 unsigned int found = invalid_uint;
80
81 for (const auto n : elem.node_index_range())
82 if (elem.master_point(n).relative_fuzzy_equals(q, TOLERANCE))
83 {
84 // Each shape function must pair with exactly one node
85 CPPUNIT_ASSERT_EQUAL(invalid_uint, found);
86 found = n;
87 }
88
89 return found;
90 }
bool relative_fuzzy_equals(const T &var1, const T2 &var2, const Real tol=TOLERANCE *TOLERANCE)
Function to check whether two variables are equal within a relative tolerance.
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
static constexpr Real TOLERANCE

References libMesh::invalid_uint, libMesh::Elem::master_point(), libMesh::Elem::node_index_range(), libMesh::TypeVector< T >::relative_fuzzy_equals(), and libMesh::TOLERANCE.

Referenced by FEGLLLagrangeAgreementTest< elem_type, order >::testAgreesWithLagrange().

◆ setUp()

template<ElemType elem_type, Order order>
void FEGLLLagrangeAgreementTest< elem_type, order >::setUp ( )
inline

Definition at line 39 of file fe_gll_lagrange_agreement_test.C.

40 {
41 _mesh = std::make_unique<Mesh>(*TestCommWorld);
42
43 const unsigned int dim = Elem::type_to_dim_map[elem_type];
44
45 if (dim == 1)
46 MeshTools::Generation::build_line(*_mesh, 1, 0., 1., elem_type);
47 else if (dim == 2)
48 MeshTools::Generation::build_square(*_mesh, 1, 1, 0., 1., 0., 1., elem_type);
49 else
50 MeshTools::Generation::build_cube(*_mesh, 1, 1, 1, 0., 1., 0., 1., 0., 1., elem_type);
51 }
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
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
void build_line(UnstructuredMesh &mesh, const unsigned int nx, const Real xmin=0., const Real xmax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 1D meshes.
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.

References FEGLLLagrangeAgreementTest< elem_type, order >::_mesh, libMesh::MeshTools::Generation::build_cube(), libMesh::MeshTools::Generation::build_line(), libMesh::MeshTools::Generation::build_square(), dim, TestCommWorld, and libMesh::Elem::type_to_dim_map.

◆ tearDown()

template<ElemType elem_type, Order order>
void FEGLLLagrangeAgreementTest< elem_type, order >::tearDown ( )
inline

◆ testAgreesWithLagrange()

template<ElemType elem_type, Order order>
void FEGLLLagrangeAgreementTest< elem_type, order >::testAgreesWithLagrange ( )
inline

Definition at line 92 of file fe_gll_lagrange_agreement_test.C.

93 {
94 LOG_UNIT_TEST;
95
96 const unsigned int dim = Elem::type_to_dim_map[elem_type];
97
98 const FEType gll_type(order, L2_LAGRANGE_GLL);
99 const FEType lagrange_type(order, LAGRANGE);
100
101 // Sample on a grid spread over the reference element, so that most points lie between
102 // the interpolation points
103 std::vector<Point> samples;
104 for (const auto a : make_range(-3, 4))
105 for (const auto b : make_range(-3, 4))
106 for (const auto c : make_range(-3, 4))
107 samples.emplace_back(a/7., (dim > 1) ? b/7. : 0., (dim > 2) ? c/7. : 0.);
108
109 unsigned int n_paired = 0;
110
111 for (const auto * elem : _mesh->active_local_element_ptr_range())
112 {
113 const unsigned int n_gll = FEInterface::n_shape_functions(gll_type, elem);
114 const unsigned int n_lag = FEInterface::n_shape_functions(lagrange_type, elem);
115
116 // The two bases span the same space here, so their sizes match
117 CPPUNIT_ASSERT_EQUAL(n_lag, n_gll);
118
119 for (const auto i : make_range(n_gll))
120 {
121 const unsigned int n = node_at(*elem, gll_point(i, dim));
122 CPPUNIT_ASSERT(n != invalid_uint);
123
124 for (const Point & q : samples)
125 LIBMESH_ASSERT_FP_EQUAL(FEInterface::shape(lagrange_type, elem, n, q),
126 FEInterface::shape(gll_type, elem, i, q),
128
129 ++n_paired;
130 }
131 }
132
133 _mesh->comm().sum(n_paired);
134 CPPUNIT_ASSERT(n_paired > 0);
135 }
unsigned int node_at(const Elem &elem, const Point &q)
The node of elem whose reference position is q, or invalid_uint if it has none.
Point gll_point(const unsigned int i, const unsigned int dim)
The interpolation point of Gauss-Lobatto shape function i.
This class provides an encapsulated access to all static public member functions of finite element cl...
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition fe_type.h:197
static const Real b

References FEGLLLagrangeAgreementTest< elem_type, order >::_mesh, b, dim, FEGLLLagrangeAgreementTest< elem_type, order >::gll_point(), libMesh::invalid_uint, libMesh::L2_LAGRANGE_GLL, libMesh::LAGRANGE, libMesh::make_range(), libMesh::FEInterface::n_shape_functions(), FEGLLLagrangeAgreementTest< elem_type, order >::node_at(), libMesh::FEInterface::shape(), libMesh::TOLERANCE, and libMesh::Elem::type_to_dim_map.

Member Data Documentation

◆ _mesh

template<ElemType elem_type, Order order>
std::unique_ptr<Mesh> FEGLLLagrangeAgreementTest< elem_type, order >::_mesh
protected

◆ libmesh_suite_name

template<ElemType elem_type, Order order>
std::string FEGLLLagrangeAgreementTest< elem_type, order >::libmesh_suite_name
protected

Definition at line 36 of file fe_gll_lagrange_agreement_test.C.


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