Loading...
Searching...
No Matches
systemCall Class Reference

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

#include <systemCall.H>

Inheritance diagram for systemCall:
Collaboration diagram for systemCall:

Public Member Functions

 TypeName ("systemCall")
 Runtime type information.
 systemCall (const word &name, const Time &runTime, const dictionary &dict)
 Construct from name, Time and dictionary.
virtual ~systemCall ()=default
 Destructor.
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.
virtual bool end ()
 Execute the "endCalls" at the final time-loop.
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.
autoPtr< functionObjectclone () const
 Return clone.
virtual ~functionObject ()=default
 Destructor.
virtual const wordtype () const =0
 Runtime type information.
const wordname () const noexcept
 Return the name of this functionObject.
bool useNamePrefix () const noexcept
 Return the flag for adding a scoping name prefix.
bool useNamePrefix (bool on) noexcept
 Modify the flag for adding a scoping name prefix.
virtual bool execute (const label subIndex)
 Execute using the specified subIndex.
virtual bool adjustTimeStep ()
 Called at the end of Time::adjustDeltaT() if adjustTime is true.
virtual bool filesModified () const
 Did any file get changed during execution?
virtual void updateMesh (const mapPolyMesh &mpm)
 Update for changes of mesh.
virtual void movePoints (const polyMesh &mesh)
 Update for changes of mesh.

Protected Member Functions

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

Protected Attributes

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

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.
Public Attributes inherited from functionObject
bool log
 Flag to write log into Info.
Static Public Attributes inherited from functionObject
static int debug
 Flag to execute debug content.
static bool postProcess
 Global post-processing mode switch.
static bool defaultUseNamePrefix
 Global default for useNamePrefix.
static word outputPrefix
 Directory prefix.

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
Minimal example by using system/controlDict.functions:
systemCallFO
{
    // Mandatory entries
    type        systemCall;
    libs        (utilityFunctionObjects);
    ...

    // Optional entries
    executeCalls
    (
        "echo execute"
    );
    writeCalls
    (
        "echo === writing data ==="
    );
    endCalls
    (
        "echo === echoing .bashrc ==="
        "cat ~/.bashrc"
        "echo \*\*\* done \*\*\*"
    );

    // Inherited entries
    ...
}

where the entries mean:

Property Description Type Reqd Deflt
type Type name: systemCall word yes -
libs Library name: utilityFunctionObjects word yes -
executeCalls List of calls on execute stringList yes -
writeCalls List of calls on write stringList yes -
endCalls List of calls on end stringList yes -
master Execute on master only bool no false

The inherited entries are elaborated in:

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.

Source files

Definition at line 154 of file systemCall.H.

Constructor & Destructor Documentation

◆ systemCall() [1/2]

systemCall ( const systemCall & )
protecteddelete

No copy construct.

References systemCall().

Referenced by operator=(), and systemCall().

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

◆ systemCall() [2/2]

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

Construct from name, Time and dictionary.

Definition at line 78 of file systemCall.C.

References dict, endCalls_, executeCalls_, functionObject::functionObject(), masterOnly_, functionObject::name(), read(), and writeCalls_.

Here is the call graph for this function:

◆ ~systemCall()

virtual ~systemCall ( )
virtualdefault

Destructor.

References dict.

Member Function Documentation

◆ dispatch()

Foam::label dispatch ( const stringList & calls)
protected

Dispatch specified calls.

Definition at line 48 of file systemCall.C.

References UPstream::broadcast, UList< T >::empty(), UPstream::master(), masterOnly_, and Foam::system().

Referenced by end(), execute(), and write().

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

◆ operator=()

void operator= ( const systemCall & )
protecteddelete

No copy assignment.

References systemCall().

Here is the call graph for this function:

◆ TypeName()

TypeName ( "systemCall" )

Runtime type information.

References dict, functionObject::name(), and runTime.

Here is the call graph for this function:

◆ read()

bool read ( const dictionary & dict)
virtual

Read the function-object dictionary.

Reimplemented from functionObject.

Definition at line 97 of file systemCall.C.

References dynamicCode::allowSystemOperations, Foam::foamVersion::api, dict, endCalls_, Foam::endl(), executeCalls_, Foam::exit(), Foam::FatalError, FatalErrorInFunction, Foam::isAdministrator(), masterOnly_, Foam::nl, functionObject::read(), WarningInFunction, and writeCalls_.

Referenced by systemCall().

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

◆ execute()

bool execute ( )
virtual

Execute the function-object operations.

Execute the "executeCalls" at each time-step

Implements functionObject.

Definition at line 145 of file systemCall.C.

References dispatch(), and executeCalls_.

Here is the call graph for this function:

◆ write()

bool write ( )
virtual

Write the function-object results.

Write, execute the "writeCalls"

Implements functionObject.

Definition at line 152 of file systemCall.C.

References dispatch(), and writeCalls_.

Here is the call graph for this function:

◆ end()

bool end ( )
virtual

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

Reimplemented from functionObject.

Definition at line 159 of file systemCall.C.

References dispatch(), and endCalls_.

Here is the call graph for this function:

Member Data Documentation

◆ executeCalls_

stringList executeCalls_
protected

List of calls to execute - every step.

Definition at line 165 of file systemCall.H.

Referenced by execute(), read(), and systemCall().

◆ writeCalls_

stringList writeCalls_
protected

List of calls to execute - write steps.

Definition at line 170 of file systemCall.H.

Referenced by read(), systemCall(), and write().

◆ endCalls_

stringList endCalls_
protected

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

Definition at line 175 of file systemCall.H.

Referenced by end(), read(), and systemCall().

◆ masterOnly_

bool masterOnly_
protected

Perform system calls on the master only.

Definition at line 180 of file systemCall.H.

Referenced by dispatch(), read(), and systemCall().


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