Skip to content

Commit

Permalink
Fix bug in interval refinement test (#3331)
Browse files Browse the repository at this point in the history
* Rename interval refinement test file

Pytest discovery previously ignored the interval test case, since it did not match the expected `test_` naming scheme

* Fix: implicit ghost_mode of interval mesh made explicit

* Fix: Bug for parallel interval refinement

Caused by assumption that ghost cells are refined on the process as well, which is not the case -> job of remote process that owns it
  • Loading branch information
schnellerhase authored Aug 5, 2024
1 parent 5d15d26 commit 8e4122b
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
5 changes: 3 additions & 2 deletions cpp/dolfinx/mesh/generation.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,16 @@ Mesh<T> create_rectangle(MPI_Comm comm, std::array<std::array<double, 2>, 2> p,
/// @param[in] comm MPI communicator to build the mesh on.
/// @param[in] n Number of cells.
/// @param[in] p End points of the interval.
/// @param[in] ghost_mode ghost mode of the created mesh, defaults to none
/// @param[in] partitioner Partitioning function for distributing cells
/// across MPI ranks.
/// @return A mesh.
template <std::floating_point T = double>
Mesh<T> create_interval(MPI_Comm comm, std::int64_t n, std::array<double, 2> p,
Mesh<T> create_interval(MPI_Comm comm, std::int64_t n, std::array<double, 2> p, mesh::GhostMode ghost_mode = mesh::GhostMode::none,
CellPartitionFunction partitioner = nullptr)
{
if (!partitioner and dolfinx::MPI::size(comm) > 1)
partitioner = create_cell_partitioner();
partitioner = create_cell_partitioner(ghost_mode);

fem::CoordinateElement<T> element(CellType::interval, 1);
std::vector<T> x;
Expand Down
1 change: 0 additions & 1 deletion cpp/dolfinx/refinement/interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ compute_interval_refinement(const mesh::Mesh<T>& mesh,

// Build the topology on the new vertices
const auto refined_cell_count = mesh.topology()->index_map(1)->size_local()
+ mesh.topology()->index_map(1)->num_ghosts()
+ number_of_refined_cells;

std::vector<std::int64_t> cell_topology;
Expand Down
2 changes: 1 addition & 1 deletion python/dolfinx/wrappers/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void declare_mesh(nb::module_& m, std::string type)
const PythonCellPartitionFunction& part)
{
return dolfinx::mesh::create_interval<T>(
comm.get(), n, p, create_cell_partitioner_cpp(part));
comm.get(), n, p, ghost_mode, create_cell_partitioner_cpp(part));
},
nb::arg("comm"), nb::arg("n"), nb::arg("p"), nb::arg("ghost_mode"),
nb::arg("partitioner").none());
Expand Down
File renamed without changes.

0 comments on commit 8e4122b

Please sign in to comment.