Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
pyGSPHModel.cpp File Reference

Python bindings for the GSPH (Godunov SPH) model. More...

#include "shambase/exception.hpp"
#include "shambase/memory.hpp"
#include "shambindings/pybindaliases.hpp"
#include "shambindings/pytypealias.hpp"
#include "shamcomm/worldInfo.hpp"
#include "shammath/sphkernels.hpp"
#include "shammodels/common/shamrock_json_to_py_json.hpp"
#include "shammodels/gsph/Model.hpp"
#include "shamrock/scheduler/PatchScheduler.hpp"
#include <pybind11/cast.h>
#include <pybind11/numpy.h>
#include <memory>
Include dependency graph for pyGSPHModel.cpp:

Go to the source code of this file.

Typedefs

using VariantGSPHModelBind

Functions

template<class Tvec, template< class > class SPHKernel>
void add_gsph_instance (py::module &m, std::string name_config, std::string name_model)
 add_gsph_instance< f64_3, shammath::M4 > (mgsph, "GSPHModel_f64_3_M4_SolverConfig", "GSPHModel_f64_3_M4")
 add_gsph_instance< f64_3, shammath::M6 > (mgsph, "GSPHModel_f64_3_M6_SolverConfig", "GSPHModel_f64_3_M6")
 add_gsph_instance< f64_3, shammath::M8 > (mgsph, "GSPHModel_f64_3_M8_SolverConfig", "GSPHModel_f64_3_M8")
 add_gsph_instance< f64_3, shammath::C2 > (mgsph, "GSPHModel_f64_3_C2_SolverConfig", "GSPHModel_f64_3_C2")
 add_gsph_instance< f64_3, shammath::C4 > (mgsph, "GSPHModel_f64_3_C4_SolverConfig", "GSPHModel_f64_3_C4")
 add_gsph_instance< f64_3, shammath::C6 > (mgsph, "GSPHModel_f64_3_C6_SolverConfig", "GSPHModel_f64_3_C6")
def ("get_Model_GSPH", [](ShamrockCtx &ctx, std::string vector_type, std::string kernel) -> VariantGSPHModelBind { VariantGSPHModelBind ret;if(vector_type=="f64_3" &&kernel=="M4") { ret=std::make_unique< Model< f64_3, shammath::M4 > >(ctx);} else if(vector_type=="f64_3" &&kernel=="M6") { ret=std::make_unique< Model< f64_3, shammath::M6 > >(ctx);} else if(vector_type=="f64_3" &&kernel=="M8") { ret=std::make_unique< Model< f64_3, shammath::M8 > >(ctx);} else if(vector_type=="f64_3" &&kernel=="C2") { ret=std::make_unique< Model< f64_3, shammath::C2 > >(ctx);} else if(vector_type=="f64_3" &&kernel=="C4") { ret=std::make_unique< Model< f64_3, shammath::C4 > >(ctx);} else if(vector_type=="f64_3" &&kernel=="C6") { ret=std::make_unique< Model< f64_3, shammath::C6 > >(ctx);} else { throw shambase::make_except_with_loc< std::invalid_argument >("unknown combination of representation and kernel");} return ret;}, py::kw_only(), py::arg("context"), py::arg("vector_type")="f64_3", py::arg("sph_kernel")="M4", R"==( Create a GSPH (Godunov SPH) model. GSPH uses Riemann solvers at particle interfaces instead of artificial viscosity, giving sharper shock resolution. Parameters ---------- context : ShamrockCtx Shamrock context vector_type : str Vector type, e.g., "f64_3" for 3D double precision (default: "f64_3") sph_kernel : str SPH kernel type: "M4" (cubic spline, default), "M6", "M8" (quintic spline), "C2", "C4", "C6" (Wendland kernels) Returns ------- GSPHModel A GSPH model instance Examples -------- >>> ctx = shamrock.ShamrockCtx() >>> model = shamrock.get_Model_GSPH(context=ctx) # Uses M4 kernel by default >>> config = model.gen_default_config() >>> config.set_riemann_hllc() >>> config.set_eos_adiabatic(1.4) >>> model.set_solver_config(config) )==")

Variables

 ON_PYTHON_INIT
py::module mgsph = m.def_submodule("model_gsph", "Shamrock GSPH (Godunov SPH) solver")

Detailed Description

Python bindings for the GSPH (Godunov SPH) model.

Author
Guo Yansong (guo.y.nosp@m.anso.nosp@m.ng.ng.nosp@m.y@gm.nosp@m.ail.c.nosp@m.om)
Timothée David–Cléris (tim.s.nosp@m.hamr.nosp@m.ock@p.nosp@m.roto.nosp@m.n.me)
Yona Lapeyre (yona..nosp@m.lape.nosp@m.yre@e.nosp@m.ns-l.nosp@m.yon.f.nosp@m.r) –no git blame–

This provides Python interface for GSPH simulations using Riemann solvers.

References:

  • Inutsuka, S. (2002) "Reformulation of Smoothed Particle Hydrodynamics with Riemann Solver"
  • Cha, S.-H. & Whitworth, A.P. (2003) "Implementations and tests of Godunov-type particle hydrodynamics"

Definition in file pyGSPHModel.cpp.

Typedef Documentation

◆ VariantGSPHModelBind

using VariantGSPHModelBind
Initial value:
std::variant<
std::unique_ptr<Model<f64_3, shammath::M4>>,
std::unique_ptr<Model<f64_3, shammath::M6>>,
std::unique_ptr<Model<f64_3, shammath::M8>>,
std::unique_ptr<Model<f64_3, shammath::C2>>,
std::unique_ptr<Model<f64_3, shammath::C4>>,
std::unique_ptr<Model<f64_3, shammath::C6>>>

Definition at line 330 of file pyGSPHModel.cpp.

Function Documentation

◆ add_gsph_instance()

template<class Tvec, template< class > class SPHKernel>
void add_gsph_instance ( py::module & m,
std::string name_config,
std::string name_model )

Definition at line 40 of file pyGSPHModel.cpp.

Variable Documentation

◆ mgsph

py::module mgsph = m.def_submodule("model_gsph", "Shamrock GSPH (Godunov SPH) solver")

Definition at line 311 of file pyGSPHModel.cpp.

◆ ON_PYTHON_INIT

ON_PYTHON_INIT
Initial value:
{
auto &m = root_module

Definition at line 308 of file pyGSPHModel.cpp.