parthenon-hpc-lab / parthenon

Parthenon AMR infrastructure
https://parthenon-hpc-lab.github.io/parthenon/
Other
113 stars 36 forks source link

When outputting a variable, Parthenon also outputs all versions with suffixes #1032

Open bprather opened 7 months ago

bprather commented 7 months ago

TIL this wasn't an intentional feature. I agree with the voiced consensus upon discussing it, which is that we should support a more explicit form of this trick.

When outputting variables, one specifies a list:

variables = my.variable.1, my.variable.2, another.variable

However, if your code contains the variables above, it will actually still output them all if given only the prefix:

variables = my.variable, another.variable

That is, given name, parthenon outputs all variables which match name*.

While disgusting, this is actually also really convenient. By naming variables prims.rho, prims.u, etc I can ensure that regardless of which are enabled or the theory I'm evolving, all primitive variables will be output so long as I specify a list prims, etc, etc. However, it's definitely more bug than feature, and can be a problem if you have variables with suffixes (in my case, I discovered it by naming fields prims.B and prims.Bf for faces).

Thus it seems like we should replace the limited-match behavior with globbing. i.e., rather than treat prims == prims*, require the user to write prims* if they actually want to match all suffixes. Note some jerk may also expect support for prims.*.face or *.B* or other monstrosities (or god forbid regex) so we should decide where the madness stops, and implement/document a suitable compromise.

pgrete commented 7 months ago

I also wasn't aware of this "feature" and am in favor of keeping (but documenting/properly implementing it). The constraint might be to disallow * in the variable names (which is probably a good idea anyway).