|
core
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 |
Public Member Functions | |
| void | init (const Octree &t, Real h0, Vec< 3 > origin=Vec< 3 >{}) |
| 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.
|
inline |
Definition at line 86 of file cut_cell.hpp.
|
inline |
Definition at line 94 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 95 of file cut_cell.hpp.
|
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 99 of file cut_cell.hpp.
|
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 101 of file cut_cell.hpp.
|
inline |
Definition at line 102 of file cut_cell.hpp.
|
inline |
Definition at line 103 of file cut_cell.hpp.
|
inline |
α=1 C/F ∇² geometry for regular cells
Definition at line 108 of file cut_cell.hpp.
|
inline |
per-cell SDF sample (build Pass 1)
Definition at line 111 of file cut_cell.hpp.
|
inline |
n·6 periodic face-neighbour indices
Definition at line 114 of file cut_cell.hpp.
|
inline |
Definition at line 115 of file cut_cell.hpp.
|
inline |
Definition at line 116 of file cut_cell.hpp.
|
inline |
Definition at line 117 of file cut_cell.hpp.
|
inline |
n·6 ξ-overlay off-diagonals
Definition at line 118 of file cut_cell.hpp.
|
inline |
Definition at line 119 of file cut_cell.hpp.
|
inline |
Definition at line 120 of file cut_cell.hpp.
Referenced by peclet::core::amr::AmrCutCell< Bits >::build().
|
inline |
Definition at line 121 of file cut_cell.hpp.
|
inline |
buildCutStencil's β (= mu_/h0²)
Definition at line 122 of file cut_cell.hpp.
Referenced by peclet::core::amr::AmrCutCell< Bits >::build(), and peclet::core::amr::AmrCutCell< Bits >::buildCutStencil().
|
inline |
Definition at line 123 of file cut_cell.hpp.
|
inline |
Definition at line 124 of file cut_cell.hpp.
|
inline |
Definition at line 125 of file cut_cell.hpp.
|
inline |
Definition at line 126 of file cut_cell.hpp.
|
inline |
Definition at line 127 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 133 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(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
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 218 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(), and peclet::core::amr::AmrCutCell< Bits >::Assembled::start.
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 282 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(), and peclet::core::amr::AmrCutCell< Bits >::Assembled::start.
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 294 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::faceCsrApplyRow(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
inline |
Definition at line 304 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::faceCsrApplyRow(), peclet::core::amr::AmrCutCell< Bits >::hostOp(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
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 324 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(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
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 344 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
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 384 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
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 440 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
inline |
Definition at line 455 of file cut_cell.hpp.
References peclet::core::amr::AmrCutCell< Bits >::applyOpGeometric(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
inline |
Definition at line 469 of file cut_cell.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), and peclet::core::amr::AmrCutCell< Bits >::numLeaves().
|
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 516 of file cut_cell.hpp.
|
inline |
Definition at line 520 of file cut_cell.hpp.
|
inlinestatic |
Definition at line 536 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(), and peclet::core::amr::cc::poly_Nc().
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.