# HG changeset patch # User Matthew Turk # Date 1283411265 25200 # Branch yt # Node ID d9bdb37f8046d00d41ea506c0b960782e80121d8 # Parent e2b55f386569be8b3cf398dcbd19ce1875fa46b9 Cache particle indices, which speeds things up a surprising amount... diff -r e2b55f386569be8b3cf398dcbd19ce1875fa46b9 -r d9bdb37f8046d00d41ea506c0b960782e80121d8 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 e2b55f386569be8b3cf398dcbd19ce1875fa46b9 -r d9bdb37f8046d00d41ea506c0b960782e80121d8 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: