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

The shamrock SPH model. More...

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

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

Classes

struct  SolverStepCallback

Public Types

using Tscal = shambase::VecComponent<Tvec>
using Kernel = SPHKernel<Tscal>
using Config = SolverConfig<Tvec, SPHKernel>
using u_morton = typename Config::u_morton
using GhostHandle = sph::BasicSPHGhostHandler<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", not solver_graph "dt").
Tscal & cfl_multiplier_edge_value ()
 Access synchronized CFL multiplier (scheduler edge "cfl_multiplier").
Tscal get_time ()
void set_time (Tscal t)
Tscal get_dt_sph ()
void set_next_dt (Tscal dt)
Tscal get_cfl_multipler ()
void set_cfl_multipler (Tscal lambda)
void ensure_time_state_edges ()
 Register time/dt/cfl_multiplier synchronized edges if missing (idempotent).
void init_required_fields ()
void gen_serial_patch_tree ()
void reset_serial_patch_tree ()
void gen_ghost_handler (Tscal time_val)
void reset_ghost_handler ()
void build_ghost_cache ()
 Builds ghost particle interface cache for inter-patch communication.
void clear_ghost_cache ()
 Clears ghost particle cache to free memory.
void merge_position_ghost ()
 Merges ghost particle positions from neighboring patches.
void build_merged_pos_trees ()
 Builds spatial BVH trees for merged positions including ghosts.
void clear_merged_pos_trees ()
 Clears merged position trees to free memory.
void compute_presteps_rint ()
 Computes maximum smoothing length in tree nodes for neighbor search.
void reset_presteps_rint ()
 Resets tree radius interval field.
void start_neighbors_cache ()
 Builds neighbor particle cache for SPH calculations.
void reset_neighbors_cache ()
 Resets neighbor cache.
void sph_prestep (Tscal time_val, Tscal dt)
 Performs pre-step operations for SPH timestep.
void apply_position_boundary (Tscal time_val)
 Applies position-based boundary conditions.
void update_artificial_viscosity (Tscal dt)
 Updates artificial viscosity coefficients for shock capturing.
void init_ghost_layout ()
 Initializes data layout for ghost particle fields.
void communicate_merge_ghosts_fields ()
 Communicates and merges ghost particle fields across processes.
void reset_merge_ghosts_fields ()
 Resets merged ghost field data.
void compute_eos_fields ()
 Computes equation of state fields (pressure, sound speed).
void reset_eos_fields ()
 Frees memory allocated for EOS fields.
void prepare_corrector ()
 Saves old derivative fields for predictor-corrector integration.
void update_derivs (Tscal dt_hydro)
 Updates time derivatives and applies external forces.
bool apply_corrector (Tscal dt, u64 Npart_all)
void update_sync_load_values ()
 Updates load balancing values and synchronizes patch ownership.
 Solver (ShamrockCtx &context)
void init_solver_graph ()
 Initializes the solver graph for computation pipeline.
void vtk_do_dump (std::string filename, bool add_patch_world_id)
 Writes VTK dump file for visualization.
void set_debug_dump (bool _do_debug_dump, std::string _debug_dump_filename)
void print_timestep_logs ()
TimestepLog evolve_once ()
 Performs one complete SPH timestep evolution.
Tscal evolve_once_time_expl (Tscal t_current, Tscal dt_input)
 Evolves system by one explicit timestep with specified time and dt.
EvolveUntilResults evolve_until (Tscal target_time, i32 niter_max, f64 max_walltime=-1)

Public Attributes

ShamrockCtx & context
SolverStorage< Tvec, u_morton > storage {}
Config solver_config
SolverLog solve_logs
std::vector< SolverStepCallback > timestep_callbacks {}

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::sph::Solver< Tvec, SPHKernel >

The shamrock SPH model.

Template Parameters
Tvec
SPHKernel

Definition at line 151 of file Solver.hpp.

Member Typedef Documentation

◆ Config

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

Definition at line 157 of file Solver.hpp.

◆ GhostHandle

template<class Tvec, template< class > class SPHKernel>
using shammodels::sph::Solver< Tvec, SPHKernel >::GhostHandle = sph::BasicSPHGhostHandler<Tvec>

Definition at line 243 of file Solver.hpp.

◆ GhostHandleCache

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

Definition at line 244 of file Solver.hpp.

◆ Kernel

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

Definition at line 155 of file Solver.hpp.

◆ RTree

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

Definition at line 301 of file Solver.hpp.

◆ Tscal

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

Definition at line 153 of file Solver.hpp.

◆ u_morton

template<class Tvec, template< class > class SPHKernel>
using shammodels::sph::Solver< Tvec, SPHKernel >::u_morton = typename Config::u_morton

Definition at line 159 of file Solver.hpp.

Constructor & Destructor Documentation

◆ Solver()

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

Definition at line 355 of file Solver.hpp.

Member Function Documentation

◆ apply_corrector()

template<class Tvec, template< class > class Kern>
bool shammodels::sph::Solver< Tvec, Kern >::apply_corrector ( Tscal dt,
u64 Npart_all )
Returns
true corrector is converged
false corrector is not converged

Definition at line 2454 of file Solver.cpp.

◆ apply_position_boundary()

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

Applies position-based boundary conditions.

Applies position boundary conditions to the particles.

Parameters
time_valthe current time value

Definition at line 1461 of file Solver.cpp.

Here is the call graph for this function:

◆ build_ghost_cache()

template<class Tvec, template< class > class Kern>
void shammodels::sph::Solver< Tvec, Kern >::build_ghost_cache ( )

Builds ghost particle interface cache for inter-patch communication.

Definition at line 1507 of file Solver.cpp.

◆ build_merged_pos_trees()

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

Builds spatial BVH trees for merged positions including ghosts.

Definition at line 1572 of file Solver.cpp.

Here is the call graph for this function:

◆ cfl_multiplier_edge_value()

template<class Tvec, template< class > class SPHKernel>
Tscal & shammodels::sph::Solver< Tvec, SPHKernel >::cfl_multiplier_edge_value ( )
inline

Access synchronized CFL multiplier (scheduler edge "cfl_multiplier").

Definition at line 188 of file Solver.hpp.

◆ clear_ghost_cache()

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

Clears ghost particle cache to free memory.

Definition at line 1523 of file Solver.cpp.

◆ clear_merged_pos_trees()

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

Clears merged position trees to free memory.

Definition at line 1577 of file Solver.cpp.

◆ communicate_merge_ghosts_fields()

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

Communicates and merges ghost particle fields across processes.

Definition at line 1918 of file Solver.cpp.

Here is the call graph for this function:

◆ compute_eos_fields()

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

Computes equation of state fields (pressure, sound speed).

Definition at line 2180 of file Solver.cpp.

Here is the call graph for this function:

◆ compute_presteps_rint()

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

Computes maximum smoothing length in tree nodes for neighbor search.

Definition at line 1847 of file Solver.cpp.

◆ dt_edge_value()

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

Access synchronized next dt (scheduler edge "dt", not solver_graph "dt").

Definition at line 180 of file Solver.hpp.

◆ ensure_time_state_edges()

template<class Tvec, template< class > class SPHKernel>
void shammodels::sph::Solver< Tvec, SPHKernel >::ensure_time_state_edges ( )
inline

Register time/dt/cfl_multiplier synchronized edges if missing (idempotent).

Definition at line 204 of file Solver.hpp.

◆ evolve_once()

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

Performs one complete SPH timestep evolution.

patch_rank_owner is automatically updated since it is just a lambda

must be after the mpi timer to not count the barrier of the system metrics

Definition at line 2466 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::sph::Solver< Tvec, SPHKernel >::evolve_once_time_expl ( Tscal t_current,
Tscal dt_input )
inline

Evolves system by one explicit timestep with specified time and dt.

Definition at line 378 of file Solver.hpp.

Here is the call graph for this function:

◆ evolve_until()

template<class Tvec, template< class > class SPHKernel>
EvolveUntilResults shammodels::sph::Solver< Tvec, SPHKernel >::evolve_until ( Tscal target_time,
i32 niter_max,
f64 max_walltime = -1 )
inline

Definition at line 385 of file Solver.hpp.

◆ gen_ghost_handler()

template<class Tvec, template< class > class SPHKernel>
void shammodels::sph::Solver< Tvec, SPHKernel >::gen_ghost_handler ( Tscal time_val)
inline

Definition at line 246 of file Solver.hpp.

◆ gen_serial_patch_tree()

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

Definition at line 1447 of file Solver.cpp.

◆ get_cfl_multipler()

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::sph::Solver< Tvec, SPHKernel >::get_cfl_multipler ( )
inline

Definition at line 200 of file Solver.hpp.

◆ get_dt_sph()

template<class Tvec, template< class > class SPHKernel>
Tscal shammodels::sph::Solver< Tvec, SPHKernel >::get_dt_sph ( )
inline

Definition at line 198 of file Solver.hpp.

◆ get_time()

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

Definition at line 196 of file Solver.hpp.

◆ init_ghost_layout()

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

Initializes data layout for ghost particle fields.

Definition at line 1832 of file Solver.cpp.

Here is the call graph for this function:

◆ init_required_fields()

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

Definition at line 236 of file Solver.hpp.

◆ init_solver_graph()

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

Initializes the solver graph for computation pipeline.

Definition at line 263 of file Solver.cpp.

Here is the call graph for this function:

◆ merge_position_ghost()

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

Merges ghost particle positions from neighboring patches.

Definition at line 1529 of file Solver.cpp.

Here is the call graph for this function:

◆ prepare_corrector()

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

Saves old derivative fields for predictor-corrector integration.

Definition at line 2192 of file Solver.cpp.

Here is the call graph for this function:

◆ print_timestep_logs()

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

Definition at line 367 of file Solver.hpp.

◆ reset_eos_fields()

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

Frees memory allocated for EOS fields.

Definition at line 2186 of file Solver.cpp.

Here is the call graph for this function:

◆ reset_ghost_handler()

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

Definition at line 290 of file Solver.hpp.

◆ reset_merge_ghosts_fields()

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

Resets merged ghost field data.

Definition at line 2160 of file Solver.cpp.

◆ reset_neighbors_cache()

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

Resets neighbor cache.

Definition at line 1913 of file Solver.cpp.

◆ reset_presteps_rint()

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

Resets tree radius interval field.

Definition at line 1884 of file Solver.cpp.

◆ reset_serial_patch_tree()

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

Definition at line 240 of file Solver.hpp.

◆ scheduler()

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

Definition at line 164 of file Solver.hpp.

◆ set_cfl_multipler()

template<class Tvec, template< class > class SPHKernel>
void shammodels::sph::Solver< Tvec, SPHKernel >::set_cfl_multipler ( Tscal lambda)
inline

Definition at line 201 of file Solver.hpp.

◆ set_debug_dump()

template<class Tvec, template< class > class SPHKernel>
void shammodels::sph::Solver< Tvec, SPHKernel >::set_debug_dump ( bool _do_debug_dump,
std::string _debug_dump_filename )
inline

Definition at line 363 of file Solver.hpp.

◆ set_next_dt()

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

Definition at line 199 of file Solver.hpp.

◆ set_time()

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

Definition at line 197 of file Solver.hpp.

◆ sph_prestep()

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

Performs pre-step operations for SPH timestep.

Definition at line 1583 of file Solver.cpp.

Here is the call graph for this function:

◆ start_neighbors_cache()

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

Builds neighbor particle cache for SPH calculations.

Definition at line 1889 of file Solver.cpp.

Here is the call graph for this function:

◆ time_edge_value()

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

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

Definition at line 172 of file Solver.hpp.

◆ update_artificial_viscosity()

template<class Tvec, template< class > class Kern>
void shammodels::sph::Solver< Tvec, Kern >::update_artificial_viscosity ( Tscal dt)

Updates artificial viscosity coefficients for shock capturing.

Definition at line 2169 of file Solver.cpp.

◆ update_derivs()

template<class Tvec, template< class > class Kern>
void shammodels::sph::Solver< Tvec, Kern >::update_derivs ( Tscal dt_hydro)

Updates time derivatives and applies external forces.

Definition at line 2288 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::sph::Solver< Tvec, Kern >::update_sync_load_values ( )

Updates load balancing values and synchronizes patch ownership.

Definition at line 2459 of file Solver.cpp.

◆ vtk_do_dump()

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

Writes VTK dump file for visualization.

Definition at line 1284 of file Solver.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ context

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

Definition at line 163 of file Solver.hpp.

◆ dim

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

Definition at line 154 of file Solver.hpp.

◆ Rkern

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

Definition at line 161 of file Solver.hpp.

◆ solve_logs

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

Definition at line 169 of file Solver.hpp.

◆ solver_config

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

Definition at line 168 of file Solver.hpp.

◆ storage

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

Definition at line 166 of file Solver.hpp.

◆ timestep_callbacks

template<class Tvec, template< class > class SPHKernel>
std::vector<SolverStepCallback> shammodels::sph::Solver< Tvec, SPHKernel >::timestep_callbacks {}

Definition at line 234 of file Solver.hpp.


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