peclet.voro 1.0.4
Device-native moving-particle Voronoi dynamics
Loading...
Searching...
No Matches
peclet::voro::fv Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  CollocatedNS
 
struct  CovolumeNS
 The covolume NS solver state: face fluxes u, cell pressure p (from the last projection). More...
 
struct  DecEdges
 
struct  FaceMesh
 
struct  GhostExchange
 
struct  PolyMesh
 
struct  PressureSolver
 

Typedefs

template<class Real >
using DV = Kokkos::View< Real *, peclet::core::MemSpace >
 

Functions

template<class Real >
void perotTranspose (const FaceMesh< Real > &m, const DV< Real > &acell, const DV< Real > &out)
 Transpose of the Perot reconstruction: face-normal tendency from cell tendencies (3N).
 
template<class Real >
void cellTendency (const FaceMesh< Real > &m, const DV< Real > &u, const DV< Real > &U, Real nu, const DV< Real > &out, const DV< Real > &force=DV< Real >{}, Real convScale=Real(1), const DV< Real > &Uwall=DV< Real >{}, const DV< Real > &wallGrad=DV< Real >{})
 
template<class Real >
DecEdges< Real > buildDecEdges (const TessellationView< Real > &view, const FaceMesh< Real > &m)
 Build the DEC edge structure. facetOfFace-style inverse maps are built here from the mesh.
 
template<class Real >
void decLaplacian (const FaceMesh< Real > &m, const DecEdges< Real > &d, const DV< Real > &u, const DV< Real > &divScratch, const DV< Real > &out)
 
template<class Real >
FaceMesh< Real > buildFaceMesh (const TessellationView< Real > &view, const AuxMaps< Real > &aux, int nOwned=-1)
 
template<class Real >
void divergence (const FaceMesh< Real > &m, const DV< Real > &u, const DV< Real > &out)
 (div u)_i from face-normal fluxes u (nFaces; boundary faces included, along the outward normal).
 
template<class Real >
void faceGradient (const FaceMesh< Real > &m, const DV< Real > &p, const DV< Real > &out, const DV< Real > &pb=DV< Real >{})
 
template<class Real >
void laplacian (const FaceMesh< Real > &m, const DV< Real > &p, const DV< Real > &out, DV< Real > &scratchFace, const DV< Real > &pb=DV< Real >{})
 L p = div(grad p): the two-point Laplacian (Neumann on boundary faces unless pb is given).
 
template<class Real >
void greenGaussGradient (const FaceMesh< Real > &m, const DV< Real > &p, const DV< Real > &out)
 Green–Gauss cell gradient (3N): distance-weighted face values, boundary faces use p_A.
 
template<class Real >
void perotVelocity (const FaceMesh< Real > &m, const DV< Real > &u, const DV< Real > &out)
 Perot reconstruction of the cell velocity (3N) from face-normal fluxes.
 
template<class Real >
KOKKOS_INLINE_FUNCTION void cellSkewInverse (const FaceMesh< Real > &m, int i, Real R[9])
 
template<class Real >
void vectorGreenGauss (const FaceMesh< Real > &m, const DV< Real > &U, const DV< Real > &out, const DV< Real > &Uwall=DV< Real >{})
 
template<class Real >
void projectToFaces (const FaceMesh< Real > &m, const DV< Real > &ucell, const DV< Real > &out, const DV< Real > &gradU=DV< Real >{}, const DV< Real > &ub=DV< Real >{})
 
template<class Real >
Real dotCells (const FaceMesh< Real > &m, const DV< Real > &a, const DV< Real > &b)
 
template<class Real >
Real dotFaces (const FaceMesh< Real > &m, const DV< Real > &a, const DV< Real > &b)
 
template<class Real >
void faceInterpTranspose (const FaceMesh< Real > &m, const DV< Real > &g, const DV< Real > &out, bool skew=false, const DV< Real > &scratch9=DV< Real >{}, bool wallPrescribed=false, const std::function< void(const DV< Real > &, int)> &exchange={})
 
template<class Real >
void wallGradientLS (const FaceMesh< Real > &m, const DV< Real > &U, const DV< Real > &gradU, const DV< Real > &Uwall, const DV< Real > &out)
 
template<class Real >
int poissonCG (const FaceMesh< Real > &m, const DV< Real > &f, const DV< Real > &p, Real tol, int maxIter, Real &resOut)
 
template<class Real >
int mergeWallVertices (PolyMesh< Real > &m, const Real L[3], Real tol)
 
template<class Real , int MAXP, int MAXT>
PolyMesh< Real > buildPolyMesh (const TopologyStore< MAXP, MAXT > &store, const Kokkos::View< Real *, peclet::core::MemSpace > &pos, int N, const Real L[3], WallStore< Real > wall={}, Kokkos::View< Real *, peclet::core::MemSpace > xRef={}, Real quantum=Real(1e-9))
 Assemble the polyhedral mesh of a store at positions posHost (3N, world, in [0,L)).
 
template<class Real >
bool writeVtu (const std::string &path, const PolyMesh< Real > &m, const std::vector< Real > *cellScalar=nullptr, const char *scalarName="scalar")
 

Typedef Documentation

◆ DV

template<class Real >
using peclet::voro::fv::DV = typedef Kokkos::View<Real*, peclet::core::MemSpace>

Function Documentation

◆ buildDecEdges()

template<class Real >
DecEdges< Real > peclet::voro::fv::buildDecEdges ( const TessellationView< Real > &  view,
const FaceMesh< Real > &  m 
)

Build the DEC edge structure. facetOfFace-style inverse maps are built here from the mesh.

◆ buildFaceMesh()

template<class Real >
FaceMesh< Real > peclet::voro::fv::buildFaceMesh ( const TessellationView< Real > &  view,
const AuxMaps< Real > &  aux,
int  nOwned = -1 
)

Build the face mesh. aux = buildAuxMaps(view). Interior faces are owned by the facet with the lower index of the reciprocal pair; wall facets (facetNbr == kBoundaryFacet) and box facets (−1) become boundary faces. Distributed (rung C5): nOwned ≥ 0 marks cells [0, nOwned) as this rank's owned cells (the tessellation was built for them only, ghosts [nOwned, N) are candidates without facets); a facet toward a ghost is an INTERFACE face owned here (B = the ghost's combined index; the other rank owns its own copy of the same face and computes the same flux from the exchanged fields).

◆ buildPolyMesh()

template<class Real , int MAXP, int MAXT>
PolyMesh< Real > peclet::voro::fv::buildPolyMesh ( const TopologyStore< MAXP, MAXT > &  store,
const Kokkos::View< Real *, peclet::core::MemSpace > &  pos,
int  N,
const Real  L[3],
WallStore< Real >  wall = {},
Kokkos::View< Real *, peclet::core::MemSpace >  xRef = {},
Real  quantum = Real(1e-9) 
)

Assemble the polyhedral mesh of a store at positions posHost (3N, world, in [0,L)).

◆ cellSkewInverse()

template<class Real >
KOKKOS_INLINE_FUNCTION void peclet::voro::fv::cellSkewInverse ( const FaceMesh< Real > &  m,
int  i,
Real  R[9] 
)

Skewness correction of the Green–Gauss gradient. For a LINEAR field the plain Green–Gauss gradient (face values at the connector foot) is (I − S) ∇p with the geometric tensor S = (1/V) Σ_f s_f A_f t_f ⊗ n_f (t_f = the face centroid's tangential offset from the connector; Gauss: Σ_f A_f c_f ⊗ n_f = V I). R = (I − S)⁻¹ makes it exact for linear fields on any polyhedral cell; zero on a lattice / centroidal-symmetric cell.

◆ cellTendency()

template<class Real >
void peclet::voro::fv::cellTendency ( const FaceMesh< Real > &  m,
const DV< Real > &  u,
const DV< Real > &  U,
Real  nu,
const DV< Real > &  out,
const DV< Real > &  force = DV<Real>{},
Real  convScale = Real(1),
const DV< Real > &  Uwall = DV<Real>{},
const DV< Real > &  wallGrad = DV<Real>{} 
)

Cell-centred tendency of the reconstructed velocity U (3N) under the face flux u: a_i = −(1/V_i) Σ_f s_if u_f A_f ½(U_i + U_j) + (ν/V_i) Σ_f A_f/d_f (U_j − U_i) + F_i Boundary faces (walls, C3): the face velocity is the prescribed Uwall (3 × nBoundary; zero = no-slip when not given) at distance h_A — two-point wall flux ν A_f (U_wall − U_i)/h_A, and the convective flux F_f carries U_wall (F_f = 0 on an impermeable wall). force (3N) optional.

◆ decLaplacian()

template<class Real >
void peclet::voro::fv::decLaplacian ( const FaceMesh< Real > &  m,
const DecEdges< Real > &  d,
const DV< Real > &  u,
const DV< Real > &  divScratch,
const DV< Real > &  out 
)

The DEC Laplacian of the face flux u (interior faces): out_f = grad_f(div u) − (curl curl u)_f, with grad div through the C1 operators; divScratch (nCells). Faces with a skipped edge get only the grad-div part (flagged by weight 0 — the caller decides how to treat them).

◆ divergence()

template<class Real >
void peclet::voro::fv::divergence ( const FaceMesh< Real > &  m,
const DV< Real > &  u,
const DV< Real > &  out 
)

(div u)_i from face-normal fluxes u (nFaces; boundary faces included, along the outward normal).

◆ dotCells()

template<class Real >
Real peclet::voro::fv::dotCells ( const FaceMesh< Real > &  m,
const DV< Real > &  a,
const DV< Real > &  b 
)

◆ dotFaces()

template<class Real >
Real peclet::voro::fv::dotFaces ( const FaceMesh< Real > &  m,
const DV< Real > &  a,
const DV< Real > &  b 
)

◆ faceGradient()

template<class Real >
void peclet::voro::fv::faceGradient ( const FaceMesh< Real > &  m,
const DV< Real > &  p,
const DV< Real > &  out,
const DV< Real > &  pb = DV<Real>{} 
)

Two-point normal gradient on faces. Boundary faces: Dirichlet value pb(f − nInterior) if pb is sized, else zero flux (Neumann).

◆ faceInterpTranspose()

template<class Real >
void peclet::voro::fv::faceInterpTranspose ( const FaceMesh< Real > &  m,
const DV< Real > &  g,
const DV< Real > &  out,
bool  skew = false,
const DV< Real > &  scratch9 = DV<Real>{},
bool  wallPrescribed = false,
const std::function< void(const DV< Real > &, int)> &  exchange = {} 
)

Transpose of the constraint interpolation T (projectToFaces) in the inner products ⟨·,·⟩_V / ⟨·,·⟩_F: ⟨T U, g⟩_F = ⟨U, Tᵀ g⟩_V for every cell field U and face field g. Plain part: (T₀ᵀ g)_i = (1/V_i) Σ_{f∈i} A_f d_f w_if g_f n_f (w_if = the interpolation weight of cell i on f; on a cubic lattice this IS the central difference = Green–Gauss). With skew the transpose of the centroid correction T₁ ∘ GG is added (two passes: the per-cell moment M_i,ck = Σ_f A_f d_f w_if g_f n_fc t_fk, then the Green–Gauss transpose through the faces). Applied to g = the two-point face gradient of φ this is the cell pressure gradient that makes the ABC cell correction the exact adjoint of the face constraint — flow's gauge-exact gradient (gpCenterGrad, the transpose of centerToFace) on the Voronoi mesh: the pressure does no work on the constraint manifold. scratch9 (9N) is needed for the skew part.

◆ greenGaussGradient()

template<class Real >
void peclet::voro::fv::greenGaussGradient ( const FaceMesh< Real > &  m,
const DV< Real > &  p,
const DV< Real > &  out 
)

Green–Gauss cell gradient (3N): distance-weighted face values, boundary faces use p_A.

◆ laplacian()

template<class Real >
void peclet::voro::fv::laplacian ( const FaceMesh< Real > &  m,
const DV< Real > &  p,
const DV< Real > &  out,
DV< Real > &  scratchFace,
const DV< Real > &  pb = DV<Real>{} 
)

L p = div(grad p): the two-point Laplacian (Neumann on boundary faces unless pb is given).

◆ mergeWallVertices()

template<class Real >
int peclet::voro::fv::mergeWallVertices ( PolyMesh< Real > &  m,
const Real  L[3],
Real  tol 
)

Conforming wall faces (rung B3 follow-up): every wall cell clips its wall-adjacent faces with ITS OWN tangent plane of a curved wall, so the two copies of a shared edge's wall endpoint (one per cell) differ by the tangent-plane mismatch (~the sagitta, O(h²/R)). This post-pass merges wall vertices closer than tol (union–find on a hash grid, periodic min-image distances) into their mean, rewrites the face polygons, drops repeated vertices and degenerate (< 3-vertex) faces. MEASURED (2026-09-04, test_polymesh): it does NOT make the wall layer conforming — the mismatch is topological (the two cells' copies of a shared interface face are clipped by different tangent planes into polygons of different shape), 106 of 108 non-conforming wall cells keep failing Euler. Conforming walls need one wall plane per wall EDGE inside the clipper. Kept as a coincident-vertex cleanup. Returns the number of vertices merged away.

◆ perotTranspose()

template<class Real >
void peclet::voro::fv::perotTranspose ( const FaceMesh< Real > &  m,
const DV< Real > &  acell,
const DV< Real > &  out 
)

Transpose of the Perot reconstruction: face-normal tendency from cell tendencies (3N).

◆ perotVelocity()

template<class Real >
void peclet::voro::fv::perotVelocity ( const FaceMesh< Real > &  m,
const DV< Real > &  u,
const DV< Real > &  out 
)

Perot reconstruction of the cell velocity (3N) from face-normal fluxes.

◆ poissonCG()

template<class Real >
int peclet::voro::fv::poissonCG ( const FaceMesh< Real > &  m,
const DV< Real > &  f,
const DV< Real > &  p,
Real  tol,
int  maxIter,
Real &  resOut 
)

Conjugate gradients on −L p = f (matrix-free, Neumann/periodic: the mean of f is removed and the mean of p pinned to zero — L is symmetric negative semi-definite with the constant null space). Returns the iteration count; resOut the final relative residual. Unpreconditioned: the coarse-grid / AMG preconditioner is track C2.

◆ projectToFaces()

template<class Real >
void peclet::voro::fv::projectToFaces ( const FaceMesh< Real > &  m,
const DV< Real > &  ucell,
const DV< Real > &  out,
const DV< Real > &  gradU = DV<Real>{},
const DV< Real > &  ub = DV<Real>{} 
)

The centre→face CONSTRAINT interpolation T: u_f = U_f·n_f with U_f the distance-weighted average of the two cell velocities (exact at the connector foot for linear fields). With gradU (9N, vectorGreenGauss) the SKEW correction adds each cell's gradient times the tangential offset t_f = c_f − h_A n_f of the face centroid from the connector, so U_f is the value AT THE FACE CENTROID (second order on skewed faces). Boundary faces: U(A)·n.

◆ vectorGreenGauss()

template<class Real >
void peclet::voro::fv::vectorGreenGauss ( const FaceMesh< Real > &  m,
const DV< Real > &  U,
const DV< Real > &  out,
const DV< Real > &  Uwall = DV<Real>{} 
)

Skew-corrected Green–Gauss gradient of a cell VECTOR field (3N → 9N, (∂_k U_c)_i at 9i + 3c + k): the plain distance-weighted Green–Gauss gradient times R = (I − S)⁻¹ (cellSkewInverse) — exact for linear fields on every cell; boundary faces use the cell value.

◆ wallGradientLS()

template<class Real >
void peclet::voro::fv::wallGradientLS ( const FaceMesh< Real > &  m,
const DV< Real > &  U,
const DV< Real > &  gradU,
const DV< Real > &  Uwall,
const DV< Real > &  out 
)

Second-order wall gradient (3 × nBoundary): for each boundary face f of cell i, the normal derivative AT THE WALL of the wall-anchored quadratic u(s) = U_wall + a s + b s² (s = distance from the wall plane) least-squares fitted to the cell value and its interior neighbours, each sample corrected for the tangential variation with the cell gradient gradU (9N; may be empty). The two-point flux (U_i − U_wall)/h_A is the derivative at s = h_A/2 (the half-cell O(h) wall shear that limits the sphere drag, C4); this is flow's wall-anchored quadratic (centerToFaceWallAware) on the unstructured mesh. On a lattice wall cell the fit passes through (wall, U_i, U_above) exactly, so Poiseuille is reproduced to round-off.

◆ writeVtu()

template<class Real >
bool peclet::voro::fv::writeVtu ( const std::string &  path,
const PolyMesh< Real > &  m,
const std::vector< Real > *  cellScalar = nullptr,
const char *  scalarName = "scalar" 
)

Write the mesh as an ASCII VTU of VTK_POLYHEDRON cells (with per-cell volume and, if given, a per-cell scalar), readable by ParaView / pyvista.