diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Particles/MultiParticleContainer.H | 2 | ||||
-rw-r--r-- | Source/Particles/MultiParticleContainer.cpp | 2 | ||||
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.H | 4 | ||||
-rw-r--r-- | Source/Particles/PhysicalParticleContainer.cpp | 7 | ||||
-rw-r--r-- | Source/Particles/Resampling/LevelingThinning.H | 10 | ||||
-rw-r--r-- | Source/Particles/Resampling/LevelingThinning.cpp | 6 | ||||
-rw-r--r-- | Source/Particles/Resampling/Resampling.H | 9 | ||||
-rw-r--r-- | Source/Particles/Resampling/Resampling.cpp | 10 | ||||
-rw-r--r-- | Source/Particles/Resampling/ResamplingTrigger.H | 7 | ||||
-rw-r--r-- | Source/Particles/Resampling/ResamplingTrigger.cpp | 8 | ||||
-rw-r--r-- | Source/Particles/WarpXParticleContainer.H | 2 |
11 files changed, 45 insertions, 22 deletions
diff --git a/Source/Particles/MultiParticleContainer.H b/Source/Particles/MultiParticleContainer.H index 6d11d53f9..73a8207bd 100644 --- a/Source/Particles/MultiParticleContainer.H +++ b/Source/Particles/MultiParticleContainer.H @@ -277,8 +277,6 @@ protected: std::vector<PCTypes> species_types; - Resampling m_resampler; - /** Whether to absorb particles exiting the domain */ ParticleBC m_boundary_conditions = ParticleBC::none; diff --git a/Source/Particles/MultiParticleContainer.cpp b/Source/Particles/MultiParticleContainer.cpp index a740330d7..9bcb19b2e 100644 --- a/Source/Particles/MultiParticleContainer.cpp +++ b/Source/Particles/MultiParticleContainer.cpp @@ -722,7 +722,7 @@ void MultiParticleContainer::doResampling (const int timestep) // do_resampling can only be true for PhysicalParticleContainers if (!pc->do_resampling){ continue; } - pc->resample(m_resampler, timestep); + pc->resample(timestep); } } diff --git a/Source/Particles/PhysicalParticleContainer.H b/Source/Particles/PhysicalParticleContainer.H index 30105ddcb..1e1307072 100644 --- a/Source/Particles/PhysicalParticleContainer.H +++ b/Source/Particles/PhysicalParticleContainer.H @@ -287,7 +287,7 @@ public: * @param[in] resampler the Resampling object used for resampling. * @param[in] timestep the current timestep. */ - void resample (const Resampling& resampler, const int timestep) override final; + void resample (const int timestep) override final; #ifdef WARPX_QED //Functions decleared in WarpXParticleContainer.H @@ -338,6 +338,8 @@ protected: bool boost_adjust_transverse_positions = false; bool do_backward_propagation = false; + Resampling m_resampler; + // Inject particles during the whole simulation void ContinuousInjection (const amrex::RealBox& injection_box) override; diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp index b71ff2920..0f0ac96f5 100644 --- a/Source/Particles/PhysicalParticleContainer.cpp +++ b/Source/Particles/PhysicalParticleContainer.cpp @@ -123,6 +123,7 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp pp.query("do_field_ionization", do_field_ionization); pp.query("do_resampling", do_resampling); + if (do_resampling) m_resampler = Resampling(species_name); //check if Radiation Reaction is enabled and do consistency checks pp.query("do_classical_radiation_reaction", do_classical_radiation_reaction); @@ -1996,18 +1997,18 @@ PhysicalParticleContainer::getIonizationFunc (const WarpXParIter& pti, ion_atomic_number); } -void PhysicalParticleContainer::resample (const Resampling& resampler, const int timestep) +void PhysicalParticleContainer::resample (const int timestep) { const amrex::Real global_numparts = TotalNumberOfParticles(); - if (resampler.triggered(timestep, global_numparts)) + if (m_resampler.triggered(timestep, global_numparts)) { amrex::Print() << "Resampling " << species_name << ".\n"; for (int lev = 0; lev <= maxLevel(); lev++) { for (WarpXParIter pti(*this, lev); pti.isValid(); ++pti) { - resampler(pti, lev, this); + m_resampler(pti, lev, this); } } } diff --git a/Source/Particles/Resampling/LevelingThinning.H b/Source/Particles/Resampling/LevelingThinning.H index 920fa07c9..14d0f8e6a 100644 --- a/Source/Particles/Resampling/LevelingThinning.H +++ b/Source/Particles/Resampling/LevelingThinning.H @@ -19,10 +19,18 @@ */ class LevelingThinning: public ResamplingAlgorithm { public: + + /** + * \brief Default constructor of the LevelingThinning class. + */ + LevelingThinning () = default; + /** * \brief Constructor of the LevelingThinning class + * + * @param[in] species_name the name of the resampled species */ - LevelingThinning (); + LevelingThinning (const std::string species_name); /** * \brief A method that performs leveling thinning for the considered species. diff --git a/Source/Particles/Resampling/LevelingThinning.cpp b/Source/Particles/Resampling/LevelingThinning.cpp index 0fc347241..7ac28932e 100644 --- a/Source/Particles/Resampling/LevelingThinning.cpp +++ b/Source/Particles/Resampling/LevelingThinning.cpp @@ -9,12 +9,12 @@ #include <AMReX_Particles.H> -LevelingThinning::LevelingThinning () +LevelingThinning::LevelingThinning (const std::string species_name) { using namespace amrex::literals; - amrex::ParmParse pp("resampling_algorithm"); - pp.query("target_ratio", m_target_ratio); + amrex::ParmParse pp(species_name); + pp.query("resampling_algorithm_target_ratio", m_target_ratio); AMREX_ALWAYS_ASSERT_WITH_MESSAGE( m_target_ratio > 0._rt, "Resampling target ratio should be strictly greater than 0"); if (m_target_ratio <= 1._rt) diff --git a/Source/Particles/Resampling/Resampling.H b/Source/Particles/Resampling/Resampling.H index de919bfcb..b381771f8 100644 --- a/Source/Particles/Resampling/Resampling.H +++ b/Source/Particles/Resampling/Resampling.H @@ -39,10 +39,17 @@ class Resampling public: /** + * \brief Default constructor of the Resampling class. + */ + Resampling () = default; + + /** * \brief Constructor of the Resampling class. Reads the chosen resampling algorithm from the * input file. + * + * @param[in] species_name the name of the resampled species */ - Resampling (); + Resampling (const std::string species_name); /** * \brief A method that returns true if resampling should be done for the considered species diff --git a/Source/Particles/Resampling/Resampling.cpp b/Source/Particles/Resampling/Resampling.cpp index 65332d191..b5c2d8b4f 100644 --- a/Source/Particles/Resampling/Resampling.cpp +++ b/Source/Particles/Resampling/Resampling.cpp @@ -7,18 +7,20 @@ #include "Resampling.H" #include "LevelingThinning.H" -Resampling::Resampling () +Resampling::Resampling (const std::string species_name) { - amrex::ParmParse pp("resampling_algorithm"); + amrex::ParmParse pp(species_name); std::string resampling_algorithm_string = "leveling_thinning"; // default resampling algorithm - pp.query("type", resampling_algorithm_string); + pp.query("resampling_algorithm", resampling_algorithm_string); if (resampling_algorithm_string.compare("leveling_thinning") == 0) { - m_resampling_algorithm = std::make_unique<LevelingThinning>(); + m_resampling_algorithm = std::make_unique<LevelingThinning>(species_name); } else { amrex::Abort("Unknown resampling algorithm."); } + + m_resampling_trigger = ResamplingTrigger(species_name); } bool Resampling::triggered (const int timestep, const amrex::Real global_numparts) const diff --git a/Source/Particles/Resampling/ResamplingTrigger.H b/Source/Particles/Resampling/ResamplingTrigger.H index 7e373289a..830b511f2 100644 --- a/Source/Particles/Resampling/ResamplingTrigger.H +++ b/Source/Particles/Resampling/ResamplingTrigger.H @@ -22,10 +22,15 @@ class ResamplingTrigger public: /** + * \brief Default constructor of the ResamplingTrigger class. + */ + ResamplingTrigger () = default; + + /** * \brief Constructor of the ResamplingTrigger class. Reads the resampling trigger parameters * from the input file. */ - ResamplingTrigger (); + ResamplingTrigger (const std::string species_name); /** * \brief A method that returns true if resampling should be done for the considered species diff --git a/Source/Particles/Resampling/ResamplingTrigger.cpp b/Source/Particles/Resampling/ResamplingTrigger.cpp index c89f01848..97407d51a 100644 --- a/Source/Particles/Resampling/ResamplingTrigger.cpp +++ b/Source/Particles/Resampling/ResamplingTrigger.cpp @@ -7,15 +7,15 @@ #include "ResamplingTrigger.H" #include "WarpX.H" -ResamplingTrigger::ResamplingTrigger () +ResamplingTrigger::ResamplingTrigger (const std::string species_name) { - amrex::ParmParse pprt("resampling_trigger"); + amrex::ParmParse pprt(species_name); std::vector<std::string> resampling_trigger_int_string_vec = {"0"}; - pprt.queryarr("intervals", resampling_trigger_int_string_vec); + pprt.queryarr("resampling_trigger_intervals", resampling_trigger_int_string_vec); m_resampling_intervals = IntervalsParser(resampling_trigger_int_string_vec); - pprt.query("max_avg_ppc", m_max_avg_ppc); + pprt.query("resampling_trigger_max_avg_ppc", m_max_avg_ppc); } bool ResamplingTrigger::triggered (const int timestep, const amrex::Real global_numparts) const diff --git a/Source/Particles/WarpXParticleContainer.H b/Source/Particles/WarpXParticleContainer.H index 8f1cab717..12dbd1289 100644 --- a/Source/Particles/WarpXParticleContainer.H +++ b/Source/Particles/WarpXParticleContainer.H @@ -343,7 +343,7 @@ public: * override the method for every derived class. Note that in practice this function is never * called because resample() is only called for PhysicalParticleContainers. */ - virtual void resample (const Resampling& /*resampler*/, const int /*timestep*/) {} + virtual void resample (const int /*timestep*/) {} protected: amrex::Array<amrex::Real,3> m_v_galilean = {{0}}; |