42 {
44
45 const unsigned int n_elem_per_side = 5;
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;
51
53 n_elem_per_side,
54 ny,
55 nz,
56 0., 1.,
57 0., ymax,
58 0., zmax,
59 elem_type);
60
62
63
64
66#if defined(LIBMESH_ENABLE_EXCEPTIONS) && !defined(NDEBUG)
67 auto test_exception = [&locator, p]()
68 {
69 bool threw_desired_exception = false;
70 try {
71 locator->operator()(p);
72 }
74 std::regex msg_regex("out_of_mesh_mode");
75 CPPUNIT_ASSERT(std::regex_search(e.what(), msg_regex));
76 threw_desired_exception = true;
77 }
78 catch (...) {
79 CPPUNIT_ASSERT_MESSAGE("Unexpected exception type thrown", false);
80 }
81 CPPUNIT_ASSERT(threw_desired_exception);
82 };
83 test_exception();
84#endif
85
87 locator->enable_out_of_mesh_mode();
88
89 for (unsigned int i=0; i != n_elem_per_side+1; ++i)
90 {
91 for (unsigned int j=0; j != ny+1; ++j)
92 {
93 for (unsigned int k=0; k != nz+1; ++k)
94 {
96 Point p(i*h, j*h, k*h);
97
98 const Elem *elem = locator->operator()(p);
99
100 bool found_elem = elem;
103
104 CPPUNIT_ASSERT(found_elem);
105 if (elem)
106 {
108 }
109
110 const Node *node = locator->locate_node(p);
111
112 bool found_node = node;
115
116 CPPUNIT_ASSERT(found_node);
117
118 if (node)
119 {
120 LIBMESH_ASSERT_FP_EQUAL(i*h, (*node)(0),
122 if (LIBMESH_DIM > 1)
123 LIBMESH_ASSERT_FP_EQUAL(j*h, (*node)(1),
125 if (LIBMESH_DIM > 2)
126 LIBMESH_ASSERT_FP_EQUAL(k*h, (*node)(2),
128 }
129 }
130 }
131 }
132
133
134
135 locator->enable_out_of_mesh_mode();
136 const Elem *elem = locator->operator()(p);
137 CPPUNIT_ASSERT(!elem);
138
139
140 locator->disable_out_of_mesh_mode();
141#if defined(LIBMESH_ENABLE_EXCEPTIONS) && !defined(NDEBUG)
142 test_exception();
143#endif
144
145 locator->clear();
146 CPPUNIT_ASSERT(!locator->initialized());
147
148 locator->init();
149 CPPUNIT_ASSERT(locator->initialized());
150
151 locator->set_close_to_point_tol(1e-1);
153 const Elem *elem2 = locator->operator()(p2);
154 bool found_elem = elem2;
157
158 CPPUNIT_ASSERT(found_elem);
159 }
void max(const T &r, T &o, Request &req) const
This is the base class from which all geometric element types are derived.
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
A class to represent the internal "this should never happen" errors, to be thrown by "libmesh_error()...
virtual bool is_serial() const
std::unique_ptr< PointLocatorBase > sub_point_locator() const
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
A Node is like a Point, but with more information.
const Parallel::Communicator & comm() const
A Point defines a location in LIBMESH_DIM dimensional Real space.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real