Skip to content

Commit

Permalink
add support for enzo-e sims without any ghost zones.
Browse files Browse the repository at this point in the history
  • Loading branch information
mabruzzo committed Jun 22, 2024
1 parent b04985d commit f50ed35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions yt/frontends/enzo_e/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,12 @@ def _parse_parameter_file(self):
ablock = fh[list(fh.keys())[0]]
self.current_time = ablock.attrs["time"][0]
self.parameters["current_cycle"] = ablock.attrs["cycle"][0]
gsi = ablock.attrs["enzo_GridStartIndex"]
gsi = ablock.attrs["enzo_GridStartIndex"] # <- always has 3 elements
gei = ablock.attrs["enzo_GridEndIndex"]
self.ghost_zones = gsi[0]
# Enzo-E technically allows each axis to have different ghost zone
# depths (this feature is not really used in practice)
self.ghost_zones = gsi
assert (self.ghost_zones[self.dimensionality:] == 0).all() # sanity check
self.root_block_dimensions = root_blocks
self.active_grid_dimensions = gei - gsi + 1
self.grid_dimensions = ablock.attrs["enzo_GridDimension"]
Expand Down
15 changes: 12 additions & 3 deletions yt/frontends/enzo_e/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,17 @@ class EnzoEIOHandler(BaseIOHandler):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._base = self.ds.dimensionality * (
slice(self.ds.ghost_zones, -self.ds.ghost_zones),

# precompute the indexing specifying each field's active zone
# -> this assumes that each field in Enzo-E shares the same number of
# ghost-zones. Technically, Enzo-E allows each field to have a
# different number of ghost zones (but this feature isn't currently
# used & it currently doesn't record this information)
# -> our usage of a negative stop value ensures compatability with
# both cell-centered and face-centered fields
self._activezone_idx = tuple(
slice(num_zones, -num_zones) if num_zones > 0 else slice(None)
for num_zones in self.ds.ghost_zones[self.ds.dimensionality:]
)

# Determine if particle masses are actually masses or densities.
Expand Down Expand Up @@ -186,7 +195,7 @@ def _read_obj_field(self, obj, field, fid_data):
dg.read(h5py.h5s.ALL, h5py.h5s.ALL, rdata)
if close:
fid.close()
data = rdata[self._base].T
data = rdata[self._activezone_idx].T
if self.ds.dimensionality < 3:
nshape = data.shape + (1,) * (3 - self.ds.dimensionality)
data = np.reshape(data, nshape)
Expand Down

0 comments on commit f50ed35

Please sign in to comment.