9 Hand the refine and erase requests of the last time step over to Peano,
10 and restart the time stepping if the mesh has changed
12 The last task of each time step collects refine and erase requests
13 within ::exahype2::RefinementControlService
14 (@ref exahype2.api.blockstructured.DynamicMeshRefinement). The mesh
15 adaptation phase hosts this action set in its repeating task. The action
16 set does not issue any further request. It
18 - hands the service's committed events over to Peano
19 (createGridControlEventsForNextTraversal()), so Peano realises them,
20 - calls the service's finishStep() once per rank after each mesh
21 sweep, so the events expire after their lifetime. The repeating task
22 runs until the service holds no events anymore, i.e. no request
23 survives into the next time step, and
24 - keeps track of whether a mesh sweep has created or destroyed any cell.
25 If so, it resets the solver's time step size to zero
26 (exahype2::Solver::resetTimeStepSize()) at the end of the sweep. The
27 time step size of the old mesh might violate the CFL condition on the
28 new mesh. With a time step size of zero, the subsequent time step does
29 not advance in time but derives a new admissible time step size from
32 Whether the mesh has changed is reduced over all ranks, so all ranks
33 reset the time step size consistently.
40 @param solver: exahype2.api.Solver
41 The solver whose time step size is reset if the mesh changes.
44 super().
__init__(descend_invocation_order=1, parallel=
False)
54 return " return ::exahype2::RefinementControlService::getInstance().createGridControlEventsForNextTraversal();\n"
57 return " _meshHasChanged = false;\n"
61 ::exahype2::RefinementControlService::getInstance().finishStep();
63 int localMeshHasChanged = _meshHasChanged ? 1 : 0;
64 int globalMeshHasChanged = localMeshHasChanged;
66 tarch::mpi::Rank::getInstance().allReduce(
67 &localMeshHasChanged, &globalMeshHasChanged, 1, MPI_INT, MPI_MAX,
68 [&]() -> void {{ tarch::services::ServiceRepository::getInstance().receiveDanglingMessages(); }}
71 if (globalMeshHasChanged > 0) {{
72 logInfo( "unprepareTraversal()", "mesh has changed, reset time step size of {self._solver.name} to zero" );
73 repositories::{self._solver.get_name_of_global_instance()}.resetTimeStepSize();
78 if operation_name
in [
79 ActionSet.OPERATION_CREATE_CELL,
80 ActionSet.OPERATION_DESTROY_CELL,
82 return " _meshHasChanged = true;\n"
87 static std::atomic<bool> _meshHasChanged;
92 f
"std::atomic<bool> {full_qualified_classname}::_meshHasChanged(false);\n"
96 return __name__.replace(
".py",
"").replace(
".",
"_")
105#include "exahype2/RefinementControlService.h"
106#include "tarch/mpi/Rank.h"
107#include "tarch/services/ServiceRepository.h"
109 + self.
_solver._get_default_includes()
110 + self.
_solver.user_solver_includes
Hand the refine and erase requests of the last time step over to Peano, and restart the time stepping...
get_attributes(self)
Return attributes as copied and pasted into the generated class.
get_body_of_unprepareTraversal(self)
user_should_modify_template(self)
Is the user allowed to modify the output.
get_constructor_body(self)
Define a tailored constructor body.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_static_initialisations(self, full_qualified_classname)
get_destructor_body(self)
get_body_of_createGridControlEventsForNextTraversal(self)
Return the grid control events that this action set wants to trigger.
get_includes(self)
Return include statements that you need.
get_body_of_prepareTraversal(self)
get_action_set_name(self)
Return unique action set name.
Action set (reactions to events)