Peano
Loading...
Searching...
No Matches
SommerfeldBoundaryConditions.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from __future__ import annotations
4
5from typing import Sequence
6
7from ..PDETerm import PDETerm
8
9
11 """!
12
13 Sommerfeld (radiative, outgoing) boundary conditions: waves leave the
14 domain with little reflection, and the solution approaches a far-field
15 solution towards infinity
16
17 The term is an alternative to exahype2.api.DirichletBoundaryConditions.
18 @ref exahype2::blockstructured::applySommerfeldBoundaryConditions()
19 documents the conditions, their discretisation, and how block-structured
20 schemes realise them. The user specifies the far-field solution
21 @f$ u_\\infty @f$:
22
23 @code
24 virtual void sommerfeldFarFieldSolution(
25 const tarch::la::Vector<Dimensions, double>& x,
26 double* __restrict__ Q // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
27 );
28 @endcode
29
30 Only the first NUMBER_OF_UNKNOWNS entries of Q are read, i.e. the
31 implementation does not have to set the auxiliary variables.
32
33 The wave speed is the solver's maximum eigenvalue along the face normal,
34 i.e. the solver has to hold an exahype2.api.MaxEigenvalue term. The wave
35 speed does not need any solver state, so the boundary conditions use the
36 stateless variant of the term if the solver holds one, and the variant
37 with state otherwise (@see
38 exahype2.api.blockstructured.BoundaryConditions.get_max_eigenvalue_term_for_sommerfeld()). The ghost cells are initialised with the initial condition
39 (exahype2.api.InitPointWisely) before the first time step.
40
41 Different to Dirichlet conditions, there is no separate boundary task
42 in the time step. The Sommerfeld update replaces the roll over of the
43 face data instead (@see
44 exahype2.api.fv.actionsets.RollOverUpdatedFaceWithSommerfeldBoundaryConditions and
45 exahype2.api.rkfd4.actionsets.RollOverUpdatedFaceWithSommerfeldBoundaryConditions).
46 Runge-Kutta schemes accept the term only if the time stamps of their
47 stages do not decrease.
48
49 A solver needs a boundary condition term if and only if at least one
50 axis of the domain is not periodic (@see
51 exahype2.api.blockstructured.BoundaryConditions.get_boundary_conditions()).
52
53 Only the non-stateless variant is supported, i.e. the term has to be
54 added with stateless=False.
55
56 """
57
58 SIGNATURE = (
59 "const tarch::la::Vector<Dimensions, double>& x, " "double* __restrict__ Q"
60 )
61
62 NAME = "sommerfeldFarFieldSolution"
63
65 self,
66 implementation: str = None,
67 origin: Sequence[float] = None,
68 stateless: bool = False,
69 ):
70 """!
71
72 @param implementation: str
73 A C++ snippet that becomes sommerfeldFarFieldSolution()'s body, or
74 None (the default) to leave sommerfeldFarFieldSolution() pure
75 virtual for you to implement by hand.
76
77 @param origin: Sequence[float]
78 Centre of the system, i.e. the point the outgoing spherical waves
79 emanate from. One entry per dimension. None (the default) is the
80 origin of the coordinate system.
81
82 @param stateless: bool
83 Has to be False, @see the class documentation.
84
85 """
86 super().__init__(
87 name=self.NAME,
88 implementation=implementation,
89 stateless=stateless,
90 )
91 self.origin = None if origin is None else [float(x) for x in origin]
92
93 def get_origin(self, dimensions: int):
94 """!
95
96 The origin with one entry per dimension
97
98 @param dimensions: int
99 Number of dimensions of the domain.
100
101 @return List[float]
102
103 """
104 if self.origin is None:
105 return [0.0] * dimensions
106 if len(self.origin) != dimensions:
107 raise ValueError(
108 f"The origin {self.origin} of the Sommerfeld boundary conditions has "
109 f"{len(self.origin)} entries, but the domain has {dimensions} dimensions."
110 )
111 return list(self.origin)
112
114 """!
115
116 SommerfeldBoundaryConditions-specific code generation
117
118 Reuses PDETerm.Generator as-is - SommerfeldBoundaryConditions.SIGNATURE
119 is picked up automatically. Declared explicitly for the same reason
120 as Flux.Generator.
121
122 """
Turns a PDETerm into the C++ text for its generated method: exactly one method - the static,...
Definition PDETerm.py:85
Represents one named, point-wise PDE operator that a solver exposes for the user to implement: a C++ ...
Definition PDETerm.py:6
Sommerfeld (radiative, outgoing) boundary conditions: waves leave the domain with little reflection,...
__init__(self, str implementation=None, Sequence[float] origin=None, bool stateless=False)