[Yt-svn] yt: Cache particle indices, which speeds things up a surprising ...
hg at spacepope.org
hg at spacepope.org
Thu Sep 2 00:07:57 PDT 2010
hg Repository: yt
details: yt/rev/d9bdb37f8046
changeset: 3369:d9bdb37f8046
user: Matthew Turk <matthewturk at gmail.com>
date:
Thu Sep 02 00:07:45 2010 -0700
description:
Cache particle indices, which speeds things up a surprising amount...
diffstat:
yt/frontends/flash/data_structures.py | 2 ++
yt/frontends/flash/io.py | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diffs (26 lines):
diff -r e2b55f386569 -r d9bdb37f8046 yt/frontends/flash/data_structures.py
--- a/yt/frontends/flash/data_structures.py Wed Sep 01 23:34:38 2010 -0700
+++ b/yt/frontends/flash/data_structures.py Thu Sep 02 00:07:45 2010 -0700
@@ -115,6 +115,8 @@
for ax in 'xyz']
self.grid_dimensions[:] *= (nxb, nyb, nzb)
self.grid_particle_count[:] = f["/localnp"][:][:,None]
+ self._particle_indices = na.zeros(self.num_grids + 1, dtype='int64')
+ na.add.accumulate(self.grid_particle_count, out=self._particle_indices[1:])
# This will become redundant, as _prepare_grid will reset it to its
# current value. Note that FLASH uses 1-based indexing for refinement
# levels, but we do not, so we reduce the level by 1.
diff -r e2b55f386569 -r d9bdb37f8046 yt/frontends/flash/io.py
--- a/yt/frontends/flash/io.py Wed Sep 01 23:34:38 2010 -0700
+++ b/yt/frontends/flash/io.py Thu Sep 02 00:07:45 2010 -0700
@@ -69,8 +69,8 @@
f = self._handle
if field in self._particle_fields:
if grid.NumberOfParticles == 0: return na.array([], dtype='float64')
- start = na.sum(self.pf.h.grid_particle_count[:grid.id-grid._id_offset])
- end = start + grid.NumberOfParticles
+ start = self.pf.h._particle_indices[grid.id - grid._id_offset]
+ end = self.pf.h._particle_indices[grid.id - grid._id_offset + 1]
fi = self._particle_fields[field]
tr = f["/tracer particles"][start:end, fi]
else:
More information about the yt-svn
mailing list