25#ifndef OPENSWMM_ENGINE_2D_GPU_ARKODE_KOKKOS_SURFACE_SOLVER_HPP
26#define OPENSWMM_ENGINE_2D_GPU_ARKODE_KOKKOS_SURFACE_SOLVER_HPP
32#include <nvector/nvector_kokkos.hpp>
33#include <sundials/sundials_context.h>
34#include <sundials/sundials_linearsolver.h>
35#include <sundials/sundials_types.h>
47using VecType = ::sundials::kokkos::Vector<ExecSpace>;
70 double advance(
double t_current,
double t_target)
override;
76 bool is_initialized() const noexcept
override {
return arkode_mem_ !=
nullptr; }
79 SUNContext sun_ctx_ =
nullptr;
80 void* arkode_mem_ =
nullptr;
81 SUNLinearSolver ls_ =
nullptr;
82 std::unique_ptr<VecType> y_;
83 std::unique_ptr<VecType> abstol_;
99 long last_nsteps_ = 0;
100 double last_h_ = 0.0;
104 void uploadSources();
106 void downloadState();
108 static int fe_cb(sunrealtype t, N_Vector
y, N_Vector ydot,
void* user_data);
109 static int fi_cb(sunrealtype t, N_Vector
y, N_Vector ydot,
void* user_data);
110 static int psetup_cb(sunrealtype t, N_Vector
y, N_Vector fy,
111 sunbooleantype jok, sunbooleantype* jcurPtr,
112 sunrealtype gamma,
void* user_data);
113 static int psolve_cb(sunrealtype t, N_Vector
y, N_Vector fy,
114 N_Vector r, N_Vector z,
115 sunrealtype gamma, sunrealtype delta,
int lr,
Backend-neutral interface for the 2D surface-routing time integrator.
Performance-portable RHS + preconditioner for the local-inertial solver.
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
bool is_initialized() const noexcept override
True once initialize() has completed and the solver is ready.
Definition ArkodeKokkosSurfaceSolver.hpp:76
void finalize() override
Release all backend resources.
Definition ArkodeKokkosSurfaceSolver.cpp:286
ArkodeKokkosSurfaceSolver(const ArkodeKokkosSurfaceSolver &)=delete
void reinitialize(double t0) override
Reinitialize the integrator at t0 after external state edits.
Definition ArkodeKokkosSurfaceSolver.cpp:280
double advance(double t_current, double t_target) override
Definition ArkodeKokkosSurfaceSolver.cpp:263
long last_num_steps() const noexcept override
Number of internal integrator steps in the last advance() call.
Definition ArkodeKokkosSurfaceSolver.hpp:74
double last_step_size() const noexcept override
Last internal step size used by the integrator.
Definition ArkodeKokkosSurfaceSolver.hpp:75
~ArkodeKokkosSurfaceSolver() override
Definition ArkodeKokkosSurfaceSolver.cpp:186
ArkodeKokkosSurfaceSolver()
void initialize(MeshData &mesh, SurfaceStateData &state, SolverOptions2D &opts) override
One-time setup. mesh and state must outlive the solver.
Definition ArkodeKokkosSurfaceSolver.cpp:188
ArkodeKokkosSurfaceSolver & operator=(const ArkodeKokkosSurfaceSolver &)=delete
Definition ArkodeKokkosSurfaceSolver.cpp:29
::sundials::kokkos::Vector< ExecSpace > VecType
SUNDIALS Kokkos vector specialised on the default execution space.
Definition ArkodeKokkosSurfaceSolver.hpp:47
Kokkos::View< double *, MemSpace > DView
mutable double array
Definition KokkosSurfaceKernels.hpp:81
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 ARKStep callbacks via ARKodeSetUserData().
Definition ArkodeKokkosSurfaceSolver.hpp:50
DView prec_wq
[ne] friction-damped q-diagonal
Definition ArkodeKokkosSurfaceSolver.hpp:54
int nt
Definition ArkodeKokkosSurfaceSolver.hpp:56
InertialEdgeViews * edges
Definition ArkodeKokkosSurfaceSolver.hpp:53
double dry_depth
Definition ArkodeKokkosSurfaceSolver.hpp:55
MeshViews * mesh
Definition ArkodeKokkosSurfaceSolver.hpp:51
int ne
Definition ArkodeKokkosSurfaceSolver.hpp:57
StateViews * state
Definition ArkodeKokkosSurfaceSolver.hpp:52
Definition KokkosInertialKernels.hpp:34
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