Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels::basegodunov Namespace Reference

namespace for the basegodunov model More...

Namespaces

namespace  modules
 namespace for the basegodunov model modules

Classes

struct  AMRStencilCache
struct  CoolingConfig
 Cooling of the gas, applied on top of the (adiabatic) equation of state. More...
struct  ExtForceConfig
 List of the external forces applied to the gas. More...
class  GhostZonesData
 Class to hold information related to ghost zones. More...
class  Model
class  SolverStorage
class  Solver
struct  DragConfig
 alphas is the dust collision rate (the inverse of the stopping time) More...
struct  DustConfig
struct  PassiveScalarGasConfig
 Npscal_gas is the number of gas passive scalars. More...
struct  GravityConfig
struct  AMRMode
struct  EOSConfig
 Equation of state of the gas, each alternative maps to a shammath FluidStateSpec. More...
struct  BCConfig
struct  SolverConfig

Typedefs

using Direction = shammodels::basegodunov::modules::Direction
template<class T>
using Component = shambase::StorageComponent<T>

Enumerations

enum  AMRInterpMode { FIRST_ORDER = 0 , SECOND_ORDER = 1 }
enum  DragSolverMode { NoDrag = 0 , IRK1 = 1 , IRK2 = 2 , EXPO = 3 }
enum  DustRiemannSolverMode { NoDust = 0 , DHLL = 1 , HB = 2 }
 Dust Riemann solver mode enum. More...
enum  ExtForceCoupling { Midpoint = 0 , Trapezoidal = 1 }
 Time quadrature used to couple the external forces source term to the solver. More...
enum  GravityMode {
  NoGravity = 0 , CG = 1 , PCG = 2 , BICGSTAB = 3 ,
  MULTIGRID = 4
}
enum  RiemannSolverMode {
  Rusanov = 0 , HLL = 1 , HLLC_PVRS = 2 , HLLC_Davis = 3 ,
  HLLC_RAMSES = 4
}
 Gas Riemann solver used by the Ramses (Godunov) model. More...
enum  SlopeMode {
  None = 0 , VanLeer_f = 1 , VanLeer_std = 2 , VanLeer_sym = 3 ,
  Minmod = 4
}
 Slope limiter modes. More...

Functions

template<class Tvec>
void to_json (nlohmann::json &j, const CoolingConfig< Tvec > &p)
template<class Tvec>
void from_json (const nlohmann::json &j, CoolingConfig< Tvec > &p)
 SHAMROCK_JSON_SERIALIZE_ENUM (AMRInterpMode, {{AMRInterpMode::FIRST_ORDER, "amr_first_order"}, {AMRInterpMode::SECOND_ORDER, "amr_second_order"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (DragSolverMode, {{DragSolverMode::NoDrag, "no_drag"}, {DragSolverMode::IRK1, "irk1"}, {DragSolverMode::IRK2, "irk2"}, {DragSolverMode::EXPO, "expo"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (DustRiemannSolverMode, {{DustRiemannSolverMode::NoDust, "no_dust"}, {DustRiemannSolverMode::DHLL, "dhll"}, {DustRiemannSolverMode::HB, "hb"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (ExtForceCoupling, {{ExtForceCoupling::Midpoint, "midpoint"}, {ExtForceCoupling::Trapezoidal, "trapezoidal"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (GravityMode, {{GravityMode::NoGravity, "no_gravity"}, {GravityMode::CG, "cg"}, {GravityMode::PCG, "pcg"}, {GravityMode::BICGSTAB, "bicgstab"}, {GravityMode::MULTIGRID, "multigrid"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (RiemannSolverMode, {{RiemannSolverMode::Rusanov, "rusanov"}, {RiemannSolverMode::HLL, "hll"}, {RiemannSolverMode::HLLC_PVRS, "hllc_pvrs"}, {RiemannSolverMode::HLLC_Davis, "hllc_davis"}, {RiemannSolverMode::HLLC_RAMSES, "hllc_ramses"}, {RiemannSolverMode::HLLC_PVRS, "hllc"}})
 SHAMROCK_JSON_SERIALIZE_ENUM (SlopeMode, {{SlopeMode::None, "none"}, {SlopeMode::VanLeer_f, "vanleer_f"}, {SlopeMode::VanLeer_std, "vanleer_std"}, {SlopeMode::VanLeer_sym, "vanleer_sym"}, {SlopeMode::Minmod, "minmod"}})
template<class Tvec>
void to_json (nlohmann::json &j, const ExtForceConfig< Tvec > &p)
template<class Tvec>
void from_json (const nlohmann::json &j, ExtForceConfig< Tvec > &p)
template<class T, class Tvec, class ACCField>
T laplacian_7pt_with_Aii (const shambase::VecComponent< Tvec > *cell_sizes, const u32 block_size, const u32 cell_global_id, const AMRGraphLinkiterator &graph_iter_xp, const AMRGraphLinkiterator &graph_iter_xm, const AMRGraphLinkiterator &graph_iter_yp, const AMRGraphLinkiterator &graph_iter_ym, const AMRGraphLinkiterator &graph_iter_zp, const AMRGraphLinkiterator &graph_iter_zm, ACCField &&field_access, T &Aii)
 Get the discretized (finite volume) Laplacian, and the diagonal coefficient of the associated matrix.
template<class T, class Tvec, class ACCField>
T laplacian_7pt (const shambase::VecComponent< Tvec > *cell_sizes, const u32 block_size, const u32 cell_global_id, const AMRGraphLinkiterator &graph_iter_xp, const AMRGraphLinkiterator &graph_iter_xm, const AMRGraphLinkiterator &graph_iter_yp, const AMRGraphLinkiterator &graph_iter_ym, const AMRGraphLinkiterator &graph_iter_zp, const AMRGraphLinkiterator &graph_iter_zm, ACCField &&field_access)
 Get the discretized (finite volume) Laplacian.
template<class T, class Tvec>
T jacobi_weight_7pt (const shambase::VecComponent< Tvec > *cell_sizes, const u32 block_size, const u32 cell_global_id, const AMRGraphLinkiterator &graph_iter_xp, const AMRGraphLinkiterator &graph_iter_xm, const AMRGraphLinkiterator &graph_iter_yp, const AMRGraphLinkiterator &graph_iter_ym, const AMRGraphLinkiterator &graph_iter_zp, const AMRGraphLinkiterator &graph_iter_zm)
 Get the weight of the Jacobi preconditioner of the 7-point Laplacian.
void to_json (nlohmann::json &j, const BCConfig::GhostType &e)
void from_json (const nlohmann::json &j, BCConfig::GhostType &e)
void to_json (nlohmann::json &j, const BCConfig &p)
void from_json (const nlohmann::json &j, BCConfig &p)
void to_json (nlohmann::json &j, const DragConfig &p)
void from_json (const nlohmann::json &j, DragConfig &p)
template<class Tvec, class TgridVec>
void amr_config_to_json (nlohmann::json &j, const AMRMode< Tvec, TgridVec > &p)
template<class Tvec, class TgridVec>
void amr_config_from_json (const nlohmann::json &j, AMRMode< Tvec, TgridVec > &p)
template<class Tvec>
void to_json (nlohmann::json &j, const EOSConfig< Tvec > &p)
template<class Tvec>
void from_json (const nlohmann::json &j, EOSConfig< Tvec > &p)
template<class Tvec, class TgridVec>
void to_json (nlohmann::json &j, const AMRMode< Tvec, TgridVec > &p)
template<class Tvec, class TgridVec>
void from_json (const nlohmann::json &j, AMRMode< Tvec, TgridVec > &p)
template<class Tvec, class TgridVec>
void to_json (nlohmann::json &j, const SolverConfig< Tvec, TgridVec > &p)
 Serialize a SolverConfig to a JSON object.
template<class Tvec, class TgridVec>
void from_json (const nlohmann::json &j, SolverConfig< Tvec, TgridVec > &p)
 Deserializes a SolverConfig object from a JSON object.
template<class Tvec, class TgridVec>
void add_instance (py::module &m, std::string name_config, std::string name_model)
template void to_json< f64_3, i64_3 > (nlohmann::json &j, const SolverConfig< f64_3, i64_3 > &p)
template void from_json< f64_3, i64_3 > (const nlohmann::json &j, SolverConfig< f64_3, i64_3 > &p)

Detailed Description

namespace for the basegodunov model

Typedef Documentation

◆ Component

template<class T>
using shammodels::basegodunov::Component = shambase::StorageComponent<T>

Definition at line 59 of file SolverStorage.hpp.

◆ Direction

using shammodels::basegodunov::Direction = shammodels::basegodunov::modules::Direction

Definition at line 28 of file CGLaplacianStencil.hpp.

Enumeration Type Documentation

◆ AMRInterpMode

enum shammodels::basegodunov::AMRInterpMode

Definition at line 26 of file enum_AMRInterpMode.hpp.

◆ DragSolverMode

enum shammodels::basegodunov::DragSolverMode

Definition at line 26 of file enum_DragSolverMode.hpp.

◆ DustRiemannSolverMode

Dust Riemann solver mode enum.

Enumerator
NoDust 

No dust, so no Riemann solver is used.

DHLL 

Dust HLL. This is merely the HLL solver for dust. It's then a Rusanov like.

HB 

Huang and Bai. Pressureless Riemann solver by Huang and Bai (2022) in Athena++.

Definition at line 27 of file enum_DustRiemannSolverMode.hpp.

◆ ExtForceCoupling

Time quadrature used to couple the external forces source term to the solver.

Both are second order in time.

Enumerator
Midpoint 

Explicit midpoint rule: the forces are evaluated once, at t^{n+1/2}, from the time centered state (density, momentum, ...), and applied over the whole time step

Trapezoidal 

Trapezoidal rule (time centred source term, as in RAMSES): the forces are evaluated at t^n and t^{n+1}, and the average of the two source terms is applied over the whole time step

Definition at line 30 of file enum_ExtForceCoupling.hpp.

◆ GravityMode

enum shammodels::basegodunov::GravityMode

Definition at line 25 of file enum_GravityMode.hpp.

◆ RiemannSolverMode

Gas Riemann solver used by the Ramses (Godunov) model.

  • Rusanov : local Lax-Friedrichs flux
  • HLL : Harten-Lax-van Leer flux
  • HLLC_PVRS : HLLC flux with the wave speeds estimated from the primitive variable Riemann solver (PVRS) star pressure, following Toro (see shammath::hllc_adiab_toro_flux)
  • HLLC_Davis : HLLC flux with the Davis (1988) wave speed estimate (see shammath::hllc_davis_flux)
  • HLLC_RAMSES : HLLC flux with the wave speed estimate of the RAMSES code (see shammath::hllc_ramses_flux)

Definition at line 37 of file enum_RiemannSolverMode.hpp.

◆ SlopeMode

Slope limiter modes.

Definition at line 25 of file enum_SlopeMode.hpp.

Function Documentation

◆ add_instance()

template<class Tvec, class TgridVec>
void shammodels::basegodunov::add_instance ( py::module & m,
std::string name_config,
std::string name_model )

Definition at line 55 of file pyRamsesModel.cpp.

◆ amr_config_from_json()

template<class Tvec, class TgridVec>
void shammodels::basegodunov::amr_config_from_json ( const nlohmann::json & j,
AMRMode< Tvec, TgridVec > & p )
inline

Definition at line 538 of file SolverConfig.hpp.

◆ amr_config_to_json()

template<class Tvec, class TgridVec>
void shammodels::basegodunov::amr_config_to_json ( nlohmann::json & j,
const AMRMode< Tvec, TgridVec > & p )
inline

Definition at line 516 of file SolverConfig.hpp.

◆ from_json() [1/8]

template<class Tvec, class TgridVec>
void shammodels::basegodunov::from_json ( const nlohmann::json & j,
AMRMode< Tvec, TgridVec > & p )
inline

Definition at line 610 of file SolverConfig.hpp.

◆ from_json() [2/8]

void shammodels::basegodunov::from_json ( const nlohmann::json & j,
BCConfig & p )
inline

Definition at line 496 of file SolverConfig.hpp.

◆ from_json() [3/8]

void shammodels::basegodunov::from_json ( const nlohmann::json & j,
BCConfig::GhostType & e )
inline

Definition at line 475 of file SolverConfig.hpp.

◆ from_json() [4/8]

template<class Tvec>
void shammodels::basegodunov::from_json ( const nlohmann::json & j,
CoolingConfig< Tvec > & p )
inline

Definition at line 105 of file CoolingConfig.hpp.

◆ from_json() [5/8]

void shammodels::basegodunov::from_json ( const nlohmann::json & j,
DragConfig & p )
inline

Definition at line 509 of file SolverConfig.hpp.

◆ from_json() [6/8]

template<class Tvec>
void shammodels::basegodunov::from_json ( const nlohmann::json & j,
EOSConfig< Tvec > & p )
inline

Definition at line 579 of file SolverConfig.hpp.

◆ from_json() [7/8]

template<class Tvec>
void shammodels::basegodunov::from_json ( const nlohmann::json & j,
ExtForceConfig< Tvec > & p )
inline

Definition at line 112 of file ExtForceConfig.hpp.

◆ from_json() [8/8]

template<class Tvec, class TgridVec>
void shammodels::basegodunov::from_json ( const nlohmann::json & j,
SolverConfig< Tvec, TgridVec > & p )

Deserializes a SolverConfig object from a JSON object.

Parameters
jThe JSON object to deserialize from.
pThe SolverConfig object to populate.

Definition at line 85 of file SolverConfig.cpp.

Here is the call graph for this function:

◆ jacobi_weight_7pt()

template<class T, class Tvec>
T shammodels::basegodunov::jacobi_weight_7pt ( const shambase::VecComponent< Tvec > * cell_sizes,
const u32 block_size,
const u32 cell_global_id,
const AMRGraphLinkiterator & graph_iter_xp,
const AMRGraphLinkiterator & graph_iter_xm,
const AMRGraphLinkiterator & graph_iter_yp,
const AMRGraphLinkiterator & graph_iter_ym,
const AMRGraphLinkiterator & graph_iter_zp,
const AMRGraphLinkiterator & graph_iter_zm )
inline

Get the weight of the Jacobi preconditioner of the 7-point Laplacian.

Sum over the directions having at least one neighbour of \( \Delta x^2 / d \), \( d \) being the distance between the cell centers used in laplacian_7pt_with_Aii ( \( 6 \Delta x \) on a uniform grid).

TODO: (kept from new_amr_plus_grav) unlike the Aii output of laplacian_7pt_with_Aii (used by CGInit for z_0), a direction without neighbour does not contribute here, so the two differ on the cells missing a neighbour (outer ghost cells, non periodic boundaries).

Template Parameters
Tfield type
Tvecvector type
Parameters
cell_sizescell size per block
block_sizenumber of cells per block
cell_global_idid of the cell
graph_iter_xpneighbour graph accessor in the +x direction
graph_iter_xmneighbour graph accessor in the -x direction
graph_iter_ypneighbour graph accessor in the +y direction
graph_iter_ymneighbour graph accessor in the -y direction
graph_iter_zpneighbour graph accessor in the +z direction
graph_iter_zmneighbour graph accessor in the -z direction
Returns
T the Jacobi weight of the cell

Definition at line 203 of file CGLaplacianStencil.hpp.

◆ laplacian_7pt()

template<class T, class Tvec, class ACCField>
T shammodels::basegodunov::laplacian_7pt ( const shambase::VecComponent< Tvec > * cell_sizes,
const u32 block_size,
const u32 cell_global_id,
const AMRGraphLinkiterator & graph_iter_xp,
const AMRGraphLinkiterator & graph_iter_xm,
const AMRGraphLinkiterator & graph_iter_yp,
const AMRGraphLinkiterator & graph_iter_ym,
const AMRGraphLinkiterator & graph_iter_zp,
const AMRGraphLinkiterator & graph_iter_zm,
ACCField && field_access )
inline

Get the discretized (finite volume) Laplacian.

Same as laplacian_7pt_with_Aii (see it for the details of the discretization), without the diagonal coefficient.

Template Parameters
Tfield type
Tvecvector type
ACCFieldfield accessor type, T(u32 cell_id)
Parameters
cell_sizescell size per block
block_sizenumber of cells per block
cell_global_idid of the cell
graph_iter_xpneighbour graph accessor in the +x direction
graph_iter_xmneighbour graph accessor in the -x direction
graph_iter_ypneighbour graph accessor in the +y direction
graph_iter_ymneighbour graph accessor in the -y direction
graph_iter_zpneighbour graph accessor in the +z direction
graph_iter_zmneighbour graph accessor in the -z direction
field_accessfield accessor
Returns
T the discretized \( -\Delta x^3 \Delta W \)

Definition at line 152 of file CGLaplacianStencil.hpp.

Here is the call graph for this function:

◆ laplacian_7pt_with_Aii()

template<class T, class Tvec, class ACCField>
T shammodels::basegodunov::laplacian_7pt_with_Aii ( const shambase::VecComponent< Tvec > * cell_sizes,
const u32 block_size,
const u32 cell_global_id,
const AMRGraphLinkiterator & graph_iter_xp,
const AMRGraphLinkiterator & graph_iter_xm,
const AMRGraphLinkiterator & graph_iter_yp,
const AMRGraphLinkiterator & graph_iter_ym,
const AMRGraphLinkiterator & graph_iter_zp,
const AMRGraphLinkiterator & graph_iter_zm,
ACCField && field_access,
T & Aii )
inline

Get the discretized (finite volume) Laplacian, and the diagonal coefficient of the associated matrix.

The Laplacian is written in flux form: for each direction the gradient across the interface is the mean over the neighbours of \( (W_b - W_i) / d \), \( d \) being the distance between the cell centers ( \( \Delta x \) for a neighbour of the same level, \( 3 \Delta x / 2 \) for a coarser one and \( 3 \Delta x / 4 \) for a finer one, assuming a 2:1 refinement). The fluxes are then multiplied by the face surface \( \Delta x^2 \), so that the result is \( -\Delta x^3 \Delta W \) (the volume integral of \( -\Delta W \) over the cell). A direction without any neighbour contributes a zero flux.

The matrix is symmetric, including across level jumps (the coarse/fine coupling is \( \Delta x_{\rm coarse} / 3 \) from both sides). The scheme is second order on a uniform grid, but at a level jump the two-point flux ignores the lateral offset between the cell centers: the pointwise truncation error is O(1) there and the scheme is first order in the weak sense (see NodeSpMVPoisson3DTests.cpp).

The minus sign makes the matrix positive. With it we solve \( -\Delta \phi = -4 \pi G (\rho - \bar{\rho}) \) (multiplied by the cell volume).

Template Parameters
Tfield type
Tvecvector type
ACCFieldfield accessor type, T(u32 cell_id)
Parameters
cell_sizescell size per block
block_sizenumber of cells per block
cell_global_idid of the cell
graph_iter_xpneighbour graph accessor in the +x direction
graph_iter_xmneighbour graph accessor in the -x direction
graph_iter_ypneighbour graph accessor in the +y direction
graph_iter_ymneighbour graph accessor in the -y direction
graph_iter_zpneighbour graph accessor in the +z direction
graph_iter_zmneighbour graph accessor in the -z direction
field_accessfield accessor
Aiidiagonal coefficient of the matrix for this cell (output)
Returns
T the discretized \( -\Delta x^3 \Delta W \)

Definition at line 69 of file CGLaplacianStencil.hpp.

◆ to_json() [1/8]

template<class Tvec, class TgridVec>
void shammodels::basegodunov::to_json ( nlohmann::json & j,
const AMRMode< Tvec, TgridVec > & p )
inline

Definition at line 603 of file SolverConfig.hpp.

◆ to_json() [2/8]

void shammodels::basegodunov::to_json ( nlohmann::json & j,
const BCConfig & p )
inline

Definition at line 489 of file SolverConfig.hpp.

◆ to_json() [3/8]

void shammodels::basegodunov::to_json ( nlohmann::json & j,
const BCConfig::GhostType & e )
inline

Definition at line 464 of file SolverConfig.hpp.

◆ to_json() [4/8]

template<class Tvec>
void shammodels::basegodunov::to_json ( nlohmann::json & j,
const CoolingConfig< Tvec > & p )
inline

Definition at line 85 of file CoolingConfig.hpp.

◆ to_json() [5/8]

void shammodels::basegodunov::to_json ( nlohmann::json & j,
const DragConfig & p )
inline

Definition at line 502 of file SolverConfig.hpp.

◆ to_json() [6/8]

template<class Tvec>
void shammodels::basegodunov::to_json ( nlohmann::json & j,
const EOSConfig< Tvec > & p )
inline

Definition at line 559 of file SolverConfig.hpp.

◆ to_json() [7/8]

template<class Tvec>
void shammodels::basegodunov::to_json ( nlohmann::json & j,
const ExtForceConfig< Tvec > & p )
inline

Definition at line 85 of file ExtForceConfig.hpp.

◆ to_json() [8/8]

template<class Tvec, class TgridVec>
void shammodels::basegodunov::to_json ( nlohmann::json & j,
const SolverConfig< Tvec, TgridVec > & p )

Serialize a SolverConfig to a JSON object.

Parameters
[out]jThe JSON object to write to
[in]pThe SolverConfig to serialize

Definition at line 57 of file SolverConfig.cpp.