aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/RigidInjectedParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar WeiqunZhang <WeiqunZhang@lbl.gov> 2020-09-08 12:36:52 -0700
committerGravatar GitHub <noreply@github.com> 2020-09-08 12:36:52 -0700
commit65d1c056be23365a045bbcaebf4413378c4c977d (patch)
tree8dfb4d990c6e59a3a5e391dd21aff62aeecffe7c /Source/Particles/RigidInjectedParticleContainer.cpp
parentd3deb238aee2fca44a099ec45c08dc265223ca52 (diff)
downloadWarpX-65d1c056be23365a045bbcaebf4413378c4c977d.tar.gz
WarpX-65d1c056be23365a045bbcaebf4413378c4c977d.tar.zst
WarpX-65d1c056be23365a045bbcaebf4413378c4c977d.zip
Remove ManagedVector from Particles/ (#1273)
Diffstat (limited to 'Source/Particles/RigidInjectedParticleContainer.cpp')
-rw-r--r--Source/Particles/RigidInjectedParticleContainer.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/Particles/RigidInjectedParticleContainer.cpp b/Source/Particles/RigidInjectedParticleContainer.cpp
index 8b8237ceb..338a23675 100644
--- a/Source/Particles/RigidInjectedParticleContainer.cpp
+++ b/Source/Particles/RigidInjectedParticleContainer.cpp
@@ -246,7 +246,7 @@ RigidInjectedParticleContainer::PushPX (WarpXParIter& pti,
auto& uzp = attribs[PIdx::uz];
// Save the position and momenta, making copies
- Gpu::ManagedDeviceVector<ParticleReal> xp_save, yp_save, zp_save;
+ Gpu::DeviceVector<ParticleReal> xp_save, yp_save, zp_save;
RealVector uxp_save, uyp_save, uzp_save;
const auto GetPosition = GetParticlePosition(pti);
@@ -453,9 +453,12 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt,
}
// Save the position and momenta, making copies
- auto uxp_save = uxp;
- auto uyp_save = uyp;
- auto uzp_save = uzp;
+ amrex::Gpu::DeviceVector<ParticleReal> uxp_save(np);
+ amrex::Gpu::DeviceVector<ParticleReal> uyp_save(np);
+ amrex::Gpu::DeviceVector<ParticleReal> uzp_save(np);
+ ParticleReal* const AMREX_RESTRICT ux_save = uxp_save.dataPtr();
+ ParticleReal* const AMREX_RESTRICT uy_save = uyp_save.dataPtr();
+ ParticleReal* const AMREX_RESTRICT uz_save = uzp_save.dataPtr();
// Loop over the particles and update their momentum
const amrex::Real q = this->charge;
@@ -466,6 +469,10 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt,
amrex::ParallelFor( np, [=] AMREX_GPU_DEVICE (long ip)
{
+ ux_save[ip] = uxpp[ip];
+ uy_save[ip] = uypp[ip];
+ uz_save[ip] = uzpp[ip];
+
amrex::ParticleReal xp, yp, zp;
getPosition(ip, xp, yp, zp);
@@ -513,9 +520,6 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt,
// Undo the push for particles not injected yet.
// It is assumed that PushP will only be called on the first and last steps
// and that no particles will cross zinject_plane.
- const ParticleReal* const AMREX_RESTRICT ux_save = uxp_save.dataPtr();
- const ParticleReal* const AMREX_RESTRICT uy_save = uyp_save.dataPtr();
- const ParticleReal* const AMREX_RESTRICT uz_save = uzp_save.dataPtr();
const ParticleReal zz = zinject_plane_levels[lev];
amrex::ParallelFor( pti.numParticles(), [=] AMREX_GPU_DEVICE (long i)
{
@@ -527,6 +531,8 @@ RigidInjectedParticleContainer::PushP (int lev, Real dt,
uzpp[i] = uz_save[i];
}
});
+
+ amrex::Gpu::synchronize();
}
}
}