25#ifndef PECLET_AMR_MOMENTUM_ASSEMBLY_HPP
26#define PECLET_AMR_MOMENTUM_ASSEMBLY_HPP
34#include "peclet/core/common/view.hpp"
57template <
unsigned Bits = 21u>
76 const std::size_t
s =
static_cast<std::size_t
>(
i);
78 for (
int k = 0; k < 6; ++k) {
79 const double a =
off(
s * 6 + k);
87 const double invV = 1.0 /
geom.cellVolume(
i);
107 const double invV = 1.0 /
geom.cellVolume(
i);
124template <
unsigned Bits>
133 Kokkos::parallel_for(
135 const double f =
static_cast<double>(
Index(1) << levels(
i));
136 const double inv = 1.0 / (
f *
f);
138 const double AC0 =
id0 + ((2.0 * beta[0] + 2.0 * beta[1]) + 2.0 * beta[2]);
139 const std::size_t
s =
static_cast<std::size_t
>(
i);
142 for (
int k = 0; k < 6; ++k)
143 off(
s * 6 + k) = 0.0;
150 for (
int k = 0; k < 6; ++k) {
151 const Index j = nbr6(
s * 6 + k);
158 for (
int k = 0; k < 6; ++k)
159 offl[k] = -beta[k / 2];
164 for (
int k = 0; k < 6; ++k)
165 off(
s * 6 + k) =
offl[k];
175template <
unsigned Bits>
187 View<double> AC(Kokkos::view_alloc(
"mom::AC", Kokkos::WithoutInitializing),
188 static_cast<std::size_t
>(n));
189 View<double> off(Kokkos::view_alloc(
"mom::off", Kokkos::WithoutInitializing),
190 static_cast<std::size_t
>(n) * 6);
191 View<char> cut(Kokkos::view_alloc(
"mom::cut", Kokkos::WithoutInitializing),
192 static_cast<std::size_t
>(n));
193 View<double> rscale(Kokkos::view_alloc(
"mom::rscale", Kokkos::WithoutInitializing),
194 static_cast<std::size_t
>(n));
195 rebuildCutStencil<Bits>(n, beta,
ccop.idiag(),
sdfC, nbr6, fluid, ov.
levels, AC, off, cut,
201 for (
int d = 0; d < 3; ++d)
202 geom.
h0[d] =
ccop.lap().h0()[d];
205 for (
int d = 0; d < 3; ++d)
214 emit.rscale = rscale;
231 op.faceStart =
csr.start;
232 op.faceNbr =
csr.nbr;
233 op.faceCoef =
csr.coef;
235 op.diag =
View<double>(Kokkos::view_alloc(
"mom::diag", Kokkos::WithoutInitializing),
236 static_cast<std::size_t
>(n));
static void buildCutStencil(double sdf_c, const double sdf_n[6], const double beta[3], double AC0, double &ACout, double off[6], double &rscaleOut, double &inhomOut)
Phase 3: beta[3] — the viscous coefficient of each AXIS; face k uses beta[k/2].
void rebuildCutStencil(Index n, const double betaIn[3], double idiag, const View< double > &sdfC, const View< Index > &nbr6, const View< char > &fluid, const View< std::uint8_t > &levels, 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...
Csr buildFaceCsr(Index n, const Emit &emit)
Build a face-CSR on device from a per-cell emit functor.
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.
std::vector< std::array< double, Dim > > transferFieldGradients(const BlockOctree< Dim, Bits > &oldT, const std::vector< double > &oldF)
Per-old-leaf minmod prolongation gradients (per fine-coordinate unit) — transferField's stencil,...
Device mirror of a BlockOctree's leaf arrays + device-callable queries.
View< std::uint8_t > levels
An assembled face-CSR: row offsets (size n+1), neighbour index + coefficient per face (size nFaces).
Device-callable reproduction of AmrPoisson's per-cell face walk + geometry.
Coord fineExt[Dim]
periodic-wrap modulus per axis
View_t ov
device octree (codes/levels/locate)
Real h0[Dim]
finest cell width PER AXIS (Phase 3); set by the emitters
Device-callable reproduction of AmrCutCell::assembleOperator's per-cell row + diagonal.
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 > advNbr
View< const Index > nbr6
n·6 periodic face-neighbour indices (cut-stencil order)
View< const Index > advStart
double diag(Index i) const
Diagonal of row i: 1 (solid), AC (cut), or idiag + μ·invV·Σ(a·c) (regular), plus folded advection.
View< const double > advCoef
FvFaceEmit< 3, Bits > geom
α=1 (hasOpen=false) C/F-aware ∇² traversal for regular fluid cells
double cellVolume(Index i) const
View< const double > advDiag
View< const double > rscale
off is n·6 (ξ-overlay), AC/rscale are n
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)