45 const unsigned int n_elem_per_side = 5;
46 const unsigned int dim = Elem::type_to_dim_map[elem_type];
47 const unsigned int ymax =
dim > 1;
48 const unsigned int zmax =
dim > 2;
49 const unsigned int ny = ymax * n_elem_per_side;
50 const unsigned int nz = zmax * n_elem_per_side;
66 #if defined(LIBMESH_ENABLE_EXCEPTIONS) && !defined(NDEBUG) 67 auto test_exception = [&locator, p]()
69 bool threw_desired_exception =
false;
71 locator->operator()(p);
74 std::regex msg_regex(
"out_of_mesh_mode");
75 CPPUNIT_ASSERT(std::regex_search(e.what(), msg_regex));
76 threw_desired_exception =
true;
79 CPPUNIT_ASSERT_MESSAGE(
"Unexpected exception type thrown",
false);
81 CPPUNIT_ASSERT(threw_desired_exception);
87 locator->enable_out_of_mesh_mode();
89 for (
unsigned int i=0; i != n_elem_per_side+1; ++i)
91 for (
unsigned int j=0; j != ny+1; ++j)
93 for (
unsigned int k=0; k != nz+1; ++k)
96 Point p(i*h, j*h, k*h);
98 const Elem *elem = locator->operator()(p);
100 bool found_elem = elem;
104 CPPUNIT_ASSERT(found_elem);
110 const Node *node = locator->locate_node(p);
112 bool found_node = node;
116 CPPUNIT_ASSERT(found_node);
120 LIBMESH_ASSERT_FP_EQUAL(i*h, (*node)(0),
123 LIBMESH_ASSERT_FP_EQUAL(j*h, (*node)(1),
126 LIBMESH_ASSERT_FP_EQUAL(k*h, (*node)(2),
135 locator->enable_out_of_mesh_mode();
136 const Elem *elem = locator->operator()(p);
137 CPPUNIT_ASSERT(!elem);
140 locator->disable_out_of_mesh_mode();
141 #if defined(LIBMESH_ENABLE_EXCEPTIONS) && !defined(NDEBUG) 143 #endif // LIBMESH_ENABLE_EXCEPTIONS 146 CPPUNIT_ASSERT(!locator->initialized());
149 CPPUNIT_ASSERT(locator->initialized());
151 locator->set_close_to_point_tol(1e-1);
153 const Elem *elem2 = locator->operator()(p2);
154 bool found_elem = elem2;
158 CPPUNIT_ASSERT(found_elem);
A Node is like a Point, but with more information.
std::unique_ptr< PointLocatorBase > sub_point_locator() const
libMesh::Parallel::Communicator * TestCommWorld
static constexpr Real TOLERANCE
This is the base class from which all geometric element types are derived.
const Parallel::Communicator & comm() const
virtual bool is_serial() const
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void max(const T &r, T &o, Request &req) const
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Point defines a location in LIBMESH_DIM dimensional Real space.