Go to the documentation of this file.
40 namespace functionObjects
42 namespace runTimeControls
56 { satisfiedAction::ABORT,
"abort"},
57 { satisfiedAction::END,
"end"},
58 { satisfiedAction::SET_TRIGGER,
"setTrigger"},
63 Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
75 satisfiedAction_(satisfiedAction::END),
77 active_(getObjectProperty(
name,
"active",
true))
90 if (functionObject::postProcess)
93 <<
" function object for post-processing"
103 const wordList conditionNames(conditionsDict.
toc());
104 conditions_.
setSize(conditionNames.size());
106 label uniqueGroupi = 0;
107 forAll(conditionNames, conditioni)
109 const word& conditionName = conditionNames[conditioni];
118 label groupi = conditions_[conditioni].groupID();
120 if (groupMap_.insert(groupi, uniqueGroupi))
126 dict.readIfPresent(
"nWriteStep", nWriteStep_);
129 if (conditions_.empty())
132 <<
" No conditions present" <<
nl
139 for (
const auto& condition : conditions_)
141 if (condition.active())
151 <<
" All conditions are inactive" <<
nl
159 satisfiedActionNames.getOrDefault
166 if (satisfiedAction_ == satisfiedAction::SET_TRIGGER)
168 triggerIndex_ =
dict.get<label>(
"trigger");
191 List<bool> groupSatisfied(groupMap_.size(),
true);
192 List<bool> groupActive(groupMap_.size(),
false);
194 forAll(conditions_, conditioni)
200 bool conditionSatisfied = condition.
apply();
202 label groupi = condition.
groupID();
204 auto conditionIter = groupMap_.cfind(groupi);
206 if (!conditionIter.found())
209 <<
"group " << groupi <<
" not found in map"
213 if (conditionSatisfied)
215 IDs.append(conditioni);
217 groupActive[conditionIter()] =
true;
223 groupSatisfied[conditionIter()] =
true;
229 groupSatisfied[conditionIter()] =
false;
235 forAll(groupSatisfied, groupi)
237 if (groupSatisfied[groupi] && groupActive[groupi])
246 for (label conditioni : IDs)
248 Info<<
" " << conditions_[conditioni].type() <<
": "
249 << conditions_[conditioni].name()
250 <<
" condition satisfied" <<
nl;
253 switch (satisfiedAction_)
261 if (writeStepI_ < nWriteStep_ - 1)
264 Info<<
" Writing fields - step " << writeStepI_ <<
nl;
269 Info<<
" Stopping calculation" <<
nl
270 <<
" Writing fields";
272 if (nWriteStep_ != 0)
274 Info<<
" - final step" <<
nl;
301 Info<<
" Setting trigger " << triggerIndex_ <<
nl;
313 Info<<
" Conditions not met" <<
nl;
324 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.
"end" - write and exit cleanly
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
"setTrigger" - trigger another condition
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.
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.
static void check(const int retVal, const char *what)
messageStream Info
Information stream (stdout output on master, null elsewhere)
void setSize(const label n)
Alias for resize()
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool setTrigger(const label triggeri, bool increaseOnly=true)
Set the trigger index. Normally only if greater than current.
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)
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 word & name() const noexcept
Return the name of this functionObject.
const Time & time() const
Return time database.
virtual const word & type() const =0
Runtime type information.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
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.
"abort" - write and emit a FatalError
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.