Writing expressions

Expressions are VisIt’s vehicle for creating derived quantities on a mesh, specifically for derived quantities that are defined on a per-cell or per-node basis. Because new expressions are frequently developed, and it is anticipated that they will be into the future, it would be appropriate for VisIt to employ its plugin mechanism for the handling of expressions. However, that step has not been taken yet. For now, adding a new expressions requires making modifications to the main code.

The purpose of this page is to detail the steps necessary to add an expression to VisIt.

Interface

The only interface for expressions is in the gui. You can add your new expression by modifying /gui/QvisExpressionWindow.C. This file has lists of expressions through the variable exprlist and the arrays that exprlist points at. You can add your expression by adding its name to one of these arrays.

Connecting your expression to the parser

The strings that define expressions are passed to the engine, where they are parsed. You can connect your new expression to the parser by adding a test for your new expression name to avtFunctionExpr::CreateFilters, which is located in /avt/Expressions/Management/avtExprNode.C

Implementing your expression

There are many abstract types dealing with expressions and the primary question will be which one of these types to inherit from. The base class to all of them is avtExpressionFilter, which ultimately derives from avtFilter. Decide which class below you want to inherit from, copy an example and start developing.

Base class Defining characteristics Examples
avtExpressionStreamer An abstract type providing infrastructure to have avtDataTree's processed as vtkDataSets one at a time. All expression filters inherit from this class, except for Macro filters. other base types inherit from this class
avtMacroFilter Implements expressions by using existing expression filters. avtCurlFilter, avtDivergenceFilter
avtSingleInputExpression An expression that performs a calculation by looking at a mesh or single variable. This expression expects derived types to reimplement DeriveVariable, which takes in a mesh and returns an array. avtMagnitudeFilter, avtMeshCoordinateFilter
avtMultipleInputExpression An expression that performs a calculation by looking at multiple variables. This expression expects derived types to reimplement DeriveVariable, which takes in a mesh and returns an array. avtVectorComposeFilter, avtConditionalFilter
avtUnaryMathFilter An expression that performs a calculation by looking at a single array. This expression expects derived types to reimplement DoOperation, which takes in an array and returns an array. avtUnaryMinusFilter, avtSinFilter
avtBinaryMathFilter An expression that performs a calculation by looking at multiple variables. This expression expects derived types to reimplement DoOperation, which takes in an array and returns an array. avtBinaryPlusFilter, avtBinaryMinusFilter