236 self, exahype2_project, peano_project, stage: int, number_of_stages: int
240 Create the chain of reconstruction tasks of one stage
242 The CCZ4 solver has to be realised before, as the routine needs its
243 data. The graph holds one chain of tasks, without any dependency on the
244 CCZ4 solver's tasks. Its sources are the two interpolation tasks, its only
245 sink the roll over. The host (exagrype.api.FOSOSolver) wires the chain
246 into the stage of the CCZ4 solver.
248 @param exahype2_project: exahype2.api.Project
249 The project that hosts the solvers (unused).
251 @param peano_project: peano4.api.Project
252 The Peano project that the exahype2 project assembles.
255 Stage of the Runge-Kutta scheme of the CCZ4 solver, 0 for Finite Volumes.
257 @param number_of_stages: int
258 Number of stages (unused).
260 @return peano4.api.taskgraph.Graph
263 reconstruction = self
266 scheme, actionsets, reconstruction_function, stages, per_stage = self.
_layout()
267 derivatives = ccz4.derivatives
269 Access = peano4.api.taskgraph.Task.DataAccess
270 Entity = peano4.api.taskgraph.Task.GridEntity
271 n = scheme.patch_size
272 h = scheme.HALO_SIZE
if per_stage
else scheme.overlap
273 cell_guard = ccz4.grid_selector.createCellGuard()
274 face_guard = ccz4.grid_selector.createFaceGuard()
276 ccz4._get_default_includes()
277 + ccz4.user_solver_includes
278 +
'\n#include "exagrype/ccz4/SecondOrderAuxiliaryVariablesReconstruction.h"\n'
284 def create_scratch_halo(unknowns, halo_name):
286 (n + 2 * h, n + 2 * h, n + 2 * h), unknowns, halo_name
288 halo.grid_selector = ccz4.grid_selector
292 peano_project.datamodel.add_cell(halo)
298 create_scratch_halo(ccz4.unknowns, name +
"PrimaryVariablesWithHalo"),
300 derivatives.size, name + derivatives.data_name +
"WithHalo"
306 f
"::exagrype::ccz4::{reconstruction_function}("
307 f
"oldQWithHalo, marker.h(), {n}, {h}, newQ);"
310 stage_input = ccz4._patch
if stage == 0
else ccz4._stage_input
311 suffix = f
" stage {stage}" if per_stage
else ""
313 def create_task(task_name):
315 name=f
"{name}_{task_name}{suffix}", entity=Entity.CELL
324 reconstruct_primary = create_task(
"Reconstruct primary variables")
325 reconstruct_primary.use_cell(stage_input, Access.READ_AND_WRITE)
326 reconstruct_primary.use_cell(primary_halo, Access.WRITE)
327 reconstruct_primary.use_face(
328 ccz4._patch_overlap_current_time_step, Access.READ_AND_WRITE
330 reconstruct_primary.add_action_set(
331 toolbox.blockstructured.api.ReconstructPatchWithHalo(
333 patch_overlap=ccz4._patch_overlap_current_time_step,
334 reconstructed_patch=primary_halo,
336 add_assertions_to_halo_exchange=
False,
337 additional_includes=includes,
344 interpolate_primary = create_task(
345 "Interpolate primary variables on hanging faces"
347 interpolate_primary.use_face(
348 ccz4._patch_overlap_current_time_step, Access.READ_AND_WRITE
350 interpolate_primary.add_action_set(
351 toolbox.blockstructured.api.InterpolateHangingFaces(
352 ccz4._patch_overlap_current_time_step,
353 scheme=scheme.interpolation,
354 additional_includes=includes,
357 interpolate_derivatives = create_task(
358 "Interpolate derivative variables on hanging faces"
360 interpolate_derivatives.use_face(
361 derivatives.patch_overlap_current_time_step, Access.READ_AND_WRITE
363 interpolate_derivatives.add_action_set(
364 toolbox.blockstructured.api.InterpolateHangingFaces(
365 derivatives.patch_overlap_current_time_step,
366 scheme=scheme.interpolation,
367 additional_includes=includes,
370 reconstruct_derivatives = create_task(
"Reconstruct derivative variables")
371 reconstruct_derivatives.use_cell(derivatives.patch, Access.READ_AND_WRITE)
372 reconstruct_derivatives.use_cell(derivative_halo, Access.WRITE)
373 reconstruct_derivatives.use_face(
374 derivatives.patch_overlap_current_time_step, Access.READ_AND_WRITE
376 reconstruct_derivatives.add_action_set(
377 toolbox.blockstructured.api.ReconstructPatchWithHalo(
378 patch=derivatives.patch,
379 patch_overlap=derivatives.patch_overlap_current_time_step,
380 reconstructed_patch=derivative_halo,
382 add_assertions_to_halo_exchange=
False,
383 additional_includes=includes,
388 apply_stencil = create_task(
"Reconstruct derivatives")
389 apply_stencil.use_cell(primary_halo, Access.READ_AND_DISCARD)
390 apply_stencil.use_cell(derivative_halo, Access.READ_AND_DISCARD)
391 apply_stencil.use_cell(derivatives.patch, Access.READ_AND_WRITE)
392 apply_stencil.add_action_set(
393 ApplyReconstructionFunctor(
394 patch=derivatives.patch,
395 primary_variables_with_halo=primary_halo,
396 derivative_variables_with_halo=derivative_halo,
397 functor_implementation=functor,
399 additional_includes=includes,
402 apply_stencil.add_dependency(reconstruct_primary)
403 apply_stencil.add_dependency(reconstruct_derivatives)
406 project = create_task(
"Project derivative variables onto faces")
407 project.use_cell(derivatives.patch, Access.READ_AND_WRITE)
408 project.use_face(derivatives.patch_overlap_update, Access.TEMPORARY)
413 project.use_face(derivatives.patch_overlap_current_time_step, Access.WRITE)
414 project.add_action_set(
415 actionsets.ProjectPatchOntoFaces(
417 derivatives.patch_overlap_update,
422 project.add_dependency(apply_stencil)
428 if derivatives.mode == exahype2.api.AuxiliaryVariables.Mode.CHANGING_ON_FACES:
429 restrict = create_task(
"Restrict derivative variables on hanging faces")
430 restrict.use_face(derivatives.patch_overlap_update, Access.TEMPORARY)
431 restrict.add_action_set(
432 toolbox.blockstructured.api.RestrictHangingFaces(
433 derivatives.patch_overlap_update,
434 scheme=scheme.restriction,
435 clear_guard=face_guard,
436 additional_includes=includes,
439 restrict.add_dependency(last_task)
443 roll_over = create_task(
"Roll over derivative variable faces")
444 roll_over.use_face(derivatives.patch_overlap_update, Access.TEMPORARY)
446 derivatives.patch_overlap_current_time_step, Access.TEMPORARY
448 roll_over.add_action_set(
449 actionsets.RollOverUpdatedFace(
450 derivatives.patch_overlap_current_time_step,
451 derivatives.patch_overlap_update,
456 roll_over.add_dependency(last_task)
458 reconstruct_derivatives.add_dependency(interpolate_derivatives)
459 reconstruct_primary.add_dependency(interpolate_primary)