From 809decbc563eab07f05f0fbe478683390f514daa Mon Sep 17 00:00:00 2001 From: Patrick Mullen Date: Mon, 13 Nov 2023 15:28:24 -0700 Subject: [PATCH 1/3] Construct integrators via string name --- src/time_integration/butcher_integrator.cpp | 19 +++++++++++++++++-- .../low_storage_integrator.cpp | 16 ++++++++++++++-- src/time_integration/staged_integrator.hpp | 2 ++ 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/time_integration/butcher_integrator.cpp b/src/time_integration/butcher_integrator.cpp index d90de479ec68..40096dd1eeba 100644 --- a/src/time_integration/butcher_integrator.cpp +++ b/src/time_integration/butcher_integrator.cpp @@ -36,8 +36,12 @@ namespace parthenon { * alpha_k = c_k * c_k = b_k */ -ButcherIntegrator::ButcherIntegrator(ParameterInput *pin) - : StagedIntegrator(pin->GetOrAddString("parthenon/time", "integrator", "rk2")) { + +//---------------------------------------------------------------------------------------- +//! \class ButcherIntegrator::ButcherIntegrator(const std::string &name) +//! \brief Constructs a ButcherIntegrator instance given a string (e.g., rk2, rk3..) + +ButcherIntegrator::ButcherIntegrator(const std::string &name) : StagedIntegrator(name) { if (name_ == "rk1") { nstages = nbuffers = 1; Resize_(nstages); @@ -219,6 +223,17 @@ ButcherIntegrator::ButcherIntegrator(ParameterInput *pin) } } +//---------------------------------------------------------------------------------------- +//! \class ButcherIntegrator::ButcherIntegrator(ParameterInput *pin) +//! \brief Constructs a ButcherIntegrator instance given ParameterInput *pin + +ButcherIntegrator::ButcherIntegrator(ParameterInput *pin) + : ButcherIntegrator(pin->GetOrAddString("parthenon/time", "integrator", "rk2")) {} + +//---------------------------------------------------------------------------------------- +//! \fn void ButcherIntegrator::Resize_(int nstages) +//! \brief Resizes ButcherIntegrator registers given a supplied integer nstages + void ButcherIntegrator::Resize_(int nstages) { a.resize(nstages); for (int i = 0; i < a.size(); ++i) { diff --git a/src/time_integration/low_storage_integrator.cpp b/src/time_integration/low_storage_integrator.cpp index ab874d98e050..d833ddd8ad20 100644 --- a/src/time_integration/low_storage_integrator.cpp +++ b/src/time_integration/low_storage_integrator.cpp @@ -43,8 +43,13 @@ namespace parthenon { * Stone et al., ApJS (2020) 249:4 * See equations 11 through 15. */ -LowStorageIntegrator::LowStorageIntegrator(ParameterInput *pin) - : StagedIntegrator(pin->GetOrAddString("parthenon/time", "integrator", "rk2")) { + +//---------------------------------------------------------------------------------------- +//! \class LowStorageIntegrator::LowStorageIntegrator(const std::string &name) +//! \brief Constructs a LowStorageIntegrator instance given a string (e.g., rk2, rk3..) + +LowStorageIntegrator::LowStorageIntegrator(const std::string &name) + : StagedIntegrator(name) { if (name_ == "rk1") { nstages = 1; nbuffers = 1; @@ -155,4 +160,11 @@ LowStorageIntegrator::LowStorageIntegrator(ParameterInput *pin) MakePeriodicNames_(stage_name, nstages); } +//---------------------------------------------------------------------------------------- +//! \class LowStorageIntegrator::LowStorageIntegrator(ParameterInput *pin) +//! \brief Constructs a LowStorageIntegrator instance given ParameterInput *pin + +LowStorageIntegrator::LowStorageIntegrator(ParameterInput *pin) + : LowStorageIntegrator(pin->GetOrAddString("parthenon/time", "integrator", "rk2")) {} + } // namespace parthenon diff --git a/src/time_integration/staged_integrator.hpp b/src/time_integration/staged_integrator.hpp index 0d22d7d85600..329f69bc294b 100644 --- a/src/time_integration/staged_integrator.hpp +++ b/src/time_integration/staged_integrator.hpp @@ -49,6 +49,7 @@ class StagedIntegrator { class LowStorageIntegrator : public StagedIntegrator { public: LowStorageIntegrator() = default; + explicit LowStorageIntegrator(const std::string &name); explicit LowStorageIntegrator(ParameterInput *pin); std::vector delta; std::vector beta; @@ -60,6 +61,7 @@ class LowStorageIntegrator : public StagedIntegrator { class ButcherIntegrator : public StagedIntegrator { public: ButcherIntegrator() = default; + explicit ButcherIntegrator(const std::string &name); explicit ButcherIntegrator(ParameterInput *pin); // TODO(JMM): Should I do a flat array with indexing instead? std::vector> a; From 2f105da3426c90ccd3e9823fd4f8d8da61cafcda Mon Sep 17 00:00:00 2001 From: Patrick Mullen Date: Mon, 13 Nov 2023 16:14:13 -0700 Subject: [PATCH 2/3] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 051e8cc3fe66..915c804c52ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ - [[PR 868]](https://github.com/parthenon-hpc-lab/parthenon/pull/868) Add block-local face, edge, and nodal fields and allow for packing ### Changed (changing behavior/API/variables/...) +- [[PR 975]](https://github.com/parthenon-hpc-lab/parthenon/pull/975) Construct staged integrators via arbitrary name - [[PR 965]](https://github.com/parthenon-hpc-lab/parthenon/pull/965) Allow leading whitespace in input parameters - [[PR 926]](https://github.com/parthenon-hpc-lab/parthenon/pull/926) Internal refinement op registration - [[PR 897]](https://github.com/parthenon-hpc-lab/parthenon/pull/897) Deflate compression filter is not called any more if compression is soft disabled From 4eba4d3cdd7a1757847c8c6b4c897ea14a8a1dfb Mon Sep 17 00:00:00 2001 From: Patrick Mullen Date: Wed, 15 Nov 2023 09:07:31 -0700 Subject: [PATCH 3/3] Fix bad merge conflict resolution --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5483071f9b18..7a63de5567e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ - [[PR 868]](https://github.com/parthenon-hpc-lab/parthenon/pull/868) Add block-local face, edge, and nodal fields and allow for packing ### Changed (changing behavior/API/variables/...) -<<<<<<< HEAD - [[PR 975]](https://github.com/parthenon-hpc-lab/parthenon/pull/975) Construct staged integrators via arbitrary name - [[PR 976]](https://github.com/parthenon-hpc-lab/parthenon/pull/976) Move UserWorkBeforeLoop to be after first output - [[PR 965]](https://github.com/parthenon-hpc-lab/parthenon/pull/965) Allow leading whitespace in input parameters