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::MomentumSolver Class Reference

#include <csr_bicgstab.hpp>

Classes

struct  Result
 

Public Member Functions

void setJacobi (int preSweeps, double omega)
 
void setDistributed (std::function< void(View< double >)> refresh, std::function< double(double)> dotReduce, Index nExt)
 Distributed solve (docs/amr_distributed_flow.md, rung 2): refresh re-fills the ghost tail [op.n, nExt) of a vector from its owners (LeafHaloExchange::exchange) and is called before EVERY read of a vector's neighbour entries — the initial residual, each preconditioner Jacobi sweep, each matvec of a preconditioned direction.
 
void setPreconditioner (std::function< void(View< const double >, View< double >)> fn)
 Set a generic preconditioner z = M⁻¹ r (a host callable that launches device kernels) — the multigrid V-cycle gives the smooth-mode coverage Jacobi lacks, so the momentum iteration count stops growing with N.
 
double solveJacobi (const MomentumOp &op, View< double > u, View< const double > b, int sweeps)
 Plain weighted-Jacobi solve (the simple parallel mirror of the host GS smoother): sweeps damped-Jacobi sweeps of A u = b in place.
 
Result solveDefectCorrection (const MomentumOp &op, View< double > u, View< const double > b, int maxIters=200, double tol=1e-8)
 MG-preconditioned defect-correction (Richardson) solve of A u = b in place: u ← u + M⁻¹(b − A u), M = the preconditioner (velocity-MG if set, else Jacobi sweeps).
 
Result solveBiCGStab (const MomentumOp &op, View< double > u, View< const double > b, int maxIters=500, double tol=1e-10)
 Jacobi-preconditioned BiCGStab solve of A u = b in place.
 

Detailed Description

Definition at line 33 of file csr_bicgstab.hpp.

Member Function Documentation

◆ setJacobi()

void peclet::core::solver::MomentumSolver::setJacobi ( int  preSweeps,
double  omega 
)
inline

Definition at line 35 of file csr_bicgstab.hpp.

◆ setDistributed()

void peclet::core::solver::MomentumSolver::setDistributed ( std::function< void(View< double >)>  refresh,
std::function< double(double)>  dotReduce,
Index  nExt 
)
inline

Distributed solve (docs/amr_distributed_flow.md, rung 2): refresh re-fills the ghost tail [op.n, nExt) of a vector from its owners (LeafHaloExchange::exchange) and is called before EVERY read of a vector's neighbour entries — the initial residual, each preconditioner Jacobi sweep, each matvec of a preconditioned direction.

dotReduce folds a local dot into the global one (an MPI_Allreduce lambda — kept as a callable so this header stays MPI-free; local rows only, ghosts are never summed). Scratch vectors are allocated at nExt so they can carry ghost tails. Jacobi preconditioning reads only the previous iterate, so the distributed iterate sequence matches the single-rank one bit-for-bit up to the dots' reduction order. Unset (default): the single-rank behaviour, bit-identical.

Definition at line 49 of file csr_bicgstab.hpp.

◆ setPreconditioner()

void peclet::core::solver::MomentumSolver::setPreconditioner ( std::function< void(View< const double >, View< double >)>  fn)
inline

Set a generic preconditioner z = M⁻¹ r (a host callable that launches device kernels) — the multigrid V-cycle gives the smooth-mode coverage Jacobi lacks, so the momentum iteration count stops growing with N.

Decoupled from the MG type (Galerkin MomentumMG or rediscretized VelocityMG) via std::function, so the two coarse-operator strategies are interchangeable (and the solver carries no MG type). Pass an empty function to revert to damped-Jacobi. The preconditioner never changes the converged solution (the matvec is the exact operator).

Definition at line 62 of file csr_bicgstab.hpp.

◆ solveJacobi()

double peclet::core::solver::MomentumSolver::solveJacobi ( const MomentumOp &  op,
View< double >  u,
View< const double >  b,
int  sweeps 
)
inline

Plain weighted-Jacobi solve (the simple parallel mirror of the host GS smoother): sweeps damped-Jacobi sweeps of A u = b in place.

Returns the final residual L2.

Definition at line 68 of file csr_bicgstab.hpp.

References peclet::core::solver::jacobiMom(), and peclet::core::solver::residualMom().

◆ solveDefectCorrection()

Result peclet::core::solver::MomentumSolver::solveDefectCorrection ( const MomentumOp &  op,
View< double >  u,
View< const double >  b,
int  maxIters = 200,
double  tol = 1e-8 
)
inline

MG-preconditioned defect-correction (Richardson) solve of A u = b in place: u ← u + M⁻¹(b − A u), M = the preconditioner (velocity-MG if set, else Jacobi sweeps).

Unlike BiCGStab it cannot break down — robust for the strongly non-symmetric momentum operator with implicit-FOU advection, where the velocity-MG (built from the viscous base) is only an approximate inverse. Converges when the advection is a perturbation of the viscous+reaction operator (low–moderate cell Reynolds number). maxIters caps the iterations; tol is relative to ||b−Au₀||.

Definition at line 92 of file csr_bicgstab.hpp.

References peclet::core::solver::axpy(), and peclet::core::solver::residualMom().

◆ solveBiCGStab()

Result peclet::core::solver::MomentumSolver::solveBiCGStab ( const MomentumOp &  op,
View< double >  u,
View< const double >  b,
int  maxIters = 500,
double  tol = 1e-10 
)
inline

Jacobi-preconditioned BiCGStab solve of A u = b in place.

maxIters caps the outer iterations; tol is relative to ||b−Au0||. Returns {iters, final residual L2}.

Definition at line 122 of file csr_bicgstab.hpp.

References peclet::core::solver::applyMom(), peclet::core::solver::axpy(), peclet::core::solver::bicgPUpdate(), and peclet::core::solver::residualMom().


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