60 this->
normFactor(psi, tsource(), Apsi, finestCorrection);
128 (scratch1.
size() ? scratch1 : Apsi),
129 (scratch2.
size() ? scratch2 : finestCorrection),
138 finestResidual = tsource();
139 finestResidual -= Apsi;
172 void Foam::GAMGSolver::Vcycle
191 const label coarsestLevel = matrixLevels_.size() - 1;
194 agglomeration_.restrictField(coarseSources[0], finestResidual, 0,
true);
196 if (nPreSweeps_ && ((log_ >= 2) || (
debug >= 2)))
198 Pout<<
"Pre-smoothing scaling factors: ";
203 for (label leveli = 0; leveli < coarsestLevel; leveli++)
205 if (coarseSources.
set(leveli + 1))
211 coarseCorrFields[leveli] = 0.0;
213 smoothers[leveli + 1].scalarSmooth
215 coarseCorrFields[leveli],
216 coarseSources[leveli],
220 nPreSweeps_ + preSweepsLevelMultiplier_*leveli,
228 coarseCorrFields[leveli].size()
233 if (scaleCorrection_ && leveli < coarsestLevel - 1)
237 coarseCorrFields[leveli],
238 const_cast<solveScalarField&>
242 matrixLevels_[leveli],
243 interfaceLevelsBouCoeffs_[leveli],
244 interfaceLevels_[leveli],
245 coarseSources[leveli],
251 matrixLevels_[leveli].Amul
253 const_cast<solveScalarField&>
257 coarseCorrFields[leveli],
258 interfaceLevelsBouCoeffs_[leveli],
259 interfaceLevels_[leveli],
263 coarseSources[leveli] -= ACf;
267 agglomeration_.restrictField
269 coarseSources[leveli + 1],
270 coarseSources[leveli],
277 if (nPreSweeps_ && ((log_ >= 2) || (
debug >= 2)))
284 if (coarseCorrFields.
set(coarsestLevel))
288 coarseCorrFields[coarsestLevel],
289 coarseSources[coarsestLevel]
293 if ((log_ >= 2) || (
debug >= 2))
295 Pout<<
"Post-smoothing scaling factors: ";
303 for (label leveli = coarsestLevel - 1; leveli >= 0; leveli--)
305 if (coarseCorrFields.
set(leveli))
313 coarseCorrFields[leveli].size()
320 preSmoothedCoarseCorrField = coarseCorrFields[leveli];
323 agglomeration_.prolongField
325 coarseCorrFields[leveli],
327 coarseCorrFields.
set(leveli + 1)
328 ? coarseCorrFields[leveli + 1]
340 coarseCorrFields[leveli].size()
348 if (interpolateCorrection_)
350 if (coarseCorrFields.
set(leveli+1))
354 coarseCorrFields[leveli],
356 matrixLevels_[leveli],
357 interfaceLevelsBouCoeffs_[leveli],
358 interfaceLevels_[leveli],
359 agglomeration_.restrictAddressing(leveli + 1),
360 coarseCorrFields[leveli + 1],
368 coarseCorrFields[leveli],
370 matrixLevels_[leveli],
371 interfaceLevelsBouCoeffs_[leveli],
372 interfaceLevels_[leveli],
383 && (interpolateCorrection_ || leveli < coarsestLevel - 1)
388 coarseCorrFields[leveli],
390 matrixLevels_[leveli],
391 interfaceLevelsBouCoeffs_[leveli],
392 interfaceLevels_[leveli],
393 coarseSources[leveli],
402 coarseCorrFields[leveli] += preSmoothedCoarseCorrField;
405 smoothers[leveli + 1].scalarSmooth
407 coarseCorrFields[leveli],
408 coarseSources[leveli],
412 nPostSweeps_ + postSweepsLevelMultiplier_*leveli,
420 agglomeration_.prolongField
428 if (interpolateCorrection_)
437 agglomeration_.restrictAddressing(0),
443 if (scaleCorrection_)
460 psi[i] += finestCorrection[i];
473 void Foam::GAMGSolver::initVcycle
475 PtrList<solveScalarField>& coarseCorrFields,
476 PtrList<solveScalarField>& coarseSources,
477 PtrList<lduMatrix::smoother>& smoothers,
482 label maxSize = matrix_.diag().size();
484 coarseCorrFields.setSize(matrixLevels_.size());
485 coarseSources.setSize(matrixLevels_.size());
486 smoothers.setSize(matrixLevels_.size() + 1);
503 forAll(matrixLevels_, leveli)
505 if (agglomeration_.nCells(leveli) >= 0)
507 label nCoarseCells = agglomeration_.nCells(leveli);
512 if (matrixLevels_.set(leveli))
514 const lduMatrix& mat = matrixLevels_[leveli];
516 label nCoarseCells = mat.diag().size();
518 maxSize =
max(maxSize, nCoarseCells);
528 matrixLevels_[leveli],
529 interfaceLevelsBouCoeffs_[leveli],
530 interfaceLevelsIntCoeffs_[leveli],
531 interfaceLevels_[leveli],
538 if (maxSize > matrix_.diag().size())
541 scratch1.setSize(maxSize);
542 scratch2.setSize(maxSize);
553 dictionary
dict(IStringStream(
"solver PCG; preconditioner DIC;")());
567 dictionary
dict(IStringStream(
"solver PBiCGStab; preconditioner DILU;")());
575 void Foam::GAMGSolver::solveCoarsestLevel
581 const label coarsestLevel = matrixLevels_.size() - 1;
583 const label coarseComm = matrixLevels_[coarsestLevel].mesh().comm();
585 if (directSolveCoarsest_)
587 PrecisionAdaptor<scalar, solveScalar> tcorrField(coarsestCorrField);
589 coarsestLUMatrixPtr_->solve
592 ConstPrecisionAdaptor<scalar, solveScalar>(coarsestSource)()
696 coarsestCorrField = 0;
699 coarsestSolverPtr_->scalarSolve
706 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.