aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Resampling/LevelingThinning.cpp
diff options
context:
space:
mode:
authorGravatar NeilZaim <49716072+NeilZaim@users.noreply.github.com> 2020-09-28 23:00:57 +0200
committerGravatar GitHub <noreply@github.com> 2020-09-28 14:00:57 -0700
commitcafd5549a21a6e49f3de4015d6634e69dec2c8da (patch)
tree51a5a9dc5ef20213d4de922d48ddcaebed087828 /Source/Particles/Resampling/LevelingThinning.cpp
parentfc22f938978589b41285aa6ab3948155bc0580ef (diff)
downloadWarpX-cafd5549a21a6e49f3de4015d6634e69dec2c8da.tar.gz
WarpX-cafd5549a21a6e49f3de4015d6634e69dec2c8da.tar.zst
WarpX-cafd5549a21a6e49f3de4015d6634e69dec2c8da.zip
Add option to only resample cells with high enough number of macroparticles (#1385)
* Add option to only resample cells with high enough number of macroparticles * Apply suggestions from code review Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja>
Diffstat (limited to 'Source/Particles/Resampling/LevelingThinning.cpp')
-rw-r--r--Source/Particles/Resampling/LevelingThinning.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/Source/Particles/Resampling/LevelingThinning.cpp b/Source/Particles/Resampling/LevelingThinning.cpp
index 1504a0f6b..ec1205fa8 100644
--- a/Source/Particles/Resampling/LevelingThinning.cpp
+++ b/Source/Particles/Resampling/LevelingThinning.cpp
@@ -22,6 +22,10 @@ LevelingThinning::LevelingThinning (const std::string species_name)
amrex::Warning("WARNING: target ratio for leveling thinning is smaller or equal to one."
" It is possible that no particle will be removed during resampling");
}
+
+ pp.query("resampling_algorithm_min_ppc", m_min_ppc);
+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE(m_min_ppc >= 1,
+ "Resampling min_ppc should be greater than or equal to 1");
}
void LevelingThinning::operator() (WarpXParIter& pti, const int lev,
@@ -47,6 +51,7 @@ void LevelingThinning::operator() (WarpXParIter& pti, const int lev,
const auto cell_offsets = bins.offsetsPtr();
const amrex::Real target_ratio = m_target_ratio;
+ const int min_ppc = m_min_ppc;
// Loop over cells
amrex::ParallelForRNG( n_cells,
@@ -58,8 +63,9 @@ void LevelingThinning::operator() (WarpXParIter& pti, const int lev,
const auto cell_stop = static_cast<int>(cell_offsets[i_cell+1]);
const int cell_numparts = cell_stop - cell_start;
- // do nothing for cells without particles
- if (cell_numparts == 0)
+ // do nothing for cells with less particles than min_ppc
+ // (this intentionally includes skipping empty cells, too)
+ if (cell_numparts < min_ppc)
return;
amrex::Real average_weight = 0._rt;