Commit 9b330a9e authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: updated residuals function object field output

Fields now correspond to the initial residual for the first solver
iteration
parent 6312f809
......@@ -342,7 +342,26 @@ void Foam::lduMatrix::setResidualField
if (residualPtr)
{
*residualPtr = residual;
const IOdictionary* dataPtr =
lduMesh_.thisDb().lookupObjectPtr<IOdictionary>("data");
if (dataPtr)
{
if (initial && dataPtr->found("firstIteration"))
{
*residualPtr = residual;
DebugInfo
<< "Setting residual field for first solver iteration "
<< "for solver field: " << fieldName << endl;
}
}
else
{
*residualPtr = residual;
DebugInfo
<< "Setting residual field for solver field "
<< fieldName << endl;
}
}
}
......
......@@ -120,6 +120,18 @@ bool Foam::pimpleControl::criteriaSatisfied()
}
void Foam::pimpleControl::setFirstIterFlag(const bool check, const bool force)
{
DebugInfo
<< "corr:" << corr_
<< " corrPISO:" << corrPISO_
<< " corrNonOrtho:" << corrNonOrtho_
<< endl;
solutionControl::setFirstIterFlag(check && corrPISO_ <= 1, force);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pimpleControl::pimpleControl(fvMesh& mesh, const word& dictName)
......@@ -181,6 +193,8 @@ bool Foam::pimpleControl::loop()
Info<< algorithmName_ << " loop: corr = " << corr_ << endl;
}
setFirstIterFlag();
if (corr_ == nCorrPIMPLE_ + 1)
{
if (!residualControl_.empty() && (nCorrPIMPLE_ != 1))
......
......@@ -100,6 +100,13 @@ protected:
//- Return true if all convergence checks are satisfied
virtual bool criteriaSatisfied();
//- Set the firstIteration flag on the mesh data dictionary
virtual void setFirstIterFlag
(
const bool check = true,
const bool force = false
);
public:
......@@ -161,7 +168,7 @@ public:
inline bool solveFlow() const;
//- Return true to solve for turbulence
inline bool turbCorr() const;
inline bool turbCorr();
};
......
......@@ -51,6 +51,8 @@ inline bool Foam::pimpleControl::SIMPLErho() const
inline bool Foam::pimpleControl::correct()
{
setFirstIterFlag();
++corrPISO_;
if (debug)
......@@ -64,6 +66,9 @@ inline bool Foam::pimpleControl::correct()
}
corrPISO_ = 0;
setFirstIterFlag();
return false;
}
......@@ -101,8 +106,27 @@ inline bool Foam::pimpleControl::solveFlow() const
}
inline bool Foam::pimpleControl::turbCorr() const
inline bool Foam::pimpleControl::turbCorr()
{
if (turbOnFinalIterOnly_)
{
if (finalIter())
{
setFirstIterFlag(true, true);
}
}
else
{
if (firstIter())
{
setFirstIterFlag(true, true);
}
else
{
setFirstIterFlag();
}
}
return !turbOnFinalIterOnly_ || finalIter();
}
......
......@@ -122,6 +122,8 @@ Foam::simpleControl::simpleControl(fvMesh& mesh, const word& dictName)
bool Foam::simpleControl::loop()
{
solutionControl::setFirstIterFlag(true, true);
read();
Time& runTime = const_cast<Time&>(mesh_.time());
......
......@@ -178,6 +178,32 @@ Foam::Pair<Foam::scalar> Foam::solutionControl::maxResidual
}
void Foam::solutionControl::setFirstIterFlag
(
const bool check,
const bool force
)
{
DebugInfo
<< "solutionControl: force:" << force
<< " check: " << check
<< " corr: " << corr_
<< " corrNonOrtho:" << corrNonOrtho_
<< endl;
if (force || (check && corr_ <= 1 && corrNonOrtho_ == 0))
{
DebugInfo<< "solutionControl: set firstIteration flag" << endl;
mesh_.data::set("firstIteration", true);
}
else
{
DebugInfo<< "solutionControl: remove firstIteration flag" << endl;
mesh_.data::remove("firstIteration");
}
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
template<class Type>
......
......@@ -162,6 +162,13 @@ protected:
// as second (last) member
Pair<scalar> maxResidual(const entry& solverPerfDictEntry) const;
//- Set the firstIteration flag on the mesh data dictionary
virtual void setFirstIterFlag
(
const bool check = true,
const bool force = false
);
private:
......
......@@ -81,6 +81,8 @@ inline bool Foam::solutionControl::frozenFlow() const
inline bool Foam::solutionControl::correctNonOrthogonal()
{
setFirstIterFlag();
++corrNonOrtho_;
if (debug)
......@@ -95,6 +97,9 @@ inline bool Foam::solutionControl::correctNonOrthogonal()
}
corrNonOrtho_ = 0;
setFirstIterFlag();
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment