38 lduMatrix::solver::addasymMatrixConstructorToTable<PBiCG>
47 const word& fieldName,
86 const label nCells =
psi.size();
88 solveScalar* __restrict__ psiPtr =
psi.begin();
91 solveScalar* __restrict__ pAPtr = pA.begin();
94 solveScalar* __restrict__ wAPtr = wA.begin();
97 matrix_.Amul(wA,
psi, interfaceBouCoeffs_, interfaces_, cmpt);
102 solveScalar* __restrict__ rAPtr = rA.begin();
104 matrix().setResidualField
112 const solveScalar normFactor = this->normFactor(
psi, tsource(), wA, pA);
114 if ((log_ >= 2) || (lduMatrix::debug >= 2))
116 Info<<
" Normalisation factor = " << normFactor <<
endl;
120 solverPerf.initialResidual() =
123 solverPerf.finalResidual() = solverPerf.initialResidual();
129 || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
133 solveScalar* __restrict__ pTPtr = pT.begin();
136 solveScalar* __restrict__ wTPtr = wT.begin();
139 matrix_.Tmul(wT,
psi, interfaceIntCoeffs_, interfaces_, cmpt);
143 solveScalar* __restrict__ rTPtr = rT.begin();
146 solveScalar wArT = 0;
162 const solveScalar wArTold = wArT;
165 preconPtr_->precondition(wA, rA, cmpt);
166 preconPtr_->preconditionT(wT, rT, cmpt);
171 if (solverPerf.nIterations() == 0)
181 const solveScalar
beta = wArT/wArTold;
192 matrix_.Amul(wA, pA, interfaceBouCoeffs_, interfaces_, cmpt);
193 matrix_.Tmul(wT, pT, interfaceIntCoeffs_, interfaces_, cmpt);
195 const solveScalar wApT =
gSumProd(wA, pT, matrix().
mesh().comm());
198 if (solverPerf.checkSingularity(
mag(wApT)/normFactor))
206 const solveScalar
alpha = wArT/wApT;
215 solverPerf.finalResidual() =
221 ++solverPerf.nIterations() < maxIter_
222 && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
224 || solverPerf.nIterations() < minIter_
231 if (solverPerf.nIterations() > upperMaxIters)
234 <<
"PBiCG has failed to converge within the maximum iterations: "
235 << upperMaxIters <<
nl
236 <<
" Please try the more robust PBiCGStab solver."
242 preconPtr_->setFinished(solverPerf);
245 matrix().setResidualField
A const Field/List wrapper with possible data conversion.
A field of fields is a PtrList of fields with reference counting.
Preconditioned bi-conjugate gradient solver for asymmetric lduMatrices using a run-time selectable pr...
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
A non-const Field/List wrapper with possible data conversion.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
A cell is defined as a list of faces with extra functionality.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary).
const FieldField< Field, scalar > & interfaceIntCoeffs() const noexcept
const lduMatrix & matrix_
label maxIter_
Maximum number of iterations in the solver.
solver(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Construct solver for given field name, matrix etc.
scalar tolerance_
Final convergence tolerance.
const lduInterfaceFieldPtrsList & interfaces() const noexcept
lduInterfaceFieldPtrsList interfaces_
const FieldField< Field, scalar > & interfaceBouCoeffs_
label minIter_
Minimum number of iterations in the solver.
const lduMatrix & matrix() const noexcept
solveScalarField::cmptType normFactor(const solveScalarField &psi, const solveScalarField &source, const solveScalarField &Apsi, solveScalarField &tmpField, const lduMatrix::normTypes normType) const
Return the matrix norm using the specified norm method.
int log_
Verbosity level for solver output statements.
scalar relTol_
Convergence tolerance relative to the initial.
const FieldField< Field, scalar > & interfaceIntCoeffs_
const FieldField< Field, scalar > & interfaceBouCoeffs() const noexcept
dictionary controlDict_
Dictionary of solution controls.
const word & fieldName() const noexcept
lduMatrix is a general matrix class in which the coefficients are stored as three arrays,...
static constexpr const label defaultMaxIter
Default maximum number of iterations for solvers (1000).
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const volScalarField & psi
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
scalarProduct< Type, Type >::type gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< solveScalar > solveScalarField
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
lduMatrix::solver::addasymMatrixConstructorToTable< PBiCG > addPBiCGAsymMatrixConstructorToTable_
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
constexpr char nl
The newline '\n' character (0x0a).
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)