47 solutionDict.getOrDefault<label>(
"nNonOrthogonalCorrectors", 0);
62 for (
const entry& dEntry : residualDict)
64 const word& fName = dEntry.keyword();
69 fd.name = fName.c_str();
73 fd.absTol = residualDict.get<scalar>(fName);
75 fd.initialResidual = -1;
77 else if (dEntry.isDict())
80 fd.absTol = fieldDict.get<scalar>(
"tolerance");
81 fd.relTol = fieldDict.get<scalar>(
"relTol");
82 fd.initialResidual = 0.0;
87 <<
"Residual data for " << dEntry.keyword()
88 <<
" must be specified as a dictionary"
99 fd.absTol = residualDict.get<scalar>(fName);
101 else if (dEntry.isDict())
104 fd.absTol = fieldDict.get<scalar>(
"tolerance");
105 fd.relTol = fieldDict.get<scalar>(
"relTol");
110 <<
"Residual data for " << dEntry.keyword()
111 <<
" must be specified as a dictionary"
124 Info<<
"residualControl[" << i <<
"]:" <<
nl
125 <<
" name : " << fd.name <<
nl
126 <<
" absTol : " << fd.absTol <<
nl
127 <<
" relTol : " << fd.relTol <<
nl
128 <<
" iniResid : " << fd.initialResidual <<
endl;
144 const word& fieldName,
148 forAll(residualControl_, i)
150 if (residualControl_[i].
name.match(fieldName, !useRegEx))
187 <<
"solutionControl: force:" << force
188 <<
" check: " <<
check
189 <<
" corr: " << corr_
190 <<
" corrNonOrtho:" << corrNonOrtho_
193 if (force || (
check && corr_ <= 1 && corrNonOrtho_ == 0))
195 DebugInfo<<
"solutionControl: set firstIteration flag" <<
endl;
196 mesh_.data().setFirstIteration(
true);
200 DebugInfo<<
"solutionControl: remove firstIteration flag" <<
endl;
201 mesh_.data().setFirstIteration(
false);
220 const entry& solverPerfDictEntry,
226 const word& fieldName = solverPerfDictEntry.
keyword();
244 const fvMesh& fvmesh,
245 const entry& solverPerfDictEntry
248 Pair<scalar> residuals(0,0);
253 maxTypeResidual<scalar>(fvmesh, solverPerfDictEntry, residuals)
254 || maxTypeResidual<vector>(fvmesh, solverPerfDictEntry, residuals)
255 || maxTypeResidual<sphericalTensor>(fvmesh, solverPerfDictEntry, residuals)
256 || maxTypeResidual<symmTensor>(fvmesh, solverPerfDictEntry, residuals)
257 || maxTypeResidual<tensor>(fvmesh, solverPerfDictEntry, residuals)
260 if (!ok && solutionControl::debug)
262 Info<<
"no residual for " << solverPerfDictEntry.keyword()
263 <<
" on mesh " << fvmesh.name() <<
nl;
272Foam::solutionControl::solutionControl(
fvMesh&
mesh,
const word& algorithmName)
287 algorithmName_(algorithmName),
289 momentumPredictor_(true),
fvSolution solutionDict(runTime)
p_rghFluid[i] storePrevIter()
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
T & last() noexcept
Access last element of the list, position [N-1] - back().
Generic GeometricField class.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
const Time & time() const noexcept
Return Time associated with the objectRegistry.
const word & name() const noexcept
Return the object name.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
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,...
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Find and return a sub-dictionary as a copy, otherwise return an empty dictionary.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
const keyType & keyword() const noexcept
Return keyword.
Mesh data needed to do the Finite Volume discretisation.
const word & name() const
Return reference to name.
bool foundObject(const word &name, const bool recursive=false) const
Contains the named Type?
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
regIOobject(const IOobject &io, const bool isTimeObject=false)
Construct from IOobject. The optional flag adds special handling if the object is the top-level regIO...
Base class for solution control classes.
bool frozenFlow_
Flag to indicate that the flow system of equations should not.
bool transonic_
Flag to indicate to solve using transonic algorithm.
virtual bool writeData(Ostream &) const
Dummy write for regIOobject.
const word algorithmName_
The dictionary name, e.g. SIMPLE, PIMPLE.
label corrNonOrtho_
Current non-orthogonal corrector loop index.
label corr_
Current corrector loop index.
static bool maxTypeResidual(const fvMesh &fvmesh, const entry &solverPerfDictEntry, Pair< scalar > &residuals)
Initial and final residual of the specified field-name, provided that the corresponding volume field ...
bool momentumPredictor_
Flag to indicate to solve for momentum.
List< fieldData > residualControl_
List of residual data per field.
virtual const dictionary dict() const
Return the solution dictionary.
bool consistent_
Flag to indicate to relax pressure using the.
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.
label nNonOrthCorr_
Maximum number of non-orthogonal correctors.
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.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
#define DebugInfo
Report an information message using Foam::Info.
Namespace for handling debugging switches.
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)
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
void cmptMax(FieldField< Field, typename FieldField< Field, Type >::cmptType > &cf, const FieldField< Field, Type > &f)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Simple convenient storage of field residuals.