Skip to content

Commit

Permalink
Merge pull request #4734 from cphyc/RAMSES-lazy-loading
Browse files Browse the repository at this point in the history
Read AMR domains lazily
  • Loading branch information
matthewturk authored Dec 6, 2023
2 parents 6b53539 + bcf3447 commit 1e90fd7
Show file tree
Hide file tree
Showing 13 changed files with 522 additions and 401 deletions.
10 changes: 8 additions & 2 deletions yt/data_objects/index_subobjects/octree_subset.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import abc
from contextlib import contextmanager
from functools import cached_property
from itertools import product, repeat
Expand Down Expand Up @@ -33,7 +34,7 @@ def cc_cache_func(self, dobj):
return cc_cache_func


class OctreeSubset(YTSelectionContainer):
class OctreeSubset(YTSelectionContainer, abc.ABC):
_spatial = True
_num_ghost_zones = 0
_type_name = "octree_subset"
Expand All @@ -51,12 +52,17 @@ def __init__(self, base_region, domain, ds, num_zones=2, num_ghost_zones=0):
self.domain_id = domain.domain_id
self.ds = domain.ds
self._index = self.ds.index
self.oct_handler = domain.oct_handler
self._last_mask = None
self._last_selector_id = None
self.base_region = base_region
self.base_selector = base_region.selector

@property
@abc.abstractmethod
def oct_handler(self):
# In charge of returning the oct_handler
pass

def __getitem__(self, key):
tr = super().__getitem__(key)
try:
Expand Down
10 changes: 9 additions & 1 deletion yt/frontends/art/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,10 @@ def _is_valid(cls, filename: str, *args, **kwargs) -> bool:


class ARTDomainSubset(OctreeSubset):
@property
def oct_handler(self):
return self.domain.oct_handler

def fill(self, content, ftfields, selector):
"""
This is called from IOHandler. It takes content
Expand Down Expand Up @@ -798,7 +802,11 @@ def __init__(self, ds, nvar, oct_handler, domain_id):
self._level_count = None
self._level_oct_offsets = None
self._level_child_offsets = None
self.oct_handler = oct_handler
self._oct_handler = oct_handler

@property
def oct_handler(self):
return self._oct_handler

@property
def level_count(self):
Expand Down
6 changes: 5 additions & 1 deletion yt/frontends/artio/data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, base_region, sfc_start, sfc_end, oct_handler, ds):
self.field_parameters = {}
self.sfc_start = sfc_start
self.sfc_end = sfc_end
self.oct_handler = oct_handler
self._oct_handler = oct_handler
self.ds = ds
self._last_mask = None
self._last_selector_id = None
Expand All @@ -43,6 +43,10 @@ def __init__(self, base_region, sfc_start, sfc_end, oct_handler, ds):
self.base_region = base_region
self.base_selector = base_region.selector

@property
def oct_handler(self):
return self._oct_handler

@property
def min_ind(self):
return self.sfc_start
Expand Down
Loading

0 comments on commit 1e90fd7

Please sign in to comment.