23#include <nlohmann/json.hpp>
35 using Tscal = shambase::VecComponent<Tvec>;
52 Tscal gamma0 = 5. / 3.;
59 using Variant = std::variant<None, InstantBarotropic>;
61 Variant config =
None{};
63 inline void set_none() { config = None{}; }
64 inline void set_instant_barotropic(Tscal rho0, Tscal cs0, Tscal gamma0) {
65 config = InstantBarotropic{rho0, cs0, gamma0};
68 inline bool is_cooling_on()
const {
return !std::holds_alternative<None>(config); }
73 if (!(cfg->rho0 > 0.0) || !(cfg->cs0 > 0.0)) {
75 "InstantBarotropic cooling: rho0 and cs0 must be > 0, currently rho0 = "
85 inline void to_json(nlohmann::json &j,
const CoolingConfig<Tvec> &p) {
86 using Cooling = CoolingConfig<Tvec>;
90 [&](
const typename Cooling::None &) {
91 j = {{
"type",
"none"}};
93 [&](
const typename Cooling::InstantBarotropic &cfg) {
95 = {{
"type",
"instant_barotropic"},
98 {
"gamma0", cfg.gamma0}};
106 using Tscal = shambase::VecComponent<Tvec>;
108 const std::string type = j.at(
"type").get<std::string>();
109 if (type ==
"none") {
111 }
else if (type ==
"instant_barotropic") {
112 p.set_instant_barotropic(
113 j.at(
"rho0").get<Tscal>(), j.at(
"cs0").get<Tscal>(), j.at(
"gamma0").get<Tscal>());
FluidStateSpec implementation for a barotropic equation of state that is isothermal below a threshold...
This header file contains utility functions related to exception handling in the code.
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
namespace for the basegodunov model
Gas and dust conservative/primitive states and axis-transform helpers shared by every gas and dust Ri...
Build an overload set out of several callables, for use with std::visit.
Instantaneous cooling onto a barotrope (RAMSES-like).
Cooling of the gas, applied on top of the (adiabatic) equation of state.
void check_config() const
Throws std::invalid_argument if the parameters of the cooling are invalid.