Peano
Loading...
Searching...
No Matches
Flux.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 .PDETerm import PDETerm
6
7
8class Flux(PDETerm):
9 """!
10
11 The conservative flux F(Q) of a hyperbolic PDE
12
13 See python/exahype2/solvers/fv/riemann/kernels.py for the legacy
14 equivalent, which additionally threads h/t/dt through the signature.
15 This new API's flux() is, for now, deliberately reduced to
16
17 @code
18 virtual void flux(
19 const double* __restrict__ Q, // Q[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
20 const tarch::la::Vector<Dimensions, double>& x,
21 int normal,
22 double* __restrict__ F // F[{{NUMBER_OF_UNKNOWNS}}]
23 );
24 @endcode
25
26 h/t/dt will return once PDE terms are tied to real C code snippets with
27 proper signatures; until then every term merely gets position, normal
28 (where physically meaningful) and its input/output.
29
30 Q holds unknowns+auxiliary_variables entries, whereas the output F only
31 holds unknowns entries: only the actual unknowns are subject to the
32 hyperbolic formulation, auxiliary variables are not.
33
34 """
35
36 SIGNATURE = (
37 "const double* __restrict__ Q, "
38 "const tarch::la::Vector<Dimensions, double>& x, "
39 "int normal, "
40 "double* __restrict__ F"
41 )
42
43 NAME = "flux"
44
46 self,
47 implementation: str = None,
48 stateless: bool = False,
49 ):
50 """!
51
52 implementation: str
53 A C++ snippet that becomes flux()'s body (the empty string is a
54 valid, generated no-op body), or None (the default) to leave
55 flux() pure virtual for you to implement by hand. Don't add this
56 term to a solver at all if the PDE has no flux contribution.
57
58 """
59 super().__init__(
60 name=self.NAMENAME,
61 implementation=implementation,
62 stateless=stateless,
63 )
64
66 """!
67
68 Flux-specific code generation
69
70 Reuses PDETerm.Generator's declaration/definition/GPU-offload logic
71 as-is - Flux.SIGNATURE is picked up automatically. Declared
72 explicitly (rather than left to be inherited implicitly) so that
73 Flux.Generator is the obvious place to add flux-specific generation
74 behaviour later, and so flux_term.generator reports its type as
75 Flux.Generator rather than the more generic PDETerm.Generator.
76
77 """
Flux-specific code generation.
Definition Flux.py:65
The conservative flux F(Q) of a hyperbolic PDE.
Definition Flux.py:8
__init__(self, str implementation=None, bool stateless=False)
implementation: str A C++ snippet that becomes flux()'s body (the empty string is a valid,...
Definition Flux.py:49
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