Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't get domain dimensions from cparam file for Boxlib frontend. #3470

Merged
merged 2 commits into from
Aug 24, 2021

Conversation

atmyers
Copy link
Member

@atmyers atmyers commented Aug 11, 2021

The domain dimensions are always stored in the pltfile Header for Boxlib / AMReX datasets, so reading it from the job_info file is at best redundant, and worst incorrect, in the event that users have chosen to only output data on a subset of the domain.

For example, the attached WarpX plotfile should have domain dimensions of 81, but it gets read as 128 in the following code snippet:

import yt
ds = yt.load("diag200001")

diag200001.tar.gz

@atmyers atmyers added code frontends Things related to specific frontends bug labels Aug 11, 2021
Copy link
Member

@matthewturk matthewturk left a comment

Choose a reason for hiding this comment

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

LGTM, but @zingale might want to weigh-in?

My only concern is the dimensionality here, which we may need to pad for lower-than-3 dimensions.

@atmyers
Copy link
Member Author

atmyers commented Aug 11, 2021

The attached file is 2D and seems to get padded correctly, it should be handled here:

# Now we read the global index space, to get
index_space = header_file.readline()
# This will be of the form:
#  ((0,0,0) (255,255,255) (0,0,0)) ((0,0,0) (511,511,511) (0,0,0))
# So note that if we split it all up based on spaces, we should be
# fine, as long as we take the first two entries, which correspond to
# the root level.  I'm not 100% pleased with this solution.
root_space = index_space.replace("(", "").replace(")", "").split()[:2]
start = np.array(root_space[0].split(","), dtype="int64")
stop = np.array(root_space[1].split(","), dtype="int64")
dd = np.ones(3, dtype="int64")
dd[: self.dimensionality] = stop - start + 1
self.domain_dimensions = dd

@neutrinoceros
Copy link
Member

LGTM, but I note that the "amr.n_cell" param is also being mentioned here

"amr.n_cell": "TopGridDimensions",

although it looks like this definitions.py module has fell out of use ? I feel like it's be a good time to maybe clean it up as well.

@atmyers
Copy link
Member Author

atmyers commented Aug 12, 2021

It looks like nothing from definitions.py is imported anywhere - are you suggesting just removing those dictionaries? I think that would be fine.

@neutrinoceros
Copy link
Member

yup, that's what I'm suggesting. It looks the content was added in 2013 and unless I'm mistaken, yt/frontends/*/definitions.py modules are not supposed to be part of the public api (as opposed to yt.frontends/*/api.py :) )

@zingale
Copy link
Member

zingale commented Aug 12, 2021

hi folks, I just got back into town from vacation, so I am catching up. If needed, I can test something tonight.

@neutrinoceros
Copy link
Member

@zingale I think we're mostly letting this open so you can change our minds if this isn't acceptable to you. Maybe you could attempt to load a data file with reduced dimensions and see if all goes well ? Unless you think this could be breaking up any real world case I believe it's okay to not test it too thoroughly.

@atmyers
Copy link
Member Author

atmyers commented Aug 24, 2021

Do you think this could go in, @zingale?

@zingale
Copy link
Member

zingale commented Aug 24, 2021

trying to test it, but seems I hit a yt bug with matplotlib, so I need to figure out how to hack around that

@zingale
Copy link
Member

zingale commented Aug 24, 2021

okay, it works for me with a Castro dataset.

elif self.dimensionality == 2:
vals = self.domain_dimensions = np.array([vals[0], vals[1], 1])
elif param == "amr.ref_ratio":
if param == "amr.ref_ratio":
vals = self.refine_by = int(vals[0])
elif param == "Prob.lo_bc":
Copy link
Member

Choose a reason for hiding this comment

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

does this work when we specify several different ref_ratios for different jumps between levels? e.g.

amr.ref_ratio = 2 4 2 2 

Copy link
Member Author

Choose a reason for hiding this comment

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

It "works" in the sense that it will not crash if you give it vector - it takes the first value for the ref_ratio between levels 0 and 1. But I don't think yt itself supports different ref_ratios between different levels.

Copy link
Member

Choose a reason for hiding this comment

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

I think (hope) it does, since we use it with that all the time.

Copy link
Member

Choose a reason for hiding this comment

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

That's right, it's not supported yet.
Maybe you'd want to have a warning here in this case, because it's not necessarily obvious from the user standpoint

Copy link
Member Author

Choose a reason for hiding this comment

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

In any case, this PR doesn't change anything about the way ref_ratio is handled, so perhaps this could be sorted out in a different issue / pull request?

Copy link
Member

Choose a reason for hiding this comment

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

agree. That just caught my eye.

@atmyers atmyers merged commit e628ad1 into main Aug 24, 2021
@neutrinoceros neutrinoceros deleted the dd_from_header branch August 24, 2021 21:18
@neutrinoceros neutrinoceros mentioned this pull request Oct 12, 2021
42 tasks
@matthewturk
Copy link
Member

@meeseeksdev backport to yt-4.0.x

meeseeksmachine pushed a commit to meeseeksmachine/yt that referenced this pull request Oct 15, 2021
neutrinoceros added a commit that referenced this pull request Oct 16, 2021
…0-on-yt-4.0.x

Backport PR #3470 on branch yt-4.0.x (Don't get domain dimensions from cparam file for Boxlib frontend.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug code frontends Things related to specific frontends
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants