core 1.5.0
Shared MPI block decomposition, asynchronous ghost-layer exchange, SDF geometry, load balancing (header-only C++20)
Loading...
Searching...
No Matches
peclet::core::solver Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  AmgParams
 
struct  AndersonComm
 The collectives of a distributed run. More...
 
class  AndersonCore
 
struct  AndersonState
 The state descriptor (design §5.1): exactly what the caller's step reads across steps, as full padded x-fastest buffers over one box, with their roles. More...
 
struct  CgResult
 PCG on A x = b preconditioned by an already-built GraphAMG (one V-cycle per iteration). More...
 
struct  Coloring
 A graph colouring of a face CSR: cells grouped by colour. More...
 
struct  FaceCsrOpT
 A backend-agnostic view of an assembled face-CSR operator. More...
 
struct  FvCsrOpT
 A backend-agnostic view of an assembled FV (weight-CSR) operator. More...
 
class  GraphAMG
 Smoothed-aggregation AMG hierarchy usable as z = M⁻¹ r (one symmetric V-cycle from a zero initial guess) — the CG preconditioner that makes the iteration count mesh-independent. More...
 
class  GraphAMGDevice
 
struct  HostArr
 A uniform accessor over a raw host array, giving it the operator()(i) that Kokkos::View has, so the row kernels can be written once for both. More...
 
struct  HostCsrOp
 A general assembled sparse operator in CSR form: the diagonal is stored separately and the CSR (start/nbr/coef) holds only the OFF-diagonal entries. More...
 
struct  MomentumOp
 Assembled momentum operator on the device: (A u)_i = diag_i u_i + Σ coef·u[nbr], with an optional implicit-FOU advection part (rebuilt each step from the lagged velocity): a per-cell outflow diagonal advDiag + per-face inflow coefficients over a second (face-geometry) CSR. More...
 
class  MomentumSolver
 

Enumerations

enum class  AndersonRole : int { Velocity = 0 , Carried = 2 }
 What a state field is to the metric (design §3.1–3.2, rev 1: the metric is velocity only). More...
 

Functions

AndersonComm andersonComm (MPI_Comm comm)
 The collectives of comm for an AndersonState. The communicator must outlive the accelerator.
 
Coloring greedyColoring (const std::vector< Index > &start, const std::vector< Index > &nbr, Index n)
 Greedy colouring of the face CSR (start/nbr, host): each cell gets the smallest colour not used by any face neighbour, so cells of one colour share no edge (race-free parallel GS sweep).
 
FaceCsrOpT< View< const double >, View< const Index > > momView (const MomentumOp &op)
 View the assembled momentum operator through the shared, backend-agnostic FaceCsrOpT, so the device kernels and the host serial solver (cut_cell.hpp) run the same row arithmetic (face_csr.hpp) and cannot drift.
 
void applyMom (const MomentumOp &op, View< const double > u, View< double > Au)
 Au = A u (cut-cell operator + optional implicit-FOU advection).
 
void residualMom (const MomentumOp &op, View< const double > u, View< const double > b, View< double > res)
 res = b − A u.
 
void jacobiMom (const MomentumOp &op, View< double > u, View< const double > b, View< double > tmp, double omega)
 One weighted-Jacobi sweep of A u = b (in place).
 
void multicolorGSMom (const MomentumOp &op, View< double > u, View< const double > b, const Coloring &col, double omega)
 One symmetric multicolour Gauss–Seidel sweep of A u = b in place (momentum operator: diag + face CSR + optional implicit-FOU advection): a forward pass over colours 0…C-1 followed by a reverse pass C-1…0.
 
template<class Op , class U >
PECLET_HD double faceCsrApplyRow (const Op &op, Index i, const U &u)
 (A u)_i — one assembled-operator row.
 
template<class Op , class U >
PECLET_HD void faceCsrOffDiag (const Op &op, Index i, const U &u, double &off, double &d)
 Off-diagonal sum and the (advection-inclusive) diagonal for the point smoothers: out off = Σ coef·u[nbr] (+ advection inflow), d = diag (+ advection outflow).
 
PECLET_HD double faceCsrPointUpdate (double b_i, double off, double d, double uOld, double omega)
 The damped point update used by both Jacobi and (multicolour) Gauss–Seidel: returns the new u_i given the right-hand side b_i, the off-diagonal sum off, the diagonal d, the old value uOld, and the relaxation omega.
 
template<class Op , class U >
PECLET_HD double fvApplyRow (const Op &op, Index i, const U &u)
 (H u)_i = c0·u_i + cD·( invVol_i·( Σ w·(u_nbr − u_i) − bcDiag_i·u_i ) ).
 
template<class Op , class U >
PECLET_HD double fvPointSolve (const Op &op, Index i, const U &u, double rhs_i, double uOld)
 The point solve of H u = rhs for one row (raw value, before damping), matching the host point solve and device jacobiFv: the pure-L path (c0=0,cD=1) keeps the exact original expression.
 
CgResult amgPcg (const HostCsrOp &A, std::vector< double > &x, const std::vector< double > &b, const GraphAMG &M, int maxIters=500, double tol=1e-8)
 
double dotPlain (View< const double > a, View< const double > b, Index n)
 Plain (unweighted) dot product.
 
void bicgPUpdate (View< double > p, View< const double > r, View< const double > v, double beta, double omega, Index n)
 BiCGStab direction update: p = r + β(p − ω v).
 
void axpy (View< double > y, double a, View< const double > x, Index n)
 y += a·x
 
void zpby (View< double > p, View< const double > z, double b, Index n)
 p = z + b·p (CG direction update)
 
void negate (View< double > x, Index n)
 y = −x (negate in place)
 

Enumeration Type Documentation

◆ AndersonRole

What a state field is to the metric (design §3.1–3.2, rev 1: the metric is velocity only).

The integer values are those of revision 0, whose Pressure role (= 1) was deleted (WO-3b).

Enumerator
Velocity 

measured at unit weight, every inner entry

Carried 

mixed, stored and differenced like the others, but not measured (e.g. P)

Definition at line 35 of file anderson.hpp.

Function Documentation

◆ andersonComm()

AndersonComm peclet::core::solver::andersonComm ( MPI_Comm  comm)
inline

◆ greedyColoring()

Coloring peclet::core::solver::greedyColoring ( const std::vector< Index > &  start,
const std::vector< Index > &  nbr,
Index  n 
)
inline

Greedy colouring of the face CSR (start/nbr, host): each cell gets the smallest colour not used by any face neighbour, so cells of one colour share no edge (race-free parallel GS sweep).

Deterministic from the natural cell order.

The adjacency is symmetrised first (undirected: i conflicts with j if i∈nbr(j) OR j∈nbr(i)). The assembled cut-cell operator's CSR can be structurally asymmetric — the ξ-polynomial Dirichlet overlay adds extrapolation entries a cut cell references but its target doesn't reference back — and colouring only the outgoing edges would then leave two mutually-adjacent cells the same colour, a data race that makes the GS sweep a non-deterministic (inconsistent) operator and silently breaks the BiCGStab it preconditions (false convergence to NaN at scale). Symmetrising is the correctness guard; it costs one O(nnz) host pass at build/adapt time.

Definition at line 39 of file coloring.hpp.

References peclet::core::solver::Coloring::nColors, and peclet::core::toDevice().

◆ momView()

FaceCsrOpT< View< const double >, View< const Index > > peclet::core::solver::momView ( const MomentumOp &  op)
inline

View the assembled momentum operator through the shared, backend-agnostic FaceCsrOpT, so the device kernels and the host serial solver (cut_cell.hpp) run the same row arithmetic (face_csr.hpp) and cannot drift.

Non-const Views convert to their const accessor form implicitly; the advection arrays are empty (and untouched) when hasAdv is false.

Definition at line 50 of file csr_operator.hpp.

References peclet::core::solver::FaceCsrOpT< D, I >::advCoef, peclet::core::solver::FaceCsrOpT< D, I >::advDiag, peclet::core::solver::FaceCsrOpT< D, I >::advNbr, peclet::core::solver::FaceCsrOpT< D, I >::advStart, peclet::core::solver::FaceCsrOpT< D, I >::coef, peclet::core::solver::FaceCsrOpT< D, I >::diag, peclet::core::solver::FaceCsrOpT< D, I >::hasAdv, peclet::core::solver::FaceCsrOpT< D, I >::n, peclet::core::solver::FaceCsrOpT< D, I >::nbr, and peclet::core::solver::FaceCsrOpT< D, I >::start.

Referenced by applyMom(), jacobiMom(), multicolorGSMom(), and residualMom().

◆ applyMom()

void peclet::core::solver::applyMom ( const MomentumOp &  op,
View< const double >  u,
View< double >  Au 
)
inline

Au = A u (cut-cell operator + optional implicit-FOU advection).

Definition at line 66 of file csr_operator.hpp.

References faceCsrApplyRow(), and momView().

Referenced by peclet::core::solver::MomentumSolver::solveBiCGStab().

◆ residualMom()

void peclet::core::solver::residualMom ( const MomentumOp &  op,
View< const double >  u,
View< const double >  b,
View< double >  res 
)
inline

◆ jacobiMom()

void peclet::core::solver::jacobiMom ( const MomentumOp &  op,
View< double >  u,
View< const double >  b,
View< double >  tmp,
double  omega 
)
inline

One weighted-Jacobi sweep of A u = b (in place).

tmp is scratch (size n). Pass 1 reads only the previous iterate, pass 2 updates ⇒ order-independent / deterministic.

Definition at line 83 of file csr_operator.hpp.

References faceCsrOffDiag(), and momView().

Referenced by peclet::core::solver::MomentumSolver::solveJacobi().

◆ multicolorGSMom()

void peclet::core::solver::multicolorGSMom ( const MomentumOp &  op,
View< double >  u,
View< const double >  b,
const Coloring &  col,
double  omega 
)
inline

One symmetric multicolour Gauss–Seidel sweep of A u = b in place (momentum operator: diag + face CSR + optional implicit-FOU advection): a forward pass over colours 0…C-1 followed by a reverse pass C-1…0.

Each colour is a parallel_for over its cells doing the GS point update reading the current (already-updated) neighbours; cells of one colour share no edge ⇒ race-free.

The forward+reverse pairing makes the smoother symmetric, which matters when the MG V-cycle is used as a preconditioner for BiCGStab (the momentum path): a forward-only GS V-cycle is a non-symmetric, non-normal operator that breaks BiCGStab's bi-orthogonal recurrence on the larger non-symmetric 64³ system (false convergence to NaN), whereas the symmetric (SGS) V-cycle keeps it robust — the textbook remedy, and the behaviour flow gets from its RB-GS / MG-as-solver path.

Definition at line 107 of file csr_operator.hpp.

References faceCsrOffDiag(), faceCsrPointUpdate(), and momView().

◆ faceCsrApplyRow()

template<class Op , class U >
PECLET_HD double peclet::core::solver::faceCsrApplyRow ( const Op &  op,
Index  i,
const U &  u 
)

(A u)_i — one assembled-operator row.

Definition at line 57 of file face_csr.hpp.

Referenced by applyMom(), and residualMom().

◆ faceCsrOffDiag()

template<class Op , class U >
PECLET_HD void peclet::core::solver::faceCsrOffDiag ( const Op &  op,
Index  i,
const U &  u,
double &  off,
double &  d 
)

Off-diagonal sum and the (advection-inclusive) diagonal for the point smoothers: out off = Σ coef·u[nbr] (+ advection inflow), d = diag (+ advection outflow).

The point update of A u = b is then u_i ← (1−ω)u_i + ω·(b_i − off)/d.

Definition at line 73 of file face_csr.hpp.

Referenced by jacobiMom(), and multicolorGSMom().

◆ faceCsrPointUpdate()

PECLET_HD double peclet::core::solver::faceCsrPointUpdate ( double  b_i,
double  off,
double  d,
double  uOld,
double  omega 
)

The damped point update used by both Jacobi and (multicolour) Gauss–Seidel: returns the new u_i given the right-hand side b_i, the off-diagonal sum off, the diagonal d, the old value uOld, and the relaxation omega.

A zero diagonal (an inactive/identity row) leaves u_i fixed.

Definition at line 88 of file face_csr.hpp.

Referenced by multicolorGSMom().

◆ fvApplyRow()

template<class Op , class U >
PECLET_HD double peclet::core::solver::fvApplyRow ( const Op &  op,
Index  i,
const U &  u 
)

(H u)_i = c0·u_i + cD·( invVol_i·( Σ w·(u_nbr − u_i) − bcDiag_i·u_i ) ).

Definition at line 114 of file face_csr.hpp.

◆ fvPointSolve()

template<class Op , class U >
PECLET_HD double peclet::core::solver::fvPointSolve ( const Op &  op,
Index  i,
const U &  u,
double  rhs_i,
double  uOld 
)

The point solve of H u = rhs for one row (raw value, before damping), matching the host point solve and device jacobiFv: the pure-L path (c0=0,cD=1) keeps the exact original expression.

Definition at line 125 of file face_csr.hpp.

◆ amgPcg()

CgResult peclet::core::solver::amgPcg ( const HostCsrOp &  A,
std::vector< double > &  x,
const std::vector< double > &  b,
const GraphAMG &  M,
int  maxIters = 500,
double  tol = 1e-8 
)
inline

◆ dotPlain()

double peclet::core::solver::dotPlain ( View< const double >  a,
View< const double >  b,
Index  n 
)
inline

Plain (unweighted) dot product.

Definition at line 17 of file vector_ops.hpp.

◆ bicgPUpdate()

void peclet::core::solver::bicgPUpdate ( View< double >  p,
View< const double >  r,
View< const double >  v,
double  beta,
double  omega,
Index  n 
)
inline

BiCGStab direction update: p = r + β(p − ω v).

(Free function — an extended host device lambda may not live in a private/protected member function.)

Definition at line 26 of file vector_ops.hpp.

Referenced by peclet::core::solver::MomentumSolver::solveBiCGStab().

◆ axpy()

void peclet::core::solver::axpy ( View< double >  y,
double  a,
View< const double >  x,
Index  n 
)
inline

◆ zpby()

void peclet::core::solver::zpby ( View< double >  p,
View< const double >  z,
double  b,
Index  n 
)
inline

p = z + b·p (CG direction update)

Definition at line 39 of file vector_ops.hpp.

◆ negate()

void peclet::core::solver::negate ( View< double >  x,
Index  n 
)
inline

y = −x (negate in place)

Definition at line 45 of file vector_ops.hpp.