39 lduMatrix::solver::addsymMatrixConstructorToTable<FPCG>
48 const word& fieldName,
70void Foam::FPCG::gSumMagProd
72 FixedList<solveScalar, 2>& globalSum,
78 const label nCells = a.
size();
81 for (label cell=0; cell<nCells; ++cell)
83 globalSum[0] += a[cell]*
b[cell];
84 globalSum[1] +=
mag(
b[cell]);
113 label nCells =
psi.size();
115 solveScalar* __restrict__ psiPtr =
psi.begin();
118 solveScalar* __restrict__ pAPtr = pA.begin();
121 solveScalar* __restrict__ wAPtr = wA.begin();
123 solveScalar wArA = solverPerf.great_;
124 solveScalar wArAold = wArA;
127 matrix_.Amul(wA,
psi, interfaceBouCoeffs_, interfaces_, cmpt);
131 solveScalar* __restrict__ rAPtr = rA.begin();
133 matrix().setResidualField
141 solveScalar normFactor = this->normFactor(
psi, source, wA, pA);
143 if ((log_ >= 2) || (lduMatrix::debug >= 2))
145 Info<<
" Normalisation factor = " << normFactor <<
endl;
149 solverPerf.initialResidual() =
152 solverPerf.finalResidual() = solverPerf.initialResidual();
158 || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
180 preconPtr_->precondition(wA, rA, cmpt);
183 gSumMagProd(globalSum, wA, rA, matrix().
mesh().comm());
187 solverPerf.finalResidual() = globalSum[1]/normFactor;
192 (minIter_ <= 0 || solverPerf.nIterations() >= minIter_)
193 && solverPerf.checkConvergence(tolerance_, relTol_, log_)
199 if (solverPerf.nIterations() == 0)
208 const solveScalar
beta = wArA/wArAold;
218 matrix_.Amul(wA, pA, interfaceBouCoeffs_, interfaces_, cmpt);
220 solveScalar wApA =
gSumProd(wA, pA, matrix().
mesh().comm());
223 if (solverPerf.checkSingularity(
mag(wApA)/normFactor))
break;
228 const solveScalar
alpha = wArA/wApA;
238 ++solverPerf.nIterations() < maxIter_
244 preconPtr_->setFinished(solverPerf);
247 matrix().setResidualField
A const Field/List wrapper with possible data conversion.
label size() const noexcept
The number of elements in list.
A 'faster' preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time select...
virtual solverPerformance scalarSolve(solveScalarField &psi, const solveScalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
A field of fields is a PtrList of fields with reference counting.
A 1D vector of objects of type <T> with a fixed length <N>.
static constexpr label size() noexcept
Return the number of elements in the FixedList.
T * data() noexcept
Return pointer to the underlying array serving as data storage.
A non-const Field/List wrapper with possible data conversion.
iterator begin() noexcept
Return an iterator to begin traversing the UList.
void size(const label n)
Older name for setAddressableSize.
static int & msgType() noexcept
Message tag of standard messages.
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 > & 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,...
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
scalarProduct< Type, Type >::type gSumProd(const UList< Type > &f1, const UList< Type > &f2, const label comm)
lduMatrix::solver::addsymMatrixConstructorToTable< FPCG > addFPCGSymMatrixConstructorToTable_
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)
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
Field< solveScalar > solveScalarField
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
UPtrList< const lduInterfaceField > lduInterfaceFieldPtrsList
List of coupled interface fields to be used in coupling.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)