aboutsummaryrefslogtreecommitdiff
path: root/Source/Laser/LaserParticleContainer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Laser/LaserParticleContainer.cpp')
-rw-r--r--Source/Laser/LaserParticleContainer.cpp82
1 files changed, 38 insertions, 44 deletions
diff --git a/Source/Laser/LaserParticleContainer.cpp b/Source/Laser/LaserParticleContainer.cpp
index de192e65e..2bc522a8e 100644
--- a/Source/Laser/LaserParticleContainer.cpp
+++ b/Source/Laser/LaserParticleContainer.cpp
@@ -16,6 +16,7 @@
#include <WarpX_Complex.H>
#include <WarpX_f.H>
#include <MultiParticleContainer.H>
+#include <GetAndSetPosition.H>
using namespace amrex;
using namespace WarpXLaserProfiles;
@@ -432,13 +433,6 @@ LaserParticleContainer::Evolve (int lev,
plane_Yp.resize(np);
amplitude_E.resize(np);
- //
- // copy data from particle container to temp arrays
- //
- BL_PROFILE_VAR_START(blp_copy);
- pti.GetPosition(m_xp[thread_num], m_yp[thread_num], m_zp[thread_num]);
- BL_PROFILE_VAR_STOP(blp_copy);
-
if (rho) {
int* AMREX_RESTRICT ion_lev = nullptr;
DepositCharge(pti, wp, ion_lev, rho, 0, 0,
@@ -454,7 +448,7 @@ LaserParticleContainer::Evolve (int lev,
//
BL_PROFILE_VAR_START(blp_pp);
// Find the coordinates of the particles in the emission plane
- calculate_laser_plane_coordinates(np, thread_num,
+ calculate_laser_plane_coordinates(pti, np,
plane_Xp.dataPtr(),
plane_Yp.dataPtr());
@@ -465,9 +459,9 @@ LaserParticleContainer::Evolve (int lev,
t_lab, amplitude_E.dataPtr());
// Calculate the corresponding momentum and position for the particles
- update_laser_particle(np, uxp.dataPtr(), uyp.dataPtr(),
+ update_laser_particle(pti, np, uxp.dataPtr(), uyp.dataPtr(),
uzp.dataPtr(), wp.dataPtr(),
- amplitude_E.dataPtr(), dt, thread_num);
+ amplitude_E.dataPtr(), dt);
BL_PROFILE_VAR_STOP(blp_pp);
//
@@ -489,13 +483,6 @@ LaserParticleContainer::Evolve (int lev,
}
}
- //
- // copy particle data back
- //
- BL_PROFILE_VAR_START(blp_copy);
- pti.SetPosition(m_xp[thread_num], m_yp[thread_num], m_zp[thread_num]);
- BL_PROFILE_VAR_STOP(blp_copy);
-
if (rho) {
int* AMREX_RESTRICT ion_lev = nullptr;
DepositCharge(pti, wp, ion_lev, rho, 1, 0,
@@ -585,14 +572,12 @@ LaserParticleContainer::PushP (int lev, Real dt,
* in laser plane coordinate.
*/
void
-LaserParticleContainer::calculate_laser_plane_coordinates (
- const int np, const int thread_num,
- Real * AMREX_RESTRICT const pplane_Xp,
- Real * AMREX_RESTRICT const pplane_Yp)
+LaserParticleContainer::calculate_laser_plane_coordinates (const WarpXParIter& pti, const int np,
+ Real * AMREX_RESTRICT const pplane_Xp,
+ Real * AMREX_RESTRICT const pplane_Yp)
{
- ParticleReal const * const AMREX_RESTRICT xp = m_xp[thread_num].dataPtr();
- ParticleReal const * const AMREX_RESTRICT yp = m_yp[thread_num].dataPtr();
- ParticleReal const * const AMREX_RESTRICT zp = m_zp[thread_num].dataPtr();
+ const auto GetPosition = GetParticlePosition(pti);
+
Real tmp_u_X_0 = u_X[0];
Real tmp_u_X_2 = u_X[2];
Real tmp_position_0 = position[0];
@@ -608,19 +593,21 @@ LaserParticleContainer::calculate_laser_plane_coordinates (
amrex::ParallelFor(
np,
[=] AMREX_GPU_DEVICE (int i) {
+ ParticleReal x, y, z;
+ GetPosition(i, x, y, z);
#if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ)
pplane_Xp[i] =
- tmp_u_X_0 * (xp[i] - tmp_position_0) +
- tmp_u_X_1 * (yp[i] - tmp_position_1) +
- tmp_u_X_2 * (zp[i] - tmp_position_2);
+ tmp_u_X_0 * (x - tmp_position_0) +
+ tmp_u_X_1 * (y - tmp_position_1) +
+ tmp_u_X_2 * (z - tmp_position_2);
pplane_Yp[i] =
- tmp_u_Y_0 * (xp[i] - tmp_position_0) +
- tmp_u_Y_1 * (yp[i] - tmp_position_1) +
- tmp_u_Y_2 * (zp[i] - tmp_position_2);
+ tmp_u_Y_0 * (x - tmp_position_0) +
+ tmp_u_Y_1 * (y - tmp_position_1) +
+ tmp_u_Y_2 * (z - tmp_position_2);
#elif (AMREX_SPACEDIM == 2)
pplane_Xp[i] =
- tmp_u_X_0 * (xp[i] - tmp_position_0) +
- tmp_u_X_2 * (zp[i] - tmp_position_2);
+ tmp_u_X_0 * (x - tmp_position_0) +
+ tmp_u_X_2 * (z - tmp_position_2);
pplane_Yp[i] = 0.;
#endif
}
@@ -629,23 +616,26 @@ LaserParticleContainer::calculate_laser_plane_coordinates (
/* \brief push laser particles, in simulation coordinates.
*
+ * \param pti: Particle iterator
* \param np: number of laser particles
* \param puxp, puyp, puzp: pointers to arrays of particle momenta.
* \param pwp: pointer to array of particle weights.
* \param amplitude: Electric field amplitude at the position of each particle.
* \param dt: time step.
- * \param thread_num: thread number
*/
void
-LaserParticleContainer::update_laser_particle(
- const int np, ParticleReal * AMREX_RESTRICT const puxp, ParticleReal * AMREX_RESTRICT const puyp,
- ParticleReal * AMREX_RESTRICT const puzp, ParticleReal const * AMREX_RESTRICT const pwp,
- Real const * AMREX_RESTRICT const amplitude, const Real dt,
- const int thread_num)
+LaserParticleContainer::update_laser_particle(WarpXParIter& pti,
+ const int np,
+ ParticleReal * AMREX_RESTRICT const puxp,
+ ParticleReal * AMREX_RESTRICT const puyp,
+ ParticleReal * AMREX_RESTRICT const puzp,
+ ParticleReal const * AMREX_RESTRICT const pwp,
+ Real const * AMREX_RESTRICT const amplitude,
+ const Real dt)
{
- ParticleReal * const AMREX_RESTRICT xp = m_xp[thread_num].dataPtr();
- ParticleReal * const AMREX_RESTRICT yp = m_yp[thread_num].dataPtr();
- ParticleReal * const AMREX_RESTRICT zp = m_zp[thread_num].dataPtr();
+ const auto GetPosition = GetParticlePosition(pti);
+ auto SetPosition = SetParticlePosition(pti);
+
Real tmp_p_X_0 = p_X[0];
Real tmp_p_X_1 = p_X[1];
Real tmp_p_X_2 = p_X[2];
@@ -678,12 +668,16 @@ LaserParticleContainer::update_laser_particle(
puxp[i] = gamma * vx;
puyp[i] = gamma * vy;
puzp[i] = gamma * vz;
+
// Push the the particle positions
- xp[i] += vx * dt;
+ ParticleReal x, y, z;
+ GetPosition(i, x, y, z);
+ x += vx * dt;
#if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ)
- yp[i] += vy * dt;
+ y += vy * dt;
#endif
- zp[i] += vz * dt;
+ z += vz * dt;
+ SetPosition(i, x, y, z);
}
);
}