libMesh
Public Member Functions | Private Attributes | List of all members
DualShapeTest Class Reference

This class is for unit testing dual coefficient and shape function values. More...

Inheritance diagram for DualShapeTest:
[legend]

Public Member Functions

 LIBMESH_CPPUNIT_TEST_SUITE (DualShapeTest)
 
 CPPUNIT_TEST (testEdge2Lagrange)
 
 CPPUNIT_TEST_SUITE_END ()
 
void testEdge2Lagrange ()
 
void setUp ()
 
void tearDown ()
 

Private Attributes

std::unique_ptr< Mesh_mesh
 
std::unique_ptr< QGauss_qrule
 
std::unique_ptr< FEBase_fe
 
Elem_elem
 

Detailed Description

This class is for unit testing dual coefficient and shape function values.

Definition at line 19 of file dual_shape_verification_test.C.

Member Function Documentation

◆ CPPUNIT_TEST()

DualShapeTest::CPPUNIT_TEST ( testEdge2Lagrange  )

◆ CPPUNIT_TEST_SUITE_END()

DualShapeTest::CPPUNIT_TEST_SUITE_END ( )

◆ LIBMESH_CPPUNIT_TEST_SUITE()

DualShapeTest::LIBMESH_CPPUNIT_TEST_SUITE ( DualShapeTest  )

◆ setUp()

void DualShapeTest::setUp ( )
inline

Definition at line 74 of file dual_shape_verification_test.C.

References libMesh::FEGenericBase< OutputType >::build(), libMesh::MeshTools::Generation::build_line(), libMesh::FEType::default_quadrature_order(), libMesh::EDGE2, libMesh::FIRST, and libMesh::LAGRANGE.

75  {
76  FEType fe_type(FIRST, LAGRANGE);
77  _fe = FEBase::build(1, fe_type);
78  _fe->get_phi();
79  _fe->get_dual_phi();
80 
81  _mesh = std::make_unique<Mesh>(*TestCommWorld);
82 
84 
85  auto rng = _mesh->active_local_element_ptr_range();
86  _elem = rng.begin() == rng.end() ? nullptr : *(rng.begin());
87 
88  _qrule = std::make_unique<QGauss>(1, fe_type.default_quadrature_order());
89  _fe->attach_quadrature_rule(_qrule.get());
90  }
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:196
std::unique_ptr< QGauss > _qrule
std::unique_ptr< Mesh > _mesh
std::unique_ptr< FEBase > _fe
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.

◆ tearDown()

void DualShapeTest::tearDown ( )
inline

Definition at line 92 of file dual_shape_verification_test.C.

92 {}

◆ testEdge2Lagrange()

void DualShapeTest::testEdge2Lagrange ( )
inline

Definition at line 34 of file dual_shape_verification_test.C.

References libMesh::index_range(), libMesh::DenseMatrixBase< T >::m(), libMesh::DenseMatrixBase< T >::n(), libMesh::Real, and libMesh::TOLERANCE.

35  {
36  LOG_UNIT_TEST;
37  if (!_elem)
38  return;
39 
40  _fe->reinit(_elem);
41 
42  const DenseMatrix<Real> & dual_coeff = _fe->get_dual_coeff();
43 
44  CPPUNIT_ASSERT_EQUAL(dual_coeff.m(), unsigned(2));
45  CPPUNIT_ASSERT_EQUAL(dual_coeff.n(), unsigned(2));
46 
47  // TOLERANCE*TOLERANCE works with double but not float128
48  Real my_tol = TOLERANCE*std::sqrt(TOLERANCE);
49 
50  LIBMESH_ASSERT_FP_EQUAL(2, dual_coeff(0,0), my_tol);
51  LIBMESH_ASSERT_FP_EQUAL(-1, dual_coeff(0,1), my_tol);
52  LIBMESH_ASSERT_FP_EQUAL(-1, dual_coeff(1,0), my_tol);
53  LIBMESH_ASSERT_FP_EQUAL(2, dual_coeff(1,1), my_tol);
54 
55  const auto & dual_phi = _fe->get_dual_phi();
56 
57  CPPUNIT_ASSERT_EQUAL(std::size_t(2), dual_phi.size());
58 
59  const auto & qpoints = _qrule->get_points();
60 
61  CPPUNIT_ASSERT_EQUAL(qpoints.size(), dual_phi[0].size());
62 
63  for (auto qp : index_range(dual_phi[0]))
64  LIBMESH_ASSERT_FP_EQUAL(1./2. * (1. - 3.*qpoints[qp](0)), dual_phi[0][qp],
65  my_tol);
66 
67  CPPUNIT_ASSERT_EQUAL(qpoints.size(), dual_phi[1].size());
68 
69  for (auto qp : index_range(dual_phi[1]))
70  LIBMESH_ASSERT_FP_EQUAL(1./2. * (1. + 3.*qpoints[qp](0)), dual_phi[1][qp],
71  my_tol);
72  }
static constexpr Real TOLERANCE
unsigned int m() const
std::unique_ptr< QGauss > _qrule
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::unique_ptr< FEBase > _fe
unsigned int n() const
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:117

Member Data Documentation

◆ _elem

Elem* DualShapeTest::_elem
private

Definition at line 30 of file dual_shape_verification_test.C.

◆ _fe

std::unique_ptr<FEBase> DualShapeTest::_fe
private

Definition at line 29 of file dual_shape_verification_test.C.

◆ _mesh

std::unique_ptr<Mesh> DualShapeTest::_mesh
private

Definition at line 27 of file dual_shape_verification_test.C.

◆ _qrule

std::unique_ptr<QGauss> DualShapeTest::_qrule
private

Definition at line 28 of file dual_shape_verification_test.C.


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