|
core
Shared MPI block decomposition + asynchronous ghost-layer exchange (header-only C++20)
|
Cell-centered FV Poisson operator on one (periodic) block octree. More...
#include <poisson.hpp>
Classes | |
| struct | FvAssembled |
| The assembled FV (weight-CSR) operator: per-face conductance w = A_f/d_f·openness, per-cell invVol and Dirichlet boundary diagonal, in the exact face order forEachFaceNeighbor emits. More... | |
Public Types | |
| using | Octree = BlockOctree< Dim, Bits > |
| using | M = typename Octree::M |
| using | Code = typename Octree::Code |
| using | Coord = typename Octree::Coord |
Public Member Functions | |
| AmrPoisson ()=default | |
| AmrPoisson (const Octree &t, Real h0) | |
| void | init (const Octree &t, Real h0) |
| void | setOrigin (const Vec< Dim > &o) |
| double | faceOpenness (Index i, int axis, int dir) const |
Openness of leaf i's face on (axis,dir); 1 if no openness has been set. | |
| bool | hasOpenness () const |
| const std::vector< double > & | opennessRaw () const |
| void | setOpennessRaw (std::vector< double > a) |
| template<class OpenFn > | |
| void | buildOpenness (OpenFn &&openFn) |
| Build face openness from a geometry callable openFn(faceCentreWorld, axis) -> [0,1] (1 = fully fluid, 0 = fully solid). | |
| Index | numLeaves () const |
| void | setPeriodic (bool p) |
Boundary condition: periodic (default) wraps every face; non-periodic treats a domain-boundary face as a homogeneous Dirichlet wall at half a cell (see boundaryDiag), which forEachFaceNeighbor then skips (no neighbour cell). | |
| bool | periodic () const |
| void | setImmersedWall (bool w) |
| Immersed no-slip (Dirichlet) wall mode. | |
| bool | immersedWall () const |
| double | boundaryDiag (Index i) const |
Σ over leaf i's Dirichlet-wall faces of the wall weight A_f/(½·cellWidth), folded into the operator diagonal so a wall cell sees a u=0 wall at half a cell (making the operator non-singular). | |
| Real | cellWidth (Index i) const |
| Real | cellVolume (Index i) const |
| template<class Fn > | |
| void | forEachFaceNeighbor (Index i, Fn &&fn) const |
Visit each face neighbour of leaf i: fn(neighbourSlot, coeff, axis, alpha) where coeff = A_f / d_f (physical) and alpha is the face openness (fluid fraction, from the finer side). | |
| template<class Fn > | |
| void | forEachFaceFull (Index i, Fn &&fn) const |
| Like forEachFaceNeighbor but exposes geometry for a consistent FV divergence/gradient: fn(neighbour, axis, dir, areaPhys, distPhys, alpha). | |
| Index | periodicNeighbor (Index i, int axis, int dir) const |
| Periodic face neighbour leaf (covering the cell just across the face). | |
| double | coarseStar (const std::vector< double > &u, Index coarse, Index fine, int axis) const |
Quadratic coarse-fine value: the coarse leaf coarse's field, evaluated by tangential quadratic interpolation at the tangential position of fine leaf fine (Martin–Cartwright). | |
| void | applyLaplacianQuad (const std::vector< double > &u, std::vector< double > &out) const |
| out = L u with the quadratic coarse-fine flux (2nd-order at 2:1 interfaces). | |
| double | residualQuad (const std::vector< double > &u, const std::vector< double > &rhs, std::vector< double > &res) const |
| L2 norm of rhs - L_quad u. | |
| FvAssembled | assembleFv () const |
| FvCsrOpT< HostArr< double >, HostArr< Index > > | hostFvOp (const FvAssembled &A) const |
| View an FvAssembled as the backend-agnostic FvCsrOpT (c0=0,cD=1 ⇒ pure FV Laplacian). | |
| void | applyFvShared (const std::vector< double > &u, std::vector< double > &out) const |
| out = L u via the SHARED face_csr.hpp FV kernel over the assembled CSR — the same arithmetic the device applyFv runs, executed serially. | |
| void | applyLaplacian (const std::vector< double > &u, std::vector< double > &out) const |
| out = L u (periodic FV Laplacian). | |
| double | residual (const std::vector< double > &u, const std::vector< double > &rhs, std::vector< double > &res) const |
| res = rhs - L u, returns its L2 norm (sqrt(sum V_i res_i^2)). | |
| void | gaussSeidel (std::vector< double > &u, const std::vector< double > &rhs, int sweeps) const |
sweeps lexicographic Gauss-Seidel relaxations of L u = rhs (in place). | |
| void | removeMean (std::vector< double > &u) const |
| Subtract the volume-weighted mean (fixes the periodic null space). | |
| const Octree & | octree () const |
| Real | h0 () const |
| const std::array< Coord, Dim > & | fineExt () const |
| Per-axis fine-grid extent (brick·2^lmax) — the periodic wrap modulus. | |
| const Vec< Dim > & | origin () const |
Static Public Member Functions | |
| static int | faceIndex (int axis, int dir) |
Static Public Attributes | |
| static constexpr int | kFaces = 2 * Dim |
Cell-centered FV Poisson operator on one (periodic) block octree.
Definition at line 43 of file poisson.hpp.
| using peclet::core::amr::AmrPoisson< Dim, Bits >::Octree = BlockOctree<Dim, Bits> |
Definition at line 45 of file poisson.hpp.
| using peclet::core::amr::AmrPoisson< Dim, Bits >::M = typename Octree::M |
Definition at line 46 of file poisson.hpp.
| using peclet::core::amr::AmrPoisson< Dim, Bits >::Code = typename Octree::Code |
Definition at line 47 of file poisson.hpp.
| using peclet::core::amr::AmrPoisson< Dim, Bits >::Coord = typename Octree::Coord |
Definition at line 48 of file poisson.hpp.
|
default |
|
inline |
Definition at line 51 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::h0(), and peclet::core::amr::AmrPoisson< Dim, Bits >::init().
Definition at line 53 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::h0().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::AmrPoisson(), peclet::core::amr::AmrCutCell< Bits >::build(), peclet::core::amr::AmrFlow< Bits >::setSolid(), and peclet::core::amr::oracle::AmrFlow< Bits >::setSolid().
|
inline |
Definition at line 62 of file poisson.hpp.
Referenced by peclet::core::amr::AmrFlow< Bits >::setSolid(), and peclet::core::amr::oracle::AmrFlow< Bits >::setSolid().
Definition at line 66 of file poisson.hpp.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), and peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness().
|
inline |
Openness of leaf i's face on (axis,dir); 1 if no openness has been set.
Definition at line 69 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::faceIndex(), and peclet::core::amr::AmrPoisson< Dim, Bits >::kFaces.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::boundaryDiag(), peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull(), and peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor().
|
inline |
Definition at line 75 of file poisson.hpp.
Referenced by peclet::core::amr::assembleFv().
|
inline |
Definition at line 76 of file poisson.hpp.
Referenced by peclet::core::amr::assembleFv().
|
inline |
Definition at line 77 of file poisson.hpp.
|
inline |
Build face openness from a geometry callable openFn(faceCentreWorld, axis) -> [0,1] (1 = fully fluid, 0 = fully solid).
Evaluated at each face centroid, so same-level neighbours see an identical value (consistent shared faces).
Definition at line 86 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::AmrPoisson< Dim, Bits >::faceIndex(), peclet::core::amr::AmrPoisson< Dim, Bits >::kFaces, peclet::core::amr::BlockOctree< Dim, Bits >::level(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::AmrFlow< Bits >::setSolid(), and peclet::core::amr::oracle::AmrFlow< Bits >::setSolid().
|
inline |
Definition at line 110 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyFvShared(), peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian(), peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad(), peclet::core::amr::AmrPoisson< Dim, Bits >::assembleFv(), peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), peclet::core::amr::AmrPoisson< Dim, Bits >::gaussSeidel(), peclet::core::amr::AmrPoisson< Dim, Bits >::hostFvOp(), peclet::core::amr::AmrPoisson< Dim, Bits >::removeMean(), peclet::core::amr::AmrPoisson< Dim, Bits >::residual(), and peclet::core::amr::AmrPoisson< Dim, Bits >::residualQuad().
|
inline |
Boundary condition: periodic (default) wraps every face; non-periodic treats a domain-boundary face as a homogeneous Dirichlet wall at half a cell (see boundaryDiag), which forEachFaceNeighbor then skips (no neighbour cell).
Definition at line 115 of file poisson.hpp.
|
inline |
Definition at line 116 of file poisson.hpp.
Referenced by peclet::core::amr::assembleFv().
|
inline |
Immersed no-slip (Dirichlet) wall mode.
OFF (default) ⇒ the Neumann/openness operator (the pressure Poisson): a solid-adjacent face just loses its flux (α<1). ON ⇒ the velocity operator: the solid fraction (1−α) of every interior face is a u=0 wall at half a cell, folded into the diagonal (boundaryDiag). This is the one difference between the pressure and velocity discretisations on the same openness geometry, and it makes the velocity operator strongly diagonally dominant (the wall pins u) — the basis for the velocity multigrid (Multigrid built with immersedWall + Helmholtz mass).
Definition at line 125 of file poisson.hpp.
|
inline |
Definition at line 126 of file poisson.hpp.
Referenced by peclet::core::amr::assembleFv().
|
inline |
Σ over leaf i's Dirichlet-wall faces of the wall weight A_f/(½·cellWidth), folded into the operator diagonal so a wall cell sees a u=0 wall at half a cell (making the operator non-singular).
Two contributions: domain-boundary faces weighted by α (only when non-periodic), and — when immersedWall_ — the solid fraction (1−α) of every interior face (the immersed no-slip wall of the velocity operator).
Definition at line 133 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness(), and peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::assembleFv().
|
inline |
Definition at line 155 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), and peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar().
|
inline |
Definition at line 156 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellWidth().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian(), peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad(), peclet::core::amr::AmrPoisson< Dim, Bits >::assembleFv(), peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::AmrCutCell< Bits >::buildAdvectionFou(), peclet::core::amr::oracle::AmrFlow< Bits >::divergence(), peclet::core::amr::oracle::AmrFlow< Bits >::divNormFace(), peclet::core::amr::AmrPoisson< Dim, Bits >::gaussSeidel(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidelGeometric(), peclet::core::amr::AmrPoisson< Dim, Bits >::removeMean(), peclet::core::amr::AmrPoisson< Dim, Bits >::residual(), and peclet::core::amr::AmrPoisson< Dim, Bits >::residualQuad().
|
inline |
Visit each face neighbour of leaf i: fn(neighbourSlot, coeff, axis, alpha) where coeff = A_f / d_f (physical) and alpha is the face openness (fluid fraction, from the finer side).
Periodic wrap; 2:1 interfaces enumerated.
Definition at line 168 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness(), peclet::core::amr::BlockOctree< Dim, Bits >::find(), and peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian(), peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad(), peclet::core::amr::AmrPoisson< Dim, Bits >::assembleFv(), peclet::core::amr::AmrCutCell< Bits >::assembleOperator(), peclet::core::amr::AmrPoisson< Dim, Bits >::gaussSeidel(), peclet::core::amr::AmrCutCell< Bits >::gaussSeidelGeometric(), and peclet::core::amr::AmrPoisson< Dim, Bits >::residual().
|
inline |
Like forEachFaceNeighbor but exposes geometry for a consistent FV divergence/gradient: fn(neighbour, axis, dir, areaPhys, distPhys, alpha).
Same face enumeration (2:1 sub-faces) and openness as the operator, so a collocated projection built on it stays consistent with the pressure Poisson.
Definition at line 220 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness(), peclet::core::amr::BlockOctree< Dim, Bits >::find(), and peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::AmrCutCell< Bits >::buildAdvectionFou(), peclet::core::amr::oracle::AmrFlow< Bits >::buildFaceField(), peclet::core::amr::oracle::AmrFlow< Bits >::divergence(), peclet::core::amr::oracle::AmrFlow< Bits >::divNormFace(), and peclet::core::amr::oracle::AmrFlow< Bits >::setSolid().
|
inline |
Periodic face neighbour leaf (covering the cell just across the face).
Definition at line 261 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::BlockOctree< Dim, Bits >::find(), and peclet::core::amr::BlockOctree< Dim, Bits >::level().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar().
|
inline |
Quadratic coarse-fine value: the coarse leaf coarse's field, evaluated by tangential quadratic interpolation at the tangential position of fine leaf fine (Martin–Cartwright).
Replacing the raw coarse value with this in the two-point flux makes the C/F flux 2nd-order; both sides of the face use the identical value, so the operator stays symmetric/conservative (refluxing is automatic). Falls back to the raw value on any tangential axis whose coarse neighbours aren't both same-level.
Definition at line 279 of file poisson.hpp.
References peclet::core::amr::BlockOctree< Dim, Bits >::bounds(), peclet::core::amr::AmrPoisson< Dim, Bits >::cellWidth(), peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness(), peclet::core::amr::BlockOctree< Dim, Bits >::level(), and peclet::core::amr::AmrPoisson< Dim, Bits >::periodicNeighbor().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad().
|
inline |
out = L u with the quadratic coarse-fine flux (2nd-order at 2:1 interfaces).
Definition at line 314 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::BlockOctree< Dim, Bits >::level(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::residualQuad().
|
inline |
L2 norm of rhs - L_quad u.
Definition at line 336 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad(), peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
|
inline |
Definition at line 362 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::bcDiag, peclet::core::amr::AmrPoisson< Dim, Bits >::boundaryDiag(), peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::coef, peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::invVol, peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::nbr, peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves(), and peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::start.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyFvShared().
|
inline |
View an FvAssembled as the backend-agnostic FvCsrOpT (c0=0,cD=1 ⇒ pure FV Laplacian).
Definition at line 389 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::bcDiag, peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::coef, peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::invVol, peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::nbr, peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves(), and peclet::core::amr::AmrPoisson< Dim, Bits >::FvAssembled::start.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::applyFvShared().
|
inline |
out = L u via the SHARED face_csr.hpp FV kernel over the assembled CSR — the same arithmetic the device applyFv runs, executed serially.
The geometric applyLaplacian below is the oracle; test_amr_poisson asserts the two agree (anti-drift lock, no-Kokkos build).
Definition at line 402 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::assembleFv(), peclet::core::amr::fvApplyRow(), peclet::core::amr::AmrPoisson< Dim, Bits >::hostFvOp(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
|
inline |
out = L u (periodic FV Laplacian).
Definition at line 413 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
Referenced by peclet::core::amr::AmrCutCell< Bits >::applyOpGeometric().
|
inline |
res = rhs - L u, returns its L2 norm (sqrt(sum V_i res_i^2)).
Definition at line 427 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
|
inline |
sweeps lexicographic Gauss-Seidel relaxations of L u = rhs (in place).
Definition at line 446 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceNeighbor(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
|
inline |
Subtract the volume-weighted mean (fixes the periodic null space).
Definition at line 462 of file poisson.hpp.
References peclet::core::amr::AmrPoisson< Dim, Bits >::cellVolume(), and peclet::core::amr::AmrPoisson< Dim, Bits >::numLeaves().
|
inline |
Definition at line 474 of file poisson.hpp.
|
inline |
Definition at line 475 of file poisson.hpp.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::AmrPoisson(), peclet::core::amr::assembleFv(), and peclet::core::amr::AmrPoisson< Dim, Bits >::init().
|
inline |
Per-axis fine-grid extent (brick·2^lmax) — the periodic wrap modulus.
Needed by the device assembler to reproduce wrap() / the domain-boundary test on device.
Definition at line 478 of file poisson.hpp.
Referenced by peclet::core::amr::assembleFv().
|
inline |
Definition at line 479 of file poisson.hpp.
|
staticconstexpr |
Definition at line 65 of file poisson.hpp.
Referenced by peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness(), and peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness().