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

Reset cell and particle counter on load and skip cpu and level loops while loading if not required #83

Merged
merged 4 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/osyris/io/amr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def initialize(self, meta, select):
meta["unit_t"], meta["scale"]),
select=select,
infofile=meta["infofile"])
self.initialized = True
if select is not False:
self.initialized = True

def allocate_buffers(self, ngridmax, twotondim):
super().allocate_buffers(ngridmax, twotondim)
Expand Down
23 changes: 21 additions & 2 deletions src/osyris/io/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,39 @@ def load(self, select=None, cpu_list=None, meta=None):

# Initialize readers
readers = {}
do_not_load_amr = True
do_not_load_cpus = True
for group in groups:
loaded_on_init = self.readers[group].initialize(meta=meta,
select=_select[group])
if loaded_on_init is not None:
out[group] = loaded_on_init
if self.readers[group].initialized:
readers[group] = self.readers[group]
if self.readers[group].kind == ReaderKind.AMR:
do_not_load_amr = False
if self.readers[group].kind in (ReaderKind.AMR, ReaderKind.PART):
do_not_load_cpus = False
# If no reader requires the AMR tree to be read, set lmax to zero
if do_not_load_amr:
lmax = 0
else:
meta["ncells"] = 0
lmax = meta["lmax"]
if "amr" not in readers:
readers["amr"] = self.readers["amr"]

# Take into account user specified cpu list
if cpu_list is None:
cpu_list = self.readers["amr"].cpu_list if self.readers[
"amr"].cpu_list is not None else range(1, meta["ncpu"] + 1)

print("Processing {} files in {}".format(len(cpu_list), meta["infile"]))
# If no reader requires the CPUs (if loading only sinks), make empty cpu list
if do_not_load_cpus:
cpu_list = []
else:
meta["nparticles"] = 0
print("Processing {} files in {}".format(len(cpu_list), meta["infile"]))

# Allocate work arrays
twotondim = 2**meta["ndim"]
Expand Down Expand Up @@ -139,7 +158,7 @@ def load(self, select=None, cpu_list=None, meta=None):
reader.read_header(meta)

# Loop over levels
for ilevel in range(meta["lmax"]):
for ilevel in range(lmax):

for reader in readers.values():
reader.read_level_header(ilevel, twotondim)
Expand Down