Peano
Loading...
Searching...
No Matches
exahype2.api.PDETerm.PDETerm.Generator Class Reference

Turns a PDETerm into the C++ text for its generated method: exactly one method - the static, GPU-offloadable overload if the term is stateless, otherwise the virtual instance method. More...

Inheritance diagram for exahype2.api.PDETerm.PDETerm.Generator:

Public Member Functions

 __init__ (self, "PDETerm" term)
 
str signature (self)
 The term's C++ parameter list.
 
str generate_declaration (self)
 Declaration text for the abstract solver header: the static, GPU-offloadable overload if this term is stateless, otherwise the virtual instance method - never both from one term.
 
str generate_definition (self)
 Body of the generated method: the term's implementation verbatim.
 
str generate_out_of_class_definitions (self, str qualified_class_name)
 Out-of-class method body for the solver's .cpp file: the static, GPU-offloadable overload if this term is stateless, otherwise the virtual instance method - mirrors generate_declaration(), never both from one term.
 
str generate_stub_declaration (self)
 Override declaration for the concrete solver class that the Python API generates when the user hasn't provided their own implementation of this term - the empty string if the term isn't left abstract (term.implementation is not None; a stateless term's method is static and thus never overridable in the first place, but that combination cannot occur anyway,.
 
str generate_stub_definition (self, str qualified_class_name)
 Out-of-class body for generate_stub_declaration(): a trace-in (with x, and normal too if the term's signature has one), a logWarning noting the method is unimplemented, a "// @todo implement" comment, and logTraceOut - or the empty string under the same condition as generate_stub_declaration().
 

Data Fields

 term
 

Protected Member Functions

str _generate_static_offloadable_declaration (self)
 static GPU-offloadable declaration, or the empty string if the term isn't stateless.
 

Detailed Description

Turns a PDETerm into the C++ text for its generated method: exactly one method - the static, GPU-offloadable overload if the term is stateless, otherwise the virtual instance method.

Never both from the same term;

See also
exahype2.api.Solver.add_pde_term() for how to get both variants of the same conceptual operation.

If term.implementation is None, the method is left for the user to implement by hand: pure virtual (" = 0") for the non-stateless case, or - since static methods cannot be pure virtual - simply declared without a matching out-of-class definition for the stateless case. Otherwise the method is generated non-overridable ("final") with term.implementation as its body.

Embedded into PDETerm (reachable as term.generator) so that a term subclass can supply its own Generator -

See also
Flux.Generator - and term.generator resolves to the right one automatically, since it is looked up on the term's actual class rather than hardcoded to PDETerm.Generator.

Definition at line 85 of file PDETerm.py.

Constructor & Destructor Documentation

◆ __init__()

exahype2.api.PDETerm.PDETerm.Generator.__init__ (   self,
"PDETerm"  term 
)

Definition at line 109 of file PDETerm.py.

Member Function Documentation

◆ _generate_static_offloadable_declaration()

str exahype2.api.PDETerm.PDETerm.Generator._generate_static_offloadable_declaration (   self)
protected

static GPU-offloadable declaration, or the empty string if the term isn't stateless.

exahype2::Solver::Offloadable is a dummy tag argument that exists precisely because C++ cannot overload on staticness alone - it is what lets this static method coexist with the same-named, non-static, no-Offloadable-argument method that registering the same term name again without stateless would produce.

Definition at line 128 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.term.

Referenced by exahype2.api.PDETerm.PDETerm.Generator.generate_declaration().

Here is the caller graph for this function:

◆ generate_declaration()

str exahype2.api.PDETerm.PDETerm.Generator.generate_declaration (   self)

Declaration text for the abstract solver header: the static, GPU-offloadable overload if this term is stateless, otherwise the virtual instance method - never both from one term.

Pure virtual (" = 0") if term.implementation is None, "final" otherwise; the static, stateless overload is unaffected by this distinction (static methods cannot be pure virtual) -

See also
generate_out_of_class_definitions for how it is left for the user to implement by hand instead.

Definition at line 153 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator._generate_static_offloadable_declaration(), and exahype2.api.PDETerm.PDETerm.Generator.term.

Here is the call graph for this function:

◆ generate_definition()

str exahype2.api.PDETerm.PDETerm.Generator.generate_definition (   self)

Body of the generated method: the term's implementation verbatim.

Only meaningful when term.implementation is not None -

See also
generate_out_of_class_definitions, which never calls this otherwise.

Definition at line 173 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.term.

Referenced by exahype2.api.PDETerm.PDETerm.Generator.generate_out_of_class_definitions().

Here is the caller graph for this function:

◆ generate_out_of_class_definitions()

str exahype2.api.PDETerm.PDETerm.Generator.generate_out_of_class_definitions (   self,
str  qualified_class_name 
)

Out-of-class method body for the solver's .cpp file: the static, GPU-offloadable overload if this term is stateless, otherwise the virtual instance method - mirrors generate_declaration(), never both from one term.

The empty string if term.implementation is None: the user implements that method by hand instead, whether as an override of the pure virtual instance method or, for a stateless term, as an ordinary static method matching the declaration (name hiding, not override - static methods cannot be virtual).

qualified_class_name: str Fully qualified class name the definition is attached to, e.g. "examples::MySolver::AbstractMySolver".

Definition at line 182 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.generate_definition(), and exahype2.api.PDETerm.PDETerm.Generator.term.

Here is the call graph for this function:

◆ generate_stub_declaration()

str exahype2.api.PDETerm.PDETerm.Generator.generate_stub_declaration (   self)

Override declaration for the concrete solver class that the Python API generates when the user hasn't provided their own implementation of this term - the empty string if the term isn't left abstract (term.implementation is not None; a stateless term's method is static and thus never overridable in the first place, but that combination cannot occur anyway,.

See also
PDETerm.__init__).

Definition at line 220 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.term.

◆ generate_stub_definition()

str exahype2.api.PDETerm.PDETerm.Generator.generate_stub_definition (   self,
str  qualified_class_name 
)

Out-of-class body for generate_stub_declaration(): a trace-in (with x, and normal too if the term's signature has one), a logWarning noting the method is unimplemented, a "// @todo implement" comment, and logTraceOut - or the empty string under the same condition as generate_stub_declaration().

qualified_class_name: str Fully qualified class name the definition is attached to, e.g. "examples::MySolver::MySolver".

Reimplemented in exahype2.api.GradientRefinement.GradientRefinement.Generator.

Definition at line 238 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.signature(), and exahype2.api.PDETerm.PDETerm.Generator.term.

Here is the call graph for this function:

◆ signature()

str exahype2.api.PDETerm.PDETerm.Generator.signature (   self)

The term's C++ parameter list.

Looked up as a SIGNATURE attribute on the owning term (e.g. Flux.SIGNATURE); a plain, custom PDETerm has to set term.SIGNATURE itself before it can generate code.

Definition at line 113 of file PDETerm.py.

References exahype2.api.PDETerm.PDETerm.Generator.term.

Referenced by exahype2.api.PDETerm.PDETerm.Generator.generate_stub_definition().

Here is the caller graph for this function:

Field Documentation

◆ term


The documentation for this class was generated from the following file: