45 matrix_.Amul(Apsi, psi, interfaceBouCoeffs_, interfaces_, cmpt);
52 scalar normFactor = this->normFactor(psi, source, Apsi, finestCorrection);
56 Pout<<
" Normalisation factor = " << normFactor <<
endl;
66 matrix().
mesh().comm()
113 (scratch1.
size() ? scratch1 : Apsi),
114 (scratch2.
size() ? scratch2 : finestCorrection),
122 matrix_.Amul(Apsi, psi, interfaceBouCoeffs_, interfaces_, cmpt);
123 finestResidual = source;
124 finestResidual -= Apsi;
129 matrix().
mesh().comm()
150 void Foam::GAMGSolver::Vcycle
169 const label coarsestLevel = matrixLevels_.size() - 1;
172 agglomeration_.
restrictField(coarseSources[0], finestResidual, 0,
true);
174 if (debug >= 2 && nPreSweeps_)
176 Pout<<
"Pre-smoothing scaling factors: ";
181 for (
label leveli = 0; leveli < coarsestLevel; leveli++)
183 if (coarseSources.
set(leveli + 1))
189 coarseCorrFields[leveli] = 0.0;
191 smoothers[leveli + 1].smooth
193 coarseCorrFields[leveli],
194 coarseSources[leveli],
198 nPreSweeps_ + preSweepsLevelMultiplier_*leveli,
206 coarseCorrFields[leveli].size()
211 if (scaleCorrection_ && leveli < coarsestLevel - 1)
215 coarseCorrFields[leveli],
216 const_cast<scalarField&>
220 matrixLevels_[leveli],
221 interfaceLevelsBouCoeffs_[leveli],
222 interfaceLevels_[leveli],
223 coarseSources[leveli],
229 matrixLevels_[leveli].Amul
231 const_cast<scalarField&>
235 coarseCorrFields[leveli],
236 interfaceLevelsBouCoeffs_[leveli],
237 interfaceLevels_[leveli],
241 coarseSources[leveli] -= ACf;
247 coarseSources[leveli + 1],
248 coarseSources[leveli],
255 if (debug >= 2 && nPreSweeps_)
262 if (coarseCorrFields.
set(coarsestLevel))
266 coarseCorrFields[coarsestLevel],
267 coarseSources[coarsestLevel]
273 Pout<<
"Post-smoothing scaling factors: ";
281 for (
label leveli = coarsestLevel - 1; leveli >= 0; leveli--)
283 if (coarseCorrFields.
set(leveli))
291 coarseCorrFields[leveli].size()
298 preSmoothedCoarseCorrField = coarseCorrFields[leveli];
303 coarseCorrFields[leveli],
305 coarseCorrFields.
set(leveli + 1)
306 ? coarseCorrFields[leveli + 1]
318 coarseCorrFields[leveli].size()
323 if (interpolateCorrection_)
325 if (coarseCorrFields.
set(leveli+1))
329 coarseCorrFields[leveli],
331 matrixLevels_[leveli],
332 interfaceLevelsBouCoeffs_[leveli],
333 interfaceLevels_[leveli],
335 coarseCorrFields[leveli + 1],
343 coarseCorrFields[leveli],
345 matrixLevels_[leveli],
346 interfaceLevelsBouCoeffs_[leveli],
347 interfaceLevels_[leveli],
358 && (interpolateCorrection_ || leveli < coarsestLevel - 1)
363 coarseCorrFields[leveli],
365 matrixLevels_[leveli],
366 interfaceLevelsBouCoeffs_[leveli],
367 interfaceLevels_[leveli],
368 coarseSources[leveli],
377 coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
380 smoothers[leveli + 1].smooth
382 coarseCorrFields[leveli],
383 coarseSources[leveli],
387 nPostSweeps_ + postSweepsLevelMultiplier_*leveli,
403 if (interpolateCorrection_)
418 if (scaleCorrection_)
435 psi[i] += finestCorrection[i];
448 void Foam::GAMGSolver::initVcycle
459 coarseCorrFields.
setSize(matrixLevels_.size());
460 coarseSources.
setSize(matrixLevels_.size());
461 smoothers.
setSize(matrixLevels_.size() + 1);
478 forAll(matrixLevels_, leveli)
480 if (agglomeration_.
nCells(leveli) >= 0)
482 label nCoarseCells = agglomeration_.
nCells(leveli);
487 if (matrixLevels_.set(leveli))
489 const lduMatrix& mat = matrixLevels_[leveli];
493 maxSize =
max(maxSize, nCoarseCells);
503 matrixLevels_[leveli],
504 interfaceLevelsBouCoeffs_[leveli],
505 interfaceLevelsIntCoeffs_[leveli],
506 interfaceLevels_[leveli],
529 dict.
add(
"tolerance", tol);
530 dict.
add(
"relTol", relTol);
543 dict.
add(
"tolerance", tol);
544 dict.
add(
"relTol", relTol);
550 void Foam::GAMGSolver::solveCoarsestLevel
556 const label coarsestLevel = matrixLevels_.size() - 1;
558 label coarseComm = matrixLevels_[coarsestLevel].mesh().comm();
562 if (directSolveCoarsest_)
564 coarsestLUMatrixPtr_->solve(coarsestCorrField, coarsestSource);
671 coarsestCorrField = 0;
674 if (matrixLevels_[coarsestLevel].asymmetric())
676 coarseSolverPerf =
PBiCG 679 matrixLevels_[coarsestLevel],
680 interfaceLevelsBouCoeffs_[coarsestLevel],
681 interfaceLevelsIntCoeffs_[coarsestLevel],
682 interfaceLevels_[coarsestLevel],
692 coarseSolverPerf =
PCG 695 matrixLevels_[coarsestLevel],
696 interfaceLevelsBouCoeffs_[coarsestLevel],
697 interfaceLevelsIntCoeffs_[coarsestLevel],
698 interfaceLevels_[coarsestLevel],
scalar gSumMag(const FieldField< Field, Type > &f)
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const FieldField< Field, scalar > & interfaceIntCoeffs_
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const FieldField< Field, scalar > & interfaceBouCoeffs_
void size(const label)
Override size to be inconsistent with allocated storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
tmp< surfaceScalarField > interpolate(const RhoType &rho)
Pre-declare related SubField type.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
scalar tolerance_
Final convergence tolerance.
label nCells(const label leveli) const
Return number of coarse cells (before processor agglomeration)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
bool set(const label) const
Is element set.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
static label warnComm
Debugging: warn for use of any communicator differing from warnComm.
const lduMatrix & matrix_
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
prefixOSstream Pout(cout,"Pout")
Preconditioned bi-conjugate gradient solver for asymmetric lduMatrices using a run-time selectable pr...
lduInterfaceFieldPtrsList interfaces_
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
dictionary controlDict_
Dictionary of controls.
OSstream & masterStream(const label communicator)
Convert to OSstream.
void setSize(const label)
Reset size of List.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex, const bool procAgglom) const
Prolong (interpolate by injection) cell field.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Input from memory buffer stream.
static autoPtr< smoother > New(const word &fieldName, const lduMatrix &matrix, const FieldField< Field, scalar > &interfaceBouCoeffs, const FieldField< Field, scalar > &interfaceIntCoeffs, const lduInterfaceFieldPtrsList &interfaces, const dictionary &solverControls)
Return a new smoother.
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex, const bool procAgglom) const
Restrict (integrate by summation) cell field.
Preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time selectable precon...
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve.
scalar relTol_
Convergence tolerance relative to the initial.