Skip to content

Commit

Permalink
Merge pull request #12928 from tjhei/mg_repart_edits
Browse files Browse the repository at this point in the history
minor MGRepartining edits
  • Loading branch information
marcfehling committed Nov 9, 2021
2 parents db25698 + 5dded7e commit 538df70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
12 changes: 9 additions & 3 deletions include/deal.II/distributed/repartitioning_policy_tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ DEAL_II_NAMESPACE_OPEN
namespace RepartitioningPolicyTools
{
/**
* A base class of a repartitioning policy.
* The base class for repartitioning policies.
*
* Used in
* MGTransferGlobalCoarseningTools::create_geometric_coarsening_sequence().
* See the description of RepartitioningPolicyTools for more information.
*/
template <int dim, int spacedim = dim>
class Base
Expand Down Expand Up @@ -121,8 +125,10 @@ namespace RepartitioningPolicyTools
};

/**
* A policy that allows to specify a minimal number of cells per process. If
* a threshold is reached, processes might be left without cells.
* A policy that allows to specify a minimal number of cells per
* process. If a threshold is reached, processes might be left
* without cells. The cells will be distributed evenly among the
* remaining processes.
*/
template <int dim, int spacedim = dim>
class MinimalGranularityPolicy : public Base<dim, spacedim>
Expand Down
4 changes: 2 additions & 2 deletions include/deal.II/multigrid/mg_transfer_global_coarsening.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ namespace MGTransferGlobalCoarseningTools

/**
* Similar to the above function but taking in a constant version of
* @p tria and as a consequence not allowing to directly use it for
* coarsening, requiring that internally a temporal copy is created.
* @p tria. As a consequence, it can not be used for coarsening directly,
* so a temporary copy will be created internally.
*/
template <int dim, int spacedim>
std::vector<std::shared_ptr<const Triangulation<dim, spacedim>>>
Expand Down
9 changes: 6 additions & 3 deletions source/distributed/repartitioning_policy_tools.cc
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,14 @@ namespace RepartitioningPolicyTools
// a repartitioning kicks in with the aim that all processes that own
// cells have at least the specified number of cells

const unsigned int n_global_active_cells = tria_in.n_global_active_cells();
const types::global_cell_index n_global_active_cells =
tria_in.n_global_active_cells();

const unsigned int n_partitions =
std::max<unsigned int>(1,
std::min(n_global_active_cells / n_min_cells,
Utilities::MPI::n_mpi_processes(comm)));
std::min<types::global_cell_index>(
n_global_active_cells / n_min_cells,
Utilities::MPI::n_mpi_processes(comm)));

const unsigned int min_cells = n_global_active_cells / n_partitions;

Expand Down Expand Up @@ -322,6 +324,7 @@ namespace RepartitioningPolicyTools
Utilities::MPI::internal::mpi_type_id(&total_weight),
n_subdomains - 1,
mpi_communicator);
AssertThrowMPI(ierr);

// setup partition
LinearAlgebra::distributed::Vector<double> partition(partitioner);
Expand Down

0 comments on commit 538df70

Please sign in to comment.