WarpX
UpdatePositionPhoton.H
Go to the documentation of this file.
1 /* Copyright 2019 David Grote, Luca Fedeli, Maxence Thevenet
2  * Remi Lehe, Weiqun Zhang
3  *
4  * This file is part of WarpX.
5  *
6  * License: BSD-3-Clause-LBNL
7  */
8 #ifndef WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_
9 #define WARPX_PARTICLES_PUSHER_UPDATEPOSITIONPHOTON_H_
10 
11 #include "Utils/WarpXConst.H"
12 
13 #include <AMReX.H>
14 #include <AMReX_FArrayBox.H>
15 #include <AMReX_REAL.H>
16 
23  amrex::ParticleReal& x, amrex::ParticleReal& y, amrex::ParticleReal& z,
24  const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz,
25  const amrex::Real dt )
26 {
27  using namespace amrex::literals;
28 
29  // Compute speed of light over inverse of momentum modulus, avoiding a division by zero in the
30  // case where the photon has exactly zero momentum
31  const amrex::ParticleReal u_norm = std::sqrt(ux*ux + uy*uy + uz*uz);
32  const amrex::ParticleReal c_over_umod = (u_norm == 0._prt) ? 0._prt: PhysConst::c/u_norm;
33 
34  // Update positions over one time step
35 #if (AMREX_SPACEDIM >= 2)
36  x += ux * c_over_umod * dt;
37 #else
39 #endif
40 #if (defined WARPX_DIM_3D) || (defined WARPX_DIM_RZ) // RZ pushes particles in 3D
41  y += uy * c_over_umod * dt;
42 #else
44 #endif
45  z += uz * c_over_umod * dt;
46 }
47 
48 #endif // WARPX_PARTICLES_PUSHER_UPDATEPOSITION_H_
#define AMREX_INLINE
#define AMREX_GPU_HOST_DEVICE
AMREX_GPU_HOST_DEVICE AMREX_INLINE void UpdatePositionPhoton(amrex::ParticleReal &x, amrex::ParticleReal &y, amrex::ParticleReal &z, const amrex::ParticleReal ux, const amrex::ParticleReal uy, const amrex::ParticleReal uz, const amrex::Real dt)
Push the position of a photon particle over one timestep, given the value of its momenta ux,...
Definition: UpdatePositionPhoton.H:22
static constexpr auto c
vacuum speed of light [m/s]
Definition: constant.H:44
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE void ignore_unused(const Ts &...)
float dt
Definition: stencil.py:442