Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct staged integrators via arbitrary name #975

Merged
merged 5 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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 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
- [[PR 926]](https://github.com/parthenon-hpc-lab/parthenon/pull/926) Internal refinement op registration
Expand Down
19 changes: 17 additions & 2 deletions src/time_integration/butcher_integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 14 additions & 2 deletions src/time_integration/low_storage_integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/time_integration/staged_integrator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Real> delta;
std::vector<Real> beta;
Expand All @@ -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<std::vector<Real>> a;
Expand Down
Loading