32#include <pybind11/functional.h>
33#include <pybind11/numpy.h>
40 void warn_deprecated_riemann_setter(
const char *old_name,
const char *mode) {
42 shamcomm::logs::warn_ln(
45 ".{}() is deprecated and will be removed at some point, replace it by:\n"
46 " from shamrock.model_ramses import {}\n"
47 " cfg.set_riemann_solver({})",
54 template<
class Tvec,
class Tgr
idVec>
55 void add_instance(py::module &m, std::string name_config, std::string name_model) {
57 using Tscal = shambase::VecComponent<Tvec>;
58 using Tgridscal = shambase::VecComponent<TgridVec>;
61 using TConfig =
typename T::Solver::Config;
62 using TAnalysisSodTube = shammodels::basegodunov::modules::AnalysisSodTube<Tvec, TgridVec>;
65 shamlog_debug_ln(
"[Py]",
"registering class :", name_config,
typeid(T).name());
66 shamlog_debug_ln(
"[Py]",
"registering class :", name_model,
typeid(T).name());
68 py::class_<TConfig> config_cls(m, name_config.c_str());
70 shammodels::common::add_json_defs<TConfig>(config_cls);
75 [](TConfig &self, Tscal scale_factor) {
76 self.grid_coord_to_pos_fact = scale_factor;
80 [](TConfig &self, Tscal Csafe) {
85 [](TConfig &self, Tscal eos_gamma) {
86 self.set_eos_gamma(eos_gamma);
90 [](TConfig &self, Tscal gamma) {
91 self.eos_config.set_adiabatic(gamma);
95 [](TConfig &self, Tscal rho_crit, Tscal cs0, Tscal gamma) {
96 self.eos_config.set_barotropic(rho_crit, cs0, gamma);
103 "set_eos_reset_barotropic",
104 [](TConfig & , py::args , py::kwargs ) {
105 const std::string msg
106 =
".set_eos_reset_barotropic(rho_crit, cs0, gamma_baro, gamma) has been "
107 "removed, as the reset onto the barotrope is an instantaneous cooling "
108 "and not an equation of state. Replace it by:\n"
109 " from shamrock.model_ramses import InstantBarotropic\n"
110 " cfg.set_eos_adiabatic(gamma)\n"
111 " cfg.set_cooling_mode(InstantBarotropic(rho0=rho_crit, "
112 "gamma0=gamma_baro, cs0=cs0))";
113 ON_RANK_0(shamcomm::logs::err_ln(
"Ramses", msg));
117 Removed, raises an error.
119 The reset of the internal energy onto a barotrope is now a cooling mode, replace
120 ``cfg.set_eos_reset_barotropic(rho_crit=..., cs0=..., gamma_baro=..., gamma=...)`` by
121 ``cfg.set_eos_adiabatic(gamma)`` and
122 ``cfg.set_cooling_mode(InstantBarotropic(rho0=rho_crit, gamma0=gamma_baro, cs0=cs0))``.
126 [](TConfig &self,
const typename TCooling::None &) {
127 self.cooling_config.set_none();
131 Disable the cooling (the default).
135 >>> from shamrock.model_ramses import NoCooling
136 >>> cfg.set_cooling_mode(NoCooling())
140 [](TConfig &self,
const typename TCooling::InstantBarotropic &mode) {
141 self.cooling_config.config = mode;
145 Set the instantaneous barotropic cooling (RAMSES-like).
147 At the end of each timestep, before the CFL condition, the internal energy of every cell is
148 overwritten by :math:`P_{\rm baro}(\rho) / (\gamma - 1)`, with :math:`\gamma` the
149 adiabatic index of the equation of state (``cfg.set_eos_adiabatic``) and
150 :math:`P_{\rm baro}(\rho) = c_{s,0}^2 \rho (1 + (\rho / \rho_0)^{\gamma_0 - 1})`
151 (isothermal below ``rho0``, adiabatic with index ``gamma0`` above).
155 >>> from shamrock.model_ramses import InstantBarotropic
156 >>> cfg.set_cooling_mode(InstantBarotropic(rho0=1e-13, gamma0=1.4, cs0=0.2))
159 "set_riemann_solver",
161 self.set_riemann_solver(mode);
165 Set the gas Riemann solver.
169 mode : RiemannSolverMode
170 One of ``Rusanov``, ``HLL`` (the default), ``HLLC_PVRS``, ``HLLC_Davis`` or
172 :py:class:`RiemannSolverMode`.
176 >>> from shamrock.model_ramses import HLLC_PVRS
177 >>> cfg.set_riemann_solver(HLLC_PVRS)
181 >>> from shamrock.model_ramses import RiemannSolverMode
182 >>> cfg.set_riemann_solver(RiemannSolverMode.HLLC_PVRS)
185 "set_riemann_solver_hll",
187 warn_deprecated_riemann_setter(
"set_riemann_solver_hll",
"HLL");
188 self.set_riemann_solver(HLL);
191 Set the HLL Riemann solver.
194 Use ``cfg.set_riemann_solver(HLL)`` instead (see :py:meth:`set_riemann_solver`).
197 "set_riemann_solver_hllc_pvrs",
199 warn_deprecated_riemann_setter(
"set_riemann_solver_hllc_pvrs",
"HLLC_PVRS");
200 self.set_riemann_solver(HLLC_PVRS);
203 Set the HLLC_PVRS Riemann solver.
206 Use ``cfg.set_riemann_solver(HLLC_PVRS)`` instead (see :py:meth:`set_riemann_solver`).
209 "set_riemann_solver_hllc",
211 const std::string msg
212 =
".set_riemann_solver_hllc() has been removed, as several HLLC variants "
213 "are now available. Select one explicitly:\n"
214 " -> .set_riemann_solver(HLLC_PVRS) : the previous behaviour of "
215 ".set_riemann_solver_hllc()\n"
216 " -> .set_riemann_solver(HLLC_Davis)\n"
217 "with `from shamrock.model_ramses import HLLC_PVRS, HLLC_Davis`";
218 ON_RANK_0(shamcomm::logs::err_ln(
"Ramses", msg));
222 Removed, raises an error.
224 It was replaced by ``cfg.set_riemann_solver(HLLC_PVRS)`` (same solver as before) to lift the
225 ambiguity on the HLLC variant; see also ``cfg.set_riemann_solver(HLLC_Davis)`` and
226 :py:meth:`set_riemann_solver`.
229 "set_riemann_solver_hllc_davis",
231 warn_deprecated_riemann_setter(
"set_riemann_solver_hllc_davis",
"HLLC_Davis");
232 self.set_riemann_solver(HLLC_Davis);
235 Set the HLLC_Davis Riemann solver.
238 Use ``cfg.set_riemann_solver(HLLC_Davis)`` instead (see :py:meth:`set_riemann_solver`).
241 "set_riemann_solver_rusanov",
243 warn_deprecated_riemann_setter(
"set_riemann_solver_rusanov",
"Rusanov");
244 self.set_riemann_solver(Rusanov);
247 Set the Rusanov Riemann solver.
250 Use ``cfg.set_riemann_solver(Rusanov)`` instead (see :py:meth:`set_riemann_solver`).
253 "set_slope_lim_none",
255 self.slope_config = None;
258 "set_slope_lim_vanleer_f",
260 self.slope_config = VanLeer_f;
263 "set_slope_lim_vanleer_std",
265 self.slope_config = VanLeer_std;
268 "set_slope_lim_vanleer_sym",
270 self.slope_config = VanLeer_sym;
273 "set_slope_lim_minmod",
275 self.slope_config = Minmod;
278 "set_scheduler_config",
279 [](TConfig &self,
u64 split_crit,
u64 merge_crit) {
280 self.scheduler_conf.split_load_value = split_crit;
281 self.scheduler_conf.merge_load_value = merge_crit;
284 py::arg(
"split_load_value"),
285 py::arg(
"merge_load_value"))
287 "set_face_time_interpolation",
288 [](TConfig &self,
bool face_time_interpolate) {
289 self.face_half_time_interpolation = face_time_interpolate;
292 "set_boundary_condition",
293 [](TConfig &self,
const std::string &axis,
const std::string &bc_type) {
294 BCConfig::GhostType ghost_type;
295 if (bc_type ==
"periodic") {
296 ghost_type = BCConfig::GhostType::Periodic;
297 }
else if (bc_type ==
"reflective") {
298 ghost_type = BCConfig::GhostType::Reflective;
299 }
else if (bc_type ==
"outflow") {
300 ghost_type = BCConfig::GhostType::Outflow;
302 throw std::invalid_argument(
303 "Unsupported boundary condition type: " + bc_type);
307 self.bc_config.set_x(ghost_type);
308 }
else if (axis ==
"y") {
309 self.bc_config.set_y(ghost_type);
310 }
else if (axis ==
"z") {
311 self.bc_config.set_z(ghost_type);
313 throw std::invalid_argument(
"Unsupported axis: " + axis);
319 "set_dust_mode_dhll",
320 [](TConfig &self,
u32 ndust) {
321 self.dust_config = {
DHLL, ndust};
325 [](TConfig &self,
u32 ndust) {
326 self.dust_config = {
HB, ndust};
329 "set_dust_mode_none",
331 self.dust_config = {
NoDust, 0};
335 [](TConfig &self,
f32 alpha_values) {
336 return self.set_alphas_static(alpha_values);
339 "set_drag_mode_no_drag",
341 self.drag_config.drag_solver_config = NoDrag;
342 self.drag_config.enable_frictional_heating =
false;
345 "set_drag_mode_irk1",
346 [](TConfig &self,
bool frictional_status) {
347 self.drag_config.drag_solver_config = IRK1;
348 self.drag_config.enable_frictional_heating = frictional_status;
351 "set_drag_mode_irk2",
352 [](TConfig &self,
bool frictional_status) {
353 self.drag_config.drag_solver_config = IRK2;
354 self.drag_config.enable_frictional_heating = frictional_status;
357 "set_drag_mode_expo",
358 [](TConfig &self,
bool frictional_status) {
359 self.drag_config.drag_solver_config = EXPO;
360 self.drag_config.enable_frictional_heating = frictional_status;
365 self.amr_mode.set_refine_none();
368 "set_amr_mode_density_based",
369 [](TConfig &self, Tscal crit_mass) {
370 self.amr_mode.set_refine_density_based(crit_mass);
373 py::arg(
"crit_mass"))
375 "set_amr_mode_pseudo_gradient_based",
376 [](TConfig &self, Tscal error_min, Tscal error_max) {
377 self.amr_mode.set_refine_pseudo_gradient_based(error_min, error_max);
380 py::arg(
"error_min"),
381 py::arg(
"error_max"))
383 "set_amr_mode_jeans_length_based",
384 [](TConfig &self,
u32 N_jeans) {
385 self.amr_mode.set_refine_jeans_length_based(N_jeans);
390 Refine the blocks where the Jeans length is resolved by less than ``N_jeans`` cells.
392 A block is refined if one of its cells has :math:`N_J \Delta x > \lambda_J =
393 \sqrt{\pi c_s^2 / (G \rho)}`, with the sound speed of the equation of state (of the
394 barotrope with the ``InstantBarotropic`` cooling mode) and the gravitational constant of the unit
395 system (``cfg.set_units``). It is derefined if the cells twice larger would still resolve the
396 Jeans length by more than :math:`\sqrt{2} N_J` cells.
398 Only implemented in the new AMR (``cfg.set_amr_mode_old(False)``).
401 "set_amr_mode_shear_based",
402 [](TConfig &self, Tscal threshold) {
403 self.amr_mode.set_refine_shear_based(threshold);
406 py::arg(
"Threshold"))
409 [](TConfig &self,
bool use_old_amr) {
410 self.amr_mode.old_amr = use_old_amr;
413 "set_first_order_interpolation_mode",
415 self.amr_interp_mode = FIRST_ORDER;
418 "set_second_order_interpolation_mode",
420 self.amr_interp_mode = SECOND_ORDER;
423 "set_gravity_mode_no_gravity",
425 self.gravity_config.gravity_mode = NoGravity;
428 "set_gravity_mode_cg",
430 self.gravity_config.gravity_mode = CG;
433 Enable self-gravity, with the Jacobi preconditioned conjugate gradient Poisson solver.
435 Self-gravity is applied as an external force and requires the trapezoidal coupling
436 (``cfg.set_ext_force_coupling(ExtForceCoupling.Trapezoidal)``). The gravitational constant
437 is the one of the unit system (``cfg.set_units``).
440 "set_gravity_mode_pcg",
442 self.gravity_config.gravity_mode = PCG;
445 "set_gravity_mode_bicgstab",
447 self.gravity_config.gravity_mode = BICGSTAB;
450 Enable self-gravity, with the BiCGSTAB Poisson solver.
452 Self-gravity is applied as an external force and requires the trapezoidal coupling
453 (``cfg.set_ext_force_coupling(ExtForceCoupling.Trapezoidal)``). The gravitational constant
454 is the one of the unit system (``cfg.set_units``).
461 Set the unit system of the simulation (SI if not set).
463 It sets the gravitational constant used by self-gravity.
466 "set_self_gravity_Niter_max",
467 [](TConfig &self,
u32 Niter) {
468 self.gravity_config.Niter_max = Niter;
472 Set the maximum number of iterations of the self-gravity Poisson solver.
475 "set_self_gravity_tol",
476 [](TConfig &self, Tscal tol) {
477 self.gravity_config.tol = tol;
481 Set the convergence tolerance of the self-gravity Poisson solver.
483 The solver stops when the L2 norm of the residual is below tol relative to the
484 one of the right-hand side.
487 "set_self_gravity_happy_breakdown_tol",
488 [](TConfig &self, Tscal tol) {
489 self.gravity_config.tol_hp_bk = tol;
493 Set the tolerance of the BiCGSTAB lucky breakdown test.
495 BiCGSTAB restarts (shadow residual and search direction reset to the residual)
496 when |<r_k, r'_0>| < tol |r_k| |r'_0|.
499 "add_ext_force_constant_gravity",
500 [](TConfig &self, Tvec g) {
501 self.ext_force_config.add_constant_gravity(g);
505 "add_ext_force_point_mass_gravity",
506 [](TConfig &self, Tscal mass, Tvec pos, Tscal epsilon_soft) {
507 self.ext_force_config.add_point_mass_gravity(mass, pos, epsilon_soft);
511 py::arg(
"epsilon_soft"),
513 Add the gravity of a fixed point mass to the external forces:
514 a = -G M (r - pos) / (|r - pos|^2 + epsilon_soft^2)^{3/2}, with G from the unit system.
515 epsilon_soft must be > 0.
518 "set_ext_force_coupling",
520 self.ext_force_config.set_coupling(mode);
524 Set the time quadrature coupling the external forces to the solver.
528 mode : ExtForceCoupling
529 Either ``ExtForceCoupling.Midpoint`` (the default) or ``ExtForceCoupling.Trapezoidal``,
530 as obtained from ``from shamrock.model_ramses import ExtForceCoupling``.
532 .def("set_npscal_gas", [](TConfig &self,
u32 npscal_gas) {
533 self.npscal_gas_config.npscal_gas = npscal_gas;
536 std::string sod_tube_analysis_name = name_model +
"_AnalysisSodTube";
537 py::class_<TAnalysisSodTube>(m, sod_tube_analysis_name.c_str())
538 .def(
"compute_L2_dist", [](TAnalysisSodTube &self) -> std::tuple<Tscal, Tvec, Tscal> {
539 auto ret = self.compute_L2_dist();
540 return {ret.rho, ret.v, ret.P};
543 py::class_<T>(m, name_model.c_str())
544 .def(
"init", &T::init)
545 .def(
"init_scheduler", &T::init_scheduler)
546 .def(
"make_base_grid", &T::make_base_grid)
547 .def(
"dump_vtk", &T::dump_vtk)
548 .def(
"dump", &T::dump)
549 .def(
"load_from_dump", &T::load_from_dump)
550 .def(
"evolve_once_override_time", &T::evolve_once_time_expl)
551 .def(
"evolve_once", &T::evolve_once)
554 [](T &self,
f64 target_time,
i32 niter_max) {
555 return self.evolve_until(target_time, niter_max);
557 py::arg(
"target_time"),
559 py::arg(
"niter_max") = -1)
560 .def(
"timestep", &T::timestep)
561 .def(
"solver_logs_last_rate", &T::solver_logs_last_rate)
562 .def(
"solver_logs_last_obj_count", &T::solver_logs_last_obj_count)
564 "solver_logs_last_system_metrics",
566 auto system_metrics = self.solver.solve_logs.get_last_system_metrics();
568 ret[
"duration"] = system_metrics.wall_time;
569 if (system_metrics.rank_energy_consummed.has_value()) {
570 ret[
"rank_energy_consummed"] = system_metrics.rank_energy_consummed.value();
572 if (system_metrics.gpu_energy_consummed.has_value()) {
573 ret[
"gpu_energy_consummed"] = system_metrics.gpu_energy_consummed.value();
575 if (system_metrics.cpu_energy_consummed.has_value()) {
576 ret[
"cpu_energy_consummed"] = system_metrics.cpu_energy_consummed.value();
578 if (system_metrics.dram_energy_consummed.has_value()) {
579 ret[
"dram_energy_consummed"] = system_metrics.dram_energy_consummed.value();
584 "set_field_value_lambda_f64",
586 std::string field_name,
587 const std::function<
f64(Tvec, Tvec)> pos_to_val,
589 return self.template set_field_value_lambda<f64>(
590 field_name, pos_to_val, offset);
592 py::arg(
"field_name"),
593 py::arg(
"pos_to_val"),
594 py::arg(
"offset") = 0)
596 "set_field_value_lambda_f64_3",
598 std::string field_name,
599 const std::function<f64_3(Tvec, Tvec)> pos_to_val,
601 return self.template set_field_value_lambda<f64_3>(
602 field_name, pos_to_val, offset);
604 py::arg(
"field_name"),
605 py::arg(
"pos_to_val"),
606 py::arg(
"offset") = 0)
608 "gen_default_config",
609 [](T &self) -> TConfig {
614 [](T &self, TConfig cfg) {
615 if (self.ctx.is_scheduler_initialized()) {
617 "Cannot change solver config after scheduler is initialized");
620 self.solver.solver_config = cfg;
624 [](T &self, std::pair<TgridVec, TgridVec> block_coord,
u32 cell_local_id) {
625 return self.get_cell_coords(block_coord, cell_local_id);
628 "make_analysis_sodtube",
630 shamphys::SodTube sod,
636 return std::make_unique<TAnalysisSodTube>(
638 self.solver.solver_config,
648 "add_timestep_callback",
650 std::optional<std::function<
void(
void)>> step_begin_callback,
651 std::optional<std::function<
void(
void)>> step_end_callback) {
652 self.solver.timestep_callbacks.push_back(
653 {std::move(step_begin_callback), std::move(step_end_callback)});
656 py::arg(
"step_begin") = std::nullopt,
657 py::arg(
"step_end") = std::nullopt)
664 "get_solver_dot_graph",
671 [](T &self, std::string name, std::string field_type, std::vector<Tvec> positions)
672 -> std::variant<std::vector<f64>, std::vector<f64_3>> {
673 if (field_type ==
"f64") {
674 ramses::modules::GridRender<Tvec, TgridVec, f64> render(
675 self.ctx, self.solver.solver_config, self.solver.storage);
676 return render.compute_slice(name, positions).copy_to_stdvec();
679 if (field_type ==
"f64_3") {
680 ramses::modules::GridRender<Tvec, TgridVec, f64_3> render(
681 self.ctx, self.solver.solver_config, self.solver.storage);
682 return render.compute_slice(name, positions).copy_to_stdvec();
690 return self.solver.get_time();
695 return self.solver.get_dt();
699 [](T &self, Tscal t) {
700 return self.solver.set_time(t);
702 .def(
"set_next_dt", [](T &self, Tscal dt) {
703 return self.solver.set_next_dt(dt);
709 auto &m = root_module;
711 py::module mramses = m.def_submodule(
"model_ramses",
"Shamrock Ramses solver");
713 std::string base_name =
"RamsesModel";
716 py::enum_<ExtForceCoupling>(
720 Time quadrature used to couple the external forces source term to the solver.
721 Both modes are second order in time, and give the same momentum update for a constant
726 >>> from shamrock.model_ramses import ExtForceCoupling
727 >>> cfg.set_ext_force_coupling(ExtForceCoupling.Trapezoidal)
733 Explicit midpoint rule. This is the default.
735 The forces are evaluated once, at :math:`t^{n+1/2}`, from the time centered state (e.g.
736 :math:`\rho^{n+1/2} = \rho^n + \frac{\Delta t}{2} \partial_t \rho`, and the momentum for a
737 velocity dependent force), and applied over the whole time step.
743 Trapezoidal rule (time centred source term, as in RAMSES).
745 The forces are evaluated at :math:`t^n` and :math:`t^{n+1}`, each with the state at the same
746 time, and the average of the two source terms is applied over the whole time step:
747 :math:`\Delta (\rho \mathbf{v}) = \Delta t \, \frac{1}{2}
748 (\rho^n \mathbf{a}^n + \rho^{n+1} \mathbf{a}^{n+1})`.
749 A force evaluated at :math:`t^{n+1}` may only depend on the density there (e.g.
750 self-gravity), since it is known before the kick.
753 py::enum_<RiemannSolverMode>(
757 Gas Riemann solver of the Ramses solver, to be given to ``cfg.set_riemann_solver``.
759 The values are also exported in ``shamrock.model_ramses`` directly.
763 >>> from shamrock.model_ramses import HLLC_PVRS
764 >>> cfg.set_riemann_solver(HLLC_PVRS)
768 RiemannSolverMode::Rusanov,
770 Rusanov (local Lax-Friedrichs) flux.
774 RiemannSolverMode::HLL,
776 Harten-Lax-van Leer flux. This is the default.
780 RiemannSolverMode::HLLC_PVRS,
782 HLLC flux, with wave speeds estimated from the primitive variable Riemann solver (PVRS) star
783 pressure, following Toro (Riemann Solvers and Numerical Methods for Fluid Dynamics,
788 RiemannSolverMode::HLLC_Davis,
790 HLLC flux, using the Davis (1988) wave speed estimate
791 :math:`s_l = \min(v_l - c_l, v_r - c_r)`, :math:`s_r = \max(v_l + c_l, v_r + c_r)`.
795 RiemannSolverMode::HLLC_RAMSES,
797 HLLC flux, using the wave speed estimate of the RAMSES code (``riemann_hllc`` in
798 ``hydro/godunov_utils.f90``)
799 :math:`s_l = \min(v_l, v_r) - \max(c_l, c_r)`, :math:`s_r = \max(v_l, v_r) + \max(c_l, c_r)`,
800 so that the flux matches the ``hllc`` solver of RAMSES.
807 py::class_<typename Cooling::None>(
811 No cooling, to be given to ``cfg.set_cooling_mode``.
815 >>> from shamrock.model_ramses import NoCooling
816 >>> cfg.set_cooling_mode(NoCooling())
819 .def("__repr__", [](
const typename Cooling::None &) {
820 return std::string(
"NoCooling()");
823 py::class_<typename Cooling::InstantBarotropic>(
827 Instantaneous barotropic cooling (RAMSES-like), to be given to ``cfg.set_cooling_mode``.
829 At the end of each timestep, before the CFL condition, the internal energy of every cell is
830 overwritten by :math:`P_{\rm baro}(\rho) / (\gamma - 1)`, with :math:`\gamma` the
831 adiabatic index of the equation of state and
832 :math:`P_{\rm baro}(\rho) = c_{s,0}^2 \rho (1 + (\rho / \rho_0)^{\gamma_0 - 1})`.
837 Density of the isothermal to adiabatic transition of the barotrope (> 0)
839 Adiabatic index of the barotrope above ``rho0``
841 Isothermal sound speed of the barotrope below ``rho0`` (> 0)
845 >>> from shamrock.model_ramses import InstantBarotropic
846 >>> cfg.set_cooling_mode(InstantBarotropic(rho0=1e-13, gamma0=1.4, cs0=0.2))
849 py::init([](Tscal rho0, Tscal gamma0, Tscal cs0) {
850 return typename Cooling::InstantBarotropic{rho0, cs0, gamma0};
856 .def_readwrite(
"rho0", &Cooling::InstantBarotropic::rho0)
857 .def_readwrite(
"gamma0", &Cooling::InstantBarotropic::gamma0)
858 .def_readwrite(
"cs0", &Cooling::InstantBarotropic::cs0)
859 .def(
"__repr__", [](
const typename Cooling::InstantBarotropic &self) {
861 "InstantBarotropic(rho0={}, gamma0={}, cs0={})", self.rho0, self.gamma0, self.cs0);
864 add_instance<f64_3, i64_3>(
865 mramses, base_name +
"_f64_3_i64_3_SolverConfig", base_name +
"_f64_3_i64_3_Model");
867 using VariantAMRGodunovBind = std::variant<std::unique_ptr<Model<f64_3, i64_3>>>;
872 std::string vector_type,
873 std::string grid_repr) -> VariantAMRGodunovBind {
874 VariantAMRGodunovBind ret;
876 if (vector_type ==
"f64_3" && grid_repr ==
"i64_3") {
877 ret = std::make_unique<Model<f64_3, i64_3>>(ctx);
880 "unknown combination of representation and grid_repr");
887 py::arg(
"vector_type"),
888 py::arg(
"grid_repr"));
double f64
Alias for double.
float f32
Alias for float.
std::uint32_t u32
32 bit unsigned integer
std::uint64_t u64
64 bit unsigned integer
std::int32_t i32
32 bit integer
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.
T & get_check_ref(const std::unique_ptr< T > &ptr, SourceLocation loc=SourceLocation())
Takes a std::unique_ptr and returns a reference to the object it holds. It throws a std::runtime_erro...
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
RiemannSolverMode
Gas Riemann solver used by the Ramses (Godunov) model.
@ HB
Huang and Bai. Pressureless Riemann solver by Huang and Bai (2022) in Athena++.
@ DHLL
Dust HLL. This is merely the HLL solver for dust. It's then a Rusanov like.
@ NoDust
No dust, so no Riemann solver is used.
ExtForceCoupling
Time quadrature used to couple the external forces source term to the solver.
Pybind11 include and definitions.
#define ON_PYTHON_INIT
Register a Python module init function using static initialization.
Utilities to convert JSON objects to Python objects and vice versa. TODO: try to convert directly wit...
Cooling of the gas, applied on top of the (adiabatic) equation of state.
Functions related to the MPI communicator.
#define ON_RANK_0(x)
Macro to execute code only on rank 0.