An “operator template” is an expression tree that represents a DG operator. The following components can be used to build one in hedge:
Scalar constants, may be of type int, float, complex, numpy.number. These occur directly as part of the expression tree. pymbolic.primitives.is_constant() is a predicate to test for constant-ness.
numpy.ndarray with dtype=:class:object (called “object array” in numpy-speak). These evaluate to the same-shape array with each component evaluated.
Use pytools.obj_array.join_fields() to easily create object arrays from scalars and other arrays.
hedge.optemplate.Field: A placeholder for a user-supplied field.
Field instances or pymbolic.primitives.Subscript instances involving them are interpreted as scalar DG-discretized fields.
hedge.optemplate.ScalarParameter: A placeholder for a user-supplied scalar value.
pymbolic.primitives.Sum, pymbolic.primitives.Product, pymbolic.primitives.Quotient, pymbolic.primitives.Power: These are created implicitly when Expression objects are combined using the +, -, *, / and ** operators. These are all interpreted in a node-by-node fashion.
pymbolic.primitives.IfPositive offers a simple way to build conditionals and is interpreted in a node-by-node fashion.
pymbolic.primitives.CommonSubexpression (CSE for short): Prevents double evaluation of identical subexpressions when the operator expression tree is walked to evaluate the operator.
Use hedge.optemplate.primitives.make_common_subexpression() to wrap each component of an object array in a CSE.
pymbolic.primitives.Call: The function attribute must evaluate to a name that was registered by calling hedge.discretization.Discretization.add_function() or be a value of type hedge.optemplate.primitives.CFunction.
Operators may be left-multiplied with other field expressions. See Operators for an overview.
alias of Variable
Return an object array of components subscripted Variable instances.
Parameters: | components – The number of components in the vector. |
---|
A placeholder for a user-supplied scalar variable.
When the optemplate-to-code transformation is performed, prioritized subexpressions work like common subexpression in that they are assigned their own separate identifier/register location. In addition to this behavior, prioritized subexpressions are evaluated with a settable priority, allowing the user to expedite or delay the evaluation of the subexpression.