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

Public Member Functions

void setUp ()
 
void tearDown ()
 
std::unique_ptr< QBase > collocated_rule (const FEType &fe_type, const unsigned int dim)
 The family's default quadrature rule, which is collocated with the basis.
 
void testShapesAreIdentity ()
 
void testMassMatrixIsDiagonal ()
 

Protected Attributes

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

Detailed Description

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

Definition at line 33 of file fe_gll_collocation_test.C.

Member Function Documentation

◆ collocated_rule()

template<ElemType elem_type, Order order>
std::unique_ptr< QBase > FEGLLCollocationTest< elem_type, order >::collocated_rule ( const FEType &  fe_type,
const unsigned int  dim 
)
inline

The family's default quadrature rule, which is collocated with the basis.

Definition at line 69 of file fe_gll_collocation_test.C.

70 {
71 return fe_type.default_quadrature_rule(dim);
72 }
unsigned int dim
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition fe_type.C:35

References libMesh::FEType::default_quadrature_rule(), and dim.

Referenced by FEGLLCollocationTest< elem_type, order >::testMassMatrixIsDiagonal(), and FEGLLCollocationTest< elem_type, order >::testShapesAreIdentity().

◆ setUp()

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

Definition at line 40 of file fe_gll_collocation_test.C.

41 {
42 _mesh = std::make_unique<Mesh>(*TestCommWorld);
43
44 const unsigned int dim = Elem::type_to_dim_map[elem_type];
45
46 if (dim == 1)
47 MeshTools::Generation::build_line(*_mesh, 2, 0., 1., elem_type);
48 else if (dim == 2)
49 MeshTools::Generation::build_square(*_mesh, 2, 2, 0., 1., 0., 1., elem_type);
50 else
51 MeshTools::Generation::build_cube(*_mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1., elem_type);
52
53 // Shear the mesh so that the mapping to each element has off-diagonal Jacobian terms
54 for (auto * node : _mesh->node_ptr_range())
55 {
56 Node & p = *node;
57 const Real y = (LIBMESH_DIM > 1) ? p(1) : 0.;
58 const Real z = (LIBMESH_DIM > 2) ? p(2) : 0.;
59
60 p(0) += 0.3 * y + 0.17 * z;
61 if (LIBMESH_DIM > 1)
62 p(1) += 0.23 * z;
63 }
64 }
std::unique_ptr< Mesh > _mesh
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
A Node is like a Point, but with more information.
Definition node.h:55
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.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

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

◆ tearDown()

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

Definition at line 66 of file fe_gll_collocation_test.C.

66{ _mesh.reset(); }

References FEGLLCollocationTest< elem_type, order >::_mesh.

◆ testMassMatrixIsDiagonal()

template<ElemType elem_type, Order order>
void FEGLLCollocationTest< elem_type, order >::testMassMatrixIsDiagonal ( )
inline

Definition at line 108 of file fe_gll_collocation_test.C.

109 {
110 LOG_UNIT_TEST;
111
112 const FEType fe_type(order, L2_LAGRANGE_GLL);
113 const unsigned int dim = Elem::type_to_dim_map[elem_type];
114
115 std::unique_ptr<FEBase> fe = FEBase::build(dim, fe_type);
116 std::unique_ptr<QBase> qrule = collocated_rule(fe_type, dim);
117 fe->attach_quadrature_rule(qrule.get());
118
119 const std::vector<std::vector<Real>> & phi = fe->get_phi();
120 const std::vector<Real> & JxW = fe->get_JxW();
121
122 for (const auto * elem : _mesh->active_local_element_ptr_range())
123 {
124 fe->reinit(elem);
125
126 const std::size_t n_dofs = phi.size();
127
128 for (const auto i : make_range(n_dofs))
129 for (const auto j : make_range(n_dofs))
130 {
131 Real m = 0.;
132 for (const auto q : index_range(JxW))
133 m += JxW[q] * phi[i][q] * phi[j][q];
134
135 if (i == j)
136 {
137 // Each diagonal entry equals JxW at its own point, which is positive on
138 // a valid element
139 CPPUNIT_ASSERT(m > 0.);
140 LIBMESH_ASSERT_FP_EQUAL(JxW[i], m, TOLERANCE*TOLERANCE);
141 }
142 else
143 CPPUNIT_ASSERT_EQUAL(Real(0), m);
144 }
145 }
146 }
std::unique_ptr< QBase > collocated_rule(const FEType &fe_type, const unsigned int dim)
The family's default quadrature rule, which is collocated with the basis.
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
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
static constexpr Real TOLERANCE
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 FEGLLCollocationTest< elem_type, order >::_mesh, libMesh::FEGenericBase< OutputType >::build(), FEGLLCollocationTest< elem_type, order >::collocated_rule(), dim, libMesh::index_range(), libMesh::L2_LAGRANGE_GLL, libMesh::make_range(), libMesh::Real, libMesh::TOLERANCE, and libMesh::Elem::type_to_dim_map.

◆ testShapesAreIdentity()

template<ElemType elem_type, Order order>
void FEGLLCollocationTest< elem_type, order >::testShapesAreIdentity ( )
inline

Definition at line 74 of file fe_gll_collocation_test.C.

75 {
76 LOG_UNIT_TEST;
77
78 const FEType fe_type(order, L2_LAGRANGE_GLL);
79 const unsigned int dim = Elem::type_to_dim_map[elem_type];
80
81 std::unique_ptr<FEBase> fe = FEBase::build(dim, fe_type);
82 std::unique_ptr<QBase> qrule = collocated_rule(fe_type, dim);
83 fe->attach_quadrature_rule(qrule.get());
84
85 // Request phi before reinit so that reinit computes it
86 const std::vector<std::vector<Real>> & phi = fe->get_phi();
87
88 unsigned int n_elem = 0;
89
90 for (const auto * elem : _mesh->active_local_element_ptr_range())
91 {
92 fe->reinit(elem);
93
94 // The collocated rule has one point per degree of freedom
95 CPPUNIT_ASSERT_EQUAL(phi.size(), std::size_t(qrule->n_points()));
96
97 for (const auto i : index_range(phi))
98 for (const auto q : index_range(phi[i]))
99 CPPUNIT_ASSERT_EQUAL((i == q) ? Real(1) : Real(0), phi[i][q]);
100
101 ++n_elem;
102 }
103
104 _mesh->comm().sum(n_elem);
105 CPPUNIT_ASSERT(n_elem > 0);
106 }
dof_id_type n_elem(const MeshBase::const_element_iterator &begin, const MeshBase::const_element_iterator &end)
Count up the number of elements of a specific type (as defined by an iterator range).

References FEGLLCollocationTest< elem_type, order >::_mesh, libMesh::FEGenericBase< OutputType >::build(), FEGLLCollocationTest< elem_type, order >::collocated_rule(), dim, libMesh::index_range(), libMesh::L2_LAGRANGE_GLL, libMesh::Real, and libMesh::Elem::type_to_dim_map.

Member Data Documentation

◆ _mesh

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

◆ libmesh_suite_name

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

Definition at line 37 of file fe_gll_collocation_test.C.


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