Skip to content

Commit d65e09e

Browse files
authored
Solve an issue with particles async IO when having runtime added variables (AMReX-Codes#2966)
1 parent cd07b0d commit d65e09e

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Src/Particle/AMReX_WriteBinaryParticleData.H

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,25 @@ void WriteBinaryParticleDataAsync (PC const& pc,
766766
if (np_per_grid_local[lev][mfi.index()] > 0)
767767
{
768768
const auto& ptile = pc.ParticlesAt(lev, mfi);
769-
new_ptile.resize(np_per_grid_local[lev][mfi.index()]);
769+
770+
const auto np = np_per_grid_local[lev][mfi.index()];
771+
772+
new_ptile.resize(np);
773+
774+
const auto runtime_real_comps = ptile.NumRuntimeRealComps();
775+
const auto runtime_int_comps = ptile.NumRuntimeIntComps();
776+
777+
constexpr auto NReal = NArrayReal + NStructReal;
778+
constexpr auto NInt = NArrayInt + NStructInt;
779+
780+
new_ptile.define(runtime_real_comps, runtime_int_comps);
781+
782+
for (auto comp(0); comp < runtime_real_comps; ++comp)
783+
new_ptile.push_back_real(NReal+comp, np, 0.);
784+
785+
for (auto comp(0); comp < runtime_int_comps; ++comp)
786+
new_ptile.push_back_int(NInt+comp, np, 0);
787+
770788
amrex::filterParticles(new_ptile, ptile, KeepValidFilter());
771789
}
772790
}

0 commit comments

Comments
 (0)