5Decide which boundary treatment a solver's numerical scheme has to generate
7All numerical schemes evaluate the same two helpers: has_domain_boundary()
8tells whether the domain has a boundary at all, i.e. whether at least one
9axis is not periodic. get_boundary_conditions() returns the solver's
10boundary condition term and checks that the solver's PDE terms are
11consistent with the domain:
13- If all axes are periodic, the domain has no boundary. The schemes then
14 generate no boundary treatment at all, and the solver must not hold a
15 boundary condition term.
16- Otherwise, the solver has to hold exactly one boundary condition term,
17 i.e. either an exahype2.api.DirichletBoundaryConditions or an
18 exahype2.api.SommerfeldBoundaryConditions term.
21from .DirichletBoundaryConditions
import DirichletBoundaryConditions
22from ..MaxEigenvalue
import MaxEigenvalue
23from .SommerfeldBoundaryConditions
import SommerfeldBoundaryConditions
26BOUNDARY_CONDITION_TERMS = (DirichletBoundaryConditions, SommerfeldBoundaryConditions)
32 Does the domain have a boundary, i.e. is at least one axis not periodic?
34 @param exahype2_project: exahype2.api.Project
35 Provides the periodic boundary conditions (periodic_BC).
38 False if and only if all axes are periodic.
41 return not all(exahype2_project.periodic_BC)
47 Access qualifier of the persistent face data for a task of the time step
49 Sommerfeld boundary conditions advance the ghost cells within the roll
50 over of the projection onto the faces, and they read the old face data
51 there (@ref exahype2::blockstructured::applySommerfeldBoundaryConditions()).
52 The face data hence has to survive the reconstruction of the halo, and
53 the projection has to load it:
54 peano4.api.taskgraph.compiler.DeriveLoadStoreComputeFlag only stores
55 data after tasks which write it, and only loads it before tasks which
56 read it. With Sommerfeld boundary conditions, all tasks of the time step
57 which use the persistent face data therefore have to declare
60 @param solver: exahype2.api.Solver
62 @param exahype2_project: exahype2.api.Project
64 @param default: peano4.api.taskgraph.Task.DataAccess
65 The qualifier the task uses without Sommerfeld boundary conditions,
66 typically READ_AND_DISCARD for the reconstruction and WRITE for the
69 @return peano4.api.taskgraph.Task.DataAccess
77 return peano4.api.taskgraph.Task.DataAccess.READ_AND_WRITE
84 The MaxEigenvalue term Sommerfeld boundary conditions take their wave speed from
86 The wave speed does not depend on any solver state. We therefore prefer
87 the stateless variant of the eigenvalue computation if the solver holds
88 one, and fall back to the variant with state otherwise.
90 @param solver: exahype2.api.Solver
92 @return exahype2.api.MaxEigenvalue
93 The stateless term if there is one, otherwise the term with state.
94 Check its stateless attribute to see which variant is used.
97 If the solver holds no MaxEigenvalue term.
100 candidates = [term
for term
in solver.pde_terms
if isinstance(term, MaxEigenvalue)]
101 for term
in candidates:
107 f
"Solver {solver.name} uses Sommerfeld boundary conditions, which take "
108 "their wave speed from the maximum eigenvalue, but has no MaxEigenvalue "
109 "PDE term. Add one via solver.add_pde_term(exahype2.api.MaxEigenvalue(...))."
116 The solver's boundary condition term, or None if the domain has no boundary
118 @param solver: exahype2.api.Solver
119 The solver whose PDE terms are checked.
121 @param exahype2_project: exahype2.api.Project
122 Provides the periodic boundary conditions (periodic_BC).
124 @return exahype2.api.DirichletBoundaryConditions,
125 exahype2.api.SommerfeldBoundaryConditions or None
126 None if and only if all axes are periodic.
128 @exception ValueError
129 If all axes are periodic and the solver holds a boundary condition
130 term, if at least one axis is not periodic and the solver holds no or
131 more than one boundary condition term, if the term is stateless, or if
132 the solver holds a SommerfeldBoundaryConditions term but no
137 term
for term
in solver.pde_terms
if isinstance(term, BOUNDARY_CONDITION_TERMS)
139 periodic_BC = exahype2_project.periodic_BC
144 f
"Solver {solver.name} holds the boundary condition term(s) "
145 f
"{', '.join(type(term).__name__ for term in terms)}, but all axes "
146 f
"are periodic (periodic_BC={periodic_BC}), i.e. the domain has "
147 "no boundary. Remove the term(s) via solver.remove_pde_term(...), "
148 "or make at least one axis non-periodic."
154 f
"Solver {solver.name} has non-periodic boundaries "
155 f
"(periodic_BC={periodic_BC}), but no boundary condition PDE term. "
156 "Add one via solver.add_pde_term(exahype2.api.DirichletBoundaryConditions(...)) "
157 "or solver.add_pde_term(exahype2.api.SommerfeldBoundaryConditions(...)), "
158 "or make all axes periodic."
162 f
"Solver {solver.name} holds more than one boundary condition term "
163 f
"({', '.join(type(term).__name__ for term in terms)}). Keep exactly one."
169 f
"Solver {solver.name} holds a stateless {type(term).__name__} term, "
170 "but only the non-stateless variant is supported. Add it with stateless=False."
172 if isinstance(term, SommerfeldBoundaryConditions):
176 term.get_origin(len(periodic_BC))
bool has_domain_boundary(exahype2_project)
Does the domain have a boundary, i.e.
get_max_eigenvalue_term_for_sommerfeld(solver)
The MaxEigenvalue term Sommerfeld boundary conditions take their wave speed from.
get_access_to_persistent_face_data(solver, exahype2_project, default)
Access qualifier of the persistent face data for a task of the time step.
get_boundary_conditions(solver, exahype2_project)
The solver's boundary condition term, or None if the domain has no boundary.
The task graph abstraction allows users to formalise their solver steps over small task graphs which ...