Custom Fields¶
NOTE: Custom fields in the SDK are experimental. They may change or be removed in the future.
A custom field is a scalar field computed from an expression over the solution’s fields, such as
"Pressure" * 2. These are the same custom fields you define in the UI.
Custom field expressions use a subset of the vis expression language that vis queries use: the subset the solver supports. This page lists that subset. See What’s changing, below.
Using a custom field¶
Create one with vis.CustomField, register it where it is used,
and read it with to_field():
import luminarycloud.vis as vis
p2 = vis.CustomField("p2", '"Pressure" * 2')
scene.add_custom_field(p2)
display = vis.DisplayAttributes()
display.field = p2.to_field()
A custom field can be registered with:
Scene.add_custom_field, for images.DataExtractor.add_custom_field, for data extracts.the
custom_fieldsargument ofvis.range_queryandvis.extrema_query.
vis.validate_custom_fields checks expressions
against a solution without rendering anything.
Expressions¶
Part |
Example |
Notes |
|---|---|---|
A field name, in double quotes |
|
A field of the solution. |
A component of a vector field |
|
A |
Numbers |
|
|
Constants |
|
π |
Operators |
|
|
Functions |
|
See the table below. |
Function |
Arguments |
|---|---|
|
one; |
|
one, in radians |
|
two |
For example, the dynamic pressure and the speed in the x-y plane:
0.5 * "Density" * pow("Velocity-MAGNITUDE", 2)
hypot("Velocity-X", "Velocity-Y")
Limits¶
The result is one scalar at each point or cell. There are no vectors.
There are no comparisons or conditionals, and no
^; usepow.There is no mesh geometry, such as cell volume or normals.
An expression can’t use another custom field.
A vis query can’t read a custom field by name. Write the expression in the query’s program instead (see Vis Expression Language).
What’s changing¶
Custom fields will soon support the full vis expression language. They will
gain what it adds, such as vectors, if, mesh geometry like normal, and named variables. This
page will be updated when that happens.