52 pimpleDict.getOrDefault(
"turbOnFinalIterOnly",
true);
54 pimpleDict.getOrDefault(
"finalOnLastPimpleIterOnly",
false);
64 if ((corr_ == 1) || residualControl_.empty() || finalIter())
70 const bool storeIni = this->storeInitialResiduals();
75 const dictionary& solverDict = mesh_.data().solverPerformanceDict();
76 for (
const entry& solverPerfDictEntry : solverDict)
78 const word& fieldName = solverPerfDictEntry.keyword();
79 const label fieldi = applyToField(fieldName);
83 Pair<scalar> residuals = maxResidual(solverPerfDictEntry);
87 scalar relative = 0.0;
88 bool relCheck =
false;
91 (residuals.last() < residualControl_[fieldi].absTol);
95 residualControl_[fieldi].initialResidual = residuals.first();
100 (residualControl_[fieldi].initialResidual + ROOTVSMALL);
102 relative = residuals.last() / iniRes;
103 relCheck = (
relative < residualControl_[fieldi].relTol);
106 achieved = achieved && (absCheck || relCheck);
110 Info<< algorithmName_ <<
" loop:" <<
endl;
112 Info<<
" " << fieldName
113 <<
" PIMPLE iter " << corr_
115 << residualControl_[fieldi].initialResidual
116 <<
", abs tol = " << residuals.last()
117 <<
" (" << residualControl_[fieldi].absTol <<
")"
119 <<
" (" << residualControl_[fieldi].relTol <<
")"
125 return checked && achieved;
133 <<
" corrPISO:" << corrPISO_
134 <<
" corrNonOrtho:" << corrNonOrtho_
143Foam::pimpleControl::pimpleControl
156 turbOnFinalIterOnly_(true),
157 finalOnLastPimpleIterOnly_(false),
171 Info<<
": no residual control data found. "
173 <<
" corrector loops" <<
nl;
182 <<
": relTol " << ctrl.relTol
183 <<
", tolerance " << ctrl.absTol
190 Info<<
": Operating solver in PISO mode" <<
nl;
208 Info<< algorithmName_ <<
" loop: corr = " << corr_ <<
endl;
213 if (corr_ == nCorrPIMPLE_ + 1)
215 if (!residualControl_.empty() && (nCorrPIMPLE_ != 1))
217 Info<< algorithmName_ <<
": not converged within "
218 << nCorrPIMPLE_ <<
" iterations" <<
endl;
222 mesh_.data().setFinalIteration(
false);
226 bool completed =
false;
227 if (converged_ || criteriaSatisfied())
231 Info<< algorithmName_ <<
": converged in " << corr_ - 1
232 <<
" iterations" <<
endl;
234 mesh_.data().setFinalIteration(
false);
242 Info<< algorithmName_ <<
": iteration " << corr_ <<
endl;
243 storePrevIterFields();
245 mesh_.data().setFinalIteration(
true);
253 mesh_.data().setFinalIteration(
true);
256 if (corr_ <= nCorrPIMPLE_)
258 Info<< algorithmName_ <<
": iteration " << corr_ <<
endl;
259 storePrevIterFields();
const dictionary & pimpleDict
T & last() noexcept
Access last element of the list, position [N-1] - back().
An ordered pair of two objects of type <T> with first() and second() elements.
const T & first() const noexcept
Access the first element.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A keyword and a list of tokens is an 'entry'.
Mesh data needed to do the Finite Volume discretisation.
PIMPLE control class to supply convergence information/checks for the PIMPLE loop.
bool SIMPLErho_
Flag to indicate whether to update density in SIMPLE rather than PISO mode.
label corrPISO_
Current PISO corrector.
virtual bool criteriaSatisfied()
Return true if all convergence checks are satisfied.
bool finalIter() const
Return true for final PIMPLE (outer) iteration.
bool finalOnLastPimpleIterOnly_
Flag to indicate wheter the final solver is used only on the final pimple iter.
label nCorrPISO_
Maximum number of PISO correctors.
label nCorrPIMPLE_
Maximum number of PIMPLE correctors.
bool storeInitialResiduals() const
Return true to store the initial residuals.
bool solveFlow_
Flag to indicate whether to solve for the flow.
bool turbOnFinalIterOnly_
Flag to indicate whether to only solve turbulence on final iter.
virtual bool loop()
PIMPLE loop.
bool ddtCorr_
Flag to indicate that ddtCorr should be applied; default = yes.
virtual void setFirstIterFlag(const bool check=true, const bool force=false)
Set the firstIteration flag on the mesh data dictionary.
virtual bool read()
Read controls from fvSolution dictionary.
bool converged_
Converged flag.
Base class for solution control classes.
const word algorithmName_
The dictionary name, e.g. SIMPLE, PIMPLE.
label corrNonOrtho_
Current non-orthogonal corrector loop index.
label corr_
Current corrector loop index.
List< fieldData > residualControl_
List of residual data per field.
virtual const dictionary dict() const
Return the solution dictionary.
fvMesh & mesh_
Reference to the mesh database.
virtual void storePrevIterFields() const
Store previous iteration fields.
virtual label applyToField(const word &fieldName, const bool useRegEx=true) const
Return index of field in residualControl_ if present.
static Pair< scalar > maxResidual(const fvMesh &fvmesh, const entry &dataDictEntry)
Extract maximum residual for the solver performance entry, provided the corresponding volume field is...
virtual void setFirstIterFlag(const bool check=true, const bool force=false)
Set the firstIteration flag on the mesh data dictionary.
virtual bool read()
Read controls from fvSolution dictionary.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
const word dictName("faMeshDefinition")
#define DebugInfo
Report an information message using Foam::Info.
Namespace for handling debugging switches.
tmp< surfaceScalarField > relative(const tmp< surfaceScalarField > &tphi, const volVectorField &U)
Return the given absolute flux in relative form.
bool read(const char *buf, int32_t &val)
Same as readInt32.
messageStream Info
Information stream (stdout output on master, null elsewhere).
static void check(const int retVal, const char *what)
Ostream & endl(Ostream &os)
Add newline and flush stream.
constexpr char nl
The newline '\n' character (0x0a).
Simple convenient storage of field residuals.