56 { satisfiedAction::ABORT,
"abort"},
58 { satisfiedAction::SET_TRIGGER,
"setTrigger"},
64Foam::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;
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.good())
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)
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...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
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.
const word & name() const noexcept
Return the name of this functionObject.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
static bool postProcess
Global post-processing mode switch.
virtual const word & type() const =0
Runtime type information.
fvMeshFunctionObject(const fvMeshFunctionObject &)=delete
No copy construct.
const objectRegistry & obr_
Reference to the region objectRegistry.
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.
static autoPtr< runTimeCondition > New(const word &conditionName, const objectRegistry &obr, const dictionary &dict, stateFunctionObject &state)
Selector.
virtual bool active() const
Return the active flag.
static Enum< satisfiedAction > satisfiedActionNames
@ SET_TRIGGER
"setTrigger" - trigger another condition
@ ABORT
"abort" - write and emit a FatalError
@ END
"end" - write and exit cleanly
virtual bool execute()
Execute, currently does nothing.
virtual bool write()
Calculate the runTimeControl and write.
virtual bool read(const dictionary &)
Read the runTimeControl data.
bool setTrigger(const label triggeri)
Set new trigger index.
void setProperty(const word &entryName, const Type &value)
Add generic property.
Type getProperty(const word &entryName, const Type &defaultValue=Type(Zero)) const
Retrieve generic property.
const Time & time_
Reference to the time database.
const Time & time() const
Return time database.
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.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
List< word > wordList
List of word.
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.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::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.