diff options
author | 2019-03-12 14:03:56 -0700 | |
---|---|---|
committer | 2019-03-12 15:04:57 -0700 | |
commit | d767bc8b4ac6c374928f98b9807cd361df5291d9 (patch) | |
tree | 378cbf0943a88340e3791d2eeb59e609480c4ce2 /Source/Particles/PhysicalParticleContainer.cpp | |
parent | 8ad4446295dff06cac162a829af2e4725d7910fd (diff) | |
download | WarpX-d767bc8b4ac6c374928f98b9807cd361df5291d9.tar.gz WarpX-d767bc8b4ac6c374928f98b9807cd361df5291d9.tar.zst WarpX-d767bc8b4ac6c374928f98b9807cd361df5291d9.zip |
Implementation of axisymmetric solver, mode 0 only
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index b534de916..bd8a99359 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -257,6 +257,9 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) if (!part_realbox.ok()) part_realbox = geom.ProbDomain(); int num_ppc = plasma_injector->num_particles_per_cell; +#ifdef WARPX_RZ + Real rmax = std::min(plasma_injector->xmax, part_realbox.hi(0)); +#endif const Real* dx = geom.CellSize(); @@ -424,7 +427,21 @@ PhysicalParticleContainer::AddPlasmaCPU (int lev, RealBox part_realbox) dens = gamma_boost * dens * ( 1 - beta_boost*betaz_lab ); u[2] = gamma_boost * ( u[2] -beta_boost*c*gamma_lab ); } - attribs[PIdx::w ] = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac)); + Real weight = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac)); +#ifdef WARPX_RZ + if (plasma_injector->radially_weighted) { + weight *= 2*MathConst::pi*x; + } else { + // This is not correct since it might shift the particle + // out of the local grid + x = std::sqrt(x*rmax); + weight *= dx[0]; + } + Real theta = 2.*MathConst::pi*amrex::Random(); + y = x*std::sin(theta); + x = x*std::cos(theta); +#endif + attribs[PIdx::w ] = weight; attribs[PIdx::ux] = u[0]; attribs[PIdx::uy] = u[1]; attribs[PIdx::uz] = u[2]; @@ -466,6 +483,9 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) if (!part_realbox.ok()) part_realbox = geom.ProbDomain(); int num_ppc = plasma_injector->num_particles_per_cell; +#ifdef WARPX_RZ + Real rmax = std::min(plasma_injector->xmax, part_realbox.hi(0)); +#endif const Real* dx = geom.CellSize(); @@ -636,7 +656,22 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) dens = gamma_boost * dens * ( 1 - beta_boost*betaz_lab ); u[2] = gamma_boost * ( u[2] -beta_boost*c*gamma_lab ); } - attribs[PIdx::w ] = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac)); + Real weight = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac)); +#ifdef WARPX_RZ + Real r = x; + if (plasma_injector->radially_weighted) { + weight *= 2*MathConst::pi*r; + } else { + // This is not correct since it might shift the particle + // out of the local grid + x = std::sqrt(r*rmax); + weight *= dx[0]; + } + Real theta = 2.*MathConst::pi*amrex::Random(); + x = r*std::cos(theta); + y = r*std::sin(theta); +#endif + attribs[PIdx::w ] = weight; attribs[PIdx::ux] = u[0]; attribs[PIdx::uy] = u[1]; attribs[PIdx::uz] = u[2]; @@ -659,6 +694,10 @@ PhysicalParticleContainer::AddPlasmaGPU (int lev, RealBox part_realbox) p.pos(1) = y; p.pos(2) = z; #elif (AMREX_SPACEDIM == 2) +#ifdef WARPX_RZ + attribs[PIdx::theta] = theta; + x = r; +#endif p.pos(0) = x; p.pos(1) = z; #endif |