39 namespace functionObjects
66 for (
const string& call : calls)
108 executeCalls_.clear();
112 dict.readIfPresent(
"executeCalls", executeCalls_);
113 dict.readIfPresent(
"writeCalls", writeCalls_);
114 dict.readIfPresent(
"endCalls", endCalls_);
115 masterOnly_ =
dict.getOrDefault(
"master",
false);
117 if (executeCalls_.empty() && endCalls_.empty() && writeCalls_.empty())
120 <<
"No executeCalls, endCalls or writeCalls defined." 126 <<
"System calls should not be executed by someone" 127 <<
" with administrator rights for security reasons." <<
nl 134 <<
"Executing user-supplied system calls may have been disabled" 135 <<
" by default" <<
nl 136 <<
"for security reasons." <<
nl 137 <<
"If you trust the code, you may enable this by adding" 139 <<
" allowSystemOperations 1" <<
nl <<
nl 140 <<
"to the InfoSwitches setting in the system controlDict." <<
nl 141 <<
"The system controlDict is any of" <<
nl <<
nl 143 <<
" ~/.OpenFOAM/controlDict" <<
nl 144 <<
" $WM_PROJECT_DIR/etc/controlDict" <<
nl <<
endl 154 dispatch(executeCalls_);
161 dispatch(writeCalls_);
bool masterOnly_
Perform system calls on the master only.
defineTypeNameAndDebug(ObukhovLength, 0)
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool write()
Write, execute the "writeCalls".
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.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Abstract base-class for Time/database function objects.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Macros for easy insertion into run-time selection tables.
static void broadcast(Type &value, const label comm=UPstream::worldComm)
Broadcast content (contiguous or non-contiguous) to all processes in communicator.
bool read(const char *buf, int32_t &val)
Same as readInt32.
label dispatch(const stringList &calls)
Dispatch specified calls.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
virtual bool execute()
Execute the "executeCalls" at each time-step.
A class for handling words, derived from Foam::string.
static int allowSystemOperations
Flag if system operations are allowed.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation...
virtual bool read(const dictionary &dict)
Read the system calls.
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
systemCall(const systemCall &)=delete
No copy construct.
bool isAdministrator()
Is the current user the administrator (root)
#define WarningInFunction
Report a warning using Foam::Warning.
virtual bool read(const dictionary &dict)
Read and set the function object if its data have changed.
virtual bool end()
Execute the "endCalls" at the final time-loop.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
int system(const std::string &command, const bool bg=false)
Execute the specified command via the shell.