120 def __init__(self, ccz4_name: str =
"CCZ4", euler_name: str =
"Euler"):
123 Create the two solvers and the auxiliary variables through which they see each other
125 The coupling happens at the begin and at the end of the time step
126 only, so the numerical schemes of the solvers remain flexible.
128 @param ccz4_name: str
129 Name of the CCZ4 solver.
131 @param euler_name: str
132 Name of the Euler solver.
137 Mode = exahype2.api.AuxiliaryVariables.Mode
140 dict(Euler.Unknowns),
141 mode=Mode.STATIONARY_THROUGHOUT_TIME_STEPS_ON_FACES,
142 data_name=
"EulerFieldsForCCZ4",
146 dict(FOCCZ4Solver.Unknowns),
147 mode=Mode.STATIONARY_THROUGHOUT_TIME_STEPS_ON_FACES,
148 data_name=
"CCZ4FieldsForEuler",
152 self.
_name = f
"{ccz4_name}With{euler_name}"
174 Realise both solvers, couple their time stepping graphs, and add the outcome to the project's graphs
176 The arguments are those of exahype2.api.Solver.generate_solver_realisation().
177 Both solvers are realised without global tasks. The load balancing and the dynamic
178 mesh refinement wrap the coupled time step graph afterwards, through the scheme of CCZ4.
185 solver.generate_solver_realisation(
192 add_global_tasks=
False,
194 coupled_time_step.merge(own_time_step)
195 self.
_couple(exahype2_project, peano_project, coupled_time_step)
197 self.
ccz4.numerical_scheme.wrap_task_graph_in_load_balancing_and_amr_tasks(
200 if self.
ccz4.mesh_adaptation
is not None:
201 self.
ccz4.mesh_adaptation.construct_output(
202 exahype2_project, peano_project, mesh_adaptation
205 title = f
"Time stepping task graph for host {self.name}"
207 coupled_time_step.visualise(title=title)
209 coupled_time_step.log_as_text(title=title)
210 time_step.merge(coupled_time_step)
212 def _couple(self, exahype2_project, peano_project, time_step):
215 Add the preamble and the final task around the concatenated graphs
217 @param exahype2_project: exahype2.api.Project
218 The project that hosts the system.
220 @param peano_project: peano4.api.Project
221 The Peano project that the exahype2 project assembles.
223 @param time_step: peano4.api.taskgraph.Graph
224 The concatenation of the time step graphs of both solvers. It
225 receives the new tasks. All its source tasks are first tasks of a
226 solver, and all its sink tasks (but the global ones) are last tasks
231 "Coupling " + self.
ccz4.name +
" and " + self.
euler.name
233 Entity = peano4.api.taskgraph.Task.GridEntity
236 first_tasks = time_step.source_tasks()
238 task
for task
in time_step.sink_tasks()
if task.entity != Entity.GLOBAL
250 for first_task
in first_tasks:
252 first_task.add_dependency(prep)
258 for task
in last_tasks:
259 synchronise.add_dependency(task)
260 synchronise.add_action_set(SynchroniseTimeStepSizes([self.
ccz4, self.
euler]))
261 time_step.add_task(synchronise)
265 self, time_step, source_solver, target_solver, auxiliary_copies
269 Create the task that fills the auxiliary variables of one solver with the solution of the other one
271 auxiliary copies (auxiliary_copies) of the target solver (copy, with
272 auxiliary variables auxiliary_copies of the target solver (copy, with
273 interpolation if the patches differ in size), projects them onto the
274 faces, restricts them on hanging faces, and rolls the faces over. It is
275 added to time_step, but no dependencies are set: the caller wires it.
276 It is the one place that writes new face data.
278 @param time_step: peano4.api.taskgraph.Graph
281 @param source_solver: exahype2.api.Solver
284 @param target_solver: exahype2.api.Solver
285 Holds the auxiliary variables.
287 @param auxiliary_copies: exahype2.api.AuxiliaryVariables
288 The auxiliary variables of the target solver.
290 @return peano4.api.taskgraph.Task
294 Access = peano4.api.taskgraph.Task.DataAccess
295 Entity = peano4.api.taskgraph.Task.GridEntity
298 target_solver._get_default_includes() + target_solver.user_solver_includes
304 prep.use_cell(source_solver._patch, Access.READ_AND_WRITE)
305 prep.use_cell(auxiliary_copies.patch, Access.READ_AND_WRITE)
306 prep.use_face(auxiliary_copies.patch_overlap_update, Access.TEMPORARY)
307 prep.use_face(auxiliary_copies.patch_overlap_current_time_step, Access.READ_AND_WRITE)
309 CopyPatchWithLinearInterpolation(
310 source_patch=source_solver._patch,
311 target_patch=auxiliary_copies.patch,
312 guard=target_solver.grid_selector.createCellGuard(),
313 additional_includes=includes,
317 actionsets.ProjectPatchOntoFaces(
318 auxiliary_copies.patch,
319 auxiliary_copies.patch_overlap_update,
320 guard=target_solver.grid_selector.createCellGuard(),
325 toolbox.blockstructured.api.RestrictHangingFaces(
326 auxiliary_copies.patch_overlap_update,
327 scheme=target_solver.numerical_scheme.restriction,
328 clear_guard=target_solver.grid_selector.createFaceGuard(),
329 additional_includes=includes,
333 actionsets.RollOverUpdatedFace(
334 auxiliary_copies.patch_overlap_current_time_step,
335 auxiliary_copies.patch_overlap_update,
336 guard=target_solver.grid_selector.createFaceGuard(),
340 time_step.add_task(prep)