OpenSWMM Engine  6.0.0-alpha.1
Data-oriented, plugin-extensible SWMM Engine (6.0.0-alpha.1)
Loading...
Searching...
No Matches
KokkosSurfaceKernels.hpp File Reference

Performance-portable RHS pipeline for the 2D surface router (Phase 1). More...

#include <Kokkos_Core.hpp>
Include dependency graph for KokkosSurfaceKernels.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  openswmm::twoD::gpu::MeshViews
 Immutable mesh geometry/topology mirrored to device once at initialize(). More...
 
struct  openswmm::twoD::gpu::StateViews
 Mutable per-step state mirrored on device. More...
 

Namespaces

namespace  openswmm
 
namespace  openswmm::twoD
 
namespace  openswmm::twoD::gpu
 

Typedefs

using openswmm::twoD::gpu::ExecSpace = Kokkos::DefaultExecutionSpace
 
using openswmm::twoD::gpu::MemSpace = ExecSpace::memory_space
 
using openswmm::twoD::gpu::DView = Kokkos::View<double*, MemSpace>
 mutable double array
 
using openswmm::twoD::gpu::CDView = Kokkos::View<const double*, MemSpace>
 const double array
 
using openswmm::twoD::gpu::IView = Kokkos::View<int*, MemSpace>
 mutable int array
 
using openswmm::twoD::gpu::CIView = Kokkos::View<const int*, MemSpace>
 const int array
 

Enumerations

enum  : int {
  openswmm::twoD::gpu::BC_WALL = 0 ,
  openswmm::twoD::gpu::BC_NORMAL_FLOW = 1 ,
  openswmm::twoD::gpu::BC_SPECIFIED_STAGE = 2 ,
  openswmm::twoD::gpu::BC_SPECIFIED_FLOW = 3 ,
  openswmm::twoD::gpu::BC_RATING_CURVE = 4
}
 

Functions

KOKKOS_INLINE_FUNCTION double openswmm::twoD::gpu::evapSink (double rate, double depth, double dry_depth)
 Depth-limited evaporation sink (mirrors evapSink()).
 
KOKKOS_INLINE_FUNCTION double openswmm::twoD::gpu::sq (double x)
 
KOKKOS_INLINE_FUNCTION int openswmm::twoD::gpu::nbr_of (int e, int n0, int n1, int n2)
 
KOKKOS_INLINE_FUNCTION double openswmm::twoD::gpu::regSqrt (double x, double eps)
 
KOKKOS_INLINE_FUNCTION double openswmm::twoD::gpu::boundaryEdgeFlux (int bc, double slope, double h_bc, double q_flow, double depth, double head, double tri_cz, double area, double L, double n, double dh_eps)
 
void openswmm::twoD::gpu::evaluateRhs (const MeshViews &m, const StateViews &s, DView y, DView ydot, double dry_depth, double limiter_eps, double dh_eps)
 
void openswmm::twoD::gpu::precondSetup (const MeshViews &m, const StateViews &s)
 Build the per-cell diagonal D from the most recent edge fluxes/heads.
 
void openswmm::twoD::gpu::precondSolve (const StateViews &s, DView r, DView z, double gamma)
 Apply (I − γD)^{-1} element-wise: z = r / (1 − γ·D).
 

Detailed Description

Performance-portable RHS pipeline for the 2D surface router (Phase 1).

Faithful Kokkos translation of the serial finite-volume RHS in src/engine/2d/solver/SurfaceFluxCalculator.cpp and the Jacobi preconditioner in CvodeSurfaceSolver.cpp. The math is byte-for-byte the same as the CPU reference; only the loop structure changes from serial for to Kokkos::parallel_for, so the same source compiles to OpenMP (Phase 1), CUDA / HIP / SYCL (Phase 2+) by selecting the Kokkos execution space at build time.

IMPORTANT — this layout has NO cross-cell scatter. Each stage writes only the index it owns:

  • per-cell stages write cell i's slot,
  • the edge-flux stage writes cell i's own three edge slots [i*3+e] (edge flux is stored redundantly per incident cell),
  • assembly gathers cell i's own three edge slots. Gradient/limiter stages only read neighbours. So the pipeline is embarrassingly parallel and needs no atomics — the §2.4 scatter concern in docs/2D_GPU_PORTABLE_CVODE_STRATEGY.md does not arise for this data structure.

NOTE on stages: the vertex-head reconstruction and the gradient/limiter stages are recomputed each RHS call (as in the CPU path) to keep the diagnostic state fields current, even though the collapsed-FD edge flux does not consume them. Omitting them would still give an identical ydot, but we mirror the reference exactly.

Author
Caleb Buahin caleb.nosp@m..bua.nosp@m.hin@g.nosp@m.mail.nosp@m..com
License\n MIT License