aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Andrew Myers <atmyers2@gmail.com> 2022-03-03 11:04:04 -0800
committerGravatar GitHub <noreply@github.com> 2022-03-03 11:04:04 -0800
commit5d5c121c7681ac47595f5681eb014d8197d0217a (patch)
treed967900fa6f57a71944c6380ab57a1cb1ce4f4b1 /Source/Particles/PhysicalParticleContainer.cpp
parent59053225d7aeadf784ae3c4b3d43fb1aa7459c0d (diff)
downloadWarpX-5d5c121c7681ac47595f5681eb014d8197d0217a.tar.gz
WarpX-5d5c121c7681ac47595f5681eb014d8197d0217a.tar.zst
WarpX-5d5c121c7681ac47595f5681eb014d8197d0217a.zip
Fix bug in setting weight with refine_plasma option. (#2907)
* Fix bug in setting weight with refine_plasma option. * update benchmark for RefinedInjection test. * run with the right number of OMP and MPI * also use refine_plasma=1
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 71baee90e..161cac6a9 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -750,18 +750,6 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
const auto dx = geom.CellSizeArray();
const auto problo = geom.ProbLoArray();
- Real scale_fac = 0.0_rt;
-
- if(num_ppc != 0){
-#if defined(WARPX_DIM_3D)
- scale_fac = dx[0]*dx[1]*dx[2]/num_ppc;
-#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
- scale_fac = dx[0]*dx[1]/num_ppc;
-#elif defined(WARPX_DIM_1D_Z)
- scale_fac = dx[0]/num_ppc;
-#endif
- }
-
defineAllParticleTiles();
amrex::LayoutData<amrex::Real>* cost = WarpX::getCosts(lev);
@@ -1004,6 +992,18 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
Real theta_offset = 0._rt;
if (rz_random_theta) theta_offset = amrex::Random(engine) * 2._rt * MathConst::pi;
#endif
+
+ Real scale_fac = 0.0_rt;
+ if( pcounts[index] != 0) {
+#if defined(WARPX_DIM_3D)
+ scale_fac = dx[0]*dx[1]*dx[2]/pcounts[index];
+#elif defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
+ scale_fac = dx[0]*dx[1]/pcounts[index];
+#elif defined(WARPX_DIM_1D_Z)
+ scale_fac = dx[0]/pcounts[index];
+#endif
+ }
+
for (int i_part = 0; i_part < pcounts[index]; ++i_part)
{
long ip = poffset[index] + i_part;
@@ -1173,7 +1173,6 @@ PhysicalParticleContainer::AddPlasma (int lev, RealBox part_realbox)
u.y *= PhysConst::c;
u.z *= PhysConst::c;
- // Real weight = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac));
Real weight = dens * scale_fac;
#ifdef WARPX_DIM_RZ
if (radially_weighted) {
@@ -1606,8 +1605,7 @@ PhysicalParticleContainer::AddPlasmaFlux (amrex::Real dt)
}
#endif
- // Real weight = dens * scale_fac / (AMREX_D_TERM(fac, *fac, *fac));
- Real weight = dens * scale_fac * dt;
+ Real weight = dens * scale_fac * dt * num_ppc_real / pcounts[index];
#ifdef WARPX_DIM_RZ
// The particle weight is proportional to the user-specified
// flux (denoted as `dens` here) and the emission surface within