Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
LagrangianLoadBalancing< dim, PropertiesIndex > Class Template Reference

#include <load_balancing.h>

Public Member Functions

 LagrangianLoadBalancing ()
void set_parameters (const Parameters::Lagrangian::ModelParameters< dim > &model_parameters)
void copy_references (std::shared_ptr< SimulationControl > &simulation_control, parallel::distributed::Triangulation< dim > &triangulation, Particles::ParticleHandler< dim > &particle_handler, AdaptiveSparseContacts< dim, PropertiesIndex > &adaptive_sparse_contacts)
void check_load_balance_iteration () const
std::function< void()> set_iteration_check_function ()
void check_load_balance_once () const
void check_load_balance_frequent () const
void check_load_balance_dynamic ()
void check_load_balance_with_sparse_contacts ()
void connect_weight_signals ()
void connect_mobility_status_weight_signals ()

Private Member Functions

unsigned int calculate_total_cell_weight (const typename parallel::distributed::Triangulation< dim >::cell_iterator &cell, const CellStatus status) const
unsigned int calculate_total_cell_weight_with_mobility_status (const typename parallel::distributed::Triangulation< dim >::cell_iterator &cell, const CellStatus status) const

Private Attributes

Parameters::Lagrangian::ModelParameters< dim >::LoadBalanceMethod load_balance_method
std::function< void()> iteration_check_function
const unsigned int cell_weight = 1000
std::shared_ptr< Function< dim > > cell_weight_function
unsigned int particle_weight
double inactive_status_factor
double active_status_factor
unsigned int load_balance_step
unsigned int load_balance_frequency
unsigned int dynamic_check_frequency
double load_threshold
MPI_Comm mpi_communicator
const unsigned int n_mpi_processes
const unsigned int this_mpi_process
std::shared_ptr< SimulationControl > simulation_control
parallel::distributed::Triangulation< dim > * triangulation
Particles::ParticleHandler< dim > * particle_handler
AdaptiveSparseContacts< dim, PropertiesIndex > * adaptive_sparse_contacts

Detailed Description

template<int dim, typename PropertiesIndex>
class LagrangianLoadBalancing< dim, PropertiesIndex >

Manages the load balancing (repartitioning), of the domain according to the computational load of the cells and the particles. It is used by the DEM and the coupling CFD-DEM solvers.

Template Parameters
dimAn integer that denotes the number of spatial dimensions.
PropertiesIndexIndex of the properties used within the ParticleHandler.

Definition at line 25 of file load_balancing.h.

Constructor & Destructor Documentation

◆ LagrangianLoadBalancing()

template<int dim, typename PropertiesIndex>
LagrangianLoadBalancing< dim, PropertiesIndex >::LagrangianLoadBalancing ( )

Definition at line 11 of file load_balancing.cc.

References mpi_communicator, n_mpi_processes, and this_mpi_process.

Member Function Documentation

◆ calculate_total_cell_weight()

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::calculate_total_cell_weight ( const typename parallel::distributed::Triangulation< dim >::cell_iterator & cell,
const CellStatus status ) const
private

Indicates to the triangulation how much computational work is expected to happen on this cell, and consequently how the domain needs to be partitioned.

Every MPI rank receives a roughly equal amount of work (potentially not an equal number of cells). While the function is called from the outside, it is connected to the corresponding signal from inside this class, therefore it can be private. This function is the key component that allows dynamically balance the computational load. The function attributes a weight to every cell that represents the computational work on this cell. Here the majority of work is expected to happen on the particles, therefore the return value of this function is calculated based on the number of particles in the current cell. The function is connected to the cell_weight() signal inside the triangulation, and will be called once per cell, whenever the triangulation repartition the domain between ranks.

Parameters
[in]cellThe cell for which the load is calculated.
[in]statusThe status of the cell related to the coarsening level.

TODO: Remove preprocessor directives after deal.ii v.9.6 release

Returns
The total weight of the cell.

Definition at line 140 of file load_balancing.cc.

◆ calculate_total_cell_weight_with_mobility_status()

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::calculate_total_cell_weight_with_mobility_status ( const typename parallel::distributed::Triangulation< dim >::cell_iterator & cell,
const CellStatus status ) const
private

Indicates to the triangulation how much computational work is expected to happen on this cell, and consequently how the domain needs to be partitioned. Only used with the Adaptive Sparse Contacts mechanism.

Similar to the calculate_total_cell_weight(), this function is used when the cell weight is adapted to the mobility status. For instance, if the cell is inactive, its computational load will be significantly lower than if it is a mobile cell since there is no force calculation and no velocity integration for the particles that lie within it. The weight of the cells must thus be adapted to the status of the cell.

total cell weight = cell weight + load balancing factor * n particles * particle weight

Parameters
[in]cellThe cell for which the load is calculated
[in]statusThe status of the cell related to the coarsening level
Returns
The total weight of the cell

Definition at line 183 of file load_balancing.cc.

References active_status_factor, adaptive_sparse_contacts, AdaptiveSparseContacts< dim, PropertiesIndex >::advected, AdaptiveSparseContacts< dim, PropertiesIndex >::advected_active, AdaptiveSparseContacts< dim, PropertiesIndex >::inactive, inactive_status_factor, particle_handler, particle_weight, and AdaptiveSparseContacts< dim, PropertiesIndex >::static_active.

◆ check_load_balance_dynamic()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::check_load_balance_dynamic ( )
inline

Determines whether the present iteration is the load balance step when load balance method is dynamic.

Returns
bool indicating if the current time step is a load balance iteration according to the load balancing dynamic check frequencyand threshold.

Definition at line 37 of file load_balancing.cc.

References dynamic_check_frequency, DEMActionManager::get_action_manager(), DEMActionManager::load_balance_step(), load_threshold, mpi_communicator, n_mpi_processes, particle_handler, and simulation_control.

◆ check_load_balance_frequent()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::check_load_balance_frequent ( ) const
inline

Determines whether the present iteration is the load balance step when load balance method is frequent.

Returns
bool indicating if the current time step is a load balance iteration according to the load balancing frequency.

Definition at line 27 of file load_balancing.cc.

◆ check_load_balance_iteration()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::check_load_balance_iteration ( ) const
inline

Checks if the current iteration is a load balance iteration.

Returns
bool indicating if this is a load balance iteration.

Definition at line 94 of file load_balancing.h.

References iteration_check_function.

◆ check_load_balance_once()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::check_load_balance_once ( ) const
inline

Determines whether the present iteration is the load balance step when load balance method is once.

Returns
bool indicating if the current time step is a load balance iteration according to the load balancing step.

Definition at line 19 of file load_balancing.cc.

References DEMActionManager::get_action_manager(), DEMActionManager::load_balance_step(), load_balance_step, and simulation_control.

◆ check_load_balance_with_sparse_contacts()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::check_load_balance_with_sparse_contacts ( )
inline

Determines whether the present is the load balance step when load balance method is dynamic_with_sparse_contacts. It used the same method as dynamic but with the addition of factors according to the cell mobility status of the sparse contacts mechanism.

Returns
bool indicating if the current time step is a load balance iteration according to the load balancing dynamic check frequency, threshold and load factors.

Definition at line 60 of file load_balancing.cc.

References active_status_factor, adaptive_sparse_contacts, AdaptiveSparseContacts< dim, PropertiesIndex >::advected, cell_weight_function, connect_mobility_status_weight_signals(), dynamic_check_frequency, DEMActionManager::get_action_manager(), inactive_status_factor, DEMActionManager::load_balance_step(), load_threshold, mpi_communicator, n_mpi_processes, particle_handler, particle_weight, simulation_control, and triangulation.

◆ connect_mobility_status_weight_signals()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::connect_mobility_status_weight_signals ( )
inline

Connects the weight signals of the cells to the triangulation with the mobility status. Cells are reconnected when load balancing is checked with the new mobility status.

Definition at line 209 of file load_balancing.h.

References calculate_total_cell_weight_with_mobility_status(), cell_weight, and triangulation.

◆ connect_weight_signals()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::connect_weight_signals ( )
inline

Connects the weight signals of the cells to the triangulation.

In order to consider the particles when repartitioning the triangulation the algorithm needs to know three things:

  1. How much weight to assign to each cell (how many particles are in there)
  2. How to pack the particles before shipping data around
  3. How to unpack the particles after repartitioning Attach the correct functions to the signals inside parallel::distributed::Triangulation, which will be called every time the load balancing or refinement functions are called.

Definition at line 187 of file load_balancing.h.

References calculate_total_cell_weight(), cell_weight_function, and triangulation.

◆ copy_references()

template<int dim, typename PropertiesIndex>
void LagrangianLoadBalancing< dim, PropertiesIndex >::copy_references ( std::shared_ptr< SimulationControl > & simulation_control,
parallel::distributed::Triangulation< dim > & triangulation,
Particles::ParticleHandler< dim > & particle_handler,
AdaptiveSparseContacts< dim, PropertiesIndex > & adaptive_sparse_contacts )
inline

Copies the references to the simulation control, triangulation, particle handler and adaptive sparse contacts (enabled or disabled). This is necessary to access the data structures and functions of these during the load balancing check.

Parameters
[in]simulation_controlThe simulation control object (accesses to the time step)
[in]triangulationThe triangulation object (for dynamics connexion of signals with ASC)
[in]particle_handlerThe particle handler object (accesses to the particles in cells)
[in]adaptive_sparse_contactsThe adaptive sparse contacts object (accesses to the mobility status of the cells)

Definition at line 76 of file load_balancing.h.

References adaptive_sparse_contacts, particle_handler, simulation_control, and triangulation.

◆ set_iteration_check_function()

template<int dim, typename PropertiesIndex>
std::function< void()> LagrangianLoadBalancing< dim, PropertiesIndex >::set_iteration_check_function ( )
inline

Sets the load balancing iteration check function according to the chosen load balancing method. During the setup of the parameters, the validation of the method is already checked, so the default value is when the method is none.

Returns
Return a function that returns a bool indicating if the current time step is a load balance iteration.

Definition at line 109 of file load_balancing.h.

References check_load_balance_dynamic(), check_load_balance_frequent(), check_load_balance_once(), check_load_balance_with_sparse_contacts(), Parameters::Lagrangian::ModelParameters< dim >::dynamic, Parameters::Lagrangian::ModelParameters< dim >::frequent, load_balance_method, and Parameters::Lagrangian::ModelParameters< dim >::once.

◆ set_parameters()

Member Data Documentation

◆ active_status_factor

template<int dim, typename PropertiesIndex>
double LagrangianLoadBalancing< dim, PropertiesIndex >::active_status_factor
private

Load weight factor of particle weight in a cell with an active mobility status (only with ASC).

Definition at line 321 of file load_balancing.h.

◆ adaptive_sparse_contacts

template<int dim, typename PropertiesIndex>
AdaptiveSparseContacts<dim, PropertiesIndex>* LagrangianLoadBalancing< dim, PropertiesIndex >::adaptive_sparse_contacts
private

Pointer to the adaptive sparse contacts object.

Definition at line 385 of file load_balancing.h.

◆ cell_weight

template<int dim, typename PropertiesIndex>
const unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::cell_weight = 1000
private

Default hard-coded load weight of a cell.

Definition at line 302 of file load_balancing.h.

◆ cell_weight_function

template<int dim, typename PropertiesIndex>
std::shared_ptr<Function<dim> > LagrangianLoadBalancing< dim, PropertiesIndex >::cell_weight_function
private

Definition at line 304 of file load_balancing.h.

◆ dynamic_check_frequency

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::dynamic_check_frequency
private

Frequency of check for the load balancing execution, only when method is dynamic.

Definition at line 339 of file load_balancing.h.

◆ inactive_status_factor

template<int dim, typename PropertiesIndex>
double LagrangianLoadBalancing< dim, PropertiesIndex >::inactive_status_factor
private

Load weight factor of particle weight in a cell with an inactive mobility status (only with ASC).

Definition at line 315 of file load_balancing.h.

◆ iteration_check_function

template<int dim, typename PropertiesIndex>
std::function<void()> LagrangianLoadBalancing< dim, PropertiesIndex >::iteration_check_function
private

The load balancing iteration check function according to the load balancing method.

Definition at line 297 of file load_balancing.h.

◆ load_balance_frequency

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::load_balance_frequency
private

Frequency of load balancing execution, only when method is frequent.

Definition at line 333 of file load_balancing.h.

◆ load_balance_method

template<int dim, typename PropertiesIndex>
Parameters::Lagrangian::ModelParameters<dim>::LoadBalanceMethod LagrangianLoadBalancing< dim, PropertiesIndex >::load_balance_method
private

The load balancing method chosen by the user.

Definition at line 291 of file load_balancing.h.

◆ load_balance_step

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::load_balance_step
private

Iteration number for load balancing execution, only when method is once.

Definition at line 327 of file load_balancing.h.

◆ load_threshold

template<int dim, typename PropertiesIndex>
double LagrangianLoadBalancing< dim, PropertiesIndex >::load_threshold
private

Threshold (\beta) for the check load balancing execution, only when method is dynamic.

Load balancing will be done when the computational load amongst core is too uneven. If L_{max} - L_{min} > \beta \bar{L}, where L_{max}, L_{min}, and \bar{L} are the maximum, minimum, and the average load, the load balancing will be executed.

Definition at line 350 of file load_balancing.h.

◆ mpi_communicator

template<int dim, typename PropertiesIndex>
MPI_Comm LagrangianLoadBalancing< dim, PropertiesIndex >::mpi_communicator
private

MPI communicator.

Definition at line 355 of file load_balancing.h.

◆ n_mpi_processes

template<int dim, typename PropertiesIndex>
const unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::n_mpi_processes
private

Number of MPI processes.

Definition at line 360 of file load_balancing.h.

◆ particle_handler

template<int dim, typename PropertiesIndex>
Particles::ParticleHandler<dim>* LagrangianLoadBalancing< dim, PropertiesIndex >::particle_handler
private

Pointer to the particle handler object.

Definition at line 380 of file load_balancing.h.

◆ particle_weight

template<int dim, typename PropertiesIndex>
unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::particle_weight
private

Load weight of a particle, the default parameters is 10000.

Definition at line 309 of file load_balancing.h.

◆ simulation_control

template<int dim, typename PropertiesIndex>
std::shared_ptr<SimulationControl> LagrangianLoadBalancing< dim, PropertiesIndex >::simulation_control
private

Pointer to the simulation control object.

Definition at line 370 of file load_balancing.h.

◆ this_mpi_process

template<int dim, typename PropertiesIndex>
const unsigned int LagrangianLoadBalancing< dim, PropertiesIndex >::this_mpi_process
private

Rank of the current MPI process.

Definition at line 365 of file load_balancing.h.

◆ triangulation

template<int dim, typename PropertiesIndex>
parallel::distributed::Triangulation<dim>* LagrangianLoadBalancing< dim, PropertiesIndex >::triangulation
private

Pointer to the triangulation object.

Definition at line 375 of file load_balancing.h.


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