Skip to content

Commit

Permalink
also update async version
Browse files Browse the repository at this point in the history
  • Loading branch information
atmyers committed Jan 23, 2024
1 parent abf8d07 commit 16b2379
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Src/Particle/AMReX_WriteBinaryParticleData.H
Original file line number Diff line number Diff line change
Expand Up @@ -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<LayoutData<Long> > np_per_grid_local(pc.finestLevel()+1);
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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; }
}

Expand All @@ -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'; }
}

Expand Down Expand Up @@ -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; }
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 16b2379

Please sign in to comment.