aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/Resampling/Resampling.cpp
diff options
context:
space:
mode:
authorGravatar NeilZaim <49716072+NeilZaim@users.noreply.github.com> 2020-09-03 12:01:45 +0200
committerGravatar GitHub <noreply@github.com> 2020-09-03 12:01:45 +0200
commit46656318081e84c262f6f4b54f78d8e449c44df8 (patch)
treebe77de616e0ef4743cb8d9ae6a0005e23cb7284f /Source/Particles/Resampling/Resampling.cpp
parent004e96387d0cd45f2674d95151b79411ba5c1d0a (diff)
downloadWarpX-46656318081e84c262f6f4b54f78d8e449c44df8.tar.gz
WarpX-46656318081e84c262f6f4b54f78d8e449c44df8.tar.zst
WarpX-46656318081e84c262f6f4b54f78d8e449c44df8.zip
Add structure for resampling algorithms (#1265)
* First version of resampling structure * Remove new warnings * Added Doxygen comments * Minor modifications * Add do_resampling() in OneStep_sub1 * Apply suggestions from code review Co-authored-by: Luca Fedeli <luca.fedeli.88@gmail.com> * Use mutable in ResamplingTrigger and replace run with operator() * Apply suggestions from code review Co-authored-by: MaxThevenet <maxence.thevenet@desy.de> * Make LevelingThinning operator() final Co-authored-by: Luca Fedeli <luca.fedeli.88@gmail.com> Co-authored-by: MaxThevenet <maxence.thevenet@desy.de>
Diffstat (limited to 'Source/Particles/Resampling/Resampling.cpp')
-rw-r--r--Source/Particles/Resampling/Resampling.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/Source/Particles/Resampling/Resampling.cpp b/Source/Particles/Resampling/Resampling.cpp
new file mode 100644
index 000000000..a08145915
--- /dev/null
+++ b/Source/Particles/Resampling/Resampling.cpp
@@ -0,0 +1,32 @@
+/* Copyright 2019-2020 Neil Zaim
+ *
+ * This file is part of WarpX.
+ *
+ * License: BSD-3-Clause-LBNL
+ */
+#include "Resampling.H"
+#include "LevelingThinning.H"
+
+Resampling::Resampling ()
+{
+ amrex::ParmParse pp("resampling_algorithm");
+ std::string resampling_algorithm_string = "leveling_thinning"; // default resampling algorithm
+ pp.query("type", resampling_algorithm_string);
+
+ if (resampling_algorithm_string.compare("leveling_thinning") == 0)
+ {
+ m_resampling_algorithm = std::make_unique<LevelingThinning>();
+ }
+ else
+ { amrex::Abort("Unknown resampling algorithm."); }
+}
+
+bool Resampling::triggered (const int timestep, const amrex::Real global_numparts) const
+{
+ return m_resampling_trigger.triggered(timestep, global_numparts);
+}
+
+void Resampling::operator() (WarpXParIter& pti) const
+{
+ (*m_resampling_algorithm)(pti);
+}