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 24 of file elem_test.C.

Member Function Documentation

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

Definition at line 30 of file elem_test.C.

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

31  {
32  const Real minpos = 1.5, maxpos = 5.5;
33  const unsigned int N = 2;
34 
35  _mesh = new Mesh(*TestCommWorld);
36  const UniquePtr<Elem> test_elem = Elem::build(elem_type);
37  const unsigned int dim = test_elem->dim();
38  const unsigned int use_y = dim > 1;
39  const unsigned int use_z = dim > 2;
40 
42  N, N*use_y, N*use_z,
43  minpos, maxpos,
44  minpos, use_y*maxpos,
45  minpos, use_z*maxpos,
46  elem_type);
47  }
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
unsigned int dim
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Mesh * _mesh
Definition: elem_test.C:27
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
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.
template<ElemType elem_type>
void ElemTest< elem_type >::tearDown ( )

Definition at line 49 of file elem_test.C.

50  {
51  delete _mesh;
52  }
Mesh * _mesh
Definition: elem_test.C:27
template<ElemType elem_type>
void ElemTest< elem_type >::test_bounding_box ( )

Definition at line 54 of file elem_test.C.

References libMesh::DistributedMesh::active_local_elements_begin(), libMesh::DistributedMesh::active_local_elements_end(), libMesh::Elem::centroid(), libMesh::BoundingBox::contains_point(), libMesh::EDGE2, libMesh::EDGE3, libMesh::EDGE4, libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, INSTANTIATE_ELEMTEST(), libMesh::Elem::loose_bounding_box(), libMesh::Elem::n_nodes(), libMesh::Elem::point(), libMesh::PRISM15, libMesh::PRISM18, libMesh::PRISM6, libMesh::PYRAMID13, libMesh::PYRAMID14, libMesh::PYRAMID5, libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::Real, libMesh::TET10, libMesh::TET4, libMesh::TRI3, and libMesh::TRI6.

55  {
58  elem_end = _mesh->active_local_elements_end();
59  for (; elem_it != elem_end; ++elem_it)
60  {
61  const Elem & elem = **elem_it;
62 
63  const BoundingBox bbox = elem.loose_bounding_box();
64 
65  const Point centroid = elem.centroid();
66 
67  // The "loose" bounding box should actually be pretty tight
68  // in most of these cases, but for weirdly aligned triangles
69  // (such as occur in pyramid elements) it won't be, so we'll
70  // just test against a widened bounding box.
71  BoundingBox wide_bbox(elem.point(0), elem.point(0));
72 
73  for (unsigned int n = 0; n != elem.n_nodes(); ++n)
74  {
75  const Point & p = elem.point(n);
76 
77  CPPUNIT_ASSERT(bbox.contains_point(p));
78 
79  wide_bbox.union_with
80  (BoundingBox(elem.point(n), elem.point(n)));
81  }
82 
83  for (unsigned int d=0; d != LIBMESH_DIM; ++d)
84  {
85  const Real widening =
86  (wide_bbox.max()(d) - wide_bbox.min()(d)) / 3;
87  wide_bbox.min()(d) -= widening;
88  wide_bbox.max()(d) += widening;
89  }
90 
91  CPPUNIT_ASSERT(!bbox.contains_point(wide_bbox.min()));
92  CPPUNIT_ASSERT(!bbox.contains_point(wide_bbox.max()));
93  }
94  }
virtual element_iterator active_local_elements_begin() libmesh_override
bool contains_point(const Point &) const
Definition: bounding_box.C:73
The definition of the const_element_iterator struct.
Definition: mesh_base.h:1494
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
virtual element_iterator active_local_elements_end() libmesh_override
virtual unsigned int n_nodes() const =0
Defines a Cartesian bounding box by the two corner extremum.
Definition: bounding_box.h:40
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Point & point(const unsigned int i) const
Definition: elem.h:1809
virtual Point centroid() const
Definition: elem.C:446
Mesh * _mesh
Definition: elem_test.C:27
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
virtual BoundingBox loose_bounding_box() const
Definition: elem.C:2997

Member Data Documentation

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

Definition at line 27 of file elem_test.C.


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