Peano
Loading...
Searching...
No Matches
create_copy_task.py
Go to the documentation of this file.
1""" This file is part of the ExaGRyPE project. For conditions of distribution and
2 use, please see the copyright notice at www.peano-framework.org
3"""
4
5import exahype2.api
8
9from ..actionsets import CopyPatchWithLinearInterpolation
10
11
12def create_copy_task(name, source_patch, target_solver, auxiliary_copies):
13 """!
14
15 Create the task that fills the auxiliary variables of a solver with data of another solver
16
17 The task copies source_patch into the auxiliary variables auxiliary_copies of
18 target_solver (interpolating piecewise linearly if the patches differ in
19 size), projects them onto the faces, restricts them on hanging faces, and
20 rolls the faces over. The solver then reconstructs the halo of the
21 auxiliary variables from the faces. The task is the one place that writes
22 new face data of the auxiliary variables. It keeps the source patch alive,
23 i.e. the solver that owns it can still read it afterwards. The caller adds the
24 task to a graph and wires it.
25
26 @param name: str
27 Name of the task.
28
29 @param source_patch: peano4.api.datamodel.Patch
30 The data to copy, i.e. the persistent patch of the producing solver,
31 or its input of a Runge-Kutta stage.
32
33 @param target_solver: exahype2.api.Solver
34 Holds the auxiliary variables. It needs a numerical scheme already.
35
36 @param auxiliary_copies: exahype2.api.AuxiliaryVariables
37 The auxiliary variables of the target solver.
38
39 @return peano4.api.taskgraph.Task
40
41 """
42 Access = peano4.api.taskgraph.Task.DataAccess
44 includes = target_solver._get_default_includes() + target_solver.user_solver_includes
45 cell_guard = target_solver.grid_selector.createCellGuard()
46 face_guard = target_solver.grid_selector.createFaceGuard()
47
49 name=name, entity=peano4.api.taskgraph.Task.GridEntity.CELL
50 )
51 task.use_cell(source_patch, Access.READ_AND_WRITE)
52 task.use_cell(auxiliary_copies.patch, Access.READ_AND_WRITE)
53 task.use_face(auxiliary_copies.patch_overlap_update, Access.TEMPORARY)
54 task.use_face(auxiliary_copies.patch_overlap_current_time_step, Access.READ_AND_WRITE)
55 task.add_action_set(
56 CopyPatchWithLinearInterpolation(
57 source_patch=source_patch,
58 target_patch=auxiliary_copies.patch,
59 guard=cell_guard,
60 additional_includes=includes,
61 )
62 )
63 task.add_action_set(
64 actionsets.ProjectPatchOntoFaces(
65 auxiliary_copies.patch,
66 auxiliary_copies.patch_overlap_update,
67 guard=cell_guard,
68 includes=includes,
69 )
70 )
71 task.add_action_set(
72 toolbox.blockstructured.api.RestrictHangingFaces(
73 auxiliary_copies.patch_overlap_update,
74 scheme=target_solver.numerical_scheme.restriction,
75 clear_guard=face_guard,
76 additional_includes=includes,
77 )
78 )
79 task.add_action_set(
80 actionsets.RollOverUpdatedFace(
81 auxiliary_copies.patch_overlap_current_time_step,
82 auxiliary_copies.patch_overlap_update,
83 guard=face_guard,
84 includes=includes,
85 )
86 )
87 return task
One task within a peano4.api.taskgraph.Graph.
Definition Task.py:8
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...
Definition __init__.py:1