systemCall Class Reference

Executes system calls, entered in the form of string lists. More...

Inheritance diagram for systemCall:
[legend]
Collaboration diagram for systemCall:
[legend]

Public Member Functions

 TypeName ("systemCall")
 Runtime type information. More...
 
 systemCall (const word &name, const Time &runTime, const dictionary &dict)
 Construct from Time and dictionary. More...
 
virtual ~systemCall ()=default
 Destructor. More...
 
virtual bool read (const dictionary &dict)
 Read the system calls. More...
 
virtual bool execute ()
 Execute the "executeCalls" at each time-step. More...
 
virtual bool write ()
 Write, execute the "writeCalls". More...
 
virtual bool end ()
 Execute the "endCalls" at the final time-loop. More...
 
- Public Member Functions inherited from functionObject
 declareRunTimeSelectionTable (autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))
 
 functionObject (const word &name, const bool withNamePrefix=defaultUseNamePrefix)
 Construct from components. More...
 
autoPtr< functionObjectclone () const
 Return clone. More...
 
virtual ~functionObject ()=default
 Destructor. More...
 
virtual const wordtype () const =0
 Runtime type information. More...
 
const wordname () const noexcept
 Return the name of this functionObject. More...
 
bool useNamePrefix () const noexcept
 Return the flag for adding a scoping name prefix. More...
 
bool useNamePrefix (bool on) noexcept
 Modify the flag for adding a scoping name prefix. More...
 
virtual bool read (const dictionary &dict)
 Read and set the function object if its data have changed. More...
 
virtual bool execute ()=0
 Called at each ++ or += of the time-loop. More...
 
virtual bool execute (const label subIndex)
 Execute using the specified subIndex. More...
 
virtual bool write ()=0
 Called at each ++ or += of the time-loop. More...
 
virtual bool end ()
 Called when Time::run() determines that the time-loop exits. More...
 
virtual bool adjustTimeStep ()
 Called at the end of Time::adjustDeltaT() if adjustTime is true. More...
 
virtual bool filesModified () const
 Did any file get changed during execution? More...
 
virtual void updateMesh (const mapPolyMesh &mpm)
 Update for changes of mesh. More...
 
virtual void movePoints (const polyMesh &mesh)
 Update for changes of mesh. More...
 

Protected Member Functions

label dispatch (const stringList &calls)
 Dispatch specified calls. More...
 
 systemCall (const systemCall &)=delete
 No copy construct. More...
 
void operator= (const systemCall &)=delete
 No copy assignment. More...
 
- Protected Member Functions inherited from functionObject
word scopedName (const word &name) const
 Return a scoped (prefixed) name. More...
 

Protected Attributes

stringList executeCalls_
 List of calls to execute - every step. More...
 
stringList writeCalls_
 List of calls to execute - write steps. More...
 
stringList endCalls_
 List of calls to execute when exiting the time-loop. More...
 
bool masterOnly_
 Perform system calls on the master only. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from functionObject
static autoPtr< functionObjectNew (const word &name, const Time &runTime, const dictionary &dict)
 Select from dictionary, based on its "type" entry. More...
 
- Public Attributes inherited from functionObject
bool log
 Flag to write log into Info. More...
 
- Static Public Attributes inherited from functionObject
static int debug
 Flag to execute debug content. More...
 
static bool postProcess
 Global post-processing mode switch. More...
 
static bool defaultUseNamePrefix
 Global default for useNamePrefix. More...
 
static word outputPrefix
 Directory prefix. More...
 

Detailed Description

Executes system calls, entered in the form of string lists.

Calls can be made at the following points in the calculation:

  • every time step
  • every output time
  • end of the calculation
Usage
Example of the function object specification:
systemCall1
{
    type        systemCall;
    libs        (utilityFunctionObjects);
    ...
    executeCalls
    (
        "echo execute"
    );
    writeCalls
    (
        "echo === writing data ==="
    );
    endCalls
    (
        "echo === echoing .bashrc ==="
        "cat ~/.bashrc"
        "echo \*\*\* done \*\*\*"
    );
}

Where the entries comprise:

Property Description Required Default value
type type name: systemCall yes
executeCalls list of calls on execute yes
writeCalls list of calls on write yes
endCalls list of calls on end yes
master execute on master only no false
Note
Since this function object executes system calls, there is a potential security risk. In order to use the systemCall function object, the allowSystemOperations must be set to '1'; otherwise, system calls will not be allowed.

Additionally, since the system commands are normally sent via the shell, special shell character may require backslash escaping.

See also
Foam::functionObject Foam::functionObjects::timeControl
Source files

Definition at line 140 of file systemCall.H.

Constructor & Destructor Documentation

◆ systemCall() [1/2]

systemCall ( const systemCall )
protecteddelete

No copy construct.

◆ systemCall() [2/2]

systemCall ( const word name,
const Time runTime,
const dictionary dict 
)

Construct from Time and dictionary.

Definition at line 85 of file systemCall.C.

References dict, and systemCall::read().

Here is the call graph for this function:

◆ ~systemCall()

virtual ~systemCall ( )
virtualdefault

Destructor.

Member Function Documentation

◆ dispatch()

Foam::label dispatch ( const stringList calls)
protected

Dispatch specified calls.

Definition at line 55 of file systemCall.C.

References UList< T >::empty(), splitCell::master(), systemCall::masterOnly_, Pstream::scatter(), and Foam::system().

Here is the call graph for this function:

◆ operator=()

void operator= ( const systemCall )
protecteddelete

No copy assignment.

◆ TypeName()

TypeName ( "systemCall"  )

Runtime type information.

◆ read()

bool read ( const dictionary dict)
virtual

Read the system calls.

Reimplemented from functionObject.

Definition at line 104 of file systemCall.C.

References dynamicCode::allowSystemOperations, Foam::foamVersion::api, dict, Foam::endl(), Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::isAdministrator(), Foam::nl, kEpsilonLopesdaCosta< BasicTurbulenceModel >::read(), and WarningInFunction.

Referenced by systemCall::systemCall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ execute()

bool execute ( )
virtual

Execute the "executeCalls" at each time-step.

Implements functionObject.

Definition at line 152 of file systemCall.C.

◆ write()

bool write ( )
virtual

Write, execute the "writeCalls".

Implements functionObject.

Definition at line 159 of file systemCall.C.

◆ end()

bool end ( )
virtual

Execute the "endCalls" at the final time-loop.

Reimplemented from functionObject.

Definition at line 166 of file systemCall.C.

Member Data Documentation

◆ executeCalls_

stringList executeCalls_
protected

List of calls to execute - every step.

Definition at line 149 of file systemCall.H.

◆ writeCalls_

stringList writeCalls_
protected

List of calls to execute - write steps.

Definition at line 152 of file systemCall.H.

◆ endCalls_

stringList endCalls_
protected

List of calls to execute when exiting the time-loop.

Definition at line 155 of file systemCall.H.

◆ masterOnly_

bool masterOnly_
protected

Perform system calls on the master only.

Definition at line 158 of file systemCall.H.

Referenced by systemCall::dispatch().


The documentation for this class was generated from the following files: