diff options
author | 2021-08-27 11:39:37 -0700 | |
---|---|---|
committer | 2021-08-27 18:39:37 +0000 | |
commit | a4c2b99651cbac22ccbf2b0f3e1441c61e639009 (patch) | |
tree | 70b02853bf86467af24808ba442526d1b21c383e /Source/Particles/PhysicalParticleContainer.cpp | |
parent | 7975a739038724fe0ca6d5c9f3c4454cc78bf83b (diff) | |
download | WarpX-a4c2b99651cbac22ccbf2b0f3e1441c61e639009.tar.gz WarpX-a4c2b99651cbac22ccbf2b0f3e1441c61e639009.tar.zst WarpX-a4c2b99651cbac22ccbf2b0f3e1441c61e639009.zip |
Functionality to save particle positions from the previous step (#2206)
* added functionality to save particle positions from the previous step
* copied WarpX variable to local variable to fix issue with GPU and DPC++ compilation
* switched to using a species attribute to toggle whether previous positions are saved so it can be turned on for only a subset of species if desired
* changed variable name to be more verbose
* added CI test of saving the previous particle positions
* start of a table in the documentation to describe commonly used runtime attributes
* generate test benchmark data from results obtained with a 2 processor run - the same as what is done during the test
* relaxed tolerance on test
* regenerate CI test reference data with USE_PSATD=TRUE
* Update Docs/source/developers/particles.rst
Co-authored-by: Phil Miller <unmobile+gh@gmail.com>
Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index d489cddfe..c704e824a 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -230,6 +230,19 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp } #endif + // If old particle positions should be saved add the needed components + pp_species_name.query("save_previous_position", m_save_previous_position); + if (m_save_previous_position) { + AddRealComp("prev_x"); +#if (AMREX_SPACEDIM == 3) + AddRealComp("prev_y"); +#endif + AddRealComp("prev_z"); +#ifdef WARPX_DIM_RZ + amrex::Abort("Saving previous particle positions not yet implemented in RZ"); +#endif + } + // Get Galilean velocity ParmParse pp_psatd("psatd"); bool use_default_v_galilean = false; @@ -2317,6 +2330,20 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, ion_lev = pti.GetiAttribs(particle_icomps["ionization_level"]).dataPtr(); } + const bool save_previous_position = m_save_previous_position; + ParticleReal* x_old = nullptr; + ParticleReal* y_old = nullptr; + ParticleReal* z_old = nullptr; + if (save_previous_position) { + x_old = pti.GetAttribs(particle_comps["prev_x"]).dataPtr(); +#if (AMREX_SPACEDIM == 3) + y_old = pti.GetAttribs(particle_comps["prev_y"]).dataPtr(); +#else + amrex::ignore_unused(y_old); +#endif + z_old = pti.GetAttribs(particle_comps["prev_z"]).dataPtr(); + } + // Loop over the particles and update their momentum const amrex::Real q = this->charge; const amrex::Real m = this-> mass; @@ -2344,6 +2371,14 @@ PhysicalParticleContainer::PushPX (WarpXParIter& pti, amrex::ParticleReal xp, yp, zp; getPosition(ip, xp, yp, zp); + if (save_previous_position) { + x_old[ip] = xp; +#if (AMREX_SPACEDIM == 3) + y_old[ip] = yp; +#endif + z_old[ip] = zp; + } + amrex::ParticleReal Exp = 0._rt, Eyp = 0._rt, Ezp = 0._rt; amrex::ParticleReal Bxp = 0._rt, Byp = 0._rt, Bzp = 0._rt; |