10from ...blockstructured.BoundaryConditions
import get_boundary_conditions
16 Set the ghost volumes along the domain boundary through the solver's
17 exahype2.api.DirichletBoundaryConditions term
19 The action set plugs into touchFaceFirstTime() and delegates to
20 exahype2::blockstructured::applyDirichletBoundaryConditions(), which
21 holds the logic described below. Each face carries an
22 overlap of 2*overlap volumes along its normal (solver._patch_overlap_current_time_step):
23 the left half belongs to the cell left of the face, the right half to
24 the cell right of it. On the domain boundary, one of these two cells
25 lies outside of the domain. Nobody ever writes its half of the face
26 data. This action set fills exactly this half: For each of the
27 outside's volumes, it invokes
30 repositories::<solver>.dirichletBoundaryConditions( x, t, Q );
33 with x being the centre of the (ghost) volume and t the solver's
34 current time stamp getMinTimeStamp(). Faces along periodic axes are
35 skipped (PeriodicBC from the project's Constants.h). Whether a face is
36 on the domain boundary is derived from its position, i.e. compared
37 against DomainOffset and DomainOffset+DomainSize.
39 The subsequent reconstruction
40 (toolbox.blockstructured.api.ReconstructPatchWithHalo) reads the face
41 data in touchCellFirstTime(). As Peano touches all faces of a cell for
42 the first time before it enters the cell, the boundary task and the
43 reconstruction can share one mesh traversal (@ref
44 peano4.api.taskgraph.compiler.FuseSteps.translate()).
46 Use add_task_to_time_step() to add the corresponding task to a time
49 ## Why Dirichlet conditions are not part of the roll over
51 exahype2.api.SommerfeldBoundaryConditions do without a boundary task:
52 They advance the ghost cells within the roll over of the face data
53 after the projection. Dirichlet conditions could be realised the same
54 way, as the roll over could evaluate the boundary values at the time
55 stamp of the next update. We deliberately keep them as a separate task
56 which runs directly before the reconstruction, as this will not work
57 anymore once we support local time stepping: With local time stepping,
58 each cell advances with its own time step size, and the time stamp at
59 which the ghost cells have to hold the boundary values is only known
60 once the adjacent cell starts its next update, but not when the face
61 data are rolled over after its previous update.
65 TemplateTouchFaceFirstTime = jinja2.Template(
67 ::exahype2::blockstructured::applyDirichletBoundaryConditions(
68 [](const tarch::la::Vector<Dimensions,double>& x, double t, double* Q) -> void {
69 repositories::{{SOLVER_INSTANCE}}.dirichletBoundaryConditions(x, t, Q);
75 {{NUMBER_OF_VOLUMES_PER_AXIS}},
77 {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}},
78 repositories::{{SOLVER_INSTANCE}}.getMinTimeStamp(),
79 {{FACE_ACCESSOR}}.value
84 def __init__(self, solver, patch_overlap, guard):
87 @param solver: exahype2.api.Solver
88 The solver whose dirichletBoundaryConditions() is invoked.
90 @param patch_overlap: peano4.api.datamodel.Patch
91 The face data to set, i.e. solver._patch_overlap_current_time_step.
92 Its dim[0] is twice the overlap, its dim[1] the number of volumes
93 per axis of the cell patch.
96 C++ boolean expression over a FaceMarker called marker. Typically
97 solver.grid_selector.createFaceGuard().
100 super().
__init__(descend_invocation_order=1, parallel=
False)
104 "SOLVER_INSTANCE": solver.get_name_of_global_instance(),
105 "NUMBER_OF_VOLUMES_PER_AXIS": str(patch_overlap.dim[1]),
106 "OVERLAP": str(int(patch_overlap.dim[0] / 2)),
107 "NUMBER_OF_UNKNOWNS": str(solver.unknowns),
108 "NUMBER_OF_AUXILIARY_VARIABLES": str(solver.auxiliary_variables),
109 "FACE_ACCESSOR":
"fineGridFace" + patch_overlap.name,
115 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME
123 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME
129 return __name__.replace(
".py",
"").replace(
".",
"_")
137#include "exahype2/blockstructured/DirichletBoundaryConditions.h"
139 + self.
_solver._get_default_includes()
140 + self.
_solver.user_solver_includes
150 additional_guard="true",
154 Add the boundary task in front of a Finite Volume reconstruction
156 If all axes of the domain are periodic, or if the solver uses
157 exahype2.api.SommerfeldBoundaryConditions (which replace the roll
158 over instead), the routine does nothing. Otherwise, it adds a FACE
159 task which sets the ghost volumes
160 of solver._patch_overlap_current_time_step, and makes
161 reconstruction_task depend on it.
163 @param solver: exahype2.api.Solver
164 The solver. Its boundary condition terms have to be consistent
165 with the domain, @ref
166 exahype2.api.blockstructured.BoundaryConditions.get_boundary_conditions().
168 @param exahype2_project: exahype2.api.Project
169 Provides the periodic boundary conditions.
171 @param time_step: peano4.api.taskgraph.Graph
172 The time step's task graph.
174 @param reconstruction_task: peano4.api.taskgraph.Task
175 The task reading solver._patch_overlap_current_time_step to
176 reconstruct the patches' halos.
178 @param name_suffix: str
179 Appended to the task's name. The names of all tasks within one
180 graph have to differ.
182 @param additional_guard: str
183 C++ predicate which is combined with the guard of the boundary
184 action set, e.g. the is<Name>Active() of a plotter which
185 reconstructs the halo (@ref exahype2.api.fv.WriteCheckpoint).
187 @return peano4.api.taskgraph.Task or None
188 The boundary task, or None if no Dirichlet task is required.
192 get_boundary_conditions(solver, exahype2_project),
193 DirichletBoundaryConditions,
198 name=f
"{solver.name}_Apply Dirichlet BCs{name_suffix}",
199 entity=peano4.api.taskgraph.Task.GridEntity.FACE,
201 boundary_task.use_face(
202 solver._patch_overlap_current_time_step,
203 peano4.api.taskgraph.Task.DataAccess.READ_AND_WRITE,
205 boundary_task.add_action_set(
208 solver._patch_overlap_current_time_step,
212 + solver.grid_selector.createFaceGuard()
216 time_step.add_task(boundary_task)
217 reconstruction_task.add_dependency(boundary_task)
Dirichlet boundary conditions: given a position x outside of the domain and a time stamp t,...
Set the ghost volumes along the domain boundary through the solver's exahype2.api....
get_action_set_name(self)
Return unique action set name.
TemplateTouchFaceFirstTime
get_includes(self)
Return include statements that you need.
add_task_to_time_step(solver, exahype2_project, time_step, reconstruction_task, name_suffix="", additional_guard="true")
Add the boundary task in front of a Finite Volume reconstruction.
user_should_modify_template(self)
Is the user allowed to modify the output.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
__init__(self, solver, patch_overlap, guard)
Action set (reactions to events)
One task within a peano4.api.taskgraph.Graph.
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...