40namespace functionObjects
42namespace runTimeControls
56 { satisfiedAction::ABORT,
"abort"},
57 { satisfiedAction::END,
"end"},
58 { satisfiedAction::SET_TRIGGER,
"setTrigger"},
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");
199 List<bool> groupSatisfied(groupMap_.size(),
true);
200 List<bool> groupActive(groupMap_.size(),
false);
202 forAll(conditions_, conditioni)
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)
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)
331 Info<<
" Conditions not met" <<
nl;
342 for (
auto& condition : conditions_)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
virtual bool read()
Re-read model coefficients if they have changed.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual bool run() const
Return true if run should continue,.
bool writeAndEnd()
Write the objects now (not at end of iteration) and end the run.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
wordList toc() const
Return the table of contents.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Abstract base-class for Time/database function objects.
static bool postProcess
Global post-processing mode switch.
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Base class for run time conditions.
virtual void reset()=0
Reset.
virtual label groupID() const
Return the group index.
virtual bool apply()=0
Apply the condition.
virtual bool active() const
Return the active flag.
static Enum< satisfiedAction > satisfiedActionNames
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Calculate the runTimeControl and write.
virtual bool read(const dictionary &)
Read the runTimeControl data.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
messageStream Info
Information stream (stdout output on master, null elsewhere)
static void check(const int retVal, const char *what)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
#define forAll(list, i)
Loop across all elements in list.