core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::amr::AmrCutCell< Bits > Class Template Reference

#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< doublemakeRhs (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}
 

Detailed Description

template<unsigned Bits = 21u>
class peclet::core::amr::AmrCutCell< Bits >

Definition at line 75 of file cut_cell.hpp.

Member Typedef Documentation

◆ Octree

template<unsigned Bits = 21u>
using peclet::core::amr::AmrCutCell< Bits >::Octree = BlockOctree<3, Bits>

Definition at line 78 of file cut_cell.hpp.

◆ M

Definition at line 79 of file cut_cell.hpp.

◆ Code

Definition at line 80 of file cut_cell.hpp.

◆ Coord

Definition at line 81 of file cut_cell.hpp.

Member Function Documentation

◆ init()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::init ( const Octree t,
Real  h0,
Vec< 3 >  origin = Vec<3>{} 
)
inline

Definition at line 86 of file cut_cell.hpp.

◆ numLeaves()

◆ isFluid()

template<unsigned Bits = 21u>
bool peclet::core::amr::AmrCutCell< Bits >::isFluid ( Index  i) const
inline

Definition at line 95 of file cut_cell.hpp.

◆ isCut()

template<unsigned Bits = 21u>
bool peclet::core::amr::AmrCutCell< Bits >::isCut ( Index  i) const
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.

◆ neighborOf()

template<unsigned Bits = 21u>
Index peclet::core::amr::AmrCutCell< Bits >::neighborOf ( Index  i,
int  k 
) const
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.

◆ kappa()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::kappa ( Index  i) const
inline

Definition at line 102 of file cut_cell.hpp.

◆ rhsScale()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::rhsScale ( Index  i) const
inline

Definition at line 103 of file cut_cell.hpp.

◆ lap()

template<unsigned Bits = 21u>
const AmrPoisson< 3, Bits > & peclet::core::amr::AmrCutCell< Bits >::lap ( ) const
inline

α=1 C/F ∇² geometry for regular cells

Definition at line 108 of file cut_cell.hpp.

◆ sdfCRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::sdfCRaw ( ) const
inline

per-cell SDF sample (build Pass 1)

Definition at line 111 of file cut_cell.hpp.

◆ nbRaw()

template<unsigned Bits = 21u>
const std::vector< Index > & peclet::core::amr::AmrCutCell< Bits >::nbRaw ( ) const
inline

n·6 periodic face-neighbour indices

Definition at line 114 of file cut_cell.hpp.

◆ fluidRaw()

template<unsigned Bits = 21u>
const std::vector< char > & peclet::core::amr::AmrCutCell< Bits >::fluidRaw ( ) const
inline

Definition at line 115 of file cut_cell.hpp.

◆ cutRaw()

template<unsigned Bits = 21u>
const std::vector< char > & peclet::core::amr::AmrCutCell< Bits >::cutRaw ( ) const
inline

Definition at line 116 of file cut_cell.hpp.

◆ acRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::acRaw ( ) const
inline

Definition at line 117 of file cut_cell.hpp.

◆ offRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::offRaw ( ) const
inline

n·6 ξ-overlay off-diagonals

Definition at line 118 of file cut_cell.hpp.

◆ rscaleRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::rscaleRaw ( ) const
inline

Definition at line 119 of file cut_cell.hpp.

◆ idiag()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::idiag ( ) const
inline

Definition at line 120 of file cut_cell.hpp.

Referenced by peclet::core::amr::AmrCutCell< Bits >::build().

◆ mu()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::mu ( ) const
inline

Definition at line 121 of file cut_cell.hpp.

◆ beta()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::beta ( ) const
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().

◆ hasAdv()

template<unsigned Bits = 21u>
bool peclet::core::amr::AmrCutCell< Bits >::hasAdv ( ) const
inline

Definition at line 123 of file cut_cell.hpp.

◆ advDiagRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::advDiagRaw ( ) const
inline

Definition at line 124 of file cut_cell.hpp.

◆ advCoefRaw()

template<unsigned Bits = 21u>
const std::vector< double > & peclet::core::amr::AmrCutCell< Bits >::advCoefRaw ( ) const
inline

Definition at line 125 of file cut_cell.hpp.

◆ advStartRaw()

template<unsigned Bits = 21u>
const std::vector< Index > & peclet::core::amr::AmrCutCell< Bits >::advStartRaw ( ) const
inline

Definition at line 126 of file cut_cell.hpp.

◆ advNbrRaw()

template<unsigned Bits = 21u>
const std::vector< Index > & peclet::core::amr::AmrCutCell< Bits >::advNbrRaw ( ) const
inline

Definition at line 127 of file cut_cell.hpp.

◆ build()

template<unsigned Bits = 21u>
template<class SdfFn >
void peclet::core::amr::AmrCutCell< Bits >::build ( SdfFn &&  sdfFn,
double  idiag = 0.0,
double  beta = 1.0,
int  nsub = 4 
)
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().

◆ assembleOperator()

template<unsigned Bits = 21u>
Assembled peclet::core::amr::AmrCutCell< Bits >::assembleOperator ( bool  scaleAdvByRscale = false) const
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().

◆ hostOp()

◆ applyOp()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::applyOp ( const std::vector< double > &  u,
std::vector< double > &  out 
) const
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().

◆ residual()

◆ gaussSeidel()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::gaussSeidel ( std::vector< double > &  u,
const std::vector< double > &  b,
int  sweeps 
) const
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().

◆ applyOpGeometric()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::applyOpGeometric ( const std::vector< double > &  u,
std::vector< double > &  out 
) const
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().

◆ buildAdvectionFou()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::buildAdvectionFou ( const std::array< std::vector< double >, 3 > &  uadv,
double  rho,
const std::vector< double > &  uf,
const std::vector< Index > &  faceStart,
bool  useFace 
)
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().

◆ makeRhs()

template<unsigned Bits = 21u>
std::vector< double > peclet::core::amr::AmrCutCell< Bits >::makeRhs ( const std::vector< double > &  src,
double  u_bc 
) const
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().

◆ residualGeometric()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::residualGeometric ( const std::vector< double > &  u,
const std::vector< double > &  b,
std::vector< double > &  res 
) const
inline

◆ gaussSeidelGeometric()

template<unsigned Bits = 21u>
void peclet::core::amr::AmrCutCell< Bits >::gaussSeidelGeometric ( std::vector< double > &  u,
const std::vector< double > &  b,
int  sweeps 
) const
inline

◆ fouApply()

template<unsigned Bits = 21u>
double peclet::core::amr::AmrCutCell< Bits >::fouApply ( Index  i,
const std::vector< double > &  field 
) const
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.

◆ hasAdvection()

template<unsigned Bits = 21u>
bool peclet::core::amr::AmrCutCell< Bits >::hasAdvection ( ) const
inline

Definition at line 520 of file cut_cell.hpp.

◆ buildCutStencil()

Member Data Documentation

◆ Dim

template<unsigned Bits = 21u>
constexpr int peclet::core::amr::AmrCutCell< Bits >::Dim = 3
staticconstexpr

Definition at line 77 of file cut_cell.hpp.

◆ OPP

template<unsigned Bits = 21u>
constexpr int peclet::core::amr::AmrCutCell< Bits >::OPP[6] = {1, 0, 3, 2, 5, 4}
staticconstexpr

Definition at line 84 of file cut_cell.hpp.


The documentation for this class was generated from the following file: