14 Load balancing metric which assigns each cell a value
16 To use this metric, you have to do a couple of steps:
18 1. Create a new label via create_cell_label(). Capture the result object.
19 2. Create a new instance of this class.
20 3. Add the metric to the algorithmic step of your choice. A typical set is
22 project.add_action_set_to_create_grid( load_balancing_action_set )
26 So overall, a typical use looks similar to:
30 load_balancing_cell_label = exahype2.grid.FineGridCellLoadBalancingCostMetric.create_cell_label(project)
31 load_balancing_action_set = exahype2.grid.FineGridCellLoadBalancingCostMetric(load_balancing_cell_label)
32 project.add_action_set_to_create_grid( load_balancing_action_set )
33 project.set_load_balancing(
34 "toolbox::loadbalancing::strategies::cascade::SpreadOut_SplitOversizedTree",
35 "new ::exahype2::LoadBalancingConfiguration(0.98, 1, " + str(args.trees) + "), new toolbox::loadbalancing::metrics::CustomCellWeight()",
41 load_balancing_cell_label,
42 initialisation_weight = "1.0",
44 super( FineGridCellLoadBalancingCostMetric, self ).
__init__()
50 return __name__.replace(
".py",
"").replace(
".",
"_")
59 if operation_name==ActionSet.OPERATION_CREATE_CELL:
65 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
67 if (not marker.willBeRefined()) {
68 toolbox::loadbalancing::metrics::CustomCellWeight::logCellWeight(
85 _treeNumber = treeNumber;
91#include "repositories/SolverRepository.h"
92#include "toolbox/loadbalancing/metrics/CustomCellWeight.h"
96 def create_cell_label(exahype2_project,
97 name="LoadBalancingCostMetric"):
100 Create a cell label that's then used for the load balancing
107 result.peano4_mpi_and_storage_aspect.merge_implementation =
"""
109 case ::peano4::grid::TraversalObserver::SendReceiveContext::BoundaryExchange:
110 assertionMsg( false, "cells should never be subject of a boundary exchange" );
112 case ::peano4::grid::TraversalObserver::SendReceiveContext::ForkDomain:
116 assertionMsg( false, "not implemented yet" );
121 exahype2_project._project.datamodel.add_cell(result)
123 exahype2_project.plot_solution.use_cell(result)
124 exahype2_project.init_grid.use_cell(result)
125 exahype2_project.perform_time_step.use_cell(result)
126 exahype2_project.create_grid.use_cell(result)
127 exahype2_project.create_grid_but_postpone_refinement.use_cell(result)
128 exahype2_project.create_grid_and_converge_lb.use_cell(result)
cardinality is a string (you can thus use symbols as well as long as they will be defined at compile ...
Load balancing metric which assigns each cell a value.
get_constructor_body(self)
Define a tailored constructor body.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_includes(self)
Return include statements that you need.
__init__(self, load_balancing_cell_label, initialisation_weight="1.0")
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
load_balancing_cell_label
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_action_set_name(self)
Return unique action set name.
Default superclass for any data model in Peano which is stored within the grid.
Action set (reactions to events)