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

#include <pcg.hpp>

Classes

struct  Result
 

Public Types

using MG = Multigrid< Dim, Bits >
 

Public Member Functions

void setVcycle (int pre, int post, int bottom, double omega)
 V-cycle parameters used for the preconditioner application.
 
void setCyclesPerPrec (int k)
 Number of V-cycles per preconditioner application (default 1).
 
void setSingular (bool s)
 Whether to project out the constant nullspace (default true; set false for the non-singular homogeneous-Dirichlet operator).
 
void setDistributed (std::function< void(View< double >)> refresh, std::function< double(double)> dotReduce, Index nExt)
 Distributed solve (docs/amr_distributed_flow.md, rung 3): refresh re-fills the ghost tail [n, nExt) of a vector before its neighbour entries are read (the CG direction ahead of every matvec); dotReduce folds a local sum into the global one (an MPI_Allreduce lambda — a callable so this header stays MPI-free), applied to every volume-weighted dot AND to the nullspace-projection mean sums.
 
template<class MGT = MG>
Result solve (MGT &mg, View< double > x, View< const double > rhs, int maxIters=200, double tol=1e-10)
 Solve L x = rhs on mg's finest level into x (size n; nExt distributed).
 

Detailed Description

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

Definition at line 128 of file pcg.hpp.

Member Typedef Documentation

◆ MG

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
using peclet::core::amr::PCG< Dim, Bits >::MG = Multigrid<Dim, Bits>

Definition at line 130 of file pcg.hpp.

Member Function Documentation

◆ setVcycle()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::PCG< Dim, Bits >::setVcycle ( int  pre,
int  post,
int  bottom,
double  omega 
)
inline

V-cycle parameters used for the preconditioner application.

Definition at line 139 of file pcg.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setCyclesPerPrec()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::PCG< Dim, Bits >::setCyclesPerPrec ( int  k)
inline

Number of V-cycles per preconditioner application (default 1).

Definition at line 146 of file pcg.hpp.

◆ setSingular()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::PCG< Dim, Bits >::setSingular ( bool  s)
inline

Whether to project out the constant nullspace (default true; set false for the non-singular homogeneous-Dirichlet operator).

Definition at line 149 of file pcg.hpp.

References peclet::core::amr::transferFieldGradients().

◆ setDistributed()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
void peclet::core::amr::PCG< Dim, Bits >::setDistributed ( std::function< void(View< double >)>  refresh,
std::function< double(double)>  dotReduce,
Index  nExt 
)
inline

Distributed solve (docs/amr_distributed_flow.md, rung 3): refresh re-fills the ghost tail [n, nExt) of a vector before its neighbour entries are read (the CG direction ahead of every matvec); dotReduce folds a local sum into the global one (an MPI_Allreduce lambda — a callable so this header stays MPI-free), applied to every volume-weighted dot AND to the nullspace-projection mean sums.

Scratch (and the search direction) allocate at nExt so they carry ghost tails; the multigrid passed to solve() must size its finest x(0)/b(0) at the same nExt (DistributedFlowMultigrid does). Unset (default): the single-rank behaviour, bit-identical.

Definition at line 159 of file pcg.hpp.

References peclet::core::amr::transferFieldGradients().

◆ solve()

template<int Dim, unsigned Bits = (Dim == 2 ? 32u : (Dim == 3 ? 21u : 16u))>
template<class MGT = MG>
Result peclet::core::amr::PCG< Dim, Bits >::solve ( MGT mg,
View< double x,
View< const double rhs,
int  maxIters = 200,
double  tol = 1e-10 
)
inline

Solve L x = rhs on mg's finest level into x (size n; nExt distributed).

Returns iteration count and residual history. tol is relative to the initial residual; maxIters caps the CG iterations. The multigrid mg must already be built (operator + hierarchy); any type exposing op(0)/x(0)/b(0)/numLeaves(0)/vcycle works (Multigrid, DistributedFlowMultigrid).

Definition at line 172 of file pcg.hpp.

References peclet::core::amr::applyFv(), peclet::core::amr::axpy(), peclet::core::amr::buildFluidMask(), peclet::core::amr::dotVol(), peclet::core::amr::FvOp::invVol, peclet::core::amr::maskSolid(), peclet::core::amr::negate(), peclet::core::amr::removeMeanVolReduced(), peclet::core::amr::transferFieldGradients(), and peclet::core::amr::zpby().


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