PartitionWeights< dim > Class Template Reference

Developer Documentation: MeltPoolDG::CutUtil::PartitionWeights< dim > Class Template Reference
Developer Documentation
MeltPoolDG::CutUtil::PartitionWeights< dim > Class Template Reference

Cell weights for the repartitioning of a parallel::distributed::Triangulation according to the location of the cells with respect to the level set. More...

#include <repartition.hpp>

Collaboration diagram for MeltPoolDG::CutUtil::PartitionWeights< dim >:
[legend]

Public Types

using CellIterator = typename dealii::Triangulation< dim >::cell_iterator
 

Public Member Functions

 PartitionWeights (const dealii::Triangulation< dim > &tria_in, const CutRepartitionData &repartition_data_in)
 Constructor.
 
void update (const dealii::NonMatching::MeshClassifier< dim > &mesh_classifier)
 Compute and cache the weights of the locally owned active cells according to their location with respect to the level set.
 
unsigned int get_weight (const CellIterator &cell) const
 Get the cached weight of a cell.
 
dealii::Utilities::MPI::MinMaxAvg compute_load_statistics (const MPI_Comm mpi_comm) const
 Compute statistics of the summed cell weights (i.e. the estimated load) of the locally owned cells over all MPI processes.
 

Private Member Functions

void connect_to_triangulation ()
 Connect the function returning the cached weights to the weight signal of the triangulation, and the transfer of the cached weights to the signals before and after refinement and repartitioning.
 
void prepare_transfer ()
 Attach the cached weights to the cells before the triangulation changes.
 
void finish_transfer ()
 Unpack the cached weights after the triangulation has changed.
 
unsigned int get_partition_weight (const dealii::NonMatching::LocationToLevelSet location) const
 Get the partitioning weight of a cell according to its location with respect to the level set.
 

Private Attributes

const dealii::Triangulation< dim > * tria
 Pointer to the triangulation.
 
const CutRepartitionData repartition_data
 Repartitioning parameters including the cell weights.
 
std::vector< unsigned int > weights
 Cached weights of the active cells (indexed by the active cell index)
 
unsigned int weights_handle = dealii::numbers::invalid_unsigned_int
 Handle of the cell-attached weights during a change of the triangulation.
 
std::vector< boost::signals2::scoped_connection > connections
 Connections to the signals of the triangulation.
 

Detailed Description

template<int dim>
class MeltPoolDG::CutUtil::PartitionWeights< dim >

Cell weights for the repartitioning of a parallel::distributed::Triangulation according to the location of the cells with respect to the level set.

The weights are evaluated with a dealii::NonMatching::MeshClassifier in update() and cached per active cell. Upon the first call of update(), a function returning the cached weights is connected to dealii::Triangulation::Signals::weight. It stays connected for the lifetime of this object.

With the default settings of parallel::distributed::Triangulation, p4est partitions the mesh according to the connected weights not only in an explicit repartitioning (see repartition_triangulation()), but in every call to execute_coarsening_and_refinement(). Such calls also occur if only the active FE indices change, e.g. in the solution transfer for a moved interface (see CutUtil::SolutionTransferOperator), where the level-set vector is not transferred. In these calls, no cells must be moved between the processes. Since the partitioning computed by p4est only depends on the global order of the cells and their weights, this is the case if the connected weights are exactly the ones p4est used for the current partitioning. Therefore, the weights are cached instead of evaluating the mesh classifier on the fly, and the cache is kept consistent with the partitioning as follows:

  • update() computes new weights from the current cell classification. They are used by p4est in the next change of the triangulation. Hence, update() must be called directly before an explicit repartitioning (see repartition_triangulation()).
  • The cached weights are transferred automatically in every change of the triangulation, i.e. in every call to execute_coarsening_and_refinement() and repartition(), exactly as p4est sees them: The children of a refined cell inherit the weight of their parent, and a coarsened cell gets the maximum weight of its former children (see get_weight()). This is implemented by attaching the weights to the cells (see dealii::Triangulation::register_data_attach()) in the signals pre_distributed_refinement and pre_distributed_repartition, and by unpacking them in the signals post_distributed_refinement and post_distributed_repartition of the triangulation.

Consequently, after adaptive mesh refinement the cached weights do not correspond to a fresh classification of the new cells, but they reproduce the partitioning computed during the refinement. They are updated in the next explicit repartitioning.

Note
update() must be called directly before each explicit repartitioning.

Member Typedef Documentation

◆ CellIterator

template<int dim>
using MeltPoolDG::CutUtil::PartitionWeights< dim >::CellIterator = typename dealii::Triangulation<dim>::cell_iterator

Constructor & Destructor Documentation

◆ PartitionWeights()

template<int dim>
MeltPoolDG::CutUtil::PartitionWeights< dim >::PartitionWeights ( const dealii::Triangulation< dim > &  tria_in,
const CutRepartitionData &  repartition_data_in 
)
inlineexplicit

Constructor.

Parameters
tria_inTriangulation to be repartitioned.
repartition_data_inRepartitioning parameters including the cell weights.

Member Function Documentation

◆ compute_load_statistics()

template<int dim>
dealii::Utilities::MPI::MinMaxAvg MeltPoolDG::CutUtil::PartitionWeights< dim >::compute_load_statistics ( const MPI_Comm  mpi_comm) const
inline

Compute statistics of the summed cell weights (i.e. the estimated load) of the locally owned cells over all MPI processes.

Parameters
mpi_commMPI communicator.
Returns
Minimum, maximum and average load per MPI process.

◆ connect_to_triangulation()

template<int dim>
void MeltPoolDG::CutUtil::PartitionWeights< dim >::connect_to_triangulation ( )
inlineprivate

Connect the function returning the cached weights to the weight signal of the triangulation, and the transfer of the cached weights to the signals before and after refinement and repartitioning.

◆ finish_transfer()

template<int dim>
void MeltPoolDG::CutUtil::PartitionWeights< dim >::finish_transfer ( )
inlineprivate

Unpack the cached weights after the triangulation has changed.

The children of a refined cell inherit the weight of their parent.

◆ get_partition_weight()

template<int dim>
unsigned int MeltPoolDG::CutUtil::PartitionWeights< dim >::get_partition_weight ( const dealii::NonMatching::LocationToLevelSet  location) const
inlineprivate

Get the partitioning weight of a cell according to its location with respect to the level set.

Parameters
locationLocation of the cell with respect to the level set.
Returns
Partitioning weight of the cell.

◆ get_weight()

template<int dim>
unsigned int MeltPoolDG::CutUtil::PartitionWeights< dim >::get_weight ( const CellIterator &  cell) const
inline

Get the cached weight of a cell.

Note
For cells whose children will be coarsened, the maximum weight of the children is returned.
Parameters
cellCell iterator.
Returns
Cached weight of the current cell.

◆ prepare_transfer()

template<int dim>
void MeltPoolDG::CutUtil::PartitionWeights< dim >::prepare_transfer ( )
inlineprivate

Attach the cached weights to the cells before the triangulation changes.

The packed weight of a cell is exactly the weight returned to p4est by get_weight(), i.e. the cached weight for persisting cells and cells to be refined, and the maximum weight of the children for cells whose children will be coarsened.

◆ update()

template<int dim>
void MeltPoolDG::CutUtil::PartitionWeights< dim >::update ( const dealii::NonMatching::MeshClassifier< dim > &  mesh_classifier)
inline

Compute and cache the weights of the locally owned active cells according to their location with respect to the level set.

The new weights are used by p4est in the next change of the triangulation. Therefore, this function must be called directly before an explicit repartitioning (see repartition_triangulation()).

Upon the first call, the function returning the cached weights is connected to the weight signal of the triangulation, and the transfer of the cached weights is connected to the refinement and repartitioning signals.

Parameters
mesh_classifierMesh classifier, which must be up-to-date with the current triangulation, i.e. reclassify() must have been called after the last change of the triangulation.

Member Data Documentation

◆ connections

template<int dim>
std::vector<boost::signals2::scoped_connection> MeltPoolDG::CutUtil::PartitionWeights< dim >::connections
private

Connections to the signals of the triangulation.

◆ repartition_data

template<int dim>
const CutRepartitionData MeltPoolDG::CutUtil::PartitionWeights< dim >::repartition_data
private

Repartitioning parameters including the cell weights.

◆ tria

template<int dim>
const dealii::Triangulation<dim>* MeltPoolDG::CutUtil::PartitionWeights< dim >::tria
private

Pointer to the triangulation.

◆ weights

template<int dim>
std::vector<unsigned int> MeltPoolDG::CutUtil::PartitionWeights< dim >::weights
private

Cached weights of the active cells (indexed by the active cell index)

◆ weights_handle

template<int dim>
unsigned int MeltPoolDG::CutUtil::PartitionWeights< dim >::weights_handle = dealii::numbers::invalid_unsigned_int
private

Handle of the cell-attached weights during a change of the triangulation.


The documentation for this class was generated from the following file: