|
core 0.5.0
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
|
#include <cut_cell.hpp>
Classes | |
| struct | Assembled |
| The assembled linear operator A as a per-cell diagonal + face CSR: (A u)_i = diag[i]·u_i + Σ_{k∈[start[i],start[i+1])} coef[k]·u[nbr[k]]. More... | |
Public Types | |
| using | Octree = BlockOctree< 3, Bits > |
| using | M = typename Octree::M |
| using | Code = typename Octree::Code |
| using | Coord = typename Octree::Coord |
| using | ExtResolver = typename AmrPoisson< 3, Bits >::ExtResolver |
Public Member Functions | |
| void | init (const Octree &t, Real h0, Vec< 3 > origin=Vec< 3 >{}) |
| void | setResolver (ExtResolver r) |
| void | setGhosts (std::vector< std::array< long, 3 > > lo, std::vector< unsigned > lv) |
| Ghost slots [n, n+nGhost): block-local lo (longs) + covering-leaf level. | |
| Index | numGhosts () const |
| void | setFrameShift (const std::array< long, 3 > &s) |
| Index | numLeaves () const |
| bool | isFluid (Index i) const |
| bool | isCut (Index i) const |
| True for a cut cell: a fluid cell with at least one solid face neighbour (the row-scaled ξ-overlay band). | |
| Index | neighborOf (Index i, int k) const |
| Periodic face neighbour of leaf i in direction k (0=+x,1=-x,2=+y,3=-y,4=+z,5=-z). | |
| double | kappa (Index i) const |
| double | rhsScale (Index i) const |
| const AmrPoisson< 3, Bits > & | lap () const |
| α=1 C/F ∇² geometry for regular cells | |
| const std::vector< double > & | sdfCRaw () const |
| per-cell SDF sample (build Pass 1) | |
| const std::vector< Index > & | nbRaw () const |
| n·6 periodic face-neighbour indices | |
| const std::vector< char > & | fluidRaw () const |
| const std::vector< char > & | cutRaw () const |
| const std::vector< double > & | acRaw () const |
| const std::vector< double > & | offRaw () const |
| n·6 ξ-overlay off-diagonals | |
| const std::vector< double > & | rscaleRaw () const |
| double | idiag () const |
| double | mu () const |
| double | beta () const |
| buildCutStencil's β (= mu_/h0²) | |
| bool | hasAdv () const |
| const std::vector< double > & | advDiagRaw () const |
| const std::vector< double > & | advCoefRaw () const |
| const std::vector< Index > & | advStartRaw () const |
| const std::vector< Index > & | advNbrRaw () const |
| template<class SdfFn > | |
| void | build (SdfFn &&sdfFn, double idiag=0.0, double beta=1.0, int nsub=4) |
| Build the cut-cell stencils from an SDF callable sdfFn(worldPoint) (>0 fluid, <0 solid). | |
| Assembled | assembleOperator (bool scaleAdvByRscale=false) const |
scaleAdvByRscale (default false ⇒ reproduces applyOp/gaussSeidel exactly, for the matvec test): when true, the implicit-FOU advection is multiplied by the cut-cell D_rescale row scale, so the entire cut-cell row (base + advection) is scaled consistently. | |
| FaceCsrOpT< HostArr< double >, HostArr< Index > > | hostOp (const Assembled &A) const |
| View a host Assembled as a backend-agnostic FaceCsrOpT for the shared row kernels. | |
| void | applyOp (const std::vector< double > &u, std::vector< double > &out) const |
| out = A u, via the shared kernel over the assembled CSR (== device applyMom arithmetic). | |
| double | residual (const std::vector< double > &u, const std::vector< double > &b, std::vector< double > &res) const |
| void | gaussSeidel (std::vector< double > &u, const std::vector< double > &b, int sweeps) const |
sweeps true serial Gauss–Seidel sweeps (ω=1, in place) over the assembled CSR using the shared point-update kernel — the host counterpart of the device multicolour GS, same per-cell formula. | |
| void | applyOpGeometric (const std::vector< double > &u, std::vector< double > &out) const |
| Geometric operator apply (walks the octree live) — the INDEPENDENT reference encoding, kept as the test oracle for the assembled CSR (and hence the device kernels). | |
| void | buildAdvectionFou (const std::array< std::vector< double >, 3 > &uadv, double rho, const std::vector< double > &uf, const std::vector< Index > &faceStart, bool useFace) |
Build the implicit first-order-upwind advection operator from a (lagged) advecting velocity field uadv (3 components, cell-centred), scaled by rho. | |
| std::vector< double > | makeRhs (const std::vector< double > &src, double u_bc) const |
Effective RHS for source src (≈ -h^2 f at cell centres) and wall value u_bc: row-scaled by D_rescale and shifted by the inhomogeneous boundary term. | |
| double | residualGeometric (const std::vector< double > &u, const std::vector< double > &b, std::vector< double > &res) const |
| void | gaussSeidelGeometric (std::vector< double > &u, const std::vector< double > &b, int sweeps) const |
| double | fouApply (Index i, const std::vector< double > &field) const |
The implicit-FOU advection operator applied to field at leaf i: advDiag·field_i + Σ_csr coef·field_nbr (= ρ·∇·(u_adv field) FOU). | |
| bool | hasAdvection () const |
Static Public Member Functions | |
| 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) |
Static Public Attributes | |
| static constexpr int | Dim = 3 |
| static constexpr int | OPP [6] = {1, 0, 3, 2, 5, 4} |
Definition at line 75 of file cut_cell.hpp.
| using peclet::core::amr::AmrCutCell< Bits >::Octree = BlockOctree<3, Bits> |
Definition at line 78 of file cut_cell.hpp.
Definition at line 79 of file cut_cell.hpp.
| using peclet::core::amr::AmrCutCell< Bits >::Code = typename Octree::Code |
Definition at line 80 of file cut_cell.hpp.
| using peclet::core::amr::AmrCutCell< Bits >::Coord = typename Octree::Coord |
Definition at line 81 of file cut_cell.hpp.
| using peclet::core::amr::AmrCutCell< Bits >::ExtResolver = typename AmrPoisson<3, Bits>::ExtResolver |
Definition at line 102 of file cut_cell.hpp.
|
inline |
Definition at line 86 of file cut_cell.hpp.
|
inline |
Definition at line 103 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Ghost slots [n, n+nGhost): block-local lo (longs) + covering-leaf level.
build() fills their sdfC/fluid metadata from the same world SdfFn (sampled at the ghost cell centre in the global frame — identical to the owner's sample).
Definition at line 107 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 111 of file cut_cell.hpp.
Referenced by peclet::core::amr::AmrCutCell< Bits >::build().
|
inline |
Definition at line 112 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 114 of file cut_cell.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::AmrCutCell< Bits >::applyOp(), peclet::core::amr::AmrCutCell< Bits >::applyOpGeometric(), peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::AmrCutCell< Bits >::build(), peclet::core::amr::AmrCutCell< Bits >::buildAdvectionFou(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidel(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidelGeometric(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), peclet::core::amr::AmrCutCell< Bits >::makeRhs(), peclet::core::amr::AmrCutCell< Bits >::residual(), and peclet::core::amr::AmrCutCell< Bits >::residualGeometric().
|
inline |
Definition at line 115 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
True for a cut cell: a fluid cell with at least one solid face neighbour (the row-scaled ξ-overlay band).
Its residual is D_rescale-scaled / inconsistent, so it is excluded from the velocity-MG coarse defect (the clean-fluid mask — see VelocityMG).
Definition at line 119 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Periodic face neighbour of leaf i in direction k (0=+x,1=-x,2=+y,3=-y,4=+z,5=-z).
Definition at line 121 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 122 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 123 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
α=1 C/F ∇² geometry for regular cells
Definition at line 128 of file cut_cell.hpp.
|
inline |
per-cell SDF sample (build Pass 1)
Definition at line 131 of file cut_cell.hpp.
|
inline |
n·6 periodic face-neighbour indices
Definition at line 134 of file cut_cell.hpp.
|
inline |
Definition at line 135 of file cut_cell.hpp.
|
inline |
Definition at line 136 of file cut_cell.hpp.
|
inline |
Definition at line 137 of file cut_cell.hpp.
|
inline |
n·6 ξ-overlay off-diagonals
Definition at line 138 of file cut_cell.hpp.
|
inline |
Definition at line 139 of file cut_cell.hpp.
|
inline |
Definition at line 140 of file cut_cell.hpp.
Referenced by peclet::core::amr::AmrCutCell< Bits >::build().
|
inline |
Definition at line 141 of file cut_cell.hpp.
|
inline |
buildCutStencil's β (= mu_/h0²)
Definition at line 142 of file cut_cell.hpp.
Referenced by peclet::core::amr::AmrCutCell< Bits >::build(), and peclet::core::amr::AmrCutCell< Bits >::buildCutStencil().
|
inline |
Definition at line 143 of file cut_cell.hpp.
|
inline |
Definition at line 144 of file cut_cell.hpp.
|
inline |
Definition at line 145 of file cut_cell.hpp.
|
inline |
Definition at line 146 of file cut_cell.hpp.
|
inline |
Definition at line 147 of file cut_cell.hpp.
|
inline |
Build the cut-cell stencils from an SDF callable sdfFn(worldPoint) (>0 fluid, <0 solid).
Operator A = idiag*I - beta*Laplacian (grid units, dx=1). nsub is the per-axis subsampling for the volume fraction κ.
Definition at line 153 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::beta(), peclet::core::amr::AmrCutCell< Bits >::buildCutStencil(), peclet::core::amr::AmrCutCell< Bits >::idiag(), peclet::core::amr::AmrPoisson< Dim, Bits >::init(), peclet::core::amr::AmrCutCell< Bits >::numGhosts(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), peclet::core::amr::AmrPoisson< Dim, Bits >::setFrameShift(), peclet::core::amr::AmrPoisson< Dim, Bits >::setGhosts(), peclet::core::amr::AmrPoisson< Dim, Bits >::setResolver(), and peclet::core::amr::transferFieldGradients().
|
inline |
scaleAdvByRscale (default false ⇒ reproduces applyOp/gaussSeidel exactly, for the matvec test): when true, the implicit-FOU advection is multiplied by the cut-cell D_rescale row scale, so the entire cut-cell row (base + advection) is scaled consistently.
applyOp scales the base + RHS but not the advection — fine for the host serial GS (which gives a bounded approximation) but the inconsistency leaves a (1−rscale)/rscale·FOU amplification in the exact solution that blows up an accurate device solve at thin cut cells. With the advection scaled, the row is the unscaled equation × rscale and the implicit FOU cancels the (rscale-scaled) explicit deferred-correction FOU at steady state. The collocated device flow uses this; regular fluid cells (rscale=1) are unchanged.
Definition at line 257 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrCutCell< Bits >::Assembled::coef, peclet::core::amr::AmrCutCell< Bits >::Assembled::diag, peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::AmrCutCell< Bits >::Assembled::nbr, peclet::core::amr::AmrCutCell< Bits >::numLeaves(), peclet::core::amr::AmrCutCell< Bits >::Assembled::start, and peclet::core::amr::transferFieldGradients().
Referenced by peclet::core::amr::AmrCutCell< Bits >::applyOp(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidel(), and peclet::core::amr::AmrCutCell< Bits >::residual().
|
inline |
View a host Assembled as a backend-agnostic FaceCsrOpT for the shared row kernels.
Definition at line 321 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::Assembled::coef, peclet::core::amr::AmrCutCell< Bits >::Assembled::diag, peclet::core::amr::AmrCutCell< Bits >::Assembled::nbr, peclet::core::amr::AmrCutCell< Bits >::numLeaves(), peclet::core::amr::AmrCutCell< Bits >::Assembled::start, and peclet::core::amr::transferFieldGradients().
Referenced by peclet::core::amr::AmrCutCell< Bits >::applyOp(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidel(), and peclet::core::amr::AmrCutCell< Bits >::residual().
|
inline |
out = A u, via the shared kernel over the assembled CSR (== device applyMom arithmetic).
Definition at line 333 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::faceCsrApplyRow(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 343 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::faceCsrApplyRow(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
sweeps true serial Gauss–Seidel sweeps (ω=1, in place) over the assembled CSR using the shared point-update kernel — the host counterpart of the device multicolour GS, same per-cell formula.
Definition at line 363 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::faceCsrOffDiag(), peclet::core::amr::faceCsrPointUpdate(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
Geometric operator apply (walks the octree live) — the INDEPENDENT reference encoding, kept as the test oracle for the assembled CSR (and hence the device kernels).
The runtime applyOp below routes through the shared face_csr.hpp kernels instead, so host and device run identical arithmetic; test_amr_cut_cell asserts the two agree. out = A u. A = idiag·I − μ∇² (C/F-aware) on regular fluid cells; the ξ-overlay stencil on cut cells (finest, same-level); identity on solid cells (held at u_bc).
Definition at line 383 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
Referenced by peclet::core::amr::AmrCutCell< Bits >::residualGeometric().
|
inline |
Build the implicit first-order-upwind advection operator from a (lagged) advecting velocity field uadv (3 components, cell-centred), scaled by rho.
C/F-conservative: each face (incl. the 2^(Dim-1) fine sub-faces of a coarse cell, via forEachFaceFull) contributes (1/V)·A·velOut·ρ to the diagonal (outflow) or to a CSR off-diagonal toward the upstream neighbour (inflow); the advecting velocity at a wall (solid neighbour) face is zero (no flow through the immersed boundary). Rebuilt per step. Stable base of the deferred correction. uf/faceStart (+axis face velocity per forEachFaceFull (sub)face, when useFace) is the divergence-free advecting velocity; otherwise the cell average ½(uadv_i+uadv_j) is used (before the first projection has built uf). The implicit FOU and the explicit deferred correction must use the SAME velocity, hence it lives here too — not only in the high-order term.
Definition at line 423 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
Effective RHS for source src (≈ -h^2 f at cell centres) and wall value u_bc: row-scaled by D_rescale and shifted by the inhomogeneous boundary term.
Definition at line 479 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 494 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::applyOpGeometric(), peclet::core::amr::AmrCutCell< Bits >::numLeaves(), and peclet::core::amr::transferFieldGradients().
|
inline |
The implicit-FOU advection operator applied to field at leaf i: advDiag·field_i + Σ_csr coef·field_nbr (= ρ·∇·(u_adv field) FOU).
Used by the flow solver for the explicit deferred-correction term (high-order − this).
Definition at line 555 of file cut_cell.hpp.
References peclet::core::amr::transferFieldGradients().
|
inline |
Definition at line 559 of file cut_cell.hpp.
|
inlinestatic |
Definition at line 575 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::beta(), peclet::core::amr::cc::poly_abs(), peclet::core::amr::cc::poly_D(), peclet::core::amr::cc::poly_D_sandwich(), peclet::core::amr::cc::poly_N_c_sandwich(), peclet::core::amr::cc::poly_N_nb(), peclet::core::amr::cc::poly_Nbc(), peclet::core::amr::cc::poly_Nbc_mp_sw(), peclet::core::amr::cc::poly_Nbc_pp_sw(), peclet::core::amr::cc::poly_Nc(), and peclet::core::amr::transferFieldGradients().
Referenced by peclet::core::amr::AmrCutCell< Bits >::build(), and peclet::core::amr::rebuildCutStencil().
|
staticconstexpr |
Definition at line 77 of file cut_cell.hpp.
|
staticconstexpr |
Definition at line 84 of file cut_cell.hpp.