62 this->
normFactor(psi, tsource(), Apsi, finestCorrection);
130 (scratch1.
size() ? scratch1 : Apsi),
131 (scratch2.
size() ? scratch2 : finestCorrection),
140 finestResidual = tsource();
141 finestResidual -= Apsi;
174 void Foam::GAMGSolver::Vcycle
193 const label coarsestLevel = matrixLevels_.size() - 1;
196 agglomeration_.restrictField(coarseSources[0], finestResidual, 0,
true);
198 if (nPreSweeps_ && ((log_ >= 2) || (
debug >= 2)))
200 Pout<<
"Pre-smoothing scaling factors: ";
205 for (label leveli = 0; leveli < coarsestLevel; leveli++)
207 if (coarseSources.
set(leveli + 1))
213 coarseCorrFields[leveli] = 0.0;
215 smoothers[leveli + 1].scalarSmooth
217 coarseCorrFields[leveli],
218 coarseSources[leveli],
222 nPreSweeps_ + preSweepsLevelMultiplier_*leveli,
229 if (scaleCorrection_ && leveli < coarsestLevel - 1)
234 coarseCorrFields[leveli].size()
239 coarseCorrFields[leveli],
240 const_cast<solveScalarField&>
244 matrixLevels_[leveli],
245 interfaceLevelsBouCoeffs_[leveli],
246 interfaceLevels_[leveli],
247 coarseSources[leveli],
254 matrixLevels_[leveli].residual
256 coarseSources[leveli],
257 coarseCorrFields[leveli],
258 ConstPrecisionAdaptor<scalar, solveScalar>
260 coarseSources[leveli]
262 interfaceLevelsBouCoeffs_[leveli],
263 interfaceLevels_[leveli],
269 agglomeration_.restrictField
271 coarseSources[leveli + 1],
272 coarseSources[leveli],
279 if (nPreSweeps_ && ((log_ >= 2) || (
debug >= 2)))
286 if (coarseCorrFields.
set(coarsestLevel))
290 coarseCorrFields[coarsestLevel],
291 coarseSources[coarsestLevel]
295 if ((log_ >= 2) || (
debug >= 2))
297 Pout<<
"Post-smoothing scaling factors: ";
308 for (label leveli = coarsestLevel - 1; leveli >= 0; leveli--)
310 if (coarseCorrFields.
set(leveli))
318 coarseCorrFields[leveli].size()
325 preSmoothedCoarseCorrField = coarseCorrFields[leveli];
330 const auto& cf = agglomeration_.prolongField
332 coarseCorrFields[leveli],
335 coarseCorrFields.
set(leveli + 1)
336 ? coarseCorrFields[leveli + 1]
347 coarseCorrFields[leveli].size()
355 if (interpolateCorrection_)
361 coarseCorrFields[leveli],
363 matrixLevels_[leveli],
364 interfaceLevelsBouCoeffs_[leveli],
365 interfaceLevels_[leveli],
366 agglomeration_.restrictAddressing(leveli + 1),
377 && (interpolateCorrection_ || leveli < coarsestLevel - 1)
382 coarseCorrFields[leveli],
384 matrixLevels_[leveli],
385 interfaceLevelsBouCoeffs_[leveli],
386 interfaceLevels_[leveli],
387 coarseSources[leveli],
396 coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
399 smoothers[leveli + 1].scalarSmooth
401 coarseCorrFields[leveli],
402 coarseSources[leveli],
406 nPostSweeps_ + postSweepsLevelMultiplier_*leveli,
414 agglomeration_.prolongField
422 if (interpolateCorrection_)
431 agglomeration_.restrictAddressing(0),
437 if (scaleCorrection_)
454 psi[i] += finestCorrection[i];
467 void Foam::GAMGSolver::initVcycle
469 PtrList<solveScalarField>& coarseCorrFields,
470 PtrList<solveScalarField>& coarseSources,
471 PtrList<lduMatrix::smoother>& smoothers,
476 label maxSize = matrix_.diag().size();
478 coarseCorrFields.setSize(matrixLevels_.size());
479 coarseSources.setSize(matrixLevels_.size());
480 smoothers.setSize(matrixLevels_.size() + 1);
497 forAll(matrixLevels_, leveli)
499 if (agglomeration_.nCells(leveli) >= 0)
501 label nCoarseCells = agglomeration_.nCells(leveli);
506 if (matrixLevels_.set(leveli))
508 const lduMatrix& mat = matrixLevels_[leveli];
510 label nCoarseCells = mat.diag().size();
512 maxSize =
max(maxSize, nCoarseCells);
522 matrixLevels_[leveli],
523 interfaceLevelsBouCoeffs_[leveli],
524 interfaceLevelsIntCoeffs_[leveli],
525 interfaceLevels_[leveli],
532 if (maxSize > matrix_.diag().size())
535 scratch1.setSize(maxSize);
536 scratch2.setSize(maxSize);
547 dictionary dict(IStringStream(
"solver PCG; preconditioner DIC;")());
561 dictionary dict(IStringStream(
"solver PBiCGStab; preconditioner DILU;")());
569 void Foam::GAMGSolver::solveCoarsestLevel
575 const label coarsestLevel = matrixLevels_.size() - 1;
577 const label coarseComm = matrixLevels_[coarsestLevel].mesh().comm();
579 if (directSolveCoarsest_)
581 PrecisionAdaptor<scalar, solveScalar> tcorrField(coarsestCorrField);
583 coarsestLUMatrixPtr_->solve
586 ConstPrecisionAdaptor<scalar, solveScalar>(coarsestSource)()
690 coarsestCorrField = 0;
693 coarsestSolverPtr_->scalarSolve
700 if ((log_ >= 2) ||
debug)
void size(const label n)
Older name for setAddressableSize.
Field< solveScalar > solveScalarField
A list of keyword definitions, which are a keyword followed by a number of values (eg...
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
void setResidualField(const scalarField &residual, const word &fieldName, const bool initial) const
Set the residual field using an IOField on the object registry if it exists.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
const FieldField< Field, scalar > & interfaceBouCoeffs_
const lduMatrix & matrix() const noexcept
Ostream & endl(Ostream &os)
Add newline and flush stream.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
virtual solverPerformance solve(scalarField &psi, const scalarField &source, const direction cmpt=0) const
Solve.
A non-const Field/List wrapper with possible data conversion.
int log_
Verbosity level for solver output statements.
label minIter_
Minimum number of iterations in the solver.
#define forAll(list, i)
Loop across all elements in list.
scalar tolerance_
Final convergence tolerance.
void Amul(solveScalarField &, const tmp< solveScalarField > &, const FieldField< Field, scalar > &, const lduInterfaceFieldPtrsList &, const direction cmpt) const
Matrix multiplication with updated interfaces.
label maxIter_
Maximum number of iterations in the solver.
A const Field/List wrapper with possible data conversion.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie...
const lduMatrix & matrix_
int debug
Static debugging option.
Container< Type > & ref() const
Return non-const reference to the contents of a non-null managed pointer.
lduInterfaceFieldPtrsList interfaces_
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.
typeOfMag< Type >::type gSumMag(const FieldField< Field, Type > &f)
OSstream & masterStream(const label communicator)
Return OSstream for output operations on the master process only, Snull on other processes.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
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.
messageStream Info
Information stream (stdout output on master, null elsewhere)
SubField< solveScalar > subField
Declare type of subField.
const volScalarField & psi
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
SolverPerformance< scalar > solverPerformance
SolverPerformance instantiated for a scalar.
scalar relTol_
Convergence tolerance relative to the initial.