aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Particles')
-rw-r--r--Source/Particles/PhysicalParticleContainer.H3
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp57
-rw-r--r--Source/Particles/RigidInjectedParticleContainer.cpp20
3 files changed, 48 insertions, 32 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H
index bd8cfb47e..99fc0f8da 100644
--- a/Source/Particles/PhysicalParticleContainer.H
+++ b/Source/Particles/PhysicalParticleContainer.H
@@ -77,6 +77,9 @@ public:
const amrex::MultiFab& Bx,
const amrex::MultiFab& By,
const amrex::MultiFab& Bz) override;
+
+ void warpx_copy_attribs(WarpXParIter& pti,const amrex::Real* xp,
+ const amrex::Real* yp, const amrex::Real* zp);
virtual void PostRestart () final {}
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 43b46ec49..c45f73f0f 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -1729,7 +1729,13 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti,
Real dt)
{
- // This wraps the call to warpx_particle_pusher so that inheritors can modify the call.
+ if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags)
+ {
+ warpx_copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr());
+ }
+
+ // The following attributes should be included in CPP version of warpx_particle_pusher
+ // This wraps the call to warpx_particle_pusher so that inheritors can modify the call.
auto& attribs = pti.GetAttribs();
auto& uxp = attribs[PIdx::ux];
auto& uyp = attribs[PIdx::uy];
@@ -1741,22 +1747,7 @@ PhysicalParticleContainer::PushPX(WarpXParIter& pti,
auto& Byp = attribs[PIdx::By];
auto& Bzp = attribs[PIdx::Bz];
const long np = pti.numParticles();
-
- if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags)
- {
- auto& xpold = pti.GetAttribs(particle_comps["xold"]);
- auto& ypold = pti.GetAttribs(particle_comps["yold"]);
- auto& zpold = pti.GetAttribs(particle_comps["zold"]);
- auto& uxpold = pti.GetAttribs(particle_comps["uxold"]);
- auto& uypold = pti.GetAttribs(particle_comps["uyold"]);
- auto& uzpold = pti.GetAttribs(particle_comps["uzold"]);
-
- warpx_copy_attribs(&np, xp.dataPtr(), yp.dataPtr(), zp.dataPtr(),
- uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(),
- xpold.dataPtr(), ypold.dataPtr(), zpold.dataPtr(),
- uxpold.dataPtr(), uypold.dataPtr(), uzpold.dataPtr());
- }
-
+
warpx_particle_pusher(&np,
xp.dataPtr(),
yp.dataPtr(),
@@ -1870,6 +1861,38 @@ PhysicalParticleContainer::PushP (int lev, Real dt,
}
}
+void PhysicalParticleContainer::warpx_copy_attribs(WarpXParIter& pti,const Real* xp,
+ const Real* yp, const Real* zp)
+{
+
+ auto& attribs = pti.GetAttribs();
+
+ Real* AMREX_RESTRICT uxp = attribs[PIdx::ux].dataPtr();
+ Real* AMREX_RESTRICT uyp = attribs[PIdx::uy].dataPtr();
+ Real* AMREX_RESTRICT uzp = attribs[PIdx::uz].dataPtr();
+
+ Real* AMREX_RESTRICT xpold = pti.GetAttribs(particle_comps["xold"]).dataPtr();
+ Real* AMREX_RESTRICT ypold = pti.GetAttribs(particle_comps["xold"]).dataPtr();
+ Real* AMREX_RESTRICT zpold = pti.GetAttribs(particle_comps["xold"]).dataPtr();
+ Real* AMREX_RESTRICT uxpold = pti.GetAttribs(particle_comps["uxold"]).dataPtr();
+ Real* AMREX_RESTRICT uypold = pti.GetAttribs(particle_comps["uyold"]).dataPtr();
+ Real* AMREX_RESTRICT uzpold = pti.GetAttribs(particle_comps["uzold"]).dataPtr();
+
+ const long np = pti.numParticles();
+
+ ParallelFor( np,
+ [=] AMREX_GPU_DEVICE (long i) {
+ xpold[i]=xp[i];
+ ypold[i]=yp[i];
+ zpold[i]=zp[i];
+
+ uxpold[i]=uxp[i];
+ uypold[i]=uyp[i];
+ uzpold[i]=uzp[i];
+ }
+ );
+}
+
void PhysicalParticleContainer::GetParticleSlice(const int direction, const Real z_old,
const Real z_new, const Real t_boost,
const Real t_lab, const Real dt,
diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp
index 2a3e8dd0d..ca02d1458 100644
--- a/Source/Particles/RigidInjectedParticleContainer.cpp
+++ b/Source/Particles/RigidInjectedParticleContainer.cpp
@@ -211,6 +211,11 @@ RigidInjectedParticleContainer::PushPX(WarpXParIter& pti,
Real dt)
{
+ if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags)
+ {
+ warpx_copy_attribs(pti, xp.dataPtr(), yp.dataPtr(), zp.dataPtr());
+ }
+
// This wraps the call to warpx_particle_pusher so that inheritors can modify the call.
auto& attribs = pti.GetAttribs();
auto& uxp = attribs[PIdx::ux];
@@ -224,21 +229,6 @@ RigidInjectedParticleContainer::PushPX(WarpXParIter& pti,
auto& Bzp = attribs[PIdx::Bz];
const long np = pti.numParticles();
- if (WarpX::do_boosted_frame_diagnostic && do_boosted_frame_diags)
- {
- auto& xpold = pti.GetAttribs(particle_comps["xold"]);
- auto& ypold = pti.GetAttribs(particle_comps["yold"]);
- auto& zpold = pti.GetAttribs(particle_comps["zold"]);
- auto& uxpold = pti.GetAttribs(particle_comps["uxold"]);
- auto& uypold = pti.GetAttribs(particle_comps["uyold"]);
- auto& uzpold = pti.GetAttribs(particle_comps["uzold"]);
-
- warpx_copy_attribs(&np, xp.dataPtr(), yp.dataPtr(), zp.dataPtr(),
- uxp.dataPtr(), uyp.dataPtr(), uzp.dataPtr(),
- xpold.dataPtr(), ypold.dataPtr(), zpold.dataPtr(),
- uxpold.dataPtr(), uypold.dataPtr(), uzpold.dataPtr());
- }
-
// Save the position and momenta, making copies
Cuda::ManagedDeviceVector<Real> xp_save, yp_save, zp_save;
RealVector uxp_save, uyp_save, uzp_save;