aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Remi Lehe <remi.lehe@normalesup.org> 2019-05-22 16:54:41 -0700
committerGravatar GitHub <noreply@github.com> 2019-05-22 16:54:41 -0700
commit821f0107b70d3155849d46bbde7de5d58f2d1406 (patch)
tree89ad266c3f48d1fbe7b551c35a0a358ce75d3b79 /Source/Particles/WarpXParticleContainer.cpp
parent2c5216672b4df197e81382f7a35133e1d1723859 (diff)
parentc394ff331f484fb04d0266f82a0ca41124af6f98 (diff)
downloadWarpX-821f0107b70d3155849d46bbde7de5d58f2d1406.tar.gz
WarpX-821f0107b70d3155849d46bbde7de5d58f2d1406.tar.zst
WarpX-821f0107b70d3155849d46bbde7de5d58f2d1406.zip
Merge pull request #156 from RemiLehe/pusher_kernels
Fix/Refactor the function PushX
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.cpp')
-rw-r--r--Source/Particles/WarpXParticleContainer.cpp32
1 files changed, 20 insertions, 12 deletions
diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp
index 0cf5c10b4..c7ffe956b 100644
--- a/Source/Particles/WarpXParticleContainer.cpp
+++ b/Source/Particles/WarpXParticleContainer.cpp
@@ -7,6 +7,10 @@
#include <WarpX_f.H>
#include <WarpX.H>
+// Import low-level single-particle kernels
+#include <GetAndSetPosition.H>
+#include <UpdatePosition.H>
+
using namespace amrex;
int WarpXParticleContainer::do_not_push = 0;
@@ -1048,20 +1052,24 @@ WarpXParticleContainer::PushX (int lev, Real dt)
Real* AMREX_RESTRICT ux = attribs[PIdx::ux].dataPtr();
Real* AMREX_RESTRICT uy = attribs[PIdx::uy].dataPtr();
Real* AMREX_RESTRICT uz = attribs[PIdx::uz].dataPtr();
- // Loop over the particles and update the position
- const long np = pti.numParticles();
- const Real inv_c2 = 1./(PhysConst::c*PhysConst::c);
- amrex::ParallelFor( np,
+#ifdef WARPX_RZ
+ Real* AMREX_RESTRICT theta = attribs[PIdx::theta].dataPtr();
+#endif
+ // Loop over the particles and update their position
+ amrex::ParallelFor( pti.numParticles(),
[=] AMREX_GPU_DEVICE (long i) {
- // Compute inverse Lorentz factor
- const Real inv_gamma = 1./std::sqrt(
- 1. + (ux[i]*ux[i] + uy[i]*uy[i] + uz[i]*uz[i])*inv_c2);
- // Update positions over one time step
- pstructs[i].pos(0) += ux[i] * inv_gamma * dt;
-#if (AMREX_SPACEDIM == 3) || (defined WARPX_RZ) // RZ pushes particles in 3D
- pstructs[i].pos(1) += uy[i] * inv_gamma * dt;
+ ParticleType& p = pstructs[i]; // Particle object that gets updated
+ Real x, y, z; // Temporary variables
+#ifndef WARPX_RZ
+ GetPosition( x, y, z, p ); // Initialize x, y, z
+ UpdatePosition( x, y, z, ux[i], uy[i], uz[i], dt);
+ SetPosition( p, x, y, z ); // Update the object p
+#else
+ // For WARPX_RZ, the particles are still pushed in 3D Cartesian
+ GetCartesianPositionFromCylindrical( x, y, z, p, theta[i] );
+ UpdatePosition( x, y, z, ux[i], uy[i], uz[i], dt);
+ SetCylindricalPositionFromCartesian( p, theta[i], x, y, z );
#endif
- pstructs[i].pos(2) += uz[i] * inv_gamma * dt;
}
);