64 Create the actual sequence of tasks following the description
65 from @ref page_exahype_numerical_scheme "Adding a numerical scheme", as grid construction,
66 numerical scheme, but also plotting all follow the same pattern
67 of tasks and dependencies.
71 "Create setup task graph for fourth-order Finite Differences with Runge-Kutta over a regular, block-structured mesh"
75 isinstance(term, InitPointWisely)
for term
in self.
_solver.pde_terms
77 f
"Solver {self._solver.name} has no InitPointWisely PDE term registered. "
78 "SetupSimulationOverRegularGrid needs one to fill in the initial condition - "
79 "add one via solver.add_pde_term(exahype2.api.InitPointWisely(...))."
87 name=f
"{self._solver.name}_Refine mesh",
88 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
90 "not peano4::grid::isGridStationary( peano4::parallel::SpacetreeSet::getInstance().getGridStatistics() )"
91 " or ( ::toolbox::loadbalancing::LoadBalancingService::getInstance().hasLoadBalancing()"
92 " and ( not ::toolbox::loadbalancing::LoadBalancingService::getInstance().getLoadBalancing()->hasStagnated()"
93 " or ::toolbox::loadbalancing::LoadBalancingService::getInstance().getLoadBalancing()->hasSplitRecently() ) )"
97 name=f
"{self._solver.name}_Consolidate mesh",
98 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
100 "not peano4::grid::isGridStationary( peano4::parallel::SpacetreeSet::getInstance().getGridStatistics() )"
101 " or ( ::toolbox::loadbalancing::LoadBalancingService::getInstance().hasLoadBalancing()"
102 " and ::toolbox::loadbalancing::LoadBalancingService::getInstance().getLoadBalancing()->hasSplitRecently() )"
106 assert hasattr(self.
_solver.numerical_scheme,
"patch_size"), (
107 f
"Solver {self._solver.name}'s numerical scheme has no attribute "
108 "patch_size. SetupSimulationOverRegularGrid assumes the numerical "
109 "scheme has added this field to itself immediately upon construction."
118 refine_task.add_action_set(
122 "not ::toolbox::loadbalancing::LoadBalancingService::getInstance().hasLoadBalancing()"
123 " or not ::toolbox::loadbalancing::LoadBalancingService::getInstance().getLoadBalancing()->hasSplitRecently()"
126#include "toolbox/loadbalancing/AbstractLoadBalancing.h"
127#include "toolbox/loadbalancing/LoadBalancingService.h"
132 refine_task.add_action_set(toolbox.loadbalancing.api.actionsets.LoadBalancing())
136 consolidate_load_balancing_task.add_action_set(
137 toolbox.loadbalancing.api.actionsets.ToggleLoadBalancing(
138 enable_load_balancing=
False, plug_into_prepare_traversal=
True
141 consolidate_load_balancing_task.add_action_set(
142 toolbox.loadbalancing.api.actionsets.LoadBalancing()
146 name=f
"{self._solver.name} Initial condition",
147 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
150 name=f
"{self._solver.name} Project on faces",
151 entity=peano4.api.taskgraph.Task.GridEntity.CELL,
154 consolidate_load_balancing_task.add_dependency(refine_task)
155 initial_condition_task.add_dependency(consolidate_load_balancing_task)
156 project_on_faces_task.add_dependency(initial_condition_task)
158 initial_condition_task.add_action_set(
163 project_on_faces_task.add_action_set(
164 ProjectPatchOntoFaces(
166 self.
_solver._patch_overlap_update,
167 guard=self.
_solver.grid_selector.createCellGuard(),
168 includes=self.
_solver._get_default_includes()
169 + self.
_solver.user_solver_includes,
174 project_on_faces_task.add_action_set(
175 RollOverUpdatedFaceWithSommerfeldBoundaryConditions.create_roll_over(
178 guard=self.
_solver.grid_selector.createFaceGuard(),
179 includes=self.
_solver._get_default_includes()
180 + self.
_solver.user_solver_includes,
184 add_auxiliary_variables_to_setup(
185 self.
_solver, initial_condition_task, project_on_faces_task, ProjectPatchOntoFaces, RollOverUpdatedFace
188 setup_simulation.add_task(refine_task)
189 setup_simulation.add_task(consolidate_load_balancing_task)
190 setup_simulation.add_task(initial_condition_task)
191 setup_simulation.add_task(project_on_faces_task)
193 initial_condition_task.use_cell(
194 self.
_solver._patch, peano4.api.taskgraph.Task.DataAccess.WRITE
196 project_on_faces_task.use_cell(
197 self.
_solver._patch, peano4.api.taskgraph.Task.DataAccess.READ_AND_WRITE
199 project_on_faces_task.use_face(
200 self.
_solver._patch_overlap_update,
201 peano4.api.taskgraph.Task.DataAccess.TEMPORARY,
203 project_on_faces_task.use_face(
204 self.
_solver._patch_overlap_current_time_step,
205 peano4.api.taskgraph.Task.DataAccess.WRITE,
209 setup_simulation.visualise(
210 title=
"Setup task graph for {}".format(self.
_solver.name)
213 setup_simulation.log_as_text(
214 title=
"Setup task graph for {}".format(self.
_solver.name)