-
Notifications
You must be signed in to change notification settings - Fork 67
Expression Langauge
- integer
- double
- mesh variables: strings, e.g.
"pressure"
indicate a variable defined on the mesh. - bool: Note: only produced as the result of a comparison. Not sure we need keywords
true
andfalse
since I don't see how we would use it in practice.
Functions can return objects that contain values and attributes. Objects with values can be treated as just another value in an expression. Objects with only attributes must be manipulated with function calls to extract values.
Idea: currently, vector math, e.g. v1+v2
is implemented in the binary op code. Perhaps there is a way that we can define objects
in such a way that it contains the code that defines supported ops like an overloaded operator in c++. In the near term, it is simpler to just add a add(vector,vector)
function. Additionally, its unclear how we will generate code for JIT derived expressions.
- Vector: a 3D vector created with the
vector
function, e.g.,vector(0,1,0)
.
- Histogram: contains bin counts, min values, max values, bin deltas. Values are extracted via functions.
- anytype: An internal type used by the language to allow functions to take in arguments of any type and return values of any type. This is used by functions like
history
andposition
.
- Math:
-
,+
,*
,/
,%
- Comparison:
==
,>=
,<=
,!=
,>
,<
- Boolean:
and
,or
,not
. For JIT, we can just substitute whatever we need back in. Note:not
is a unary operator.
-
Functions take a list of arguments, a subset of which are optional. Arguments are passed in the form of comma separated positional arguments followed by comma separated named arguments. The named arguments must come after all the positional arguments but the order in which the named arguments are specified has no effect.
Return the field average of a mesh variable.
Return the maximum of two scalars.
Return the maximum value from the meshvar.
Its position is also stored and is accessible via the position
function.
Return the minimum of two scalars.
Return the minimum value from the meshvar.
Its position is also stored and is accessible via the position
function.
Return the 3D position vector for the input value.
Return the current simulation cycle.
Return a vector with the input values.
Return the magnitude of the input vector.
histogram histogram(meshvar arg1, scalar num_bins[optional], scalar min_val[optional], scalar max_val[optional])
Return a histogram of the mesh variable.
-
num_bins
defaults to256
-
min_val
defaults tomin(arg1)
-
max_val
defaults tomax(arg1)
Returns the value of an expression from index
evaluations ago. expr_name
should be the name of an expression that was evaluated in the past and index
should be an integer less than the number of past evaluations.