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 volumes along the domain
18 boundary through exahype2.api.SommerfeldBoundaryConditions first
20 The action set replaces exahype2.api.fv.actionsets.RollOverUpdatedFace
21 if the solver uses Sommerfeld boundary conditions. Such a solver has no
22 separate boundary task (exahype2.api.fv.actionsets.ApplyDirichletBoundaryConditions).
23 In touchFaceLastTime(), the action set first writes the ghost volumes
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 volumes
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 time step uses this variant.
34 - Without a time_step_size, the action set initialises the ghost volumes
35 with the initial condition, i.e. it evaluates the solver's
36 initPointWisely() at their centres through
37 @ref exahype2::blockstructured::applyDirichletBoundaryConditions().
38 The grid construction uses this variant, so the first time step finds
41 The C++ header documents the conditions, their discretisation and why
42 they replace the roll over.
46 TemplateSommerfeldBoundaryConditions = jinja2.Template(
48 ::exahype2::blockstructured::applySommerfeldBoundaryConditions(
51 const tarch::la::Vector<Dimensions, double>& x,
55 repositories::{{SOLVER_INSTANCE}}.maxEigenvalue(Q, x, normal, &lambdaMax{{STATELESS_TAG}});
58 [](const tarch::la::Vector<Dimensions, double>& x, double* Q) -> void {
59 repositories::{{SOLVER_INSTANCE}}.sommerfeldFarFieldSolution(x, Q);
67 {{NUMBER_OF_UNKNOWNS}},
68 {{NUMBER_OF_AUXILIARY_VARIABLES}},
69 tarch::la::Vector<Dimensions, double>({{ORIGIN}}),
71 {{CURRENT_TIME_STEP_ACCESSOR}}.value,
72 {{UPDATE_ACCESSOR}}.value
77 TemplateInitialGhostCells = jinja2.Template(
79 ::exahype2::blockstructured::applyDirichletBoundaryConditions(
80 [](const tarch::la::Vector<Dimensions, double>& x, double t, double* Q) -> void {
81 repositories::{{SOLVER_INSTANCE}}.initPointWisely(x, Q);
89 {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}},
90 repositories::{{SOLVER_INSTANCE}}.getMinTimeStamp(),
91 {{UPDATE_ACCESSOR}}.value
99 patch_overlap_current_time_step,
100 patch_overlap_update,
108 @param solver: exahype2.api.Solver
109 The solver whose maxEigenvalue(), sommerfeldFarFieldSolution() and
110 initPointWisely() are invoked.
112 @param patch_overlap_current_time_step: peano4.api.datamodel.Patch
113 @see RollOverUpdatedFace.
115 @param patch_overlap_update: peano4.api.datamodel.Patch
116 @see RollOverUpdatedFace.
119 @see RollOverUpdatedFace.
122 @see RollOverUpdatedFace.
124 @param origin: List[float]
125 Centre of the system, one entry per dimension, @ref
126 exahype2.api.blockstructured.SommerfeldBoundaryConditions.SommerfeldBoundaryConditions.get_origin().
128 @param time_step_size: str
129 C++ expression for the time step size by which the ghost volumes
130 are advanced, or None to initialise the ghost volumes with the
131 initial condition instead.
135 patch_overlap_current_time_step, patch_overlap_update, guard, includes
138 self.
d[
"SOLVER_INSTANCE"] = solver.get_name_of_global_instance()
139 self.
d[
"NUMBER_OF_UNKNOWNS"] = str(solver.unknowns)
140 self.
d[
"NUMBER_OF_AUXILIARY_VARIABLES"] =
"0"
142 self.
d[
"STATELESS_TAG"] = (
143 ", ::exahype2::Solver::Offloadable::Yes"
144 if get_max_eigenvalue_term_for_sommerfeld(solver).stateless
147 self.
d[
"ORIGIN"] =
"{" +
", ".join(repr(float(x))
for x
in origin) +
"}"
148 self.
d[
"TIME_STEP_SIZE"] = time_step_size
154 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_FACE_LAST_TIME
161 result = template.render(**self.
d) + result
165 return __name__.replace(
".py",
"").replace(
".",
"_")
170#include "exahype2/blockstructured/DirichletBoundaryConditions.h"
171#include "exahype2/blockstructured/SommerfeldBoundaryConditions.h"
186 Create the roll over of the solver's face data
188 @return RollOverUpdatedFace
189 RollOverUpdatedFaceWithSommerfeldBoundaryConditions if the solver
190 uses exahype2.api.SommerfeldBoundaryConditions, and a plain
191 RollOverUpdatedFace otherwise, i.e. for Dirichlet boundary
192 conditions or a domain without boundary.
194 @param solver: exahype2.api.Solver
195 The solver whose solver._patch_overlap_update is rolled over into
196 solver._patch_overlap_current_time_step. Its boundary condition
197 terms have to be consistent with the domain, @ref
198 exahype2.api.blockstructured.BoundaryConditions.get_boundary_conditions().
200 @param exahype2_project: exahype2.api.Project
201 Provides the periodic boundary conditions.
204 @see RollOverUpdatedFace.
207 @see RollOverUpdatedFace.
209 @param time_step_size: str
210 @see the constructor. Ignored for a plain RollOverUpdatedFace.
213 term = get_boundary_conditions(solver, exahype2_project)
214 if isinstance(term, SommerfeldBoundaryConditions):
217 solver._patch_overlap_current_time_step,
218 solver._patch_overlap_update,
221 origin=term.get_origin(len(exahype2_project.periodic_BC)),
222 time_step_size=time_step_size,
225 solver._patch_overlap_current_time_step,
226 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 volumes along the domain boundary through exahype2....
get_action_set_name(self)
Return unique action set name.
get_includes(self)
Return include statements that you need.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
create_roll_over(solver, exahype2_project, guard, includes, time_step_size=None)
Create the roll over of the solver's face data.
__init__(self, solver, patch_overlap_current_time_step, patch_overlap_update, guard, includes, origin, time_step_size=None)
TemplateInitialGhostCells
TemplateSommerfeldBoundaryConditions
Copy patch_overlap_update - the face overlap exahype2.api.fv.actionsets.ProjectPatchOntoFaces has jus...