34void Foam::loopControl::clear()
59 timeStart = time_.userTimeToTime(timeStart);
64 && time_.value() >= (timeStart - 0.5*time_.deltaTValue())
71 timeEnd = time_.userTimeToTime(timeEnd);
76 && time_.value() <= (timeEnd + 0.5*time_.deltaTValue())
97bool Foam::loopControl::checkConverged()
const
99 if (convergenceDict_.empty())
104 bool achieved =
true;
105 bool checked =
false;
116 regionMesh.data().solverPerformanceDict();
117 for (
const entry& dataDictEntry : solverDict)
119 const word& variableName = dataDictEntry.keyword();
121 const scalar absTol =
122 convergenceDict_.getOrDefault<scalar>(variableName, -1);
136 achieved = achieved && (residuals.first() < absTol);
141 return checked && achieved;
147Foam::loopControl::loopControl
165Foam::loopControl::loopControl
185Foam::loopControl::loopControl
188 const word& algorithmName,
194 fvSolution fvsol(
time_);
202 dictptr = dictptr->findDict(
dictName);
225 bool active = (index_ < total_);
231 converged_ = checkConverged();
235 time_.functionObjects().execute(onConverged_, index_);
241 interval_ && !(index_ % interval_)
245 time_.functionObjects().execute(onLoop_, index_);
252 if (!converged_ && !onEnd_.empty())
254 time_.functionObjects().execute(onEnd_, index_);
266 os << ctrl.name() <<
": ";
267 if (ctrl.nCycles() && ctrl.index() <= ctrl.nCycles())
269 os << ctrl.index() <<
'/' << ctrl.nCycles();
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.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
A keyword and a list of tokens is an 'entry'.
Mesh data needed to do the Finite Volume discretisation.
Selector class for finite volume solution solution. fvMesh is derived from fvSolution so that all fie...
A class for managing arbitrary loops with the ability to invoke function object execution.
~loopControl()
Destructor.
word name_
Name of the loop control (the lookup dictionary name).
const word & name() const
Name of the loop control.
label interval_
The interval to execute onLoop function-objects.
wordRes onConverged_
Function object names to fire on convergence.
dictionary convergenceDict_
Dictionary for checking convergence (all regions).
bool loop()
True if looping is active, increments the index and executes the onLoop and onConverged functions.
wordRes onLoop_
Function object names to fire during the loop (at executeInterval).
wordRes onEnd_
Function object names to fire when the loop exits without convergence.
bool converged_
Convergence tests passed.
Registry of regIOobjects.
static Pair< scalar > maxResidual(const fvMesh &fvmesh, const entry &dataDictEntry)
Extract maximum residual for the solver performance entry, provided the corresponding volume field is...
const dictionary & solutionDict() const
The entire dictionary or the optional "select" sub-dictionary.
A class for managing sub-loops referencing Time.
label nCycles() const
The total number of cycles.
label index() const
The current cycle index.
subLoopTime & operator++()
Prefix increment.
void stop()
Force terminate the loop.
label index_
The current sub-cycle index.
label total_
The total number of cycles in the sub-cycle.
A class for handling words, derived from Foam::string.
Foam::autoPtr< Foam::dynamicFvMesh > meshPtr
OBJstream os(runTime.globalPath()/outputName)
const word dictName("faMeshDefinition")
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.