Skip to content

Commit

Permalink
Fix: interval refinement assertion ignores optional type (#3584)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
schnellerhase and garth-wells authored Jan 6, 2025
1 parent cb8bcfa commit fb0b994
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cpp/dolfinx/refinement/interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ compute_refinement_data(const mesh::Mesh<T>& 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<std::int32_t> offsets(refined_cell_count + 1);
std::ranges::generate(offsets, [i = 0]() mutable { return 2 * i++; });
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/mesh/generation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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::int32_t>(std::move(data));
};
Expand Down
10 changes: 10 additions & 0 deletions cpp/test/mesh/refinement/interval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<TestType>(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);
}

0 comments on commit fb0b994

Please sign in to comment.