26#ifndef PECLET_CORE_AMR_MOMENTUM_ASSEMBLY_HPP
27#define PECLET_CORE_AMR_MOMENTUM_ASSEMBLY_HPP
29#ifdef PECLET_CORE_HAVE_MORTON
59template <
unsigned Bits = 21u>
78 const std::size_t
s =
static_cast<std::size_t
>(
i);
80 for (
int k = 0; k < 6; ++k) {
81 const double a =
off(
s * 6 + k);
89 const double invV = 1.0 /
geom.cellVolume(
i);
109 const double invV = 1.0 /
geom.cellVolume(
i);
126template <
unsigned Bits>
130 Kokkos::parallel_for(
132 const std::size_t
s =
static_cast<std::size_t
>(
i);
135 for (
int k = 0; k < 6; ++k)
136 off(
s * 6 + k) = 0.0;
143 for (
int k = 0; k < 6; ++k) {
144 const Index j = nbr6(
s * 6 + k);
151 for (
int k = 0; k < 6; ++k)
157 for (
int k = 0; k < 6; ++k)
158 off(
s * 6 + k) =
offl[k];
168template <
unsigned Bits>
172 const double beta =
ccop.beta();
173 const double AC0 =
ccop.idiag() + 6.0 * beta;
179 View<double> AC(Kokkos::view_alloc(
"mom::AC", Kokkos::WithoutInitializing),
180 static_cast<std::size_t
>(n));
181 View<double> off(Kokkos::view_alloc(
"mom::off", Kokkos::WithoutInitializing),
182 static_cast<std::size_t
>(n) * 6);
183 View<char> cut(Kokkos::view_alloc(
"mom::cut", Kokkos::WithoutInitializing),
184 static_cast<std::size_t
>(n));
185 View<double> rscale(Kokkos::view_alloc(
"mom::rscale", Kokkos::WithoutInitializing),
186 static_cast<std::size_t
>(n));
192 geom.
h0 =
ccop.lap().h0();
195 for (
int d = 0; d < 3; ++d)
204 emit.rscale = rscale;
225 op.
diag =
View<double>(Kokkos::view_alloc(
"mom::diag", Kokkos::WithoutInitializing),
226 static_cast<std::size_t
>(n));
static MORTON_HD void buildCutStencil(double sdf_c, const double sdf_n[6], double beta, double AC0, double &ACout, double off[6], double &rscaleOut, double &inhomOut)
MomentumOp assembleMomentum(const AmrCutCell< Bits > &ccop, const BlockOctreeView< 3, Bits > &ov, bool scaleAdvByRscale=false)
Assemble the MomentumOp entirely on the device from a built host AmrCutCell + a device octree view.
Csr buildFaceCsr(Index n, const Emit &emit)
Build a face-CSR on device from a per-cell emit functor.
void rebuildCutStencil(Index n, double beta, double AC0, const View< double > &sdfC, const View< Index > &nbr6, const View< char > &fluid, View< double > AC, View< double > off, View< char > cut, View< double > rscale)
The per-cell ξ-overlay rebuild (build() Pass 2) on device: from the staged cell SDF + neighbour indic...
View< T > toDevice(const std::vector< T > &h, const std::string &label)
Upload a host std::vector into a freshly-sized device View (empty vector => empty view).
Kokkos::View< T *, MemSpace > View
1D device array.
std::int64_t Index
Signed index type for grids and particles (supersedes block_decomposer's long int IndxT).
An assembled face-CSR: row offsets (size n+1), neighbour index + coefficient per face (size nFaces).
Coord fineExt[Dim]
periodic-wrap modulus per axis
View_t ov
device octree (codes/levels/locate)
Device-callable reproduction of AmrCutCell::assembleOperator's per-cell row + diagonal.
View< const Index > advNbr
View< const Index > nbr6
n·6 periodic face-neighbour indices (cut-stencil order)
View< const double > rscale
off is n·6 (ξ-overlay), AC/rscale are n
View< const double > advDiag
View< const double > advCoef
double diag(Index i) const
Diagonal of row i: 1 (solid), AC (cut), or idiag + μ·invV·Σ(a·c) (regular), plus folded advection.
double cellVolume(Index i) const
FvFaceEmit< 3, Bits > geom
α=1 (hasOpen=false) C/F-aware ∇² traversal for regular fluid cells
void operator()(Index i, Sink &sink) const
Emit the off-diagonal entries of row i (S1 fill order): ξ-overlay for cut cells, −μ·invV·(a·c) for re...
View< const Index > advStart
Sink adapter: forwards each face from the FvFaceEmit traversal as (j, factor·coef) to the real CSR si...
void operator()(Index j, double c) const
Sink that just sums the geometric coeffs of a cell's faces (Σ a·c for the regular diagonal).
void operator()(Index, double c)
Assembled momentum operator on the device: (A u)_i = diag_i u_i + Σ coef·u[nbr], with an optional imp...
View< double > diag
size n
View< Index > faceNbr
neighbour leaf per off-diagonal, size nnz
View< double > faceCoef
off-diagonal coefficient, size nnz
View< Index > faceStart
CSR row offsets, size n+1.