6from .RollOverUpdatedFace
import RollOverUpdatedFace
7from ...blockstructured.BoundaryConditions
import (
8 get_boundary_conditions,
9 get_max_eigenvalue_term_for_sommerfeld,
17 Roll over the face data, and set the ghost grid cells along the domain
18 boundary through exahype2.api.SommerfeldBoundaryConditions first
20 The action set replaces exahype2.api.rkfd4.actionsets.RollOverUpdatedFace
21 if the solver uses Sommerfeld boundary conditions. Such a solver has no
22 separate boundary task (exahype2.api.rkfd4.actionsets.ApplyDirichletBoundaryConditions).
23 In touchFaceLastTime(), the action set first writes the ghost grid cells
24 into the ghost half of patch_overlap_update, and then rolls over both
25 halves into patch_overlap_current_time_step like RollOverUpdatedFace.
26 Faces within the domain and faces along periodic axes are rolled over
27 unchanged. There are two variants:
29 - With a time_step_size, the action set advances the ghost grid cells
30 through @ref exahype2::blockstructured::applySommerfeldBoundaryConditions().
31 patch_overlap_current_time_step still holds the old solution, i.e.
32 both its halves are valid, and patch_overlap_update holds the new
33 interior solution. The projection of every Runge-Kutta stage uses
34 this variant: It advances the ghost grid cells from the time stamp of
35 the stage to the one of the next stage, i.e. time_step_size is
36 @f$ (c_{k+1}-c_k) \\Delta t @f$, or @f$ (1-c_{s-1}) \\Delta t @f$ after
38 exahype2.api.rkfd4.CentralDifferencesWithRungeKutta).
39 - Without a time_step_size, the action set initialises the ghost grid cells
40 with the initial condition, i.e. it evaluates the solver's
41 initPointWisely() at their centres through
42 @ref exahype2::blockstructured::applyDirichletBoundaryConditions().
43 The grid construction uses this variant, so the first time step finds
44 valid ghost grid cells.
46 The C++ header documents the conditions, their discretisation and why
47 they replace the roll over. The class mirrors
48 exahype2.api.fv.actionsets.RollOverUpdatedFaceWithSommerfeldBoundaryConditions,
49 as rkfd4 does not depend on the Finite Volume package.
53 TemplateSommerfeldBoundaryConditions = jinja2.Template(
55 ::exahype2::blockstructured::applySommerfeldBoundaryConditions(
58 const tarch::la::Vector<Dimensions, double>& x,
62 repositories::{{SOLVER_INSTANCE}}.maxEigenvalue(Q, x, normal, &lambdaMax{{STATELESS_TAG}});
65 [](const tarch::la::Vector<Dimensions, double>& x, double* Q) -> void {
66 repositories::{{SOLVER_INSTANCE}}.sommerfeldFarFieldSolution(x, Q);
74 {{NUMBER_OF_UNKNOWNS}},
75 {{NUMBER_OF_AUXILIARY_VARIABLES}},
76 tarch::la::Vector<Dimensions, double>({{ORIGIN}}),
78 {{CURRENT_TIME_STEP_ACCESSOR}}.value,
79 {{UPDATE_ACCESSOR}}.value
84 TemplateInitialGhostCells = jinja2.Template(
86 ::exahype2::blockstructured::applyDirichletBoundaryConditions(
87 [](const tarch::la::Vector<Dimensions, double>& x, double t, double* Q) -> void {
88 repositories::{{SOLVER_INSTANCE}}.initPointWisely(x, Q);
96 {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}},
97 repositories::{{SOLVER_INSTANCE}}.getMinTimeStamp(),
98 {{UPDATE_ACCESSOR}}.value
106 patch_overlap_current_time_step,
107 patch_overlap_update,
115 @param solver: exahype2.api.Solver
116 The solver whose maxEigenvalue(), sommerfeldFarFieldSolution() and
117 initPointWisely() are invoked.
119 @param patch_overlap_current_time_step: peano4.api.datamodel.Patch
120 @see RollOverUpdatedFace.
122 @param patch_overlap_update: peano4.api.datamodel.Patch
123 @see RollOverUpdatedFace.
126 @see RollOverUpdatedFace.
129 @see RollOverUpdatedFace.
131 @param origin: List[float]
132 Centre of the system, one entry per dimension, @ref
133 exahype2.api.blockstructured.SommerfeldBoundaryConditions.SommerfeldBoundaryConditions.get_origin().
135 @param time_step_size: str
136 C++ expression for the time step size by which the ghost grid cells
137 are advanced, or None to initialise the ghost grid cells with the
138 initial condition instead.
142 patch_overlap_current_time_step, patch_overlap_update, guard, includes
145 self.
d[
"SOLVER_INSTANCE"] = solver.get_name_of_global_instance()
146 self.
d[
"NUMBER_OF_UNKNOWNS"] = str(solver.unknowns)
147 self.
d[
"NUMBER_OF_AUXILIARY_VARIABLES"] =
"0"
149 self.
d[
"STATELESS_TAG"] = (
150 ", ::exahype2::Solver::Offloadable::Yes"
151 if get_max_eigenvalue_term_for_sommerfeld(solver).stateless
154 self.
d[
"ORIGIN"] =
"{" +
", ".join(repr(float(x))
for x
in origin) +
"}"
155 self.
d[
"TIME_STEP_SIZE"] = time_step_size
161 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME
168 result = template.render(**self.
d) + result
172 return __name__.replace(
".py",
"").replace(
".",
"_")
177#include "exahype2/blockstructured/DirichletBoundaryConditions.h"
178#include "exahype2/blockstructured/SommerfeldBoundaryConditions.h"
193 Create the roll over of the solver's face data
195 @return RollOverUpdatedFace
196 RollOverUpdatedFaceWithSommerfeldBoundaryConditions if the solver
197 uses exahype2.api.SommerfeldBoundaryConditions, and a plain
198 RollOverUpdatedFace otherwise, i.e. for Dirichlet boundary
199 conditions or a domain without boundary.
201 @param solver: exahype2.api.Solver
202 The solver whose solver._patch_overlap_update is rolled over into
203 solver._patch_overlap_current_time_step. Its boundary condition
204 terms have to be consistent with the domain, @ref
205 exahype2.api.blockstructured.BoundaryConditions.get_boundary_conditions().
207 @param exahype2_project: exahype2.api.Project
208 Provides the periodic boundary conditions.
211 @see RollOverUpdatedFace.
214 @see RollOverUpdatedFace.
216 @param time_step_size: str
217 @see the constructor. Ignored for a plain RollOverUpdatedFace.
220 term = get_boundary_conditions(solver, exahype2_project)
221 if isinstance(term, SommerfeldBoundaryConditions):
224 solver._patch_overlap_current_time_step,
225 solver._patch_overlap_update,
228 origin=term.get_origin(len(exahype2_project.periodic_BC)),
229 time_step_size=time_step_size,
232 solver._patch_overlap_current_time_step,
233 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 ...