Skip to content

Commit

Permalink
Small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Sep 23, 2024
1 parent 098895e commit 22127f7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 32 deletions.
15 changes: 6 additions & 9 deletions cpp/dolfinx/refinement/refine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "refine.h"
#include <numeric>

namespace dolfinx::refinement
{
using namespace dolfinx;

graph::AdjacencyList<std::int32_t> maintain_coarse_partitioner(
MPI_Comm comm, int, const std::vector<mesh::CellType>& cell_types,
const std::vector<std::span<const std::int64_t>>& cells)
graph::AdjacencyList<std::int32_t> refinement::maintain_coarse_partitioner(
MPI_Comm comm, int /*nparts*/, std::vector<mesh::CellType> cell_types,
std::vector<std::span<const std::int64_t>> cells)
{
int mpi_rank = MPI::rank(comm);
int num_cell_vertices = mesh::num_cell_vertices(cell_types.front());
std::int32_t num_cells = cells.front().size() / num_cell_vertices;
std::vector<std::int32_t> destinations(num_cells, mpi_rank);
std::vector<std::int32_t> destinations(num_cells, dolfinx::MPI::rank(comm));
std::vector<std::int32_t> dest_offsets(num_cells + 1);
std::iota(dest_offsets.begin(), dest_offsets.end(), 0);
return graph::AdjacencyList(std::move(destinations), std::move(dest_offsets));
}

} // namespace dolfinx::refinement
14 changes: 7 additions & 7 deletions cpp/dolfinx/refinement/refine.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@

namespace dolfinx::refinement
{

/// @brief Partitioner that maintains the regional destribution for a refined
/// mesh. Meaning, process local data is just maintained and no redistribution
/// happens.
/// @brief Partitioner that maintains the regional distribution for a
/// refined mesh. Meaning, process local data is just maintained and no
/// redistribution happens.
///
/// @param[in] comm MPI Communicator
/// @param[in] nparts Number of partitions (input has no effect)
/// @param[in] cell_types Cell types in the mesh
/// @param[in] cells Lists of cells of each cell type.
/// @return Destination ranks for each cell on this process
graph::AdjacencyList<std::int32_t> maintain_coarse_partitioner(
MPI_Comm comm, int nparts, const std::vector<mesh::CellType>& cell_types,
const std::vector<std::span<const std::int64_t>>& cells);
graph::AdjacencyList<std::int32_t>
maintain_coarse_partitioner(MPI_Comm comm, int nparts,
std::vector<mesh::CellType> cell_types,
std::vector<std::span<const std::int64_t>> cells);

/// @brief Refine with markers, optionally redistributing, and
/// optionally calculating the parent-child relationships.
Expand Down
27 changes: 11 additions & 16 deletions python/dolfinx/wrappers/refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,34 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "MPICommWrapper.h"
#include "array.h"
#include <concepts>
#include <cstdint>
#include <dolfinx/mesh/Mesh.h>
#include <dolfinx/mesh/MeshTags.h>
#include <dolfinx/refinement/interval.h>
#include <dolfinx/refinement/option.h>
#include <dolfinx/refinement/plaza.h>
#include <dolfinx/refinement/refine.h>
#include <dolfinx/refinement/utils.h>
#include <functional>
#include <optional>
#include <span>

#include <nanobind/nanobind.h>
#include <nanobind/ndarray.h>
#include <nanobind/stl/array.h>
#include <nanobind/stl/optional.h>
#include <nanobind/stl/shared_ptr.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/vector.h>

#include <dolfinx/mesh/Mesh.h>
#include <dolfinx/mesh/MeshTags.h>
#include <dolfinx/refinement/interval.h>
#include <dolfinx/refinement/option.h>
#include <dolfinx/refinement/plaza.h>
#include <dolfinx/refinement/refine.h>
#include <dolfinx/refinement/utils.h>

#include "MPICommWrapper.h"
#include "array.h"
#include <optional>
#include <span>

namespace nb = nanobind;

namespace dolfinx_wrappers
{

namespace
{

using PythonCellPartitionFunction
= std::function<dolfinx::graph::AdjacencyList<std::int32_t>(
dolfinx_wrappers::MPICommWrapper, int,
Expand Down

0 comments on commit 22127f7

Please sign in to comment.