mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: solutionControl solver objects can return false positives in residualControl
Reported by Mark Olesen
This commit is contained in:
@ -59,36 +59,37 @@ bool Foam::pimpleControl::criteriaSatisfied()
|
||||
bool firstIter = corr_ == 1;
|
||||
|
||||
bool achieved = true;
|
||||
const dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
bool checked = false; // safety that some checks were indeed performed
|
||||
|
||||
const dictionary& solverDict = mesh_.solverPerformanceDict();
|
||||
forAllConstIter(dictionary, solverDict, iter)
|
||||
{
|
||||
const word& variableName = iter().keyword();
|
||||
label fieldI = applyToField(variableName);
|
||||
const label fieldI = applyToField(variableName);
|
||||
if (fieldI != -1)
|
||||
{
|
||||
const List<lduMatrix::solverPerformance> sp(iter().stream());
|
||||
const scalar residual = sp.last().initialResidual();
|
||||
|
||||
checked = true;
|
||||
|
||||
if (firstIter)
|
||||
{
|
||||
residualControl_[fieldI].initialResidual =
|
||||
sp.first().initialResidual();
|
||||
}
|
||||
|
||||
bool absCheck = residual < residualControl_[fieldI].absTol;
|
||||
|
||||
const bool absCheck = residual < residualControl_[fieldI].absTol;
|
||||
bool relCheck = false;
|
||||
|
||||
scalar relative = 0.0;
|
||||
if (!firstIter)
|
||||
{
|
||||
scalar iniRes =
|
||||
const scalar iniRes =
|
||||
residualControl_[fieldI].initialResidual
|
||||
+ ROOTVSMALL;
|
||||
|
||||
relative = residual/iniRes;
|
||||
|
||||
relCheck = relative < residualControl_[fieldI].relTol;
|
||||
}
|
||||
|
||||
@ -110,7 +111,7 @@ bool Foam::pimpleControl::criteriaSatisfied()
|
||||
}
|
||||
}
|
||||
|
||||
return achieved;
|
||||
return checked && achieved;
|
||||
}
|
||||
|
||||
|
||||
@ -129,7 +130,13 @@ Foam::pimpleControl::pimpleControl(fvMesh& mesh)
|
||||
if (nOuterCorr_ > 1)
|
||||
{
|
||||
Info<< nl;
|
||||
if (!residualControl_.empty())
|
||||
if (residualControl_.empty())
|
||||
{
|
||||
Info<< algorithmName_ << ": no residual control data found. "
|
||||
<< "Calculations will employ " << nOuterCorr_
|
||||
<< " corrector loops" << nl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< algorithmName_ << ": max iterations = " << nOuterCorr_
|
||||
<< endl;
|
||||
@ -142,12 +149,6 @@ Foam::pimpleControl::pimpleControl(fvMesh& mesh)
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< algorithmName_ << ": no residual control data found. " << nl
|
||||
<< "Calculations will employ " << nOuterCorr_
|
||||
<< " corrector loops" << nl << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user