Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shammodels::gsph::Solver< Tvec, SPHKernel > Class Template Reference

The GSPH Solver class. More...

#include <shammodels/gsph/include/shammodels/gsph/Solver.hpp>

Collaboration diagram for shammodels::gsph::Solver< Tvec, SPHKernel >:

Public Types

using Tscal = shambase::VecComponent<Tvec>
using Kernel = SPHKernel<Tscal>
using Config = SolverConfig<Tvec, SPHKernel>
using u_morton = u32
using GhostHandle = GSPHGhostHandler<Tvec>
using GhostHandleCache = typename GhostHandle::CacheMap
using RTree = typename Config::RTree

Public Member Functions

PatchScheduler & scheduler ()
Tscal & time_edge_value ()
 Access synchronized simulation time (scheduler edge "time").
Tscal & dt_edge_value ()
 Access synchronized next dt (scheduler edge "dt").
Tscal get_time ()
void set_time (Tscal t)
Tscal get_dt ()
void set_next_dt (Tscal dt)
void init_required_fields ()
void gen_serial_patch_tree ()
void reset_serial_patch_tree ()
void reset_ghost_handler ()
void build_ghost_cache (Tscal time_val)
void clear_ghost_cache ()
void merge_position_ghost ()
void build_merged_pos_trees ()
void clear_merged_pos_trees ()
void compute_presteps_rint ()
void reset_presteps_rint ()
void start_neighbors_cache ()
void reset_neighbors_cache ()
void gsph_prestep (Tscal time_val, Tscal dt)
void apply_position_boundary (Tscal time_val)
void do_predictor_leapfrog (Tscal dt)
void init_ghost_layout ()
void communicate_merge_ghosts_fields ()
void reset_merge_ghosts_fields ()
void compute_eos_fields ()
void reset_eos_fields ()
void copy_eos_to_patchdata ()
 Copy EOS fields from solvergraph to patchdata for persistence.
void compute_density ()
 Compute SPH-summation density for GSPH.
void compute_gradients ()
 Compute gradients for MUSCL reconstruction.
void prepare_corrector ()
void update_derivs ()
 Update derivatives using GSPH Riemann solver.
Tscal compute_dt_cfl ()
 Compute CFL timestep constraint.
bool apply_corrector (Tscal dt, u64 Npart_all)
void update_sync_load_values ()
 Solver (ShamrockCtx &context)
void init_solver_graph ()
void vtk_do_dump (std::string filename, bool add_patch_world_id)
void print_timestep_logs ()
TimestepLog evolve_once ()
Tscal evolve_once_time_expl (Tscal t_current, Tscal dt_input)
bool evolve_until (Tscal target_time, i32 niter_max=-1)

Public Attributes

ShamrockCtx & context
SolverStorage< Tvec, u_morton > storage {}
Config solver_config
SolverLog solve_logs

Static Public Attributes

static constexpr u32 dim = shambase::VectorProperties<Tvec>::dimension
static constexpr Tscal Rkern = Kernel::Rkern

Detailed Description

template<class Tvec, template< class > class SPHKernel>
class shammodels::gsph::Solver< Tvec, SPHKernel >

The GSPH Solver class.

Implements the Godunov SPH method using Riemann solvers at particle interfaces instead of artificial viscosity.

Template Parameters
TvecVector type (e.g., f64_3)
SPHKernelKernel type (e.g., M4, M6, C2, C4, C6)

Definition at line 71 of file Solver.hpp.

Member Typedef Documentation

◆ Config

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::Config = SolverConfig<Tvec, SPHKernel>

Definition at line 77 of file Solver.hpp.

◆ GhostHandle

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::GhostHandle = GSPHGhostHandler<Tvec>

Definition at line 119 of file Solver.hpp.

◆ GhostHandleCache

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::GhostHandleCache = typename GhostHandle::CacheMap

Definition at line 120 of file Solver.hpp.

◆ Kernel

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::Kernel = SPHKernel<Tscal>

Definition at line 75 of file Solver.hpp.

◆ RTree

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::RTree = typename Config::RTree

Definition at line 134 of file Solver.hpp.

◆ Tscal

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::Tscal = shambase::VecComponent<Tvec>

Definition at line 73 of file Solver.hpp.

◆ u_morton

template<class Tvec, template< class > class SPHKernel>
using shammodels::gsph::Solver< Tvec, SPHKernel >::u_morton = u32

Definition at line 79 of file Solver.hpp.

Constructor & Destructor Documentation

◆ Solver()

template<class Tvec, template< class > class SPHKernel>
shammodels::gsph::Solver< Tvec, SPHKernel >::Solver ( ShamrockCtx & context)
inline

Definition at line 217 of file Solver.hpp.

Member Function Documentation

◆ apply_corrector()

template<class Tvec, template< class > class Kern>
bool shammodels::gsph::Solver< Tvec, Kern >::apply_corrector ( Tscal dt,
u64 Npart_all )

Definition at line 1819 of file Solver.cpp.

◆ apply_position_boundary()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::apply_position_boundary ( Tscal time_val)

Definition at line 979 of file Solver.cpp.

◆ build_ghost_cache()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::build_ghost_cache ( Tscal time_val)

Generates the ghost handler and builds the ghost interface cache, with boundary conditions evaluated at time_val

Definition at line 172 of file Solver.cpp.

Here is the call graph for this function:

◆ build_merged_pos_trees()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::build_merged_pos_trees ( )

Definition at line 358 of file Solver.cpp.

◆ clear_ghost_cache()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::clear_ghost_cache ( )

Definition at line 307 of file Solver.cpp.

◆ clear_merged_pos_trees()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::clear_merged_pos_trees ( )

Definition at line 397 of file Solver.cpp.

◆ communicate_merge_ghosts_fields()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::communicate_merge_ghosts_fields ( )

Definition at line 1106 of file Solver.cpp.

◆ compute_density()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::compute_density ( )

Compute SPH-summation density for GSPH.

Unlike the plain SPH solver, which derives density analytically from the converged smoothing length via rho_h(pmass, h, hfact), GSPH needs an explicit summed density field (Sigma m_j W_ij) because the Riemann reconstruction and MUSCL gradients consume density directly, not just through h. This computes that summation into storage.density.

Must have h converged, neighbor cache valid.

Definition at line 638 of file Solver.cpp.

Here is the call graph for this function:

◆ compute_dt_cfl()

template<class Tvec, template< class > class Kern>
shammodels::gsph::Solver< Tvec, Kern >::Tscal shammodels::gsph::Solver< Tvec, Kern >::compute_dt_cfl ( )

Compute CFL timestep constraint.

Computes timestep from:

  • Courant condition: dt_cour = C_cour * h / vsig
  • Force condition: dt_force = C_force * sqrt(h / |a|)
Returns
Minimum CFL timestep across all particles

Definition at line 1715 of file Solver.cpp.

Here is the call graph for this function:

◆ compute_eos_fields()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::compute_eos_fields ( )

Definition at line 1290 of file Solver.cpp.

◆ compute_gradients()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::compute_gradients ( )

Compute gradients for MUSCL reconstruction.

Computes density, pressure, and velocity gradients for each particle using SPH kernel gradient summation. Only called when MUSCL reconstruction is enabled (reconstruct_config.is_muscl() == true).

Reference: Cha & Whitworth (2003)

Definition at line 1460 of file Solver.cpp.

Here is the call graph for this function:

◆ compute_presteps_rint()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::compute_presteps_rint ( )

Definition at line 403 of file Solver.cpp.

◆ copy_eos_to_patchdata()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::copy_eos_to_patchdata ( )

Copy EOS fields from solvergraph to patchdata for persistence.

Copies density, pressure, and soundspeed from the temporary solvergraph fields to the persistent patchdata layout. This ensures thermodynamic state is preserved across simulation restarts and available for VTK output.

Definition at line 1398 of file Solver.cpp.

Here is the call graph for this function:

◆ do_predictor_leapfrog()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::do_predictor_leapfrog ( Tscal dt)

Definition at line 1026 of file Solver.cpp.

◆ dt_edge_value()

template<class Tvec, template< class > class SPHKernel>
Tscal & shammodels::gsph::Solver< Tvec, SPHKernel >::dt_edge_value ( )
inline

Access synchronized next dt (scheduler edge "dt").

Definition at line 100 of file Solver.hpp.

◆ evolve_once()

template<class Tvec, template< class > class Kern>
shammodels::gsph::TimestepLog shammodels::gsph::Solver< Tvec, Kern >::evolve_once ( )

patch_rank_owner is automatically updated since it is just a lambda

Definition at line 1894 of file Solver.cpp.

Here is the call graph for this function:

◆ evolve_once_time_expl()

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::gsph::Solver< Tvec, SPHKernel >::evolve_once_time_expl ( Tscal t_current,
Tscal dt_input )
inline

Definition at line 234 of file Solver.hpp.

◆ evolve_until()

template<class Tvec, template< class > class SPHKernel>
bool shammodels::gsph::Solver< Tvec, SPHKernel >::evolve_until ( Tscal target_time,
i32 niter_max = -1 )
inline

Definition at line 241 of file Solver.hpp.

◆ gen_serial_patch_tree()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::gen_serial_patch_tree ( )

Definition at line 163 of file Solver.cpp.

◆ get_dt()

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::gsph::Solver< Tvec, SPHKernel >::get_dt ( )
inline

Definition at line 109 of file Solver.hpp.

◆ get_time()

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::gsph::Solver< Tvec, SPHKernel >::get_time ( )
inline

Definition at line 107 of file Solver.hpp.

◆ gsph_prestep()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::gsph_prestep ( Tscal time_val,
Tscal dt )

Definition at line 730 of file Solver.cpp.

◆ init_ghost_layout()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::init_ghost_layout ( )

Definition at line 1088 of file Solver.cpp.

◆ init_required_fields()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::init_required_fields ( )
inline

Definition at line 112 of file Solver.hpp.

◆ init_solver_graph()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::init_solver_graph ( )

Definition at line 83 of file Solver.cpp.

◆ merge_position_ghost()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::merge_position_ghost ( )

Definition at line 313 of file Solver.cpp.

◆ prepare_corrector()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::prepare_corrector ( )

Definition at line 1643 of file Solver.cpp.

◆ print_timestep_logs()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::print_timestep_logs ( )
inline

Definition at line 223 of file Solver.hpp.

◆ reset_eos_fields()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::reset_eos_fields ( )

Definition at line 1393 of file Solver.cpp.

◆ reset_ghost_handler()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::reset_ghost_handler ( )
inline

Definition at line 122 of file Solver.hpp.

◆ reset_merge_ghosts_fields()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::reset_merge_ghosts_fields ( )

Definition at line 1285 of file Solver.cpp.

◆ reset_neighbors_cache()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::reset_neighbors_cache ( )

Definition at line 633 of file Solver.cpp.

◆ reset_presteps_rint()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::reset_presteps_rint ( )

Definition at line 448 of file Solver.cpp.

◆ reset_serial_patch_tree()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::reset_serial_patch_tree ( )
inline

Definition at line 116 of file Solver.hpp.

◆ scheduler()

template<class Tvec, template< class > class SPHKernel>
PatchScheduler & shammodels::gsph::Solver< Tvec, SPHKernel >::scheduler ( )
inline

Definition at line 84 of file Solver.hpp.

◆ set_next_dt()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::set_next_dt ( Tscal dt)
inline

Definition at line 110 of file Solver.hpp.

◆ set_time()

template<class Tvec, template< class > class SPHKernel>
void shammodels::gsph::Solver< Tvec, SPHKernel >::set_time ( Tscal t)
inline

Definition at line 108 of file Solver.hpp.

◆ start_neighbors_cache()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::start_neighbors_cache ( )

Definition at line 453 of file Solver.cpp.

◆ time_edge_value()

template<class Tvec, template< class > class SPHKernel>
Tscal & shammodels::gsph::Solver< Tvec, SPHKernel >::time_edge_value ( )
inline

Access synchronized simulation time (scheduler edge "time").

Definition at line 92 of file Solver.hpp.

◆ update_derivs()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::update_derivs ( )

Update derivatives using GSPH Riemann solver.

This is the core GSPH step: for each particle pair, solve the 1D Riemann problem and compute forces from the interface pressure p*.

Definition at line 1708 of file Solver.cpp.

Here is the call graph for this function:

◆ update_sync_load_values()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::update_sync_load_values ( )

Definition at line 1887 of file Solver.cpp.

◆ vtk_do_dump()

template<class Tvec, template< class > class Kern>
void shammodels::gsph::Solver< Tvec, Kern >::vtk_do_dump ( std::string filename,
bool add_patch_world_id )

Definition at line 156 of file Solver.cpp.

Member Data Documentation

◆ context

template<class Tvec, template< class > class SPHKernel>
ShamrockCtx& shammodels::gsph::Solver< Tvec, SPHKernel >::context

Definition at line 83 of file Solver.hpp.

◆ dim

template<class Tvec, template< class > class SPHKernel>
u32 shammodels::gsph::Solver< Tvec, SPHKernel >::dim = shambase::VectorProperties<Tvec>::dimension
staticconstexpr

Definition at line 74 of file Solver.hpp.

◆ Rkern

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::gsph::Solver< Tvec, SPHKernel >::Rkern = Kernel::Rkern
staticconstexpr

Definition at line 81 of file Solver.hpp.

◆ solve_logs

template<class Tvec, template< class > class SPHKernel>
SolverLog shammodels::gsph::Solver< Tvec, SPHKernel >::solve_logs

Definition at line 89 of file Solver.hpp.

◆ solver_config

template<class Tvec, template< class > class SPHKernel>
Config shammodels::gsph::Solver< Tvec, SPHKernel >::solver_config

Definition at line 88 of file Solver.hpp.

◆ storage

template<class Tvec, template< class > class SPHKernel>
SolverStorage<Tvec, u_morton> shammodels::gsph::Solver< Tvec, SPHKernel >::storage {}

Definition at line 86 of file Solver.hpp.


The documentation for this class was generated from the following files: