diff options
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 81 |
1 files changed, 54 insertions, 27 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index 43b46ec49..93a0ad7ea 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -41,16 +41,19 @@ NumParticlesToAdd(const Box& overlap_box, const RealBox& overlap_realbox, int ref_num_ppc = num_ppc * AMREX_D_TERM(fac, *fac, *fac); for (int i_part=0; i_part<ref_num_ppc;i_part++) { - std::array<Real, 3> r; - plasma_injector->getPositionUnitBox(r, i_part, fac); + std::array<Real, 3> point; + plasma_injector->getPositionUnitBox(point, i_part, fac); + Real x = overlap_corner[0] + (iv[0] + point[0])*dx[0]; #if ( AMREX_SPACEDIM == 3 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; - Real y = overlap_corner[1] + (iv[1] + r[1])*dx[1]; - Real z = overlap_corner[2] + (iv[2] + r[2])*dx[2]; + Real y = overlap_corner[1] + (iv[1] + point[1])*dx[1]; + Real z = overlap_corner[2] + (iv[2] + point[2])*dx[2]; #elif ( AMREX_SPACEDIM == 2 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; Real y = 0; - Real z = overlap_corner[1] + (iv[1] + r[1])*dx[1]; +#ifdef WARPX_RZ + Real z = overlap_corner[1] + (iv[1] + point[2])*dx[1]; +#else + Real z = overlap_corner[1] + (iv[1] + point[1])*dx[1]; +#endif #endif // If the new particle is not inside the tile box, // go to the next generated particle. @@ -448,16 +451,19 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) int ref_num_ppc = num_ppc * AMREX_D_TERM(fac, *fac, *fac); for (int i_part=0; i_part<ref_num_ppc;i_part++) { - std::array<Real, 3> r; - plasma_injector->getPositionUnitBox(r, i_part, fac); + std::array<Real, 3> point; + plasma_injector->getPositionUnitBox(point, i_part, fac); + Real x = overlap_corner[0] + (iv[0] + point[0])*dx[0]; #if ( AMREX_SPACEDIM == 3 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; - Real y = overlap_corner[1] + (iv[1] + r[1])*dx[1]; - Real z = overlap_corner[2] + (iv[2] + r[2])*dx[2]; + Real y = overlap_corner[1] + (iv[1] + point[1])*dx[1]; + Real z = overlap_corner[2] + (iv[2] + point[2])*dx[2]; #elif ( AMREX_SPACEDIM == 2 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; Real y = 0; - Real z = overlap_corner[1] + (iv[1] + r[1])*dx[1]; +#ifdef WARPX_RZ + Real z = overlap_corner[1] + (iv[1] + point[2])*dx[1]; +#else + Real z = overlap_corner[1] + (iv[1] + point[1])*dx[1]; +#endif #endif // If the new particle is not inside the tile box, // go to the next generated particle. @@ -473,11 +479,18 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) Real yb = y; #ifdef WARPX_RZ - // Replace the x and y, choosing the angle randomly. + // Replace the x and y, setting an angle theta. // These x and y are used to get the momentum and density - Real theta = 2.*MathConst::pi*amrex::Random(); - y = x*std::sin(theta); - x = x*std::cos(theta); + Real theta; + if (WarpX::nmodes == 1) { + // With only 1 mode, the angle doesn't matter so + // choose it randomly. + theta = 2.*MathConst::pi*amrex::Random(); + } else { + theta = 2.*MathConst::pi*point[1]; + } + x = xb*std::cos(theta); + y = xb*std::sin(theta); #endif Real dens; @@ -690,16 +703,19 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) int ref_num_ppc = num_ppc * AMREX_D_TERM(fac, *fac, *fac); for (int i_part=0; i_part<ref_num_ppc;i_part++) { - std::array<Real, 3> r; - plasma_injector->getPositionUnitBox(r, i_part, fac); + std::array<Real, 3> point; + plasma_injector->getPositionUnitBox(point, i_part, fac); + Real x = overlap_corner[0] + (iv[0] + point[0])*dx[0]; #if ( AMREX_SPACEDIM == 3 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; - Real y = overlap_corner[1] + (iv[1] + r[1])*dx[1]; - Real z = overlap_corner[2] + (iv[2] + r[2])*dx[2]; + Real y = overlap_corner[1] + (iv[1] + point[1])*dx[1]; + Real z = overlap_corner[2] + (iv[2] + point[2])*dx[2]; #elif ( AMREX_SPACEDIM == 2 ) - Real x = overlap_corner[0] + (iv[0] + r[0])*dx[0]; Real y = 0; - Real z = overlap_corner[1] + (iv[1] + r[1])*dx[1]; +#ifdef WARPX_RZ + Real z = overlap_corner[1] + (iv[1] + point[2])*dx[1]; +#else + Real z = overlap_corner[1] + (iv[1] + point[1])*dx[1]; +#endif #endif // If the new particle is not inside the tile box, // go to the next generated particle. @@ -715,9 +731,16 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) Real yb = y; #ifdef WARPX_RZ - // Replace the x and y, choosing the angle randomly. + // Replace the x and y, setting an angle theta. // These x and y are used to get the momentum and density - Real theta = 2.*MathConst::pi*amrex::Random(); + Real theta; + if (WarpX::nmodes == 1) { + // With only 1 mode, the angle doesn't matter so + // choose it randomly. + theta = 2.*MathConst::pi*amrex::Random(); + } else { + theta = 2.*MathConst::pi*point[1]; + } x = xb*std::cos(theta); y = xb*std::sin(theta); #endif @@ -1133,6 +1156,7 @@ PhysicalParticleContainer::FieldGather (int lev, BL_TO_FORTRAN_ANYD(bxfab), BL_TO_FORTRAN_ANYD(byfab), BL_TO_FORTRAN_ANYD(bzfab), + &WarpX::nmodes, &ll4symtry, &WarpX::l_lower_order_in_v, &WarpX::do_nodal, &lvect_fieldgathe, &WarpX::field_gathering_algo); @@ -1425,6 +1449,7 @@ PhysicalParticleContainer::Evolve (int lev, BL_TO_FORTRAN_ANYD(*bxfab), BL_TO_FORTRAN_ANYD(*byfab), BL_TO_FORTRAN_ANYD(*bzfab), + &WarpX::nmodes, &ll4symtry, &WarpX::l_lower_order_in_v, &WarpX::do_nodal, &lvect_fieldgathe, &WarpX::field_gathering_algo); @@ -1512,6 +1537,7 @@ PhysicalParticleContainer::Evolve (int lev, BL_TO_FORTRAN_ANYD(*cbxfab), BL_TO_FORTRAN_ANYD(*cbyfab), BL_TO_FORTRAN_ANYD(*cbzfab), + &WarpX::nmodes, &ll4symtry, &WarpX::l_lower_order_in_v, &WarpX::do_nodal, &lvect_fieldgathe, &WarpX::field_gathering_algo); } @@ -1853,6 +1879,7 @@ PhysicalParticleContainer::PushP (int lev, Real dt, BL_TO_FORTRAN_ANYD(bxfab), BL_TO_FORTRAN_ANYD(byfab), BL_TO_FORTRAN_ANYD(bzfab), + &WarpX::nmodes, &ll4symtry, &WarpX::l_lower_order_in_v, &WarpX::do_nodal, &lvect_fieldgathe, &WarpX::field_gathering_algo); |