17#include <libmesh/elem.h>
18#include <libmesh/enum_fe_family.h>
19#include <libmesh/enum_order.h>
20#include <libmesh/fe_base.h>
21#include <libmesh/fe_type.h>
22#include <libmesh/int_range.h>
23#include <libmesh/libmesh_common.h>
24#include <libmesh/mesh.h>
25#include <libmesh/mesh_generation.h>
26#include <libmesh/node.h>
27#include <libmesh/parallel_implementation.h>
28#include <libmesh/quadrature.h>
29#include <libmesh/quadrature_nodal.h>
40template <FEFamily family, ElemType elem_type, Order order>
59 MeshTools::Generation::build_cube(*
_mesh, 2, 2, 2, 0., 1., 0., 1., 0., 1., elem_type);
62 for (
auto * node :
_mesh->node_ptr_range())
65 const Real y = (LIBMESH_DIM > 1) ? p(1) : 0.;
66 const Real z = (LIBMESH_DIM > 2) ? p(2) : 0.;
68 p(0) += 0.3 * y + 0.17 * z;
82 return std::make_unique<QNodal>(
dim);
96 std::vector<unsigned int>
99 std::vector<unsigned int> shape_qp(phi.size(),
invalid_uint);
103 std::vector<bool> qp_claimed(phi.size(),
false);
108 CPPUNIT_ASSERT_EQUAL(phi.size(), phi[i].size());
111 if (std::abs(phi[i][q] - 1) <=
tol)
117 LIBMESH_ASSERT_FP_EQUAL(
Real(0), phi[i][q],
tol);
120 CPPUNIT_ASSERT(!qp_claimed[shape_qp[i]]);
121 qp_claimed[shape_qp[i]] =
true;
131 const FEType fe_type(order, family);
136 fe->attach_quadrature_rule(qrule.get());
139 const std::vector<std::vector<Real>> & phi = fe->get_phi();
141 unsigned int n_elem = 0;
143 for (
const auto * elem :
_mesh->active_local_element_ptr_range())
151 CPPUNIT_ASSERT_EQUAL(cast_int<unsigned int>(i), shape_qp[i]);
156 _mesh->comm().sum(n_elem);
157 CPPUNIT_ASSERT(n_elem > 0);
164 const FEType fe_type(order, family);
169 fe->attach_quadrature_rule(qrule.get());
171 const std::vector<std::vector<Real>> & phi = fe->get_phi();
172 const std::vector<Real> & JxW = fe->get_JxW();
174 for (
const auto * elem :
_mesh->active_local_element_ptr_range())
178 const std::size_t n_dofs = phi.size();
186 m += JxW[q] * phi[i][q] * phi[j][q];
192 CPPUNIT_ASSERT(m > 0.);
196 LIBMESH_ASSERT_FP_EQUAL(
Real(0), m,
tol);
202#define INSTANTIATE_FECOLLOCATIONTEST(family, elemtype, order) \
203 class FECollocationTest_##family##_##order##_##elemtype : \
204 public FECollocationTest<family, elemtype, order> { \
206 FECollocationTest_##family##_##order##_##elemtype() : \
207 FECollocationTest<family, elemtype, order>() { \
208 if (unitlog->summarized_logs_enabled()) \
209 this->libmesh_suite_name = "FECollocationTest"; \
211 this->libmesh_suite_name = \
212 "FECollocationTest_" #family "_" #order "_" #elemtype; \
214 CPPUNIT_TEST_SUITE( FECollocationTest_##family##_##order##_##elemtype ); \
215 CPPUNIT_TEST( testShapesArePermutation ); \
216 CPPUNIT_TEST( testMassMatrixIsDiagonal ); \
217 CPPUNIT_TEST_SUITE_END(); \
220 CPPUNIT_TEST_SUITE_REGISTRATION( FECollocationTest_##family##_##order##_##elemtype )
void testShapesArePermutation()
std::vector< unsigned int > collocation_points(const std::vector< std::vector< Real > > &phi)
std::unique_ptr< Mesh > _mesh
static constexpr bool gll
Whether the family is one of the Gauss-Lobatto nodal families.
static constexpr Real tol
The tolerance on shape function values at the collocation points.
std::string libmesh_suite_name
void testMassMatrixIsDiagonal()
std::unique_ptr< QBase > collocated_rule(const FEType &fe_type, const unsigned int dim)
The quadrature rule collocated with the basis.
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...
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...
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
A Node is like a Point, but with more information.
Communicator * TestCommWorld
INSTANTIATE_FECOLLOCATIONTEST(L2_LAGRANGE_GLL, EDGE2, FIRST)
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
static constexpr Real TOLERANCE
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...