From fb0b99447b96434a48b44c4a256c29330ffac7c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20T=2E=20K=C3=BChner?= <56360279+schnellerhase@users.noreply.github.com> Date: Mon, 6 Jan 2025 23:24:09 +0100 Subject: [PATCH] Fix: interval refinement assertion ignores optional type (#3584) * Fix: interval refinement assert ignores optional type * Geneartion test switch to SKIP instead of FAIL for unsupported process count * Increase to n=20 * Update expected value * Update cpp/dolfinx/refinement/interval.h --------- Co-authored-by: Garth N. Wells --- cpp/dolfinx/refinement/interval.h | 2 +- cpp/test/mesh/generation.cpp | 2 +- cpp/test/mesh/refinement/interval.cpp | 10 ++++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cpp/dolfinx/refinement/interval.h b/cpp/dolfinx/refinement/interval.h index 0b1505acd43..aa2981548db 100644 --- a/cpp/dolfinx/refinement/interval.h +++ b/cpp/dolfinx/refinement/interval.h @@ -176,7 +176,7 @@ compute_refinement_data(const mesh::Mesh& mesh, } assert(cell_topology.size() == 2 * refined_cell_count); - assert(parent_cell->size() == (compute_parent_cell ? refined_cell_count : 0)); + assert(!compute_parent_cell or parent_cell->size() == refined_cell_count); std::vector offsets(refined_cell_count + 1); std::ranges::generate(offsets, [i = 0]() mutable { return 2 * i++; }); diff --git a/cpp/test/mesh/generation.cpp b/cpp/test/mesh/generation.cpp index 93bfd9dd9b8..53f2d9fb4e0 100644 --- a/cpp/test/mesh/generation.cpp +++ b/cpp/test/mesh/generation.cpp @@ -112,7 +112,7 @@ TEMPLATE_TEST_CASE("Interval mesh (parallel)", "[mesh][interval]", float, {2}, {2}, {2, 0}, {0, 2}, {0}, {0}, {0}}; } else - FAIL("Test only supports <= 3 processes"); + SKIP("Test only supports <= 3 processes"); return graph::AdjacencyList(std::move(data)); }; diff --git a/cpp/test/mesh/refinement/interval.cpp b/cpp/test/mesh/refinement/interval.cpp index 1253fe00b04..c0bfb234420 100644 --- a/cpp/test/mesh/refinement/interval.cpp +++ b/cpp/test/mesh/refinement/interval.cpp @@ -239,3 +239,13 @@ TEMPLATE_TEST_CASE("Interval Refinement (parallel)", != v_to_e->links((center_index + 2) % 3)[0]); } } + +TEMPLATE_TEST_CASE("Interval uniform refinement", "[refinement][interva]", + double, float) +{ + auto interval = dolfinx::mesh::create_interval(MPI_COMM_WORLD, 20, + {0.0, 1.0}); + auto [refined, parent_edge, parent_facet] + = dolfinx::refinement::refine(interval, std::nullopt); + CHECK(refined.topology()->index_map(0)->size_global() == 41); +}