28#ifndef OPENSWMM_ENGINE_2D_GPU_CVODE_KOKKOS_SURFACE_SOLVER_HPP
29#define OPENSWMM_ENGINE_2D_GPU_CVODE_KOKKOS_SURFACE_SOLVER_HPP
34#include <nvector/nvector_kokkos.hpp>
35#include <sundials/sundials_context.h>
36#include <sundials/sundials_linearsolver.h>
37#include <sundials/sundials_types.h>
50using VecType = ::sundials::kokkos::Vector<ExecSpace>;
52#if defined(OPENSWMM_HAVE_HYPRE)
64#if defined(OPENSWMM_HAVE_HYPRE)
82 double advance(
double t_current,
double t_target)
override;
88 bool is_initialized() const noexcept
override {
return cvode_mem_ !=
nullptr; }
92 SUNContext sun_ctx_ =
nullptr;
93 void* cvode_mem_ =
nullptr;
94 SUNLinearSolver ls_ =
nullptr;
95 std::unique_ptr<VecType> y_;
96 std::unique_ptr<VecType> abstol_;
109#if defined(OPENSWMM_HAVE_HYPRE)
110 std::unique_ptr<KokkosAmgPreconditioner> amg_precond_;
115 long last_nsteps_ = 0;
116 double last_h_ = 0.0;
120 void uploadSources();
121 void uploadBoundaryStatic();
122 void uploadBoundaryDynamic();
123 void seedVolumeFromHead();
124 void downloadState();
127 static int rhs_cb(sunrealtype t, N_Vector
y, N_Vector ydot,
void* user_data);
128 static int psetup_cb(sunrealtype t, N_Vector
y, N_Vector fy,
129 sunbooleantype jok, sunbooleantype* jcurPtr,
130 sunrealtype gamma,
void* user_data);
131 static int psolve_cb(sunrealtype t, N_Vector
y, N_Vector fy,
132 N_Vector r, N_Vector z,
133 sunrealtype gamma, sunrealtype delta,
int lr,
Backend-neutral interface for the 2D surface-routing time integrator.
Performance-portable RHS pipeline for the 2D surface router (Phase 1).
Abstract time integrator for the 2D surface-routing ODE system.
Definition ISurfaceSolver.hpp:49
void reinitialize(double t0) override
Reinitialize the integrator at t0 after external state edits.
Definition CvodeKokkosSurfaceSolver.cpp:389
~CvodeKokkosSurfaceSolver() override
Definition CvodeKokkosSurfaceSolver.cpp:238
CvodeKokkosSurfaceSolver(const CvodeKokkosSurfaceSolver &)=delete
long last_num_steps() const noexcept override
Number of internal integrator steps in the last advance() call.
Definition CvodeKokkosSurfaceSolver.hpp:86
CvodeKokkosSurfaceSolver()
bool is_initialized() const noexcept override
True once initialize() has completed and the solver is ready.
Definition CvodeKokkosSurfaceSolver.hpp:88
CvodeKokkosSurfaceSolver & operator=(const CvodeKokkosSurfaceSolver &)=delete
double last_step_size() const noexcept override
Last internal step size used by the integrator.
Definition CvodeKokkosSurfaceSolver.hpp:87
void finalize() override
Release all backend resources.
Definition CvodeKokkosSurfaceSolver.cpp:403
void initialize(MeshData &mesh, SurfaceStateData &state, SolverOptions2D &opts) override
One-time setup. mesh and state must outlive the solver.
Definition CvodeKokkosSurfaceSolver.cpp:242
double advance(double t_current, double t_target) override
Definition CvodeKokkosSurfaceSolver.cpp:369
BoomerAMG preconditioner over the Kokkos surface Newton matrix.
Definition KokkosAmgPreconditioner.hpp:40
Definition ArkodeKokkosSurfaceSolver.cpp:29
::sundials::kokkos::Vector< ExecSpace > VecType
SUNDIALS Kokkos vector specialised on the default execution space.
Definition ArkodeKokkosSurfaceSolver.hpp:47
Definition NodeCoupling.cpp:15
double * y
Definition odesolve.c:28
SoA storage for 2D triangular mesh geometry and topology.
Definition MeshData.hpp:34
Configuration for the 2D surface routing CVODE solver.
Definition SolverOptions2D.hpp:132
Definition SurfaceStateData.hpp:41
Context handed to the CVODE callbacks via CVodeSetUserData().
Definition CvodeKokkosSurfaceSolver.hpp:57
MeshViews * mesh
Definition CvodeKokkosSurfaceSolver.hpp:58
double limiter_eps
Definition CvodeKokkosSurfaceSolver.hpp:61
double flux_dh_eps
√|Δη| regularization (FLUX_DH_EPS)
Definition CvodeKokkosSurfaceSolver.hpp:62
StateViews * state
Definition CvodeKokkosSurfaceSolver.hpp:59
bool prec_diag_built
Jacobi diagonal cached (lag reuse)
Definition CvodeKokkosSurfaceSolver.hpp:63
double dry_depth
Definition CvodeKokkosSurfaceSolver.hpp:60
Immutable mesh geometry/topology mirrored to device once at initialize().
Definition KokkosSurfaceKernels.hpp:87
Mutable per-step state mirrored on device.
Definition KokkosSurfaceKernels.hpp:102