What do expressions look like? - Alpine-DAV/ascent GitHub Wiki
This is a scratch pad for the types of expressions we want to support.
Reduction expressions (triggers, queries, or filter parameters)
An expression that reduces to a single variable. Example types:
- bool (stored as an integer)
- integer
- double
- vec3
Ex
Queries
Queries compute the result of an expression and stores the result into an identifier that can be accessed by other queries or triggers. This result can be any supported types (e.g., scalars or something more complex like a histogram). These named identifiers can serve as the building blocks for more complicated expressions.
Triggers
Triggers evaluate an expression that results in a boolean value.
If true
, a set of Ascent actions are executed.
History
Since queries and triggers are actions within ascent, they execute many times during a simulation run, and with that comes a time history of each query that can be accessed.
Syntax
- bool:
max("pressure") > 10.0
- integer:
1 + 1
- double:
pow(1.0,0.5)
,magnitude(vec3(1.0, 2.0, 3.0) - coordinate(max("pressure")))
- vec3:
coordinate(max("pressure"))
Variable expressions (computing a new field on the mesh)
Language Details
Definitions
compile time
: This is a 2-phase pass- parse the text and create AST.
build_graph
ie, create the flow graph that we can execute.
runtime
: execution of the flow graph
Type System
There are types. We try to detect type mismatches at "compile time", but some are deferred to "run time".
Attributes
Any function can return an object(scalar or more complex type) that has attributes. We provide functions to access attributes, like the history function, Example attributes:
- History: named identifiers are evaluated each execution and we store the time history.
- Location: mesh queries can return the spatial location of the result.
max("pressure")
has a location
Function Input Types
Special type any_type
for functions that look for attributes and anything else we can think of.