Skip to content

Create BoutOptionsFile with grid if available#339

Merged
dschwoerer merged 3 commits intomasterfrom
input-file-grid
Apr 16, 2026
Merged

Create BoutOptionsFile with grid if available#339
dschwoerer merged 3 commits intomasterfrom
input-file-grid

Conversation

@mikekryjak
Copy link
Copy Markdown
Collaborator

Loading a BOUT++ dataset will automatically create a BoutOptionsFile, which at the moment will want to read the grid file to evaluate input file expressions with .recalculate_xyz(). However, it can't easily find the grid file on its own - it will assume it's in the working directory, which is nearly always incorrect in my case. It will then try to find nx and ny in the input file, which is always incorrect in my case.

This PR constructs a BoutOptionsFile using the already known gridfilepath if it's available, which it always is in my use case. If it's unavailable, it falls back on the previous behaviour.

This is connected to boutproject/boutdata#145. I'm trying to fix all the warnings I get when loading datasets.

mikekryjak and others added 2 commits March 6, 2026 14:37
If you want the input file and don't pass a grid, it'll struggle because nx/ny/nz are often missing from the input file, and the grid may not be in the directory where you run the script from. xBOUT knows where the grid is though!
Copy link
Copy Markdown
Contributor

@dschwoerer dschwoerer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BoutOptionsFile expects a filename for gridfilepath, but it may also be just the folder in which the grid from the options file can be found, see

if _is_dir(gridfilepath):

@mikekryjak
Copy link
Copy Markdown
Collaborator Author

@dschwoerer nice find, I actually didn't know this. If it's a directory, we can read the options file without the grid to get the name, and then read it with the grid.

On a separate note, isn't this wrong? What is options:grid? I've only ever seen options:mesh:file!

@dschwoerer
Copy link
Copy Markdown
Contributor

Also allows for the legacy "grid" field in the input file.
@mikekryjak
Copy link
Copy Markdown
Collaborator Author

@dschwoerer done, take a look

Copy link
Copy Markdown
Contributor

@dschwoerer dschwoerer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We no might warn twice about that the simulation was run without grid, but who would run simulations without grids 😇

@dschwoerer dschwoerer merged commit e4f23d5 into master Apr 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants