From 47ce69b6de673b5f5611f47cc0db0274216285ef Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Wed, 2 Oct 2024 21:53:37 -0400 Subject: [PATCH] outp: fix EveryNth output This had worked, then I broke it, this should undo the breakage. --- .../output_particles_hdf5_impl.hxx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx index bf9254727..54825b6fa 100644 --- a/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx +++ b/src/libpsc/psc_output_particles/output_particles_hdf5_impl.hxx @@ -445,7 +445,22 @@ struct OutputParticlesHdf5 int nr_kinds = grid.kinds.size(); // count all particles to be written locally - size_t n_write = mprts.size(); + size_t n_write = 0; + for (int p = 0; p < mprts.n_patches(); p++) { + auto& patch = grid.patches[p]; + int ilo[3], ihi[3], ld[3]; + int sz = find_patch_bounds(grid.ldims, patch.off, ilo, ihi, ld); + for (int jz = ilo[2]; jz < ihi[2]; jz++) { + for (int jy = ilo[1]; jy < ihi[1]; jy++) { + for (int jx = ilo[0]; jx < ihi[0]; jx++) { + for (int kind = 0; kind < nr_kinds; kind++) { + int si = sort_index(grid.ldims, nr_kinds, {jx, jy, jz}, kind); + n_write += off[p][si + 1] - off[p][si]; + } + } + } + } + } assert(sizeof(size_t) == sizeof(unsigned long)); size_t n_total, n_off = 0;