3from __future__
import annotations
5from .PDETerm
import PDETerm
11 Base class of all the PDE terms which decide where to refine or coarsen
14 An adaptivity criterion is a PDE term which writes its decision into the
15 output argument refinementCommand. It points to one
16 ::exahype2::RefinementCommand, i.e. Keep, Refine or Erase (see
17 exahype2/RefinementControl.h). The caller initialises it with Keep before
18 the call, so an implementation only has to set it if it wants to refine
19 or erase. In particular, the empty string as implementation yields a
20 criterion which always keeps the mesh.
22 The subclasses differ in what they are handed:
24 - exahype2.api.RefineErasePointwisely is handed the solution in one
26 - exahype2.api.GradientRefinement is handed a one-sided difference
27 quotient of the solution along one coordinate axis.
29 Only if a solver has an adaptivity criterion do the numerical schemes
30 and the setup evaluate it, i.e. add the action sets which collect refine
31 and erase requests (@ref exahype2.api.blockstructured.create_dynamic_mesh_refinement_action_set.create_dynamic_mesh_refinement_action_set()).
32 A solver may have at most one adaptivity criterion.
34 The class itself defines no signature, i.e. you always add one of its
35 subclasses to a solver.
42 implementation: str =
None,
43 stateless: bool =
False,
48 The C++ method name of the criterion.
50 @param implementation: str
51 A C++ snippet that becomes the method's body, or None (the default)
52 to leave the method pure virtual for you to implement by hand. The
53 empty string is a valid body: it leaves *refinementCommand
54 untouched, i.e. at Keep.
56 @param stateless: bool
57 Generate a static, GPU-offloadable method instead of a virtual
58 one. Requires an implementation.
63 implementation=implementation,
68def get_adaptivity_criterion(solver) -> AdaptivityCriterion:
71 The solver's adaptivity criterion, or None if it has none
73 Raises a ValueError if the solver has more than one adaptivity
76 @param solver: exahype2.api.Solver
77 The solver to inspect.
81 term
for term
in solver.pde_terms
if isinstance(term, AdaptivityCriterion)
85 f
"Solver {solver.name} has {len(criteria)} adaptivity criteria "
86 f
"({', '.join(term.name for term in criteria)}), but supports at most one"
88 return criteria[0]
if criteria
else None
Base class of all the PDE terms which decide where to refine or coarsen the mesh.
__init__(self, str name, str implementation=None, bool stateless=False)
Represents one named, point-wise PDE operator that a solver exposes for the user to implement: a C++ ...