Skip to content

Make .recalculate_xyz() optional, fix grid name parsing#145

Open
mikekryjak wants to merge 2 commits intomasterfrom
fix-grid-string-parse
Open

Make .recalculate_xyz() optional, fix grid name parsing#145
mikekryjak wants to merge 2 commits intomasterfrom
fix-grid-string-parse

Conversation

@mikekryjak
Copy link
Contributor

@mikekryjak mikekryjak commented Mar 6, 2026

BoutOptionsFile has a method called .recalculate_xyz which is for evaluating input file expressions. It needs the coordinates, which it infers from the input file if nx/ny/nz are specified, or from the grid file if it's provided. In my use case, I never specify nx/ny/nz in the input file, and I don't supply a grid file when I just want to read a single setting. This causes a warning that recalculate_xyz didn't work.

I would honestly prefer that recalculate_xyz was not even done at the init stage, unless someone actually uses it actively? It seems like a more niche use case than just reading input settings which is very common....

This PR makes the method call optional, but True by default. But I would prefer to just get rid of it and make users call it separately if needed.

I also found a grid name parsing issue:

except ValueError:
# Leave as a string
pass

If the user leaves quotation marks around the grid name, then BOUT++ will parse them out, but BoutOptionsFile will not, causing an error on reading. this PR strips the quotes.

If passed with quotation marks, these are stripped in BOUT++ but not here, causing issues on load
This is rarely needed, but requires either grid size data or the grid file, making it expensive and cause warnings if neither are available.
@mikekryjak mikekryjak changed the title Fix grid name parsing Make .recalculate_xyz() optional, fix grid name parsing Mar 6, 2026
@mikekryjak
Copy link
Contributor Author

Peter: change so that if you don't have a grid, and don't have nx/ny, then this doesn't do anything.

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.

1 participant