3from __future__
import annotations
5from .AdaptivityCriterion
import AdaptivityCriterion
11 Gradient-based refinement criterion: given a one-sided difference
12 quotient of the solution along one coordinate axis, decide whether the
13 mesh around this point should be refined, erased (coarsened) or kept.
16 virtual void refineEraseWithGradient(
17 const double* __restrict__ gradient, // gradient[{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}]
19 ::exahype2::RefinementCommand* __restrict__ refinementCommand
23 The action set which evaluates the criterion calls the term 2*Dimensions
24 times per volume: For each coordinate axis normal, it passes the left
25 difference quotient @f$ (Q_j - Q_{j-1})/h @f$ and the right one
26 @f$ (Q_{j+1} - Q_j)/h @f$. Each call starts from Keep. The volume asks
27 for a refinement if any of the calls says Refine, and it may be erased
28 only if all of the calls say Erase.
30 Volumes at the patch boundary have no neighbour on one side. For them,
31 the difference quotient towards the patch's interior is passed in both
32 calls (@ref exahype2::fv::computeOneSidedGradient()).
34 gradient holds unknowns+auxiliary_variables entries. The output
35 semantics are those of every adaptivity criterion
36 (@ref exahype2.api.AdaptivityCriterion).
41 "const double* __restrict__ gradient, "
43 "::exahype2::RefinementCommand* __restrict__ refinementCommand"
46 NAME =
"refineEraseWithGradient"
50 implementation: str =
None,
51 stateless: bool =
False,
55 @param implementation: str
56 A C++ snippet that becomes refineEraseWithGradient()'s body, or
57 None (the default) to leave refineEraseWithGradient() pure virtual
58 for you to implement by hand. The empty string is a valid body: it
59 leaves *refinementCommand untouched, i.e. at Keep.
61 @param stateless: bool
62 Generate a static, GPU-offloadable method instead of a virtual
63 one. Requires an implementation.
68 implementation=implementation,
75 GradientRefinement-specific code generation
77 Reuses PDETerm.Generator: GradientRefinement.SIGNATURE is picked up
78 automatically. Only the stub for the user's solver differs, as the
79 term is not handed any position x which the stub could trace.
85 Same as PDETerm.Generator.generate_stub_definition(), but traces
88 if self.
term.implementation
is not None or self.
term.stateless:
90 method_name = f
"{self.term.name}(...)"
92 f
"void {qualified_class_name}::{self.term.name}(\n"
93 f
" {self.signature}\n"
95 f
' logTraceInWith1Argument("{method_name}", normal);\n'
96 f
' logWarning("{method_name}", "not implemented yet");\n'
97 f
" // @todo implement\n"
98 f
' logTraceOut("{method_name}");\n'
Base class of all the PDE terms which decide where to refine or coarsen the mesh.
GradientRefinement-specific code generation.
str generate_stub_definition(self, str qualified_class_name)
Same as PDETerm.Generator.generate_stub_definition(), but traces normal only.
Gradient-based refinement criterion: given a one-sided difference quotient of the solution along one ...
__init__(self, str implementation=None, bool stateless=False)
Turns a PDETerm into the C++ text for its generated method: exactly one method - the static,...