Skip to content

Commit

Permalink
convergenceControl: Store solve index per-field not per-entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Bainbridge committed Feb 20, 2019
1 parent d93375f commit e29811f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -60,7 +60,6 @@ public:
wordRe name;
scalar absTol;
scalar relTol;
label solveIndex;
};


Expand Down
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -96,7 +96,6 @@ bool Foam::singleRegionCorrectorConvergenceControl::readCorrResidualControls()
rd.name = fName.c_str();
rd.absTol = readScalar(fieldDict.lookup("tolerance"));
rd.relTol = readScalar(fieldDict.lookup("relTol"));
rd.solveIndex = 0;
data.append(rd);
}
else
Expand Down Expand Up @@ -177,11 +176,11 @@ corrCriteriaSatisfied() const
const dictionary& solverDict = mesh_.solverPerformanceDict();
forAllConstIter(dictionary, solverDict, iter)
{
const word& variableName = iter().keyword();
const word& fieldName = iter().keyword();
const label fieldi =
convergenceControl::residualControlIndex
(
variableName,
fieldName,
corrResidualControl_
);
if (fieldi != -1)
Expand All @@ -190,8 +189,8 @@ corrCriteriaSatisfied() const
convergenceControl::getInitialResiduals
(
mesh_,
variableName,
corrResidualControl_[fieldi].solveIndex,
fieldName,
solveIndex_.found(fieldName) ? solveIndex_[fieldName] : 0,
iter().stream(),
firstResidual,
residual
Expand All @@ -209,7 +208,7 @@ corrCriteriaSatisfied() const

if (control_.debug)
{
Info<< control_.algorithmSpace() << " " << variableName
Info<< control_.algorithmSpace() << " " << fieldName
<< ": tolerance " << residual << " ("
<< corrResidualControl_[fieldi].absTol << ")"
<< ", relTol " << relativeResidual << " ("
Expand All @@ -225,10 +224,7 @@ corrCriteriaSatisfied() const

void Foam::singleRegionCorrectorConvergenceControl::resetCorrSolveIndex()
{
forAll(corrResidualControl_, i)
{
corrResidualControl_[i].solveIndex = 0;
}
solveIndex_.clear();
}


Expand All @@ -237,23 +233,14 @@ void Foam::singleRegionCorrectorConvergenceControl::updateCorrSolveIndex()
const dictionary& solverDict = mesh_.solverPerformanceDict();
forAllConstIter(dictionary, solverDict, iter)
{
const word& variableName = iter().keyword();
const label fieldi =
convergenceControl::residualControlIndex
(
variableName,
corrResidualControl_
);
if (fieldi != -1)
{
getNSolves
(
mesh_,
variableName,
iter().stream(),
corrResidualControl_[fieldi].solveIndex
);
}
const word& fieldName = iter().keyword();
getNSolves
(
mesh_,
fieldName,
iter().stream(),
solveIndex_(fieldName)
);
}
}

Expand Down
Expand Up @@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
Expand Down Expand Up @@ -62,6 +62,11 @@ protected:
//- List of residual data per field
List<corrResidualData> corrResidualControl_;

//- The index of the solution at the start of the corrector loop, for
// each field. If the field name is not in the table then the index is
// assumed to be zero; i.e, the first solution.
HashTable<label> solveIndex_;


public:

Expand Down

0 comments on commit e29811f

Please sign in to comment.