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();
560 if (directSolveCoarsest_)
562 coarsestLUMatrixPtr_->solve(coarsestCorrField, coarsestSource);
665 coarsestCorrField = 0;
668 if (matrixLevels_[coarsestLevel].asymmetric())
673 matrixLevels_[coarsestLevel],
674 interfaceLevelsBouCoeffs_[coarsestLevel],
675 interfaceLevelsIntCoeffs_[coarsestLevel],
676 interfaceLevels_[coarsestLevel],
686 coarseSolverPerf =
PCG 689 matrixLevels_[coarsestLevel],
690 interfaceLevelsBouCoeffs_[coarsestLevel],
691 interfaceLevelsIntCoeffs_[coarsestLevel],
692 interfaceLevels_[coarsestLevel],
703 coarseSolverPerf.
print(
Info(coarseComm));
scalar gSumMag(const FieldField< Field, Type > &f)
#define forAll(list, i)
Loop across all elements in list.
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex, const bool procAgglom) const
Restrict (integrate by summation) cell field.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const FieldField< Field, scalar > & interfaceIntCoeffs_
bool set(const label) const
Is element set.
A list of keyword definitions, which are a keyword followed by any number of values (e...
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.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve.
Pre-declare related SubField type.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
scalar tolerance_
Final convergence tolerance.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex, const bool procAgglom) const
Prolong (interpolate by injection) cell field.
const lduMatrix & matrix_
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve the matrix with this solver.
lduInterfaceFieldPtrsList interfaces_
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
dictionary controlDict_
Dictionary of controls.
void setSize(const label)
Reset size of List.
lduMatrix is a general matrix class in which the coefficients are stored as three arrays...
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.
prefixOSstream Pout(cout, "Pout")
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.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
Preconditioned conjugate gradient solver for symmetric lduMatrices using a run-time selectable precon...
Preconditioned bi-conjugate gradient stabilised solver for asymmetric lduMatrices using a run-time se...
label nCells(const label leveli) const
Return number of coarse cells (before processor agglomeration)
scalar relTol_
Convergence tolerance relative to the initial.