|
6 | 6 | #include <libmesh/elem_side_builder.h> |
7 | 7 | #include <libmesh/mesh.h> |
8 | 8 | #include <libmesh/mesh_generation.h> |
| 9 | +#include <libmesh/mesh_modification.h> |
9 | 10 |
|
10 | 11 | #include "libmesh_cppunit.h" |
11 | 12 |
|
@@ -398,6 +399,56 @@ public: |
398 | 399 | } |
399 | 400 | } |
400 | 401 |
|
| 402 | + void test_orient_elements() |
| 403 | + { |
| 404 | + LOG_UNIT_TEST; |
| 405 | + |
| 406 | + const Mesh old_mesh {*_mesh}; |
| 407 | + |
| 408 | + BoundaryInfo & boundary_info = _mesh->get_boundary_info(); |
| 409 | + const BoundaryInfo & old_boundary_info = old_mesh.get_boundary_info(); |
| 410 | + CPPUNIT_ASSERT(&boundary_info != &old_boundary_info); |
| 411 | + |
| 412 | + for (const auto & elem : _mesh->active_local_element_ptr_range()) |
| 413 | + { |
| 414 | +#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS |
| 415 | + if (elem->infinite()) |
| 416 | + continue; |
| 417 | +#endif |
| 418 | + if (elem->id()%2) |
| 419 | + elem->flip(&boundary_info); |
| 420 | + } |
| 421 | + |
| 422 | + MeshTools::Modification::orient_elements(*_mesh); |
| 423 | + |
| 424 | + // I should really create a MeshBase::operator==()... |
| 425 | + for (const auto & elem : _mesh->active_local_element_ptr_range()) |
| 426 | + { |
| 427 | + const Elem & old_elem = old_mesh.elem_ref(elem->id()); |
| 428 | + |
| 429 | + // Elem::operator==() uses node ids to compare |
| 430 | + CPPUNIT_ASSERT(*elem == old_elem); |
| 431 | + |
| 432 | + const unsigned int n_sides = elem->n_sides(); |
| 433 | + for (auto s : make_range(n_sides)) |
| 434 | + { |
| 435 | + std::vector<boundary_id_type> bcids, old_bcids; |
| 436 | + boundary_info.boundary_ids(elem, s, bcids); |
| 437 | + old_boundary_info.boundary_ids(&old_elem, s, old_bcids); |
| 438 | + CPPUNIT_ASSERT(bcids == old_bcids); |
| 439 | + |
| 440 | + if (elem->neighbor_ptr(s)) |
| 441 | + { |
| 442 | + CPPUNIT_ASSERT(old_elem.neighbor_ptr(s)); |
| 443 | + CPPUNIT_ASSERT_EQUAL(elem->neighbor_ptr(s)->id(), |
| 444 | + old_elem.neighbor_ptr(s)->id()); |
| 445 | + } |
| 446 | + else |
| 447 | + CPPUNIT_ASSERT(!old_elem.neighbor_ptr(s)); |
| 448 | + } |
| 449 | + } |
| 450 | + } |
| 451 | + |
401 | 452 | void test_center_node_on_side() |
402 | 453 | { |
403 | 454 | LOG_UNIT_TEST; |
@@ -466,6 +517,7 @@ public: |
466 | 517 | CPPUNIT_TEST( test_permute ); \ |
467 | 518 | CPPUNIT_TEST( test_flip ); \ |
468 | 519 | CPPUNIT_TEST( test_orient ); \ |
| 520 | + CPPUNIT_TEST( test_orient_elements ); \ |
469 | 521 | CPPUNIT_TEST( test_contains_point_node ); \ |
470 | 522 | CPPUNIT_TEST( test_center_node_on_side ); \ |
471 | 523 | CPPUNIT_TEST( test_side_type ); \ |
|
0 commit comments