Go to the documentation of this file.
40 namespace functionObjects
42 namespace runTimeControls
56 { satisfiedAction::END,
"end"},
57 { satisfiedAction::SET_TRIGGER,
"setTrigger"},
62 Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
74 satisfiedAction_(satisfiedAction::END),
76 active_(getObjectProperty(
name,
"active",
true))
89 if (functionObject::postProcess)
92 <<
" function object for post-processing"
102 const wordList conditionNames(conditionsDict.
toc());
103 conditions_.
setSize(conditionNames.size());
105 label uniqueGroupi = 0;
106 forAll(conditionNames, conditioni)
108 const word& conditionName = conditionNames[conditioni];
117 label groupi = conditions_[conditioni].groupID();
119 if (groupMap_.insert(groupi, uniqueGroupi))
125 dict.readIfPresent(
"nWriteStep", nWriteStep_);
128 if (conditions_.empty())
131 <<
" No conditions present" <<
nl
138 for (
const auto& condition : conditions_)
140 if (condition.active())
150 <<
" All conditions are inactive" <<
nl
158 satisfiedActionNames.getOrDefault
165 if (satisfiedAction_ == satisfiedAction::SET_TRIGGER)
167 triggerIndex_ =
dict.get<label>(
"trigger");
190 List<bool> groupSatisfied(groupMap_.size(),
true);
191 List<bool> groupActive(groupMap_.size(),
false);
193 forAll(conditions_, conditioni)
199 bool conditionSatisfied = condition.
apply();
201 label groupi = condition.
groupID();
203 auto conditionIter = groupMap_.cfind(groupi);
205 if (!conditionIter.found())
208 <<
"group " << groupi <<
" not found in map"
212 if (conditionSatisfied)
214 IDs.append(conditioni);
216 groupActive[conditionIter()] =
true;
222 groupSatisfied[conditionIter()] =
true;
228 groupSatisfied[conditionIter()] =
false;
234 forAll(groupSatisfied, groupi)
236 if (groupSatisfied[groupi] && groupActive[groupi])
245 for (label conditioni : IDs)
247 Info<<
" " << conditions_[conditioni].type() <<
": "
248 << conditions_[conditioni].name()
249 <<
" condition satisfied" <<
nl;
252 switch (satisfiedAction_)
259 if (writeStepI_ < nWriteStep_ - 1)
262 Info<<
" Writing fields - step " << writeStepI_ <<
nl;
267 Info<<
" Stopping calculation" <<
nl
268 <<
" Writing fields";
270 if (nWriteStep_ != 0)
272 Info<<
" - final step" <<
nl;
292 Info<<
" Setting trigger " << triggerIndex_ <<
nl;
304 Info<<
" Conditions not met" <<
nl;
315 for (
auto& condition : conditions_)
defineTypeNameAndDebug(averageCondition, 0)
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Base class for run time conditions.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
const Time & time_
Reference to the time database.
static Enum< satisfiedAction > satisfiedActionNames
addToRunTimeSelectionTable(runTimeCondition, averageCondition, dictionary)
virtual bool read(const dictionary &)
Read the runTimeControl data.
virtual bool write()
Calculate the runTimeControl and write.
bool setTrigger(const label triggeri)
Set the current trigger index.
Ostream & endl(Ostream &os)
Add newline and flush stream.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Controls when the calculation is terminated based on satisfying user-specified conditions.
#define forAll(list, i)
Loop across all elements in list.
bool writeAndEnd()
Write the objects now (not at end of iteration) and end the run.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Macros for easy insertion into run-time selection tables.
errorManip< error > abort(error &err)
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const Time & time() const
Return time database.
const word & name() const
Return the name of this functionObject.
virtual const word & type() const =0
Runtime type information.
virtual bool execute()
Execute, currently does nothing.
wordList toc() const
Return the table of contents.
virtual label groupID() const
Return the group index.
virtual bool active() const
Return the active flag.
void setSize(const label newSize)
Alias for resize(const label)
virtual bool run() const
Return true if run should continue,.
void setProperty(const word &entryName, const Type &value)
Add generic property.
virtual bool apply()=0
Apply the condition.