@@ -117,80 +117,102 @@ public:
117
117
elem_type );
118
118
}
119
119
120
- void test_within_edge_on_side ()
120
+ void test_within_edge ()
121
121
{
122
122
LOG_UNIT_TEST ;
123
123
124
- if (_mesh -> mesh_dimension () != 3 )
125
- return ;
124
+ const auto is_3d = _mesh -> mesh_dimension () == 3 ;
126
125
127
126
// check locations at every node
128
127
for (const auto & elem : _mesh -> active_local_element_ptr_range ())
129
- for (const auto s : elem -> side_index_range ())
130
- for (const auto e : elem -> edge_index_range ())
131
- for (const auto n : elem -> nodes_on_edge (e ))
132
- {
133
- ElemCorner corner ;
134
- const auto within = IntersectionTools ::within_edge_on_side (* elem ,
135
- elem -> point (n ),
136
- s ,
137
- corner );
138
-
139
- CPPUNIT_ASSERT_EQUAL (within , elem -> is_node_on_side (n , s ));
140
- if (elem -> is_node_on_side (n , s ))
128
+ for (const auto e : elem -> edge_index_range ())
129
+ for (const auto n : elem -> nodes_on_edge (e ))
130
+ {
131
+ ElemCorner corner ;
132
+ const auto within = IntersectionTools ::within_edge (* elem , elem -> point (n ), corner );
133
+ CPPUNIT_ASSERT (within );
134
+
135
+ if (is_3d )
136
+ for (const auto s : elem -> side_index_range ())
141
137
{
142
- CPPUNIT_ASSERT_EQUAL (elem -> is_vertex (n ), corner .at_vertex (n ));
143
- CPPUNIT_ASSERT_EQUAL (elem -> is_vertex (n ), !corner .at_edge (* elem , e ));
138
+ ElemCorner corner_on_side ;
139
+ const auto within_on_side = IntersectionTools ::within_edge_on_side (* elem ,
140
+ elem -> point (n ),
141
+ s ,
142
+ corner_on_side );
143
+
144
+ const auto node_is_on_side = elem -> is_node_on_side (n , s );
145
+ CPPUNIT_ASSERT_EQUAL (within_on_side , node_is_on_side );
146
+ if (node_is_on_side )
147
+ {
148
+ CPPUNIT_ASSERT_EQUAL (corner .at_vertex (n ), corner_on_side .at_vertex (n ));
149
+ CPPUNIT_ASSERT_EQUAL (corner .at_edge (* elem , e ), corner_on_side .at_edge (* elem , e ));
150
+ CPPUNIT_ASSERT_EQUAL (elem -> is_vertex (n ), corner_on_side .at_vertex (n ));
151
+ CPPUNIT_ASSERT_EQUAL (elem -> is_vertex (n ), !corner_on_side .at_edge (* elem , e ));
152
+ }
144
153
}
145
- }
154
+ }
146
155
147
156
// cut edges into segments
148
157
for (const auto & elem : _mesh -> active_local_element_ptr_range ())
149
158
for (const auto e : elem -> edge_index_range ())
150
- for (const auto s : elem -> side_index_range ())
151
- if (elem -> is_edge_on_side (e , s ))
152
- {
153
- const auto nodes_on_edge = elem -> nodes_on_edge (e );
154
- const auto & p1 = elem -> point (nodes_on_edge [0 ]);
155
- const auto & p2 = elem -> point (nodes_on_edge [1 ]);
156
- const auto length_vec = p2 - p1 ;
157
- const auto length = length_vec .norm ();
158
- const auto p1_to_p2 = length_vec / length ;
159
-
160
- int segments = 5 ;
161
- Real dx = (Real )1 / segments * length ;
162
- for (const auto i : make_range (-1 , segments + 1 ))
163
- {
164
- const auto p = p1 + Real (i ) * dx * p1_to_p2 ;
165
- ElemCorner corner ;
166
- const auto within = IntersectionTools ::within_edge_on_side (* elem ,
167
- p ,
168
- s ,
169
- corner );
170
-
171
- CPPUNIT_ASSERT_EQUAL (within , i >= 0 && i <= segments );
172
- CPPUNIT_ASSERT_EQUAL (corner .at_vertex (nodes_on_edge [0 ]), i == 0 );
173
- CPPUNIT_ASSERT_EQUAL (corner .at_vertex (nodes_on_edge [1 ]), i == segments );
174
- CPPUNIT_ASSERT_EQUAL (corner .at_edge (* elem , e ), i > 0 && i < segments );
175
- }
176
- }
159
+ {
160
+ const auto nodes_on_edge = elem -> nodes_on_edge (e );
161
+ const auto & p1 = elem -> point (nodes_on_edge [0 ]);
162
+ const auto & p2 = elem -> point (nodes_on_edge [1 ]);
163
+ const auto length_vec = p2 - p1 ;
164
+ const auto length = length_vec .norm ();
165
+ const auto p1_to_p2 = length_vec / length ;
166
+
167
+ int segments = 5 ;
168
+ Real dx = (Real )1 / segments * length ;
169
+ for (const auto i : make_range (-1 , segments + 1 ))
170
+ {
171
+ const auto p = p1 + Real (i ) * dx * p1_to_p2 ;
172
+
173
+ ElemCorner corner ;
174
+ const auto within = IntersectionTools ::within_edge (* elem , p , corner );
175
+ CPPUNIT_ASSERT_EQUAL (within , i >= 0 && i <= segments );
176
+
177
+ if (is_3d )
178
+ for (const auto s : elem -> side_index_range ())
179
+ if (elem -> is_edge_on_side (e , s ))
180
+ {
181
+ ElemCorner corner_on_side ;
182
+ const auto within_on_side = IntersectionTools ::within_edge_on_side (* elem ,
183
+ p ,
184
+ s ,
185
+ corner_on_side );
186
+
187
+ CPPUNIT_ASSERT_EQUAL (within_on_side , within );
188
+ CPPUNIT_ASSERT_EQUAL (corner_on_side .at_vertex (nodes_on_edge [0 ]), i == 0 );
189
+ CPPUNIT_ASSERT_EQUAL (corner_on_side .at_vertex (nodes_on_edge [1 ]), i == segments );
190
+ CPPUNIT_ASSERT_EQUAL (corner_on_side .at_edge (* elem , e ), i > 0 && i < segments );
191
+ }
192
+ }
193
+ }
177
194
178
195
// check elem centroids
179
196
for (const auto & elem : _mesh -> active_local_element_ptr_range ())
180
- for (const auto s : elem -> side_index_range ())
181
- {
182
- ElemCorner corner ;
183
- CPPUNIT_ASSERT (!IntersectionTools ::within_edge_on_side (* elem ,
184
- elem -> vertex_average (),
185
- s ,
186
- corner ));
187
- }
197
+ {
198
+ const auto p = elem -> vertex_average ();
199
+
200
+ ElemCorner corner ;
201
+ CPPUNIT_ASSERT (!IntersectionTools ::within_edge (* elem , p , corner ));
202
+
203
+ if (is_3d )
204
+ for (const auto s : elem -> side_index_range ())
205
+ {
206
+ ElemCorner corner_on_side ;
207
+ CPPUNIT_ASSERT (!IntersectionTools ::within_edge_on_side (* elem , p , s , corner_on_side ));
208
+ }
209
+ }
188
210
}
189
211
190
212
};
191
213
192
214
#define MESHEDINTERSECTIONTOOLSTEST \
193
- CPPUNIT_TEST ( test_within_edge_on_side );
215
+ CPPUNIT_TEST ( test_within_edge );
194
216
195
217
#define INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (elemtype ) \
196
218
class MeshedIntersectionToolsTest_ ##elemtype : public MeshedIntersectionToolsTest < elemtype > { \
@@ -209,6 +231,15 @@ public:
209
231
\
210
232
CPPUNIT_TEST_SUITE_REGISTRATION ( MeshedIntersectionToolsTest_ ##elemtype )
211
233
234
+ #if LIBMESH_DIM > 1
235
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (TRI3 );
236
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (TRI6 );
237
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (TRI7 );
238
+
239
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (QUAD4 );
240
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (QUAD8 );
241
+ INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (QUAD9 );
242
+ #endif // LIBMESH_DIM > 1
212
243
213
244
#if LIBMESH_DIM > 2
214
245
INSTANTIATE_MESHEDINTERSECTIONTOOLSTEST (TET4 );
0 commit comments