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 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.

Detailed Documentation

Leaf Nodes

hedge.optemplate.primitives.Field

alias of Variable

hedge.optemplate.make_sym_vector(name, components)

Return an object array of components subscripted Variable instances.

Parameters:components – The number of components in the vector.
class hedge.optemplate.primitives.ScalarParameter(name)

A placeholder for a user-supplied scalar variable.

“Wrapper” Nodes

class hedge.optemplate.primitives.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.operators.ElementwiseMaxOperator

Differentiation Operators

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

Mass Operators

class hedge.optemplate.operators.MassOperator
class hedge.optemplate.operators.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.operators.BoundarizeOperator(tag)
hedge.optemplate.primitives.make_normal()

Helpers

hedge.optemplate.tools.ptwise_mul(a, b)
hedge.optemplate.tools.ptwise_dot(logdims1, logdims2, a1, a2)