ENH: linear solvers: add variable-specific debug flags

Introduces a new optional keyword of label type 'log'
to linear-solver dictionaries to enable variable-specific
debug statements. For example, in fvOptions file:

    solvers
    {
        p
        {
            solver GAMG;
            ...
            log    2;
        }

        U
        {
            ...
            log    0;
        }
    }

The meanings of values of 'log' are:

    log    0;    <!--  no output
    log    1;    <!--  standard output
    log    2;    <!--  debug output
    // values higher than 2 are expected to have no effect

This keyword does not directly affect the operations of various
DebugSwitches and backward compatibility has been ensured in exchange
of code cleanness. The related DebugSwitches are:

    DebugSwitches
    {
        SolverPerformance    0;
        GAMG                 0;
        PCG                  0;
        PBiCG                0;
        smoothSolver         0;
    }
This commit is contained in:
Kutalmis Bercin
2021-07-19 12:24:24 +01:00
committed by Andrew Heather
parent d9b200af28
commit 6dedfe078a
19 changed files with 135 additions and 55 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -134,6 +134,9 @@ public:
//- Minimum number of iterations in the solver //- Minimum number of iterations in the solver
label minIter_; label minIter_;
//- Level of verbosity in the solver output statements
label log_;
//- Final convergence tolerance //- Final convergence tolerance
Type tolerance_; Type tolerance_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -131,6 +131,7 @@ Foam::LduMatrix<Type, DType, LUType>::solver::solver
maxIter_(defaultMaxIter_), maxIter_(defaultMaxIter_),
minIter_(0), minIter_(0),
log_(1),
tolerance_(1e-6*pTraits<Type>::one), tolerance_(1e-6*pTraits<Type>::one),
relTol_(Zero) relTol_(Zero)
{ {
@ -145,6 +146,7 @@ void Foam::LduMatrix<Type, DType, LUType>::solver::readControls()
{ {
readControl(controlDict_, maxIter_, "maxIter"); readControl(controlDict_, maxIter_, "maxIter");
readControl(controlDict_, minIter_, "minIter"); readControl(controlDict_, minIter_, "minIter");
readControl(controlDict_, log_, "log");
readControl(controlDict_, tolerance_, "tolerance"); readControl(controlDict_, tolerance_, "tolerance");
readControl(controlDict_, relTol_, "relTol"); readControl(controlDict_, relTol_, "relTol");
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -62,10 +63,11 @@ template<class Type>
bool Foam::SolverPerformance<Type>::checkConvergence bool Foam::SolverPerformance<Type>::checkConvergence
( (
const Type& Tolerance, const Type& Tolerance,
const Type& RelTolerance const Type& RelTolerance,
const label log
) )
{ {
if (debug >= 2) if ((log >= 2) || (debug >= 2))
{ {
Info<< solverName_ Info<< solverName_
<< ": Iteration " << nIterations_ << ": Iteration " << nIterations_

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -218,7 +219,8 @@ public:
bool checkConvergence bool checkConvergence
( (
const Type& tolerance, const Type& tolerance,
const Type& relTolerance const Type& relTolerance,
const label log
); );
//- Singularity test //- Singularity test

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -98,7 +99,7 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
// --- Calculate normalisation factor // --- Calculate normalisation factor
Type normFactor = this->normFactor(psi, wA, pA); Type normFactor = this->normFactor(psi, wA, pA);
if (LduMatrix<Type, DType, LUType>::debug >= 2) if ((this->log_ >= 2) || (LduMatrix<Type, DType, LUType>::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -111,7 +112,12 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
if if
( (
this->minIter_ > 0 this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_) || !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
@ -192,7 +198,12 @@ Foam::PBiCCCG<Type, DType, LUType>::solve
( (
( (
nIter++ < this->maxIter_ nIter++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_) && !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
|| nIter < this->minIter_ || nIter < this->minIter_
); );

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -95,7 +96,7 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
// --- Calculate normalisation factor // --- Calculate normalisation factor
Type normFactor = this->normFactor(psi, wA, pA); Type normFactor = this->normFactor(psi, wA, pA);
if (LduMatrix<Type, DType, LUType>::debug >= 2) if ((this->log_ >= 2) || (LduMatrix<Type, DType, LUType>::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -105,7 +106,15 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
// --- Check convergence, solve if not converged // --- Check convergence, solve if not converged
if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) if
(
!solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
)
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner>
@ -192,7 +201,12 @@ Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
} while } while
( (
nIter++ < this->maxIter_ nIter++ < this->maxIter_
&& !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) && !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
); );
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -86,7 +87,7 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
// --- Calculate normalisation factor // --- Calculate normalisation factor
Type normFactor = this->normFactor(psi, wA, pA); Type normFactor = this->normFactor(psi, wA, pA);
if (LduMatrix<Type, DType, LUType>::debug >= 2) if ((this->log_ >= 2) || (LduMatrix<Type, DType, LUType>::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -99,7 +100,12 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
if if
( (
this->minIter_ > 0 this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_) || !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
@ -184,7 +190,12 @@ Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const
( (
( (
nIter++ < this->maxIter_ nIter++ < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_) && !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
|| nIter < this->minIter_ || nIter < this->minIter_
); );

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,7 +111,7 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
} }
if (LduMatrix<Type, DType, LUType>::debug >= 2) if ((this->log_ >= 2) || (LduMatrix<Type, DType, LUType>::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -120,7 +121,12 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
if if
( (
this->minIter_ > 0 this->minIter_ > 0
|| !solverPerf.checkConvergence(this->tolerance_, this->relTol_) || !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
{ {
autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>
@ -150,7 +156,12 @@ Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const
( (
( (
(nIter += nSweeps_) < this->maxIter_ (nIter += nSweeps_) < this->maxIter_
&& !solverPerf.checkConvergence(this->tolerance_, this->relTol_) && !solverPerf.checkConvergence
(
this->tolerance_,
this->relTol_,
this->log_
)
) )
|| nIter < this->minIter_ || nIter < this->minIter_
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -120,6 +120,9 @@ public:
//- Minimum number of iterations in the solver //- Minimum number of iterations in the solver
label minIter_; label minIter_;
//- Level of verbosity in the solver output statements
label log_;
//- Final convergence tolerance //- Final convergence tolerance
scalar tolerance_; scalar tolerance_;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -164,6 +164,7 @@ void Foam::lduMatrix::solver::readControls()
{ {
maxIter_ = controlDict_.getOrDefault<label>("maxIter", defaultMaxIter_); maxIter_ = controlDict_.getOrDefault<label>("maxIter", defaultMaxIter_);
minIter_ = controlDict_.getOrDefault<label>("minIter", 0); minIter_ = controlDict_.getOrDefault<label>("minIter", 0);
log_ = controlDict_.getOrDefault<label>("log", 1);
tolerance_ = controlDict_.getOrDefault<scalar>("tolerance", 1e-6); tolerance_ = controlDict_.getOrDefault<scalar>("tolerance", 1e-6);
relTol_ = controlDict_.getOrDefault<scalar>("relTol", 0); relTol_ = controlDict_.getOrDefault<scalar>("relTol", 0);
} }

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -208,8 +209,7 @@ Foam::GAMGSolver::GAMGSolver
} }
} }
if ((log_ >= 2) || (debug & 2))
if (debug & 2)
{ {
for for
( (
@ -368,7 +368,7 @@ void Foam::GAMGSolver::readControls()
controlDict_.readIfPresent("scaleCorrection", scaleCorrection_); controlDict_.readIfPresent("scaleCorrection", scaleCorrection_);
controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_); controlDict_.readIfPresent("directSolveCoarsest", directSolveCoarsest_);
if (debug) if ((log_ >= 2) || debug)
{ {
Info<< "GAMGSolver settings :" Info<< "GAMGSolver settings :"
<< " cacheAgglomeration:" << cacheAgglomeration_ << " cacheAgglomeration:" << cacheAgglomeration_

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -59,7 +59,7 @@ Foam::solverPerformance Foam::GAMGSolver::solve
solveScalar normFactor = solveScalar normFactor =
this->normFactor(psi, tsource(), Apsi, finestCorrection); this->normFactor(psi, tsource(), Apsi, finestCorrection);
if (debug >= 2) if ((log_ >= 2) || (debug >= 2))
{ {
Pout<< " Normalisation factor = " << normFactor << endl; Pout<< " Normalisation factor = " << normFactor << endl;
} }
@ -87,7 +87,7 @@ Foam::solverPerformance Foam::GAMGSolver::solve
if if
( (
minIter_ > 0 minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_) || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
// Create coarse grid correction fields // Create coarse grid correction fields
@ -144,7 +144,7 @@ Foam::solverPerformance Foam::GAMGSolver::solve
matrix().mesh().comm() matrix().mesh().comm()
)/normFactor; )/normFactor;
if (debug >= 2) if ((log_ >= 2) || (debug >= 2))
{ {
solverPerf.print(Info.masterStream(matrix().mesh().comm())); solverPerf.print(Info.masterStream(matrix().mesh().comm()));
} }
@ -152,7 +152,7 @@ Foam::solverPerformance Foam::GAMGSolver::solve
( (
( (
++solverPerf.nIterations() < maxIter_ ++solverPerf.nIterations() < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_) && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
|| solverPerf.nIterations() < minIter_ || solverPerf.nIterations() < minIter_
); );
@ -193,7 +193,7 @@ void Foam::GAMGSolver::Vcycle
// Restrict finest grid residual for the next level up. // Restrict finest grid residual for the next level up.
agglomeration_.restrictField(coarseSources[0], finestResidual, 0, true); agglomeration_.restrictField(coarseSources[0], finestResidual, 0, true);
if (debug >= 2 && nPreSweeps_) if (nPreSweeps_ && ((log_ >= 2) || (debug >= 2)))
{ {
Pout<< "Pre-smoothing scaling factors: "; Pout<< "Pre-smoothing scaling factors: ";
} }
@ -274,7 +274,7 @@ void Foam::GAMGSolver::Vcycle
} }
} }
if (debug >= 2 && nPreSweeps_) if (nPreSweeps_ && ((log_ >= 2) || (debug >= 2)))
{ {
Pout<< endl; Pout<< endl;
} }
@ -290,7 +290,7 @@ void Foam::GAMGSolver::Vcycle
); );
} }
if (debug >= 2) if ((log_ >= 2) || (debug >= 2))
{ {
Pout<< "Post-smoothing scaling factors: "; Pout<< "Post-smoothing scaling factors: ";
} }
@ -703,7 +703,7 @@ void Foam::GAMGSolver::solveCoarsestLevel
) )
); );
if (debug) if ((log_ >= 2) || debug)
{ {
coarseSolverPerf.print(Info.masterStream(coarseComm)); coarseSolverPerf.print(Info.masterStream(coarseComm));
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -111,7 +111,7 @@ Foam::solverPerformance Foam::PBiCG::solve
// --- Calculate normalisation factor // --- Calculate normalisation factor
const solveScalar normFactor = this->normFactor(psi, tsource(), wA, pA); const solveScalar normFactor = this->normFactor(psi, tsource(), wA, pA);
if (lduMatrix::debug >= 2) if ((log_ >= 2) || (lduMatrix::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -126,7 +126,7 @@ Foam::solverPerformance Foam::PBiCG::solve
if if
( (
minIter_ > 0 minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_) || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
solveScalarField pT(nCells, 0); solveScalarField pT(nCells, 0);
@ -217,7 +217,7 @@ Foam::solverPerformance Foam::PBiCG::solve
( (
( (
++solverPerf.nIterations() < maxIter_ ++solverPerf.nIterations() < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_) && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
|| solverPerf.nIterations() < minIter_ || solverPerf.nIterations() < minIter_
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2017 OpenFOAM Foundation Copyright (C) 2016-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,7 +110,7 @@ Foam::solverPerformance Foam::PBiCGStab::scalarSolve
// --- Calculate normalisation factor // --- Calculate normalisation factor
const solveScalar normFactor = this->normFactor(psi, source, yA, pA); const solveScalar normFactor = this->normFactor(psi, source, yA, pA);
if (lduMatrix::debug >= 2) if ((log_ >= 2) || (lduMatrix::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -125,7 +125,7 @@ Foam::solverPerformance Foam::PBiCGStab::scalarSolve
if if
( (
minIter_ > 0 minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_) || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
solveScalarField AyA(nCells); solveScalarField AyA(nCells);
@ -219,7 +219,7 @@ Foam::solverPerformance Foam::PBiCGStab::scalarSolve
if if
( (
solverPerf.nIterations() >= minIter_ solverPerf.nIterations() >= minIter_
&& solverPerf.checkConvergence(tolerance_, relTol_) && solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
for (label cell=0; cell<nCells; cell++) for (label cell=0; cell<nCells; cell++)
@ -258,7 +258,7 @@ Foam::solverPerformance Foam::PBiCGStab::scalarSolve
( (
( (
++solverPerf.nIterations() < maxIter_ ++solverPerf.nIterations() < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_) && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
|| solverPerf.nIterations() < minIter_ || solverPerf.nIterations() < minIter_
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -110,7 +110,7 @@ Foam::solverPerformance Foam::PCG::scalarSolve
// --- Calculate normalisation factor // --- Calculate normalisation factor
solveScalar normFactor = this->normFactor(psi, source, wA, pA); solveScalar normFactor = this->normFactor(psi, source, wA, pA);
if (lduMatrix::debug >= 2) if ((log_ >= 2) || (lduMatrix::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -125,7 +125,7 @@ Foam::solverPerformance Foam::PCG::scalarSolve
if if
( (
minIter_ > 0 minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_) || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
// --- Select and construct the preconditioner // --- Select and construct the preconditioner
@ -193,7 +193,7 @@ Foam::solverPerformance Foam::PCG::scalarSolve
( (
( (
++solverPerf.nIterations() < maxIter_ ++solverPerf.nIterations() < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_) && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
|| solverPerf.nIterations() < minIter_ || solverPerf.nIterations() < minIter_
); );

View File

@ -107,7 +107,7 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG
solveScalarField p(nCells); solveScalarField p(nCells);
const solveScalar normFactor = this->normFactor(psi, source, w, p); const solveScalar normFactor = this->normFactor(psi, source, w, p);
if (lduMatrix::debug >= 2) if ((log_ >= 2) || (lduMatrix::debug >= 2))
{ {
Info<< " Normalisation factor = " << normFactor << endl; Info<< " Normalisation factor = " << normFactor << endl;
} }
@ -190,7 +190,7 @@ Foam::solverPerformance Foam::PPCG::scalarSolveCG
if if
( (
(minIter_ <= 0 || solverPerf.nIterations() >= minIter_) (minIter_ <= 0 || solverPerf.nIterations() >= minIter_)
&& solverPerf.checkConvergence(tolerance_, relTol_) && solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
break; break;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -149,7 +149,7 @@ Foam::solverPerformance Foam::smoothSolver::solve
solverPerf.finalResidual() = solverPerf.initialResidual(); solverPerf.finalResidual() = solverPerf.initialResidual();
} }
if (lduMatrix::debug >= 2) if ((log_ >= 2) || (lduMatrix::debug >= 2))
{ {
Info.masterStream(matrix().mesh().comm()) Info.masterStream(matrix().mesh().comm())
<< " Normalisation factor = " << normFactor << endl; << " Normalisation factor = " << normFactor << endl;
@ -160,7 +160,7 @@ Foam::solverPerformance Foam::smoothSolver::solve
if if
( (
minIter_ > 0 minIter_ > 0
|| !solverPerf.checkConvergence(tolerance_, relTol_) || !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
{ {
addProfiling(solve, "lduMatrix::smoother." + fieldName_); addProfiling(solve, "lduMatrix::smoother." + fieldName_);
@ -203,7 +203,7 @@ Foam::solverPerformance Foam::smoothSolver::solve
( (
( (
(solverPerf.nIterations() += nSweeps_) < maxIter_ (solverPerf.nIterations() += nSweeps_) < maxIter_
&& !solverPerf.checkConvergence(tolerance_, relTol_) && !solverPerf.checkConvergence(tolerance_, relTol_, log_)
) )
|| solverPerf.nIterations() < minIter_ || solverPerf.nIterations() < minIter_
); );

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -222,7 +222,14 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveSegregated
solverControls solverControls
)->solve(psiCmpt, sourceCmpt, cmpt); )->solve(psiCmpt, sourceCmpt, cmpt);
if (SolverPerformance<Type>::debug) const label log =
solverControls.getOrDefault<label>
(
"log",
SolverPerformance<Type>::debug
);
if (log)
{ {
solverPerf.print(Info.masterStream(this->mesh().comm())); solverPerf.print(Info.masterStream(this->mesh().comm()));
} }
@ -289,7 +296,14 @@ Foam::SolverPerformance<Type> Foam::fvMatrix<Type>::solveCoupled
coupledMatrixSolver->solve(psi) coupledMatrixSolver->solve(psi)
); );
if (SolverPerformance<Type>::debug) const label log =
solverControls.getOrDefault<label>
(
"log",
SolverPerformance<Type>::debug
);
if (log)
{ {
solverPerf.print(Info.masterStream(this->mesh().comm())); solverPerf.print(Info.masterStream(this->mesh().comm()));
} }

View File

@ -137,7 +137,10 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve
totalSource totalSource
); );
if (solverPerformance::debug) const label log =
solverControls.getOrDefault<label>("log", solverPerformance::debug);
if (log)
{ {
solverPerf.print(Info.masterStream(fvMat_.mesh().comm())); solverPerf.print(Info.masterStream(fvMat_.mesh().comm()));
} }
@ -264,7 +267,10 @@ Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::solveSegregated
} }
} }
if (solverPerformance::debug) const label log =
solverControls.getOrDefault<label>("log", solverPerformance::debug);
if (log)
{ {
solverPerf.print(Info.masterStream(mesh().comm())); solverPerf.print(Info.masterStream(mesh().comm()));
} }