From 0c73e9baaefd26ef599e716966e492f115ff6415 Mon Sep 17 00:00:00 2001 From: Andrew Myers Date: Fri, 8 Oct 2021 11:25:47 -0700 Subject: Fix checkpoint with runtime components through the Python interface. (#2332) * add component names to checkpoint * read in particle components and add the missing ones on restart * do not add components if one by the name already exists * sign error * Better warning messages * Update Source/Diagnostics/ParticleIO.cpp Co-authored-by: Axel Huebl * add CI test for restarting particles with runtime-added attributes * remove unused module Co-authored-by: Axel Huebl --- .../FlushFormats/FlushFormatCheckpoint.cpp | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp') diff --git a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp index 73ec84d02..9b7e2195f 100644 --- a/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp +++ b/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp @@ -159,8 +159,35 @@ FlushFormatCheckpoint::CheckpointParticles ( const amrex::Vector& particle_diags) const { for (unsigned i = 0, n = particle_diags.size(); i < n; ++i) { - particle_diags[i].getParticleContainer()->Checkpoint( - dir, particle_diags[i].getSpeciesName()); + WarpXParticleContainer* pc = particle_diags[i].getParticleContainer(); + + Vector real_names; + Vector int_names; + Vector int_flags; + Vector real_flags; + + real_names.push_back("weight"); + + real_names.push_back("momentum_x"); + real_names.push_back("momentum_y"); + real_names.push_back("momentum_z"); + +#ifdef WARPX_DIM_RZ + real_names.push_back("theta"); +#endif + + // get the names of the real comps + real_names.resize(pc->NumRealComps()); + auto runtime_rnames = pc->getParticleRuntimeComps(); + for (auto const& x : runtime_rnames) { real_names[x.second+PIdx::nattribs] = x.first; } + + // and the int comps + int_names.resize(pc->NumIntComps()); + auto runtime_inames = pc->getParticleRuntimeiComps(); + for (auto const& x : runtime_inames) { int_names[x.second+0] = x.first; } + + pc->Checkpoint(dir, particle_diags[i].getSpeciesName(), true, + real_names, int_names); } } -- cgit v1.2.3