libMesh
Public Member Functions | Private Attributes | List of all members
ElemTest< elem_type > Class Template Reference
Inheritance diagram for ElemTest< elem_type >:
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_bounding_box ()
 

Private Attributes

Mesh_mesh
 

Detailed Description

template<ElemType elem_type>
class ElemTest< elem_type >

Definition at line 13 of file elem_test.C.

Member Function Documentation

◆ setUp()

template<ElemType elem_type>
void ElemTest< elem_type >::setUp ( )
inline

Definition at line 19 of file elem_test.C.

20  {
21  const Real minpos = 1.5, maxpos = 5.5;
22  const unsigned int N = 2;
23 
24  _mesh = new Mesh(*TestCommWorld);
25  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
26  const unsigned int dim = test_elem->dim();
27  const unsigned int use_y = dim > 1;
28  const unsigned int use_z = dim > 2;
29 
31  N, N*use_y, N*use_z,
32  minpos, maxpos,
33  minpos, use_y*maxpos,
34  minpos, use_z*maxpos,
35  elem_type);
36  }

References libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), dim, libMesh::Real, and TestCommWorld.

◆ tearDown()

template<ElemType elem_type>
void ElemTest< elem_type >::tearDown ( )
inline

Definition at line 38 of file elem_test.C.

39  {
40  delete _mesh;
41  }

◆ test_bounding_box()

template<ElemType elem_type>
void ElemTest< elem_type >::test_bounding_box ( )
inline

Definition at line 43 of file elem_test.C.

44  {
45  for (const auto & elem : _mesh->active_local_element_ptr_range())
46  {
47  const BoundingBox bbox = elem->loose_bounding_box();
48 
49  const Point centroid = elem->centroid();
50 
51  // The "loose" bounding box should actually be pretty tight
52  // in most of these cases, but for weirdly aligned triangles
53  // (such as occur in pyramid elements) it won't be, so we'll
54  // just test against a widened bounding box.
55  BoundingBox wide_bbox(elem->point(0), elem->point(0));
56 
57  for (unsigned int n = 0; n != elem->n_nodes(); ++n)
58  {
59  const Point & p = elem->point(n);
60 
61  CPPUNIT_ASSERT(bbox.contains_point(p));
62 
63  wide_bbox.union_with
64  (BoundingBox(elem->point(n), elem->point(n)));
65  }
66 
67  for (unsigned int d=0; d != LIBMESH_DIM; ++d)
68  {
69  const Real widening =
70  (wide_bbox.max()(d) - wide_bbox.min()(d)) / 3;
71  wide_bbox.min()(d) -= widening;
72  wide_bbox.max()(d) += widening;
73  }
74 
75  CPPUNIT_ASSERT(!bbox.contains_point(wide_bbox.min()));
76  CPPUNIT_ASSERT(!bbox.contains_point(wide_bbox.max()));
77  }
78  }

References libMesh::DistributedMesh::active_local_element_ptr_range(), libMesh::BoundingBox::contains_point(), and libMesh::Real.

Member Data Documentation

◆ _mesh

template<ElemType elem_type>
Mesh* ElemTest< elem_type >::_mesh
private

Definition at line 16 of file elem_test.C.


The documentation for this class was generated from the following file:
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
libMesh::DistributedMesh::active_local_element_ptr_range
virtual SimpleRange< element_iterator > active_local_element_ptr_range() override
Definition: distributed_mesh.h:372
ElemTest::_mesh
Mesh * _mesh
Definition: elem_test.C:16
libMesh::BoundingBox
Defines a Cartesian bounding box by the two corner extremum.
Definition: bounding_box.h:40
libMesh::MeshTools::Generation::build_cube
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.
Definition: mesh_generation.C:298
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
TestCommWorld
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:111
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::BoundingBox::contains_point
bool contains_point(const Point &) const
Definition: bounding_box.C:135
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121