Operator Specification Language

Summary

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 hedge.tools.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.tools.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().

  • Operators may be left-multiplied with other field expressions. See Operators for an overview.

Detailed Documentation

Leaf Nodes

hedge.optemplate.Field
alias of Variable
hedge.optemplate.make_vector_field(name, components)

Return an object array of components subscripted Field instances.

Parameter:components – The number of components in the vector.
class hedge.optemplate.ScalarParameter(name)
A placeholder for a user-supplied scalar variable.

“Wrapper” Nodes

class hedge.optemplate.PrioritizedSubexpression(child, priority=0)
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.

Operators

class hedge.optemplate.OperatorBinding(op, field)
class hedge.optemplate.ElementwiseMaxOperator

Differentiation Operators

class hedge.optemplate.StiffnessOperator(xyz_axis)
class hedge.optemplate.StiffnessTOperator(xyz_axis)
class hedge.optemplate.DifferentiationOperator(xyz_axis)
class hedge.optemplate.MInvSTOperator(xyz_axis)
hedge.optemplate.make_stiffness(dim)
hedge.optemplate.make_stiffness_t(dim)
hedge.optemplate.make_nabla(dim)
hedge.optemplate.make_minv_stiffness_t(dim)

Mass Operators

class hedge.optemplate.MassOperator
class hedge.optemplate.InverseMassOperator

Boundary-valued operators

These operators are only meaningful within the bfield argument of BoundaryPair, because they evaluate to boundary vectors of the given tag.

class hedge.optemplate.BoundarizeOperator(tag)
hedge.optemplate.make_normal(tag, dimensions)