aboutsummaryrefslogtreecommitdiff
path: root/Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
diff options
context:
space:
mode:
authorGravatar Andrew Myers <atmyers@lbl.gov> 2021-10-08 11:25:47 -0700
committerGravatar GitHub <noreply@github.com> 2021-10-08 11:25:47 -0700
commit0c73e9baaefd26ef599e716966e492f115ff6415 (patch)
tree7eaa2a32a0b26fbce25c0ec1ccb3cda6b18a7698 /Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp
parenta822c928e215a83243b8da25f7e6f1b342c96179 (diff)
downloadWarpX-0c73e9baaefd26ef599e716966e492f115ff6415.tar.gz
WarpX-0c73e9baaefd26ef599e716966e492f115ff6415.tar.zst
WarpX-0c73e9baaefd26ef599e716966e492f115ff6415.zip
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 <axel.huebl@plasma.ninja> * add CI test for restarting particles with runtime-added attributes * remove unused module Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp')
-rw-r--r--Source/Diagnostics/FlushFormats/FlushFormatCheckpoint.cpp31
1 files changed, 29 insertions, 2 deletions
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<ParticleDiag>& 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<std::string> real_names;
+ Vector<std::string> int_names;
+ Vector<int> int_flags;
+ Vector<int> 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);
}
}