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

BUG: artificacts in vorticity for athena #5061

Open
chrishavlin opened this issue Nov 20, 2024 · 6 comments
Open

BUG: artificacts in vorticity for athena #5061

chrishavlin opened this issue Nov 20, 2024 · 6 comments

Comments

@chrishavlin
Copy link
Contributor

Plots of vorticity (and presumably any variable that needs a derivative) have artifacts aligned with grid boundaries where the resolution changes:

import yt 
ds = yt.load_sample("AM06")
slc = yt.SlicePlot(ds, 'x', ('gas', 'vorticity_x'), window_size=(4,4))
slc.save('vort_x.png')
slc.annotate_grids()
slc.save('vort_x_with_grids.png')

vort_x
vort_x_with_grids

Also note that you do get a RuntimeWarning:

/home/chavlin/src/yt_general/yt/yt/data_objects/construction_data_containers.py:1531: RuntimeWarning: 
Something went wrong during field computation. This is likely due to missing ghost-zones support in 
class <class 'weakref.ProxyType'>

So presumably this is a known issue, but I didn't see a clear corresponding open issue so I thought it was worth opening a new report to document it. There are, however, a number of open and closed issues that are related to ghost zones and vorticity (in athena and other frontends):

@chrishavlin
Copy link
Contributor Author

also, feel free to close this as a duplicate if I missed an open issue or if one of the linked ones handles this sufficiently :)

@neutrinoceros neutrinoceros added the code frontends Things related to specific frontends label Nov 20, 2024
@matthewturk
Copy link
Member

That is a super weird error I do not recognize. I believe that what we should look at is whether or not the "smoothed" covering grids are being used.

@chrishavlin
Copy link
Contributor Author

chrishavlin commented Nov 21, 2024

I believe that what we should look at is whether or not the "smoothed" covering grids are being used.

That would be a yes, this call to retrieve_ghost_zones hardcodes a smoothed=True parameter, which results in using a smoothed covering grid to fill the ghost zones

for og in giter:
if ngz > 0:
g = og.retrieve_ghost_zones(ngz, [], smoothed=True)
else:
g = og

@chrishavlin
Copy link
Contributor Author

setting it to False to see what happens... it does run, and the magnitude of the artifacts is lower, but they're still there:

Screenshot from 2024-11-21 16-14-15

@pgrete
Copy link
Contributor

pgrete commented Nov 27, 2024

This is equally applicable to Parthenon data.
Is there a default way to prolongate data from coarser grids into ghost zone of finer grids?
Alternatively, one could use one-sided derivatives at level boundaries.

@chrishavlin
Copy link
Contributor Author

Is there a default way to prolongate data from coarser grids into ghost zone of finer grids?

I thought that's what would happen by setting that smoothed parameter to false up in my previous comment -- when false, it will use a covering grid to fill ghost cells for each grid, which should simply sample the coarser grid(s) containing a finer grid. Relevant code is at

def retrieve_ghost_zones(self, n_zones, fields, all_levels=False, smoothed=False):
# We will attempt this by creating a datacube that is exactly bigger
# than the grid by nZones*dx in each direction
nl = self.get_global_startindex() - n_zones
new_left_edge = nl * self.dds + self.ds.domain_left_edge
# Something different needs to be done for the root grid, though
level = self.Level
if all_levels:
level = self.index.max_level + 1
kwargs = {
"dims": self.ActiveDimensions + 2 * n_zones,
"num_ghost_zones": n_zones,
"use_pbar": False,
"fields": fields,
}
# This should update the arguments to set the field parameters to be
# those of this grid.
field_parameters = {}
field_parameters.update(self.field_parameters)
if smoothed:
cube = self.ds.smoothed_covering_grid(
level, new_left_edge, field_parameters=field_parameters, **kwargs
)
else:
cube = self.ds.covering_grid(
level, new_left_edge, field_parameters=field_parameters, **kwargs
)
cube._base_grid = self
return cube

I stepped through it all and didn't notice anything obvious going wrong, but it might be easier to test with a simpler test dataset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants