Skip to content

Commit

Permalink
Rename RadhydroSimulation class to QuokkaSimulation (#702)
Browse files Browse the repository at this point in the history
### Description

What's changed in the PR:
- Renamed `RadhydroSimulation` class to `QuokkaSimulation` in all
occurances inside src/.
- Renamed `RadhydroSimulation.cpp/.hpp` to `QuokkaSimulation.cpp/.hpp` 

Why? This is the main simulation class that does all of the physics,
including HD, gravity, radiation, MHD, etc. It should be given a more
general and inclusive name to avoid the confusion caused by the name
`RadhydroSimulation`. See #428

### Related issues

Addressed issue #428 

### Checklist
_Before this pull request can be reviewed, all of these tasks should be
completed. Denote completed tasks with an `x` inside the square brackets
`[ ]` in the Markdown source below:_
- [x] I have added a description (see above).
- [x] I have added a link to any related issues see (see above).
- [x] I have read the [Contributing
Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md).
- [ ] I have added tests for any new physics that this PR adds to the
code.
- [x] I have tested this PR on my local computer and all tests pass.
- [x] I have manually triggered the GPU tests with the magic comment
`/azp run`.
- [x] I have requested a reviewer for this PR.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
chongchonghe and pre-commit-ci[bot] authored Aug 5, 2024
1 parent 9e20d50 commit fe6215e
Show file tree
Hide file tree
Showing 70 changed files with 346 additions and 348 deletions.
1 change: 1 addition & 0 deletions src/QuokkaSimulation.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "QuokkaSimulation.hpp"
178 changes: 88 additions & 90 deletions src/RadhydroSimulation.hpp → src/QuokkaSimulation.hpp

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/RadhydroSimulation.cpp

This file was deleted.

8 changes: 4 additions & 4 deletions src/linear_advection/AdvectionSimulation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ template <typename problem_t> class AdvectionSimulation : public AMRSimulation<p
void computeMaxSignalLocal(int level) override;
auto computeExtraPhysicsTimestep(int level) -> amrex::Real override;
void preCalculateInitialConditions() override;
void setInitialConditionsOnGrid(quokka::grid grid_elem) override;
void setInitialConditionsOnGridFaceVars(quokka::grid grid_elem) override;
void setInitialConditionsOnGrid(quokka::grid const &grid_elem) override;
void setInitialConditionsOnGridFaceVars(quokka::grid const &grid_elem) override;
void createInitialParticles() override;
void advanceSingleTimestepAtLevel(int lev, amrex::Real time, amrex::Real dt_lev, int /*ncycle*/) override;
void computeBeforeTimestep() override;
Expand Down Expand Up @@ -137,13 +137,13 @@ template <typename problem_t> void AdvectionSimulation<problem_t>::preCalculateI
// user should implement using problem-specific template specialization
}

template <typename problem_t> void AdvectionSimulation<problem_t>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <typename problem_t> void AdvectionSimulation<problem_t>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// default empty implementation
// user should implement using problem-specific template specialization
}

template <typename problem_t> void AdvectionSimulation<problem_t>::setInitialConditionsOnGridFaceVars(quokka::grid grid_elem)
template <typename problem_t> void AdvectionSimulation<problem_t>::setInitialConditionsOnGridFaceVars(quokka::grid const &grid_elem)
{
// default empty implementation
// user should implement using problem-specific template specialization
Expand Down
2 changes: 1 addition & 1 deletion src/problems/Advection/test_advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ AMREX_GPU_DEVICE void ComputeExactSolution(int i, int j, int k, int n, amrex::Ar
exact_arr(i, j, k, n) = value;
}

template <> void AdvectionSimulation<SawtoothProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void AdvectionSimulation<SawtoothProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down
2 changes: 1 addition & 1 deletion src/problems/Advection2D/test_advection2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ AMREX_GPU_DEVICE AMREX_FORCE_INLINE auto exactSolutionAtIndex(int i, int j, amre
return rho;
}

template <> void AdvectionSimulation<SquareProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void AdvectionSimulation<SquareProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ AMREX_GPU_DEVICE void ComputeExactSolution(int i, int j, int k, int n, amrex::Ar
exact_arr(i, j, k, n) = dens;
}

template <> void AdvectionSimulation<SemiellipseProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void AdvectionSimulation<SemiellipseProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down
12 changes: 6 additions & 6 deletions src/problems/BinaryOrbitCIC/binary_orbit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#include "AMReX_REAL.H"
#include "AMReX_ccse-mpi.H"
#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "binary_orbit.hpp"
#include "hydro/hydro_system.hpp"
#include <algorithm>
Expand Down Expand Up @@ -56,7 +56,7 @@ template <> struct SimulationData<BinaryOrbit> {
std::vector<amrex::ParticleReal> dist{};
};

template <> void RadhydroSimulation<BinaryOrbit>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<BinaryOrbit>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
const amrex::Box &indexRange = grid_elem.indexRange_;
const amrex::Array4<double> &state_cc = grid_elem.array_;
Expand All @@ -72,15 +72,15 @@ template <> void RadhydroSimulation<BinaryOrbit>::setInitialConditionsOnGrid(quo
});
}

template <> void RadhydroSimulation<BinaryOrbit>::createInitialParticles()
template <> void QuokkaSimulation<BinaryOrbit>::createInitialParticles()
{
// read particles from ASCII file
const int nreal_extra = 4; // mass vx vy vz
CICParticles->SetVerbose(1);
CICParticles->InitFromAsciiFile("BinaryOrbit_particles.txt", nreal_extra, nullptr);
}

template <> void RadhydroSimulation<BinaryOrbit>::ComputeDerivedVar(int lev, std::string const &dname, amrex::MultiFab &mf, const int ncomp_cc_in) const
template <> void QuokkaSimulation<BinaryOrbit>::ComputeDerivedVar(int lev, std::string const &dname, amrex::MultiFab &mf, const int ncomp_cc_in) const
{
// compute derived variables and save in 'mf'
if (dname == "gpot") {
Expand All @@ -91,7 +91,7 @@ template <> void RadhydroSimulation<BinaryOrbit>::ComputeDerivedVar(int lev, std
}
}

template <> void RadhydroSimulation<BinaryOrbit>::computeAfterTimestep()
template <> void QuokkaSimulation<BinaryOrbit>::computeAfterTimestep()
{
// every N cycles, save particle statistics
static int cycle = 1;
Expand Down Expand Up @@ -167,7 +167,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<BinaryOrbit> sim(BCs_cc);
QuokkaSimulation<BinaryOrbit> sim(BCs_cc);
sim.doPoissonSolve_ = 1; // enable self-gravity
sim.initDt_ = 1.0e3; // s

Expand Down
8 changes: 4 additions & 4 deletions src/problems/Cooling/test_cooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "AMReX_GpuDevice.H"
#include "AMReX_TableData.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "radiation/radiation_system.hpp"

using amrex::Real;
Expand Down Expand Up @@ -53,7 +53,7 @@ const int kmin = 0;
const int kmax = 16;
Real const A = 0.05 / kmax;

template <> void RadhydroSimulation<CoolingTest>::preCalculateInitialConditions()
template <> void QuokkaSimulation<CoolingTest>::preCalculateInitialConditions()
{
// generate random phases
amrex::Array<int, 3> tlo{kmin, kmin, kmin}; // lower bounds
Expand Down Expand Up @@ -81,7 +81,7 @@ template <> void RadhydroSimulation<CoolingTest>::preCalculateInitialConditions(
amrex::Gpu::streamSynchronize();
}

template <> void RadhydroSimulation<CoolingTest>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<CoolingTest>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// set initial conditions
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down Expand Up @@ -195,7 +195,7 @@ auto problem_main() -> int
#endif
}

RadhydroSimulation<CoolingTest> sim(BCs_cc);
QuokkaSimulation<CoolingTest> sim(BCs_cc);

// Standard PPM gives unphysically enormous temperatures when used for
// this problem (e.g., ~1e14 K or higher), but can be fixed by
Expand Down
10 changes: 5 additions & 5 deletions src/problems/FCQuantities/test_fc_quantities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "AMReX_Print.H"
#include "AMReX_REAL.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "grid.hpp"
#include "physics_info.hpp"
#include "test_fc_quantities.hpp"
Expand Down Expand Up @@ -71,7 +71,7 @@ AMREX_GPU_DEVICE void computeWaveSolution(int i, int j, int k, amrex::Array4<amr
state(i, j, k, HydroSystem<FCQuantities>::internalEnergy_index) = Eint;
}

template <> void RadhydroSimulation<FCQuantities>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<FCQuantities>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract grid information
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand All @@ -89,7 +89,7 @@ template <> void RadhydroSimulation<FCQuantities>::setInitialConditionsOnGrid(qu
});
}

template <> void RadhydroSimulation<FCQuantities>::setInitialConditionsOnGridFaceVars(quokka::grid grid_elem)
template <> void QuokkaSimulation<FCQuantities>::setInitialConditionsOnGridFaceVars(quokka::grid const &grid_elem)
{
// extract grid information
const amrex::Array4<double> &state = grid_elem.array_;
Expand Down Expand Up @@ -155,12 +155,12 @@ auto problem_main() -> int
}
}

RadhydroSimulation<FCQuantities> sim_write(BCs_cc, BCs_fc);
QuokkaSimulation<FCQuantities> sim_write(BCs_cc, BCs_fc);
sim_write.setInitialConditions();
amrex::Vector<amrex::Array<amrex::MultiFab, AMREX_SPACEDIM>> const &state_new_fc_write = sim_write.getNewMF_fc();
amrex::Print() << "\n";

RadhydroSimulation<FCQuantities> sim_restart(BCs_cc, BCs_fc);
QuokkaSimulation<FCQuantities> sim_restart(BCs_cc, BCs_fc);
sim_restart.setChkFile("chk00000");
sim_restart.setInitialConditions();
amrex::Vector<amrex::Array<amrex::MultiFab, AMREX_SPACEDIM>> const &state_new_fc_restart = sim_restart.getNewMF_fc();
Expand Down
10 changes: 5 additions & 5 deletions src/problems/HydroBlast2D/test_hydro2d_blast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "AMReX_REAL.H"
#include "AMReX_TagBox.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "hydro/hydro_system.hpp"
#include "test_hydro2d_blast.hpp"

Expand All @@ -42,7 +42,7 @@ template <> struct Physics_Traits<BlastProblem> {
static constexpr int nGroups = 1; // number of radiation groups
};

template <> void RadhydroSimulation<BlastProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<BlastProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down Expand Up @@ -94,7 +94,7 @@ template <> void RadhydroSimulation<BlastProblem>::setInitialConditionsOnGrid(qu
});
}

template <> void RadhydroSimulation<BlastProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
template <> void QuokkaSimulation<BlastProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
{
// tag cells for refinement

Expand Down Expand Up @@ -143,7 +143,7 @@ auto problem_main() -> int
return false;
};

const int ncomp_cc = RadhydroSimulation<BlastProblem>::nvarTotal_cc_;
const int ncomp_cc = QuokkaSimulation<BlastProblem>::nvarTotal_cc_;
amrex::Vector<amrex::BCRec> BCs_cc(ncomp_cc);
for (int n = 0; n < ncomp_cc; ++n) {
for (int i = 0; i < AMREX_SPACEDIM; ++i) {
Expand All @@ -164,7 +164,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<BlastProblem> sim(BCs_cc);
QuokkaSimulation<BlastProblem> sim(BCs_cc);

sim.stopTime_ = 0.1; // 1.5;
sim.cflNumber_ = 0.3;
Expand Down
12 changes: 6 additions & 6 deletions src/problems/HydroBlast3D/test_hydro3d_blast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "AMReX_Print.H"
#include "AMReX_SPACE.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "hydro/hydro_system.hpp"
#include "radiation/radiation_system.hpp"

Expand Down Expand Up @@ -52,14 +52,14 @@ template <> struct Physics_Traits<SedovProblem> {
const double rho = 1.0; // g cm^-3
double E_blast = 0.851072; // ergs

template <> void RadhydroSimulation<SedovProblem>::preCalculateInitialConditions()
template <> void QuokkaSimulation<SedovProblem>::preCalculateInitialConditions()
{
if constexpr (!simulate_full_box) {
E_blast /= 8.0; // only one octant, so 1/8 of the total energy
}
}

template <> void RadhydroSimulation<SedovProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<SedovProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// initialize a Sedov test problem using parameters from
// Richard Klein and J. Bolstad
Expand Down Expand Up @@ -115,7 +115,7 @@ template <> void RadhydroSimulation<SedovProblem>::setInitialConditionsOnGrid(qu
});
}

template <> void RadhydroSimulation<SedovProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
template <> void QuokkaSimulation<SedovProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
{
// tag cells for refinement

Expand Down Expand Up @@ -150,7 +150,7 @@ template <> void RadhydroSimulation<SedovProblem>::ErrorEst(int lev, amrex::TagB
}
}

template <> void RadhydroSimulation<SedovProblem>::computeAfterEvolve(amrex::Vector<amrex::Real> &initSumCons)
template <> void QuokkaSimulation<SedovProblem>::computeAfterEvolve(amrex::Vector<amrex::Real> &initSumCons)
{
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> const &dx0 = geom[0].CellSizeArray();
amrex::Real const vol = AMREX_D_TERM(dx0[0], *dx0[1], *dx0[2]);
Expand Down Expand Up @@ -254,7 +254,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<SedovProblem> sim(BCs_cc);
QuokkaSimulation<SedovProblem> sim(BCs_cc);

sim.reconstructionOrder_ = 3; // 2=PLM, 3=PPM
sim.stopTime_ = 1.0; // seconds
Expand Down
10 changes: 5 additions & 5 deletions src/problems/HydroContact/test_hydro_contact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "AMReX_MultiFab.H"
#include "AMReX_ParmParse.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "hydro/hydro_system.hpp"
#include "radiation/radiation_system.hpp"
#include "test_hydro_contact.hpp"
Expand Down Expand Up @@ -40,7 +40,7 @@ template <> struct Physics_Traits<ContactProblem> {

constexpr double v_contact = 0.0; // contact wave velocity

template <> void RadhydroSimulation<ContactProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<ContactProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down Expand Up @@ -83,8 +83,8 @@ template <> void RadhydroSimulation<ContactProblem>::setInitialConditionsOnGrid(
}

template <>
void RadhydroSimulation<ContactProblem>::computeReferenceSolution(amrex::MultiFab &ref, amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> const &dx,
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> const &prob_lo)
void QuokkaSimulation<ContactProblem>::computeReferenceSolution(amrex::MultiFab &ref, amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> const &dx,
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> const &prob_lo)
{
for (amrex::MFIter iter(ref); iter.isValid(); ++iter) {
const amrex::Box &indexRange = iter.validbox();
Expand Down Expand Up @@ -195,7 +195,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<ContactProblem> sim(BCs_cc);
QuokkaSimulation<ContactProblem> sim(BCs_cc);

sim.stopTime_ = 2.0;
sim.cflNumber_ = 0.8;
Expand Down
10 changes: 5 additions & 5 deletions src/problems/HydroHighMach/test_hydro_highmach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "AMReX_MultiFab.H"
#include "AMReX_ParmParse.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "hydro/hydro_system.hpp"
#include "util/fextract.hpp"
#ifdef HAVE_PYTHON
Expand Down Expand Up @@ -45,7 +45,7 @@ template <> struct Physics_Traits<HighMachProblem> {
static constexpr int nGroups = 1; // number of radiation groups
};

template <> void RadhydroSimulation<HighMachProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<HighMachProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down Expand Up @@ -81,8 +81,8 @@ template <> void RadhydroSimulation<HighMachProblem>::setInitialConditionsOnGrid
}

template <>
void RadhydroSimulation<HighMachProblem>::computeReferenceSolution(amrex::MultiFab &ref, amrex::GpuArray<Real, AMREX_SPACEDIM> const &dx,
amrex::GpuArray<Real, AMREX_SPACEDIM> const &prob_lo)
void QuokkaSimulation<HighMachProblem>::computeReferenceSolution(amrex::MultiFab &ref, amrex::GpuArray<Real, AMREX_SPACEDIM> const &dx,
amrex::GpuArray<Real, AMREX_SPACEDIM> const &prob_lo)
{

// extract solution
Expand Down Expand Up @@ -258,7 +258,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<HighMachProblem> sim(BCs_cc);
QuokkaSimulation<HighMachProblem> sim(BCs_cc);

sim.computeReferenceSolution_ = true;

Expand Down
8 changes: 4 additions & 4 deletions src/problems/HydroKelvinHelmholz/test_hydro2d_kh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "AMReX_ParmParse.H"
#include "AMReX_Print.H"

#include "RadhydroSimulation.hpp"
#include "QuokkaSimulation.hpp"
#include "hydro/hydro_system.hpp"
#include "test_hydro2d_kh.hpp"

Expand Down Expand Up @@ -43,7 +43,7 @@ template <> struct Physics_Traits<KelvinHelmholzProblem> {
static constexpr int nGroups = 1; // number of radiation groups
};

template <> void RadhydroSimulation<KelvinHelmholzProblem>::setInitialConditionsOnGrid(quokka::grid grid_elem)
template <> void QuokkaSimulation<KelvinHelmholzProblem>::setInitialConditionsOnGrid(quokka::grid const &grid_elem)
{
// extract variables required from the geom object
amrex::GpuArray<amrex::Real, AMREX_SPACEDIM> dx = grid_elem.dx_;
Expand Down Expand Up @@ -87,7 +87,7 @@ template <> void RadhydroSimulation<KelvinHelmholzProblem>::setInitialConditions
});
}

template <> void RadhydroSimulation<KelvinHelmholzProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
template <> void QuokkaSimulation<KelvinHelmholzProblem>::ErrorEst(int lev, amrex::TagBoxArray &tags, amrex::Real /*time*/, int /*ngrow*/)
{
// tag cells for refinement

Expand Down Expand Up @@ -132,7 +132,7 @@ auto problem_main() -> int
}

// Problem initialization
RadhydroSimulation<KelvinHelmholzProblem> sim(BCs_cc);
QuokkaSimulation<KelvinHelmholzProblem> sim(BCs_cc);

sim.stopTime_ = 1.5;
sim.cflNumber_ = 0.4;
Expand Down
Loading

0 comments on commit fe6215e

Please sign in to comment.