6from .RollOverUpdatedFace
import RollOverUpdatedFace
7from ...blockstructured.BoundaryConditions
import get_boundary_conditions
14 Roll over the face data, and set the ghost grid cells along the domain
15 boundary through exahype2.api.SommerfeldBoundaryConditions first
17 The action set replaces exahype2.api.rkfd4.actionsets.RollOverUpdatedFace
18 if the solver uses Sommerfeld boundary conditions. Such a solver has no
19 separate boundary task (exahype2.api.rkfd4.actionsets.ApplyDirichletBoundaryConditions).
20 In touchFaceLastTime(), the action set first writes the ghost grid cells
21 into the ghost half of patch_overlap_update, and then rolls over both
22 halves into patch_overlap_current_time_step like RollOverUpdatedFace.
23 Faces within the domain and faces along periodic axes are rolled over
24 unchanged. There are two variants:
26 - With a time_step_size, the action set advances the ghost grid cells
27 through @ref exahype2::blockstructured::applySommerfeldBoundaryConditions().
28 patch_overlap_current_time_step still holds the old solution, i.e.
29 both its halves are valid, and patch_overlap_update holds the new
30 interior solution. The projection of every Runge-Kutta stage uses
31 this variant: It advances the ghost grid cells from the time stamp of
32 the stage to the one of the next stage, i.e. time_step_size is
33 @f$ (c_{k+1}-c_k) \\Delta t @f$, or @f$ (1-c_{s-1}) \\Delta t @f$ after
35 exahype2.api.rkfd4.CentralDifferencesWithRungeKutta).
36 - Without a time_step_size, the action set initialises the ghost grid cells
37 with the initial condition, i.e. it evaluates the solver's
38 initPointWisely() at their centres through
39 @ref exahype2::blockstructured::applyDirichletBoundaryConditions().
40 The grid construction uses this variant, so the first time step finds
41 valid ghost grid cells.
43 The C++ header documents the conditions, their discretisation and why
44 they replace the roll over. The class mirrors
45 exahype2.api.fv.actionsets.RollOverUpdatedFaceWithSommerfeldBoundaryConditions,
46 as rkfd4 does not depend on the Finite Volume package.
50 TemplateSommerfeldBoundaryConditions = jinja2.Template(
52 ::exahype2::blockstructured::applySommerfeldBoundaryConditions(
55 const tarch::la::Vector<Dimensions, double>& x,
59 repositories::{{SOLVER_INSTANCE}}.maxEigenvalue(Q, x, normal, &lambdaMax);
62 [](const tarch::la::Vector<Dimensions, double>& x, double* Q) -> void {
63 repositories::{{SOLVER_INSTANCE}}.sommerfeldFarFieldSolution(x, Q);
71 {{NUMBER_OF_UNKNOWNS}},
72 {{NUMBER_OF_AUXILIARY_VARIABLES}},
73 tarch::la::Vector<Dimensions, double>({{ORIGIN}}),
75 {{CURRENT_TIME_STEP_ACCESSOR}}.value,
76 {{UPDATE_ACCESSOR}}.value
81 TemplateInitialGhostCells = jinja2.Template(
83 ::exahype2::blockstructured::applyDirichletBoundaryConditions(
84 [](const tarch::la::Vector<Dimensions, double>& x, double t, double* Q) -> void {
85 repositories::{{SOLVER_INSTANCE}}.initPointWisely(x, Q);
93 {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}},
94 repositories::{{SOLVER_INSTANCE}}.getMinTimeStamp(),
95 {{UPDATE_ACCESSOR}}.value
103 patch_overlap_current_time_step,
104 patch_overlap_update,
112 @param solver: exahype2.api.Solver
113 The solver whose maxEigenvalue(), sommerfeldFarFieldSolution() and
114 initPointWisely() are invoked.
116 @param patch_overlap_current_time_step: peano4.api.datamodel.Patch
117 @see RollOverUpdatedFace.
119 @param patch_overlap_update: peano4.api.datamodel.Patch
120 @see RollOverUpdatedFace.
123 @see RollOverUpdatedFace.
126 @see RollOverUpdatedFace.
128 @param origin: List[float]
129 Centre of the system, one entry per dimension, @ref
130 exahype2.api.blockstructured.SommerfeldBoundaryConditions.SommerfeldBoundaryConditions.get_origin().
132 @param time_step_size: str
133 C++ expression for the time step size by which the ghost grid cells
134 are advanced, or None to initialise the ghost grid cells with the
135 initial condition instead.
139 patch_overlap_current_time_step, patch_overlap_update, guard, includes
142 self.
d[
"SOLVER_INSTANCE"] = solver.get_name_of_global_instance()
143 self.
d[
"NUMBER_OF_UNKNOWNS"] = str(solver.unknowns)
144 self.
d[
"NUMBER_OF_AUXILIARY_VARIABLES"] = str(solver.auxiliary_variables)
145 self.
d[
"ORIGIN"] =
"{" +
", ".join(repr(float(x))
for x
in origin) +
"}"
146 self.
d[
"TIME_STEP_SIZE"] = time_step_size
152 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME
159 result = template.render(**self.
d) + result
163 return __name__.replace(
".py",
"").replace(
".",
"_")
168#include "exahype2/blockstructured/DirichletBoundaryConditions.h"
169#include "exahype2/blockstructured/SommerfeldBoundaryConditions.h"
184 Create the roll over of the solver's face data
186 @return RollOverUpdatedFace
187 RollOverUpdatedFaceWithSommerfeldBoundaryConditions if the solver
188 uses exahype2.api.SommerfeldBoundaryConditions, and a plain
189 RollOverUpdatedFace otherwise, i.e. for Dirichlet boundary
190 conditions or a domain without boundary.
192 @param solver: exahype2.api.Solver
193 The solver whose solver._patch_overlap_update is rolled over into
194 solver._patch_overlap_current_time_step. Its boundary condition
195 terms have to be consistent with the domain, @ref
196 exahype2.api.blockstructured.BoundaryConditions.get_boundary_conditions().
198 @param exahype2_project: exahype2.api.Project
199 Provides the periodic boundary conditions.
202 @see RollOverUpdatedFace.
205 @see RollOverUpdatedFace.
207 @param time_step_size: str
208 @see the constructor. Ignored for a plain RollOverUpdatedFace.
211 term = get_boundary_conditions(solver, exahype2_project)
212 if isinstance(term, SommerfeldBoundaryConditions):
215 solver._patch_overlap_current_time_step,
216 solver._patch_overlap_update,
219 origin=term.get_origin(len(exahype2_project.periodic_BC)),
220 time_step_size=time_step_size,
223 solver._patch_overlap_current_time_step,
224 solver._patch_overlap_update,
Sommerfeld (radiative, outgoing) boundary conditions: waves leave the domain with little reflection,...
Roll over the face data, and set the ghost grid cells along the domain boundary through exahype2....
TemplateInitialGhostCells
TemplateSommerfeldBoundaryConditions
create_roll_over(solver, exahype2_project, guard, includes, time_step_size=None)
Create the roll over of the solver's face data.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_action_set_name(self)
Return unique action set name.
__init__(self, solver, patch_overlap_current_time_step, patch_overlap_update, guard, includes, origin, time_step_size=None)
get_includes(self)
Return include statements that you need.
Copy patch_overlap_update - the face overlap exahype2.api.rkfd4.actionsets.ProjectPatchOntoFaces has ...