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, solver=None)
str kernel_signature (self)
 The signature without the auxiliary variables.
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 = term
 solver = solver
 kernel_signature

Protected Member Functions

bool _has_auxiliary_variables (self)
bool _needs_kernel_adapter (self)
 The compute kernels know nothing about auxiliary variables.
str _kernel_adapter_arguments (self)
str _generate_kernel_adapter_declaration (self)
str _generate_kernel_adapter_definition (self, str qualified_class_name)
str _generate_static_offloadable_declaration (self)
 static GPU-offloadable declaration, or the empty string if the term isn't stateless.

Protected Attributes

 _has_auxiliary_variables

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,
solver = None )
Parameters
termPDETerm
solverexahype2.api.Solver If the solver has auxiliary variables, the generated signature contains pointers to them (exahype2.api.AuxiliaryVariables).

Definition at line 109 of file PDETerm.py.

Member Function Documentation

◆ _generate_kernel_adapter_declaration()

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

Definition at line 174 of file PDETerm.py.

References _needs_kernel_adapter().

Referenced by generate_declaration().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _generate_kernel_adapter_definition()

str exahype2.api.PDETerm.PDETerm.Generator._generate_kernel_adapter_definition ( self,
str qualified_class_name )
protected

Definition at line 190 of file PDETerm.py.

References _needs_kernel_adapter().

Referenced by generate_out_of_class_definitions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _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 206 of file PDETerm.py.

References term.

Referenced by generate_declaration().

Here is the caller graph for this function:

◆ _has_auxiliary_variables()

◆ _kernel_adapter_arguments()

◆ _needs_kernel_adapter()

bool exahype2.api.PDETerm.PDETerm.Generator._needs_kernel_adapter ( self)
protected

The compute kernels know nothing about auxiliary variables.

They call the stateless terms with the original signature. If the solver has auxiliary variables, we thus add static overloads with the original signature that forward to the term with parameters.

Definition at line 151 of file PDETerm.py.

References _has_auxiliary_variables, and term.

Referenced by _generate_kernel_adapter_declaration(), and _generate_kernel_adapter_definition().

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 231 of file PDETerm.py.

References _generate_kernel_adapter_declaration(), _generate_static_offloadable_declaration(), and 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 254 of file PDETerm.py.

References term.

Referenced by 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 263 of file PDETerm.py.

References _generate_kernel_adapter_definition(), generate_definition(), and 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 301 of file PDETerm.py.

References 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 319 of file PDETerm.py.

References signature(), and term.

Here is the call graph for this function:

◆ kernel_signature()

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

The signature without the auxiliary variables.

This is the signature which the compute kernels call.

Definition at line 124 of file PDETerm.py.

References term.

◆ 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 132 of file PDETerm.py.

References term.

Referenced by generate_stub_definition().

Here is the caller graph for this function:

Field Documentation

◆ _has_auxiliary_variables

exahype2.api.PDETerm.PDETerm.Generator._has_auxiliary_variables
protected

Definition at line 145 of file PDETerm.py.

Referenced by _needs_kernel_adapter().

◆ kernel_signature

exahype2.api.PDETerm.PDETerm.Generator.kernel_signature

Definition at line 165 of file PDETerm.py.

Referenced by _kernel_adapter_arguments().

◆ solver

exahype2.api.PDETerm.PDETerm.Generator.solver = solver

Definition at line 117 of file PDETerm.py.

Referenced by _has_auxiliary_variables(), and _kernel_adapter_arguments().

◆ term


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