BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

Add ability to use variables from grid file in input file expressions

Open ZedThree opened this issue 3 weeks ago • 0 comments

This adds the ability to read fields (2D and 3D) and doubles* from the grid file (mesh:file) and use them in expressions in the input file, for example to use coordinates directly from the grid generator:

[input:grid_variables]
rho = field2d
theta = field2d
scale = boutreal

[mesh]
B = (scale / rho) * cos(theta)

* ints can also be read, but the expression parser only handles doubles


This could also be used for something like region labels to the input file by having hypnotoad make a field which is 1.0 in that region and 0.0 elsewhere:

region_pfr = 1.0 if is_in_pfr else 0.0

and using like

[input:grid_variables]
region_pfr = field2d

[some_source]
function = region_pfr * cos(x) * whatever

We could probably also do this in BOUT++ directly, making fields for each boundary region.

ZedThree avatar Dec 02 '25 17:12 ZedThree