libMesh
Public Member Functions | List of all members
PointLocatorTest Class Reference
Inheritance diagram for PointLocatorTest:
[legend]

Public Member Functions

 CPPUNIT_TEST_SUITE (PointLocatorTest)
 
 CPPUNIT_TEST (testLocatorOnEdge3)
 
 CPPUNIT_TEST (testLocatorOnQuad9)
 
 CPPUNIT_TEST (testLocatorOnTri6)
 
 CPPUNIT_TEST (testLocatorOnHex27)
 
 CPPUNIT_TEST_SUITE_END ()
 
void setUp ()
 
void tearDown ()
 
void testLocator (const ElemType elem_type)
 
void testLocatorOnEdge3 ()
 
void testLocatorOnQuad9 ()
 
void testLocatorOnTri6 ()
 
void testLocatorOnHex27 ()
 

Detailed Description

Definition at line 15 of file point_locator_test.C.

Member Function Documentation

◆ CPPUNIT_TEST() [1/4]

PointLocatorTest::CPPUNIT_TEST ( testLocatorOnEdge3  )

◆ CPPUNIT_TEST() [2/4]

PointLocatorTest::CPPUNIT_TEST ( testLocatorOnHex27  )

◆ CPPUNIT_TEST() [3/4]

PointLocatorTest::CPPUNIT_TEST ( testLocatorOnQuad9  )

◆ CPPUNIT_TEST() [4/4]

PointLocatorTest::CPPUNIT_TEST ( testLocatorOnTri6  )

◆ CPPUNIT_TEST_SUITE()

PointLocatorTest::CPPUNIT_TEST_SUITE ( PointLocatorTest  )

◆ CPPUNIT_TEST_SUITE_END()

PointLocatorTest::CPPUNIT_TEST_SUITE_END ( )

◆ setUp()

void PointLocatorTest::setUp ( )
inline

Definition at line 33 of file point_locator_test.C.

34  {}

◆ tearDown()

void PointLocatorTest::tearDown ( )
inline

Definition at line 36 of file point_locator_test.C.

37  {}

◆ testLocator()

void PointLocatorTest::testLocator ( const ElemType  elem_type)
inline

Definition at line 39 of file point_locator_test.C.

40  {
42 
43  const unsigned int n_elem_per_side = 5;
44  const std::unique_ptr<Elem> test_elem = Elem::build(elem_type);
45  const unsigned int ymax = test_elem->dim() > 1;
46  const unsigned int zmax = test_elem->dim() > 2;
47  const unsigned int ny = ymax * n_elem_per_side;
48  const unsigned int nz = zmax * n_elem_per_side;
49 
51  n_elem_per_side,
52  ny,
53  nz,
54  0., 1.,
55  0., ymax,
56  0., zmax,
57  elem_type);
58 
59  std::unique_ptr<PointLocatorBase> locator = mesh.sub_point_locator();
60 
61  if (!mesh.is_serial())
62  locator->enable_out_of_mesh_mode();
63 
64  for (unsigned int i=0; i != n_elem_per_side+1; ++i)
65  {
66  for (unsigned int j=0; j != ny+1; ++j)
67  {
68  for (unsigned int k=0; k != nz+1; ++k)
69  {
70  const libMesh::Real h = libMesh::Real(1)/n_elem_per_side;
71  Point p(i*h, j*h, k*h);
72 
73  const Elem *elem = locator->operator()(p);
74 
75  bool found_elem = elem;
76  if (!mesh.is_serial())
77  mesh.comm().max(found_elem);
78 
79  CPPUNIT_ASSERT(found_elem);
80  if (elem)
81  {
82  CPPUNIT_ASSERT(elem->contains_point(p));
83  }
84 
85  const Node *node = locator->locate_node(p);
86 
87  bool found_node = node;
88  if (!mesh.is_serial())
89  mesh.comm().max(found_node);
90 
91  CPPUNIT_ASSERT(found_node);
92 
93  if (node)
94  {
95  LIBMESH_ASSERT_FP_EQUAL((*node)(0), i*h,
97  if (LIBMESH_DIM > 1)
98  LIBMESH_ASSERT_FP_EQUAL((*node)(1), j*h,
100  if (LIBMESH_DIM > 2)
101  LIBMESH_ASSERT_FP_EQUAL((*node)(2), k*h,
103  }
104  }
105  }
106  }
107  }

References libMesh::Elem::build(), libMesh::MeshTools::Generation::build_cube(), libMesh::ParallelObject::comm(), libMesh::Elem::contains_point(), libMesh::MeshBase::is_serial(), mesh, libMesh::Real, libMesh::MeshBase::sub_point_locator(), TestCommWorld, and libMesh::TOLERANCE.

◆ testLocatorOnEdge3()

void PointLocatorTest::testLocatorOnEdge3 ( )
inline

Definition at line 111 of file point_locator_test.C.

111 { testLocator(EDGE3); }

References libMesh::EDGE3.

◆ testLocatorOnHex27()

void PointLocatorTest::testLocatorOnHex27 ( )
inline

Definition at line 114 of file point_locator_test.C.

114 { testLocator(HEX27); }

References libMesh::HEX27.

◆ testLocatorOnQuad9()

void PointLocatorTest::testLocatorOnQuad9 ( )
inline

Definition at line 112 of file point_locator_test.C.

112 { testLocator(QUAD9); }

References libMesh::QUAD9.

◆ testLocatorOnTri6()

void PointLocatorTest::testLocatorOnTri6 ( )
inline

Definition at line 113 of file point_locator_test.C.

113 { testLocator(TRI6); }

References libMesh::TRI6.


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::MeshBase::is_serial
virtual bool is_serial() const
Definition: mesh_base.h:159
libMesh::Elem::contains_point
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition: elem.C:2094
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
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::HEX27
Definition: enum_elem_type.h:49
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::Node
A Node is like a Point, but with more information.
Definition: node.h:52
libMesh::TRI6
Definition: enum_elem_type.h:40
libMesh::MeshBase::sub_point_locator
std::unique_ptr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:672
libMesh::EDGE3
Definition: enum_elem_type.h:36
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::QUAD9
Definition: enum_elem_type.h:43
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
PointLocatorTest::testLocator
void testLocator(const ElemType elem_type)
Definition: point_locator_test.C:39