38 lduMatrix::solver::addsymMatrixConstructorToTable<PPCG>
45 void Foam::PPCG::gSumMagProd
47 FixedList<solveScalar, 3>& globalSum,
52 UPstream::Request& request,
56 const label nCells = a.size();
59 for (label cell=0; cell<nCells; ++cell)
61 globalSum[0] += a[cell]*
b[cell];
62 globalSum[1] += a[cell]*
c[cell];
96 const label comm = matrix().
mesh().
comm();
97 const label nCells =
psi.
size();
101 matrix_.Amul(w,
psi, interfaceBouCoeffs_, interfaces_, cmpt);
108 const solveScalar normFactor = this->normFactor(
psi, source, w,
p);
112 Info<<
" Normalisation factor = " << normFactor <<
endl;
127 preconPtr_->precondition(u, r, cmpt);
130 matrix_.Amul(w, u, interfaceBouCoeffs_, interfaces_, cmpt);
140 FixedList<solveScalar, 3> globalSum;
141 UPstream::Request outstandingRequest;
145 gSumMagProd(globalSum, u, r, w, r, outstandingRequest, comm);
148 preconPtr_->precondition(m, w, cmpt);
153 preconPtr_->precondition(m, w, cmpt);
156 gSumMagProd(globalSum, w, u, m, r, outstandingRequest, comm);
161 matrix_.Amul(
n, m, interfaceBouCoeffs_, interfaces_, cmpt);
163 solveScalar
alpha = 0.0;
164 solveScalar
gamma = 0.0;
169 solverPerf.nIterations() = 0;
170 solverPerf.nIterations() < maxIter_;
171 solverPerf.nIterations()++
175 outstandingRequest.wait();
177 const solveScalar gammaOld =
gamma;
178 gamma = globalSum[0];
179 const solveScalar
delta = globalSum[1];
181 solverPerf.finalResidual() = globalSum[2]/normFactor;
182 if (solverPerf.nIterations() == 0)
184 solverPerf.initialResidual() = solverPerf.finalResidual();
190 (minIter_ <= 0 || solverPerf.nIterations() >= minIter_)
191 && solverPerf.checkConvergence(tolerance_, relTol_, log_)
198 if (solverPerf.nIterations() == 0)
211 for (label cell=0; cell<nCells; ++cell)
213 z[cell] =
n[cell] +
beta*z[cell];
214 q[cell] = m[cell] +
beta*q[cell];
215 s[cell] = w[cell] +
beta*
s[cell];
216 p[cell] = u[cell] +
beta*
p[cell];
220 for (label cell=0; cell<nCells; ++cell)
224 u[cell] -=
alpha*q[cell];
225 w[cell] -=
alpha*z[cell];
231 gSumMagProd(globalSum, u, r, w, r, outstandingRequest, comm);
234 preconPtr_->precondition(m, w, cmpt);
239 preconPtr_->precondition(m, w, cmpt);
242 gSumMagProd(globalSum, w, u, m, r, outstandingRequest, comm);
246 matrix_.Amul(
n, m, interfaceBouCoeffs_, interfaces_, cmpt);
250 outstandingRequest.wait();
254 preconPtr_->setFinished(solverPerf);
273 const word& fieldName,
dimensioned< typename typeOfMag< Type >::type > sumMag(const DimensionedField< Type, GeoMesh > &f1)
void size(const label n)
Older name for setAddressableSize.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< solveScalar > solveScalarField
A list of keyword definitions, which are a keyword followed by a number of values (eg...
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
static int & msgType() noexcept
Message tag of standard messages.
virtual label comm() const =0
Return communicator used for parallel communication.
A non-const Field/List wrapper with possible data conversion.
Preconditioned pipelined conjugate gradient solver for symmetric lduMatrices using a run-time selecta...
A field of fields is a PtrList of fields with reference counting.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
A class for handling words, derived from Foam::string.
static autoPtr< preconditioner > New(const solver &sol, const dictionary &solverControls)
Return a new preconditioner.
A const Field/List wrapper with possible data conversion.
int debug
Static debugging option.
defineTypeNameAndDebug(combustionModel, 0)
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
const lduMesh & mesh() const noexcept
Return the LDU mesh from which the addressing is obtained.
const dimensionedScalar c
Speed of light in a vacuum.
messageStream Info
Information stream (stdout output on master, null elsewhere)
dimensionedScalar beta("beta", dimless/dimTemperature, laminarTransport)
static word getName(const dictionary &)
Find the preconditioner name (directly or from a sub-dictionary)
const volScalarField & psi
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
void reduce(T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce) using linear/tree communication schedule.
lduMatrix::solver::addsymMatrixConstructorToTable< PPCG > addPPCGSymMatrixConstructorToTable_
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
solverPerformance scalarSolveCG(solveScalarField &psi, const solveScalarField &source, const direction cmpt, const bool cgMode) const
CG solver. Operates either in conjugate-gradient mode or conjugate residual.