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 28 of file point_locator_test.C.

Member Function Documentation

PointLocatorTest::CPPUNIT_TEST ( testLocatorOnEdge3  )
PointLocatorTest::CPPUNIT_TEST ( testLocatorOnQuad9  )
PointLocatorTest::CPPUNIT_TEST ( testLocatorOnTri6  )
PointLocatorTest::CPPUNIT_TEST ( testLocatorOnHex27  )
PointLocatorTest::CPPUNIT_TEST_SUITE ( PointLocatorTest  )
PointLocatorTest::CPPUNIT_TEST_SUITE_END ( )
void PointLocatorTest::setUp ( )

Definition at line 42 of file point_locator_test.C.

43  {}
void PointLocatorTest::tearDown ( )

Definition at line 45 of file point_locator_test.C.

46  {}
void PointLocatorTest::testLocator ( const ElemType  elem_type)

Definition at line 48 of file point_locator_test.C.

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

49  {
51 
52  const unsigned n_elem_per_side = 5;
53  const UniquePtr<Elem> test_elem = Elem::build(elem_type);
54  const Real ymax = test_elem->dim() > 1;
55  const Real zmax = test_elem->dim() > 2;
56  const unsigned int ny = ymax * n_elem_per_side;
57  const unsigned int nz = zmax * n_elem_per_side;
58 
60  n_elem_per_side,
61  ny,
62  nz,
63  0., 1.,
64  0., ymax,
65  0., zmax,
66  elem_type);
67 
69 
70  if (!mesh.is_serial())
71  locator->enable_out_of_mesh_mode();
72 
73  for (unsigned int i=0; i != n_elem_per_side+1; ++i)
74  {
75  for (unsigned int j=0; j != ny+1; ++j)
76  {
77  for (unsigned int k=0; k != nz+1; ++k)
78  {
79  const libMesh::Real h = libMesh::Real(1)/n_elem_per_side;
80  Point p(i*h, j*h, k*h);
81 
82  const Elem *elem = locator->operator()(p);
83 
84  bool found_elem = elem;
85  if (!mesh.is_serial())
86  mesh.comm().max(found_elem);
87 
88  CPPUNIT_ASSERT(found_elem);
89  if (elem)
90  {
91  CPPUNIT_ASSERT(elem->contains_point(p));
92  }
93 
94  const Node *node = locator->locate_node(p);
95 
96  bool found_node = node;
97  if (!mesh.is_serial())
98  mesh.comm().max(found_node);
99 
100  CPPUNIT_ASSERT(found_node);
101 
102  if (node)
103  {
104  CPPUNIT_ASSERT_DOUBLES_EQUAL((*node)(0), i*h,
106  CPPUNIT_ASSERT_DOUBLES_EQUAL((*node)(1), j*h,
108  CPPUNIT_ASSERT_DOUBLES_EQUAL((*node)(2), k*h,
110  }
111  }
112  }
113  }
114  }
A Node is like a Point, but with more information.
Definition: node.h:52
virtual bool is_serial() const
Definition: mesh_base.h:140
void max(T &r) const
Take a local variable and replace it with the maximum of it&#39;s values on all processors.
libMesh::Parallel::Communicator * TestCommWorld
Definition: driver.C:28
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
MeshBase & mesh
static const Real TOLERANCE
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Parallel::Communicator & comm() const
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
UniquePtr< PointLocatorBase > sub_point_locator() const
Definition: mesh_base.C:534
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.
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition: elem.C:2448
void PointLocatorTest::testLocatorOnEdge3 ( )

Definition at line 118 of file point_locator_test.C.

References libMesh::EDGE3.

118 { testLocator(EDGE3); }
void testLocator(const ElemType elem_type)
void PointLocatorTest::testLocatorOnHex27 ( )

Definition at line 121 of file point_locator_test.C.

References CPPUNIT_TEST_SUITE_REGISTRATION(), and libMesh::HEX27.

121 { testLocator(HEX27); }
void testLocator(const ElemType elem_type)
void PointLocatorTest::testLocatorOnQuad9 ( )

Definition at line 119 of file point_locator_test.C.

References libMesh::QUAD9.

119 { testLocator(QUAD9); }
void testLocator(const ElemType elem_type)
void PointLocatorTest::testLocatorOnTri6 ( )

Definition at line 120 of file point_locator_test.C.

References libMesh::TRI6.

120 { testLocator(TRI6); }
void testLocator(const ElemType elem_type)

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