71 std::string fileContent;
73 std::ifstream is(filename);
74 std::getline(is, fileContent,
'\0');
76 const auto equals = fileContent.find(
'=');
78 if (equals != std::string::npos)
101 return "continue simulation to the endTime";
107 return "stop without writing data";
113 return "stop and write data";
119 return "stop after next data write";
126 return "unknown action";
137Foam::functionObjects::abort::abort
146 defaultAction_(
Time::stopAtControls::saUnknown),
167 if (
dict.readIfPresent(
"file", file_))
170 if (!file_.empty() && !file_.isAbsolute())
172 file_ = time_.globalPath()/file_;
180 file_ = time_.globalPath()/
name();
195 <<
" File: " << file_ <<
endl;
217 action = defaultAction_;
222 int intAction(action);
228 triggered_ = time_.stopAt(action);
232 Info<<
"USER REQUESTED ABORT (timeIndex="
233 << time_.timeIndex() <<
"): "
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Inter-processor communication reduction functions.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
EnumType getOrDefault(const word &key, const dictionary &dict, const EnumType deflt, const bool warnOnly=false) const
Find the key in the dictionary and return the corresponding enumeration element based on its name.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
static const Enum< stopAtControls > stopAtControlNames
Names for stopAtControls.
stopAtControls
Stop-run control options, which are primarily used when altering the stopAt condition.
@ saNoWriteNow
Adjust endTime to stop immediately w/o writing.
@ saWriteNow
adjust endTime to stop immediately w/ writing
@ saUnknown
Dummy no-op. Do not change current value.
@ saEndTime
Stop when Time reaches prescribed endTime.
@ saNextWrite
stop at the next data write interval
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
@ broadcast
broadcast [MPI]
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
Watches for presence of the named trigger file in the case directory and signals a simulation stop (o...
virtual bool read(const dictionary &dict)
Read the function-object dictionary.
virtual bool execute()
Execute the function-object operations.
virtual bool write()
Write the function-object results (no-op).
virtual bool end()
Remove the trigger file after the final time-loop.
const Time & time_
Reference to the time database.
timeFunctionObject(const timeFunctionObject &)=delete
No copy construct.
A class for handling words, derived from Foam::string.
static word validate(const std::string &s, const bool prefix=false)
Construct validated word (no invalid characters).
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Function objects are OpenFOAM utilities to ease workflow configurations and enhance workflows.
bool rm(const fileName &file)
Remove a file (or its gz equivalent), returning true if successful.
static enum Time::stopAtControls getStopAction(const std::string &filename)
messageStream Info
Information stream (stdout output on master, null elsewhere).
static std::string longDescription(const Time::stopAtControls ctrl)
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.
bool isFile(const fileName &name, const bool checkGzip=true, const bool followLink=true)
Does the name exist as a FILE in the file system?
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
constexpr char nl
The newline '\n' character (0x0a).