From 16b2379afda5eec58c09a96ac9b1ce95ff5f539d Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Tue, 23 Jan 2024 09:11:16 -0800 Subject: [PATCH] also update async version --- Src/Particle/AMReX_WriteBinaryParticleData.H | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Src/Particle/AMReX_WriteBinaryParticleData.H b/Src/Particle/AMReX_WriteBinaryParticleData.H index 804eefbe408..449c26c6ef2 100644 --- a/Src/Particle/AMReX_WriteBinaryParticleData.H +++ b/Src/Particle/AMReX_WriteBinaryParticleData.H @@ -689,7 +689,11 @@ void WriteBinaryParticleDataAsync (PC const& pc, const int NProcs = ParallelDescriptor::NProcs(); const int IOProcNumber = NProcs - 1; - AMREX_ALWAYS_ASSERT(real_comp_names.size() == pc.NumRealComps() + NStructReal); + if constexpr(PC::ParticleType::is_soa_particle) { + AMREX_ALWAYS_ASSERT(real_comp_names.size() == pc.NumRealComps() + NStructReal - AMREX_SPACEDIM); // pure SoA: skip positions + } else { + AMREX_ALWAYS_ASSERT(real_comp_names.size() == pc.NumRealComps() + NStructReal); + } AMREX_ALWAYS_ASSERT( int_comp_names.size() == pc.NumIntComps() + NStructInt); Vector > np_per_grid_local(pc.finestLevel()+1); @@ -853,6 +857,7 @@ void WriteBinaryParticleDataAsync (PC const& pc, int nrc = pc.NumRealComps(); int nic = pc.NumIntComps(); + int rnames_size = (int) real_comp_names.size(); auto RD = pc.ParticleRealDescriptor; @@ -887,7 +892,7 @@ void WriteBinaryParticleDataAsync (PC const& pc, } int num_output_real = 0; - for (int i = 0; i < nrc + NStructReal; ++i) { + for (int i = 0; i < rnames_size; ++i) { if (write_real_comp[i]) { ++num_output_real; } } @@ -903,7 +908,7 @@ void WriteBinaryParticleDataAsync (PC const& pc, HdrFile << num_output_real << '\n'; // Real component names - for (int i = 0; i < NStructReal + nrc; ++i ) { + for (int i = 0; i < rnames_size; ++i ) { if (write_real_comp[i]) { HdrFile << real_comp_names[i] << '\n'; } } @@ -1053,7 +1058,7 @@ void WriteBinaryParticleDataAsync (PC const& pc, // Write the Real data in binary. int num_output_real = 0; - for (int i = 0; i < nrc + NStructReal; ++i) { + for (int i = 0; i < rnames_size; ++i) { if (write_real_comp[i]) { ++num_output_real; } } @@ -1099,7 +1104,9 @@ void WriteBinaryParticleDataAsync (PC const& pc, const int real_start_offset = PC::ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0; // pure SoA: positions for (int j = real_start_offset; j < nrc; j++) { - if (write_real_comp[NStructReal+j]) + const int write_comp_offset = PC::ParticleType::is_soa_particle ? AMREX_SPACEDIM : 0; // pure SoA: skip positions + const int write_comp_index = PC::NStructReal+j-write_comp_offset; + if (write_real_comp[write_comp_index]) { *rptr = (typename PC::ParticleType::RealType) soa.GetRealData(j)[pindex]; ++rptr;