34 void Foam::loopControl::clear()
48 void Foam::loopControl::read(
const dictionary&
dict)
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())
97 bool Foam::loopControl::checkConverged()
const 99 if (convergenceDict_.empty())
104 HashTable<const fvMesh*>
meshes = time_.lookupClass<
const fvMesh>();
106 bool achieved =
true;
107 bool checked =
false;
111 const fvMesh& regionMesh = *(meshIter.val());
113 const dictionary& solverDict = regionMesh.solverPerformanceDict();
114 for (
const entry& dataDictEntry : solverDict)
116 const word& variableName = dataDictEntry.keyword();
118 const scalar absTol =
119 convergenceDict_.getOrDefault<scalar>(variableName, -1);
125 Pair<scalar> residuals =
133 achieved = achieved && (residuals.first() < absTol);
138 return checked && achieved;
144 Foam::loopControl::loopControl
162 Foam::loopControl::loopControl
182 Foam::loopControl::loopControl
185 const word& algorithmName,
191 fvSolution fvsol(
time_);
194 const dictionary* dictptr = fvsol.solutionDict().
findDict(algorithmName);
222 bool active = (index_ < total_);
228 converged_ = checkConverged();
232 time_.functionObjects().execute(onConverged_, index_);
238 interval_ && !(index_ % interval_)
242 time_.functionObjects().execute(onLoop_, index_);
249 if (!converged_ && !onEnd_.empty())
251 time_.functionObjects().execute(onEnd_, index_);
263 os << ctrl.
name() <<
": ";
264 if (ctrl.nCycles() && ctrl.index() <= ctrl.nCycles())
266 os << ctrl.index() <<
'/' << ctrl.nCycles();
A class for managing sub-loops referencing Time.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const word dictName("faMeshDefinition")
wordRes onLoop_
Function object names to fire during the loop (at executeInterval)
label total_
The total number of cycles in the sub-cycle.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool loop()
True if looping is active, increments the index and executes the onLoop and onConverged functions...
static Pair< scalar > maxResidual(const fvMesh &fvmesh, const entry &dataDictEntry)
Extract maximum residual for the solver performance entry, provided the corresponding volume field is...
wordRes onEnd_
Function object names to fire when the loop exits without convergence.
void clear()
Clear the list, i.e. set size to zero.
A class for handling words, derived from Foam::string.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
wordRes onConverged_
Function object names to fire on convergence.
label interval_
The interval to execute onLoop function-objects.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
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...
OBJstream os(runTime.globalPath()/outputName)
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. ...
bool converged_
Convergence tests passed.
virtual const fileName & name() const
Read/write access to the name of the stream.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
dictionary convergenceDict_
Dictionary for checking convergence (all regions)
~loopControl()
Destructor.
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...
void clear()
Clear the dictionary.
A class for managing arbitrary loops with the ability to invoke function object execution.
forAllConstIters(mixture.phases(), phase)
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and a sub-dictionary) otherwise return nullptr...