49 DragSolverMode drag_solver_config = NoDrag;
50 std::vector<f64> alphas;
51 bool enable_frictional_heating
59 inline bool is_dust_on() {
60 if (dust_riemann_config !=
NoDust) {
64 "Dust is on with ndust == 0");
77 inline bool is_gas_passive_scalar_on() {
return npscal_gas > 0; }
82 using Tscal = shambase::VecComponent<Tvec>;
83 GravityMode gravity_mode = NoGravity;
84 bool analytical_gravity =
false;
86 inline Tscal get_tolerance() {
return tol; }
87 inline bool is_gravity_on() {
return gravity_mode != NoGravity; }
93 template<
class Tvec,
class Tgr
idVec>
96 using Tscal = shambase::VecComponent<Tvec>;
103 using mode = std::variant<None, DensityBased>;
105 mode config =
None{};
106 void set_refine_none() { config = None{}; }
107 void set_refine_density_based(Tscal crit_mass) { config = DensityBased{crit_mass}; }
109 bool need_level_zero_compute() {
return false; }
110 bool need_amr_level_compute() {
return false; }
114 enum class GhostType { Periodic = 0, Reflective = 1, Outflow = 2 };
116 GhostType ghost_type_x = GhostType::Periodic;
117 GhostType ghost_type_y = GhostType::Periodic;
118 GhostType ghost_type_z = GhostType::Periodic;
120 GhostType get_x()
const {
return ghost_type_x; }
121 GhostType get_y()
const {
return ghost_type_y; }
122 GhostType get_z()
const {
return ghost_type_z; }
124 void set_x(GhostType ghost_type) { ghost_type_x = ghost_type; }
125 void set_y(GhostType ghost_type) { ghost_type_y = ghost_type; }
126 void set_z(GhostType ghost_type) { ghost_type_z = ghost_type; }
129 template<
class Tvec,
class Tgr
idVec>
138 using Tscal = shambase::VecComponent<Tvec>;
144template<
class Tvec,
class Tgr
idVec>
147 using Tscal = shambase::VecComponent<Tvec>;
149 Tscal eos_gamma = 5. / 3.;
151 Tscal grid_coord_to_pos_fact = 1;
153 static constexpr u32 NsideBlockPow = 1;
156 inline void set_eos_gamma(Tscal gamma) { eos_gamma = gamma; }
158 RiemannSolverMode riemann_config = HLL;
160 bool face_half_time_interpolation =
true;
162 inline bool should_compute_rho_mean() {
return is_gravity_on() && is_boundary_periodic(); }
171 inline bool is_dust_on() {
return dust_config.is_dust_on(); }
174 inline void set_alphas_static(
f32 alpha_values) {
176 drag_config.alphas.push_back(alpha_values);
191 inline bool is_gas_passive_scalar_on() {
return npscal_gas_config.is_gas_passive_scalar_on(); }
199 inline Tscal get_constant_G() {
208 inline bool is_boundary_periodic() {
return true; }
210 inline Tscal get_constant_4piG() {
211 auto scal_G = get_constant_G();
212 return 4 * M_PI * scal_G;
214 inline Tscal get_grav_tol() {
return gravity_config.get_tolerance(); }
215 inline bool is_gravity_on() {
return gravity_config.is_gravity_on(); }
216 inline bool is_coordinate_field_required() {
return gravity_config.analytical_gravity; }
230 std::optional<shamunits::UnitSystem<Tscal>>
unit_sys = {};
262 inline void check_config() {
263 if (grid_coord_to_pos_fact <= 0) {
265 "grid_coord_to_pos_fact must be > 0, got {}", grid_coord_to_pos_fact));
272 if (is_gravity_on()) {
274 u32 mode = gravity_config.gravity_mode;
278 "self gravity mode is not enabled but gravity mode is set to {} (> 0 whith 0 "
284 if (!(eos_gamma > 1.0)) {
286 shambase::format(
"Gamma must be > 1, currently Gamma = {}", eos_gamma));
289 if (is_gas_passive_scalar_on()) {
290 ON_RANK_0(logger::warn_ln(
"Ramses::SolverConfig",
"Passive scalars are experimental"));
293 "gas passive scalars mode is not enabled but gas passive scalars mode is set "
296 npscal_gas_config.npscal_gas));
300 void set_layout(shamrock::patch::PatchDataLayerLayout &pdl);
307 j = nlohmann::json{{
"time", p.time}, {
"dt", p.dt}};
313 j.at(
"time").get_to<Tscal>(p.time);
314 j.at(
"dt").get_to<Tscal>(p.dt);
323 template<
class Tvec,
class Tgr
idVec>
331 template<
class Tvec,
class Tgr
idVec>
utility to manipulate AMR blocks
float f32
Alias for float.
std::uint32_t u32
32 bit unsigned integer
Drag solver mode enum + json serialization/deserialization.
Dust Riemann solver mode enum + json serialization/deserialization.
Gravity mode enum + json serialization/deserialization.
Riemann solver mode enum + json serialization/deserialization.
Slope mode enum + json serialization/deserialization.
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.
ExcptTypes make_except_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Create an exception with a message and a location.
namespace for the basegodunov model
DustRiemannSolverMode
Dust Riemann solver mode enum.
@ NoDust
No dust, so no Riemann solver is used.
SlopeMode
Slope limiter modes.
void experimental_feature_check(const std::string &message, SourceLocation loc=SourceLocation{})
Check if experimental features are enabled, if not throw with the given message.
void warn_ln(std::string module_name, Types... var2)
Prints a log message with multiple arguments followed by a newline.
shambase::details::BasicStackEntry StackEntry
Alias for shambase::details::BasicStackEntry.
utility class to handle AMR blocks
alphas is the dust collision rate (the inverse of the stopping time)
Npscal_gas is the number of gas passive scalars.
SolverStatusVar< Tvec > SolverStatusVar
Alias to SolverStatusVar type.
Tscal get_time()
Get the current time.
AMRMode< Tvec, TgridVec > amr_mode
AMR refinement mode.
void set_next_dt(Tscal dt)
Set the time step for the next iteration.
std::optional< shamunits::UnitSystem< Tscal > > unit_sys
The unit system of the simulation.
Tscal get_dt()
Get the time step for the next iteration.
void set_time(Tscal t)
Set the current time.
void set_units(shamunits::UnitSystem< Tscal > new_sys)
Set the unit system of the simulation.
SolverStatusVar time_state
The time sate of the simulation.
Tscal dt
Current time step.
shambase::VecComponent< Tvec > Tscal
The type of the scalar used to represent the quantities.
constexpr T G()
get the value of G in the current unit system units
#define ON_RANK_0(x)
Macro to execute code only on rank 0.