30 template<
class Tvec,
class Tgr
idVec>
31 inline void SolverConfig<Tvec, TgridVec>::set_layout(
35 pdl.
add_field<Tscal>(
"rho", AMRBlock::block_size);
36 pdl.
add_field<Tvec>(
"rhovel", AMRBlock::block_size);
37 pdl.
add_field<Tscal>(
"rhoetot", AMRBlock::block_size);
40 u32 ndust = dust_config.ndust;
41 pdl.
add_field<Tscal>(
"rho_dust", (ndust * AMRBlock::block_size));
42 pdl.
add_field<Tvec>(
"rhovel_dust", (ndust * AMRBlock::block_size));
45 if (is_gravity_on()) {
46 pdl.
add_field<Tscal>(
"phi", AMRBlock::block_size);
49 if (is_gas_passive_scalar_on()) {
50 u32 npscal_gas = npscal_gas_config.npscal_gas;
51 pdl.
add_field<Tscal>(
"rho_gas_pscal", (npscal_gas * AMRBlock::block_size));
55 template<
class Tvec,
class Tgr
idVec>
60 {
"scheduler_config", p.scheduler_conf},
61 {
"courant_safety_factor", p.Csafe},
62 {
"dust_riemann_solver", p.dust_config.dust_riemann_config},
63 {
"eos_gamma", p.eos_gamma},
64 {
"face_half_time_interpolation", p.face_half_time_interpolation},
65 {
"gravity_solver", p.gravity_config.gravity_mode},
66 {
"grid_coord_to_pos_fact", p.grid_coord_to_pos_fact},
67 {
"hydro_riemann_solver", p.riemann_config},
68 {
"passive_scalar_mode", p.npscal_gas_config.npscal_gas},
69 {
"slope_limiter", p.slope_config},
70 {
"time_state", p.time_state},
71 {
"unit_sys", p.unit_sys}};
74 template<
class Tvec,
class Tgr
idVec>
78 if (j.contains(
"type_id")) {
80 std::string type_id = j.at(
"type_id").get<std::string>();
85 +
" but got " + type_id);
89 bool has_used_defaults =
false;
90 bool has_updated_config =
false;
92 auto _get_to_if_contains = [&](
const std::string &key,
auto &value) {
96 _get_to_if_contains(
"scheduler_config", p.scheduler_conf);
99 _get_to_if_contains(
"courant_safety_factor", p.Csafe);
100 _get_to_if_contains(
"dust_riemann_solver", p.dust_config.dust_riemann_config);
101 _get_to_if_contains(
"eos_gamma", p.eos_gamma);
102 _get_to_if_contains(
"face_half_time_interpolation", p.face_half_time_interpolation);
103 _get_to_if_contains(
"gravity_solver", p.gravity_config.gravity_mode);
104 _get_to_if_contains(
"grid_coord_to_pos_fact", p.grid_coord_to_pos_fact);
105 _get_to_if_contains(
"hydro_riemann_solver", p.riemann_config);
106 _get_to_if_contains(
"passive_scalar_mode", p.npscal_gas_config.npscal_gas);
107 _get_to_if_contains(
"slope_limiter", p.slope_config);
108 _get_to_if_contains(
"time_state", p.time_state);
109 _get_to_if_contains(
"unit_sys", p.unit_sys);
111 if (has_used_defaults || has_updated_config) {
114 "Ramses::SolverConfig",
120 template void to_json<f64_3, i64_3>(nlohmann::json &j,
const SolverConfig<f64_3, i64_3> &p);
121 template void from_json<f64_3, i64_3>(
const nlohmann::json &j, SolverConfig<f64_3, i64_3> &p);
std::uint32_t u32
32 bit unsigned integer
void add_field(const std::string &field_name, u32 nvar, SourceLocation loc=SourceLocation{})
add a field of type T to the layout
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.
i32 world_rank()
Gives the rank of the current process in the MPI communicator.
namespace for the basegodunov model
void to_json(nlohmann::json &j, const EOSConfig< Tvec > &p)
Serialize EOSConfig to json.
void from_json(const nlohmann::json &j, EOSConfig< Tvec > &p)
Deserializes an EOSConfig<Tvec> from a JSON object.
void get_to_if_contains(const nlohmann::json &j, const std::string &key, T &value, bool &has_used_defaults)
std::string log_json_changes(const nlohmann::json &j_current, const nlohmann::json &j, bool has_used_defaults, bool has_updated_config)
Shown the changes between two JSON objects to log config changes.