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

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 Octreeoctree () 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
 

Detailed Description

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
class peclet::core::amr::AmrPoisson< Dim, Bits >

Cell-centered FV Poisson operator on one (periodic) block octree.

Definition at line 43 of file poisson.hpp.

Member Typedef Documentation

◆ Octree

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::AmrPoisson< Dim, Bits >::Octree = BlockOctree<Dim, Bits>

Definition at line 45 of file poisson.hpp.

◆ M

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::AmrPoisson< Dim, Bits >::M = typename Octree::M

Definition at line 46 of file poisson.hpp.

◆ Code

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::AmrPoisson< Dim, Bits >::Code = typename Octree::Code

Definition at line 47 of file poisson.hpp.

◆ Coord

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::AmrPoisson< Dim, Bits >::Coord = typename Octree::Coord

Definition at line 48 of file poisson.hpp.

Constructor & Destructor Documentation

◆ AmrPoisson() [1/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
peclet::core::amr::AmrPoisson< Dim, Bits >::AmrPoisson ( )
default

◆ AmrPoisson() [2/2]

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
peclet::core::amr::AmrPoisson< Dim, Bits >::AmrPoisson ( const Octree t,
Real  h0 
)
inline

Member Function Documentation

◆ init()

◆ setOrigin()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::setOrigin ( const Vec< Dim > &  o)
inline

◆ faceIndex()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
static int peclet::core::amr::AmrPoisson< Dim, Bits >::faceIndex ( int  axis,
int  dir 
)
inlinestatic

◆ faceOpenness()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::AmrPoisson< Dim, Bits >::faceOpenness ( Index  i,
int  axis,
int  dir 
) const
inline

◆ hasOpenness()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
bool peclet::core::amr::AmrPoisson< Dim, Bits >::hasOpenness ( ) const
inline

Definition at line 75 of file poisson.hpp.

Referenced by peclet::core::amr::assembleFv().

◆ opennessRaw()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const std::vector< double > & peclet::core::amr::AmrPoisson< Dim, Bits >::opennessRaw ( ) const
inline

Definition at line 76 of file poisson.hpp.

Referenced by peclet::core::amr::assembleFv().

◆ setOpennessRaw()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::setOpennessRaw ( std::vector< double a)
inline

Definition at line 77 of file poisson.hpp.

◆ buildOpenness()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class OpenFn >
void peclet::core::amr::AmrPoisson< Dim, Bits >::buildOpenness ( OpenFn &&  openFn)
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().

◆ numLeaves()

◆ setPeriodic()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::setPeriodic ( bool  p)
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.

◆ periodic()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
bool peclet::core::amr::AmrPoisson< Dim, Bits >::periodic ( ) const
inline

Definition at line 116 of file poisson.hpp.

Referenced by peclet::core::amr::assembleFv().

◆ setImmersedWall()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::setImmersedWall ( bool  w)
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.

◆ immersedWall()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
bool peclet::core::amr::AmrPoisson< Dim, Bits >::immersedWall ( ) const
inline

Definition at line 126 of file poisson.hpp.

Referenced by peclet::core::amr::assembleFv().

◆ boundaryDiag()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::AmrPoisson< Dim, Bits >::boundaryDiag ( Index  i) const
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().

◆ cellWidth()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Real peclet::core::amr::AmrPoisson< Dim, Bits >::cellWidth ( Index  i) const
inline

◆ cellVolume()

◆ forEachFaceNeighbor()

◆ forEachFaceFull()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class Fn >
void peclet::core::amr::AmrPoisson< Dim, Bits >::forEachFaceFull ( Index  i,
Fn &&  fn 
) const
inline

◆ periodicNeighbor()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Index peclet::core::amr::AmrPoisson< Dim, Bits >::periodicNeighbor ( Index  i,
int  axis,
int  dir 
) const
inline

◆ coarseStar()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::AmrPoisson< Dim, Bits >::coarseStar ( const std::vector< double > &  u,
Index  coarse,
Index  fine,
int  axis 
) const
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().

◆ applyLaplacianQuad()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacianQuad ( const std::vector< double > &  u,
std::vector< double > &  out 
) const
inline

◆ residualQuad()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::AmrPoisson< Dim, Bits >::residualQuad ( const std::vector< double > &  u,
const std::vector< double > &  rhs,
std::vector< double > &  res 
) const
inline

◆ assembleFv()

◆ hostFvOp()

◆ applyFvShared()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::applyFvShared ( const std::vector< double > &  u,
std::vector< double > &  out 
) const
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().

◆ applyLaplacian()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::applyLaplacian ( const std::vector< double > &  u,
std::vector< double > &  out 
) const
inline

◆ residual()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
double peclet::core::amr::AmrPoisson< Dim, Bits >::residual ( const std::vector< double > &  u,
const std::vector< double > &  rhs,
std::vector< double > &  res 
) const
inline

◆ gaussSeidel()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::gaussSeidel ( std::vector< double > &  u,
const std::vector< double > &  rhs,
int  sweeps 
) const
inline

◆ removeMean()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::AmrPoisson< Dim, Bits >::removeMean ( std::vector< double > &  u) const
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().

◆ octree()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const Octree & peclet::core::amr::AmrPoisson< Dim, Bits >::octree ( ) const
inline

Definition at line 474 of file poisson.hpp.

◆ h0()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
Real peclet::core::amr::AmrPoisson< Dim, Bits >::h0 ( ) const
inline

◆ fineExt()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const std::array< Coord, Dim > & peclet::core::amr::AmrPoisson< Dim, Bits >::fineExt ( ) const
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().

◆ origin()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
const Vec< Dim > & peclet::core::amr::AmrPoisson< Dim, Bits >::origin ( ) const
inline

Definition at line 479 of file poisson.hpp.

Member Data Documentation

◆ kFaces

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
constexpr int peclet::core::amr::AmrPoisson< Dim, Bits >::kFaces = 2 * Dim
staticconstexpr

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