|
15 | 15 | #include "test_comm.h" |
16 | 16 | #include "libmesh_cppunit.h" |
17 | 17 |
|
| 18 | +#include "libmesh/mesh_refinement.h" |
| 19 | + |
18 | 20 | using namespace libMesh; |
19 | 21 |
|
20 | 22 | static const Real b = 1.0; |
@@ -185,6 +187,10 @@ public: |
185 | 187 | #if defined(LIBMESH_HAVE_SOLVER) |
186 | 188 | CPPUNIT_TEST( testTempJump ); |
187 | 189 | CPPUNIT_TEST( testTempJumpRefine ); |
| 190 | + // This test intentionally triggers find_neighbors() consistency check |
| 191 | + // failure after AMR refinement across disconnected interfaces. |
| 192 | + // Expected: libmesh_assert_valid_neighbors() fails. |
| 193 | + CPPUNIT_TEST_EXCEPTION(testTempJumpLocalRefineFail, std::exception); |
188 | 194 | #endif |
189 | 195 | CPPUNIT_TEST_SUITE_END(); |
190 | 196 |
|
@@ -387,8 +393,22 @@ private: |
387 | 393 | } |
388 | 394 |
|
389 | 395 |
|
| 396 | + void testTempJumpLocalRefineFail() |
| 397 | + { |
| 398 | + try |
| 399 | + { |
| 400 | + Mesh mesh(*TestCommWorld, 2); |
| 401 | + build_split_mesh_with_interface(mesh, true); |
| 402 | + } |
| 403 | + catch (const std::exception &e) |
| 404 | + { |
| 405 | + CPPUNIT_ASSERT(std::string(e.what()).find("Mesh contains disconnected boundary interfaces") != std::string::npos); |
| 406 | + throw; |
| 407 | + } |
| 408 | + } |
| 409 | + |
390 | 410 | // The interface is located at x = 0.5; nx must be even (split evenly into left and right subdomains) |
391 | | - void build_split_mesh_with_interface(Mesh &mesh) |
| 411 | + void build_split_mesh_with_interface(Mesh &mesh, bool test_local_refinement = false) |
392 | 412 | { |
393 | 413 | // Ensure nx is even so the interface aligns with element boundaries |
394 | 414 | libmesh_error_msg_if(nx % 2 != 0, "nx must be even!"); |
@@ -495,7 +515,25 @@ private: |
495 | 515 | mesh.add_disconnected_boundaries(interface_left_id, interface_right_id, RealVectorValue(0.0, 0.0, 0.0)); |
496 | 516 |
|
497 | 517 | mesh.prepare_for_use(); |
| 518 | + |
| 519 | +#if LIBMESH_ENABLE_AMR |
| 520 | + if (test_local_refinement) |
| 521 | + { |
| 522 | + // set refinement flags |
| 523 | + for (auto & elem : mesh.element_ptr_range()) |
| 524 | + { |
| 525 | + const Real xmid = elem->vertex_average()(0); |
| 526 | + if ((xmid < 0.5 && xmid > 0.5 - dx) || |
| 527 | + (xmid > 0.5 && xmid < 0.5 + dx)) |
| 528 | + elem->set_refinement_flag(Elem::REFINE); |
| 529 | + } |
| 530 | + |
| 531 | + // refine |
| 532 | + MeshRefinement(mesh).refine_elements(); |
| 533 | + } |
| 534 | +#endif |
498 | 535 | } |
| 536 | + |
499 | 537 | }; |
500 | 538 |
|
501 | 539 | CPPUNIT_TEST_SUITE_REGISTRATION( DisconnectedNeighborTest ); |
0 commit comments