40 namespace functionObjects
42 namespace runTimeControls
56 { satisfiedAction::ABORT,
"abort"},
57 { satisfiedAction::END,
"end"},
58 { satisfiedAction::SET_TRIGGER,
"setTrigger"},
64 Foam::functionObjects::runTimeControls::runTimeControl::runTimeControl
76 satisfiedAction_(satisfiedAction::END),
78 active_(getProperty(
"active", true)),
79 canRestart_(getProperty(
"canRestart", false))
95 <<
" function object for post-processing" 107 const wordList conditionNames(conditionsDict.
toc());
108 conditions_.
setSize(conditionNames.size());
110 label uniqueGroupi = 0;
111 forAll(conditionNames, conditioni)
113 const word& conditionName = conditionNames[conditioni];
122 label groupi = conditions_[conditioni].groupID();
124 if (groupMap_.insert(groupi, uniqueGroupi))
130 dict.readIfPresent(
"nWriteStep", nWriteStep_);
133 if (conditions_.empty())
135 Info<<
" No conditions present" <<
endl;
141 for (
const auto& condition : conditions_)
143 if (condition.active())
152 Info<<
" All conditions are inactive" <<
endl;
161 satisfiedActionNames.getOrDefault
168 if (satisfiedAction_ == satisfiedAction::SET_TRIGGER)
170 triggerIndex_ =
dict.get<label>(
"trigger");
196 DynamicList<label> IDs(conditions_.size());
199 List<bool> groupSatisfied(groupMap_.size(),
true);
200 List<bool> groupActive(groupMap_.size(),
false);
202 forAll(conditions_, conditioni)
204 runTimeCondition& condition = conditions_[conditioni];
206 if (condition.active())
208 bool conditionSatisfied = condition.apply();
210 const label groupi = condition.groupID();
212 auto conditionIter = groupMap_.cfind(groupi);
214 if (!conditionIter.found())
217 <<
"group " << groupi <<
" not found in map" 221 if (conditionSatisfied)
223 IDs.append(conditioni);
225 groupActive[conditionIter()] =
true;
231 groupSatisfied[conditionIter()] =
true;
237 groupSatisfied[conditionIter()] =
false;
243 forAll(groupSatisfied, groupi)
245 if (groupSatisfied[groupi] && groupActive[groupi])
254 for (label conditioni : IDs)
256 Info<<
" " << conditions_[conditioni].type() <<
": " 257 << conditions_[conditioni].name()
258 <<
" condition satisfied" <<
nl;
261 switch (satisfiedAction_)
263 case satisfiedAction::ABORT:
264 case satisfiedAction::END:
267 Time& time =
const_cast<Time&
>(time_);
269 if (writeStepI_ < nWriteStep_ - 1)
272 Info<<
" Writing fields - step " << writeStepI_ <<
nl;
277 Info<<
" Stopping calculation" <<
nl 278 <<
" Writing fields";
280 if (nWriteStep_ != 0)
282 Info<<
" - final step";
294 if (satisfiedAction_ == satisfiedAction::ABORT)
303 case satisfiedAction::SET_TRIGGER:
305 Info<<
" Setting trigger " << triggerIndex_ <<
nl;
307 setTrigger(triggerIndex_);
311 setProperty(
"active", active_);
315 setProperty(
"canRestart", canRestart_);
319 forAll(conditions_, conditioni)
321 runTimeCondition& condition = conditions_[conditioni];
331 Info<<
" Conditions not met" <<
nl;
342 for (
auto& condition : conditions_)
errorManipArg< error, int > exit(error &err, const int errNo=1)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static bool postProcess
Global post-processing mode switch.
constexpr char nl
The newline '\n' character (0x0a)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual bool write()
Calculate the runTimeControl and write.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool read(const dictionary &)
Read the runTimeControl data.
Macros for easy insertion into run-time selection tables.
wordList toc() const
Return the table of contents.
#define forAll(list, i)
Loop across all elements in list.
static Enum< satisfiedAction > satisfiedActionNames
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
void setSize(const label n)
Alias for resize()
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
A class for handling words, derived from Foam::string.
errorManip< error > abort(error &err)
defineTypeNameAndDebug(averageCondition, 0)
static void check(const int retVal, const char *what)
addToRunTimeSelectionTable(runTimeCondition, averageCondition, dictionary)
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
virtual bool execute()
Execute, currently does nothing.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Selector.
virtual bool read(const dictionary &dict)
Read optional controls.
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.