Skip to content

Commit 1fe0b9e

Browse files
committed
Unit tests for Elem::orient()
1 parent a0954e4 commit 1fe0b9e

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

tests/geom/elem_test.C

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,70 @@ public:
334334
}
335335
}
336336

337+
void test_orient()
338+
{
339+
LOG_UNIT_TEST;
340+
341+
BoundaryInfo & boundary_info = _mesh->get_boundary_info();
342+
343+
for (const auto & elem : _mesh->active_local_element_ptr_range())
344+
{
345+
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
346+
if (elem->infinite())
347+
continue;
348+
#endif
349+
const Point vertex_avg = elem->vertex_average();
350+
351+
const unsigned int n_sides = elem->n_sides();
352+
std::vector<std::set<Point*>> side_nodes(n_sides);
353+
std::vector<Elem*> neighbors(n_sides);
354+
std::vector<std::vector<boundary_id_type>> bcids(n_sides);
355+
for (auto s : make_range(n_sides))
356+
{
357+
for (auto n : elem->nodes_on_side(s))
358+
side_nodes[s].insert(elem->node_ptr(n));
359+
neighbors[s] = elem->neighbor_ptr(s);
360+
boundary_info.boundary_ids(elem, s, bcids[s]);
361+
}
362+
363+
if (elem->id()%2)
364+
elem->flip(&boundary_info);
365+
366+
elem->orient(&boundary_info);
367+
368+
// Our map should still be affine.
369+
// ... except for stupid singular pyramid maps
370+
if (elem->dim() < 3 ||
371+
elem->n_vertices() != 5)
372+
CPPUNIT_ASSERT(elem->has_affine_map());
373+
374+
// The neighbors and bcids should have flipped back to where
375+
// they were.
376+
for (auto s : make_range(n_sides))
377+
{
378+
std::set<Point*> new_side_nodes;
379+
for (auto n : elem->nodes_on_side(s))
380+
new_side_nodes.insert(elem->node_ptr(n));
381+
382+
std::vector<boundary_id_type> new_bcids;
383+
boundary_info.boundary_ids(elem, s, new_bcids);
384+
385+
CPPUNIT_ASSERT(side_nodes[s] ==
386+
new_side_nodes);
387+
388+
CPPUNIT_ASSERT(neighbors[s] ==
389+
elem->neighbor_ptr(s));
390+
391+
CPPUNIT_ASSERT(bcids[s] == new_bcids);
392+
}
393+
394+
const Point new_vertex_avg = elem->vertex_average();
395+
for (const auto d : make_range(LIBMESH_DIM))
396+
LIBMESH_ASSERT_FP_EQUAL(vertex_avg(d), new_vertex_avg(d),
397+
TOLERANCE*TOLERANCE);
398+
}
399+
}
400+
337401
void test_center_node_on_side()
338402
{
339403
LOG_UNIT_TEST;
@@ -401,6 +465,7 @@ public:
401465
CPPUNIT_TEST( test_maps ); \
402466
CPPUNIT_TEST( test_permute ); \
403467
CPPUNIT_TEST( test_flip ); \
468+
CPPUNIT_TEST( test_orient ); \
404469
CPPUNIT_TEST( test_contains_point_node ); \
405470
CPPUNIT_TEST( test_center_node_on_side ); \
406471
CPPUNIT_TEST( test_side_type ); \

0 commit comments

Comments
 (0)