systemCall.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::systemCall
26 
27 Description
28  Executes system calls, entered in the form of a string lists.
29 
30  Calls can be made at the following points in the calculation:
31  - every time step
32  - every output time
33  - end of the calculation
34 
35  Example of function object specification:
36  \verbatim
37  systemCall1
38  {
39  type systemCall;
40  libs ("libutilityFunctionObjects.so");
41  ...
42  executeCalls
43  (
44  "echo execute"
45  );
46  writeCalls
47  (
48  "echo \*\*\* writing data \*\*\*"
49  );
50  endCalls
51  (
52  "echo \*\*\* writing .bashrc \*\*\*"
53  "cat ~/.bashrc"
54  "echo \*\*\* done \*\*\*"
55  );
56  }
57  \endverbatim
58 
59 Usage
60  \table
61  Property | Description | Required | Default value
62  type | type name: systemCall | yes |
63  executeCalls | list of calls on execute | yes |
64  writeCalls | list of calls on write | yes |
65  endCalls | list of calls on end | yes |
66  \endtable
67 
68 Note
69  Since this function object executes system calls, there is a potential
70  security risk. In order to use the \c systemCall function object, the
71  \c allowSystemOperations must be set to '1'; otherwise, system calls will
72  not be allowed.
73 
74 See also
75  Foam::functionObject
76  Foam::functionObjects::timeControl
77 
78 SourceFiles
79  systemCall.C
80 
81 \*---------------------------------------------------------------------------*/
82 
83 #ifndef functionObjects_systemCall_H
84 #define functionObjects_systemCall_H
85 
86 #include "functionObject.H"
87 #include "stringList.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 namespace Foam
92 {
93 namespace functionObjects
94 {
95 
96 /*---------------------------------------------------------------------------*\
97  Class systemCall Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 class systemCall
101 :
102  public functionObject
103 {
104 protected:
105 
106  // Private Data
107 
108  //- List of calls to execute - every step
110 
111  //- List of calls to execute when exiting the time-loop
113 
114  //- List of calls to execute - write steps
116 
117 
118 public:
119 
120  //- Runtime type information
121  TypeName("systemCall");
122 
123 
124  // Constructors
125 
126  //- Construct from Time and dictionary
127  systemCall
128  (
129  const word& name,
130  const Time& runTime,
131  const dictionary& dict
132  );
134  //- Disallow default bitwise copy construction
135  systemCall(const systemCall&) = delete;
137 
138  //- Destructor
139  virtual ~systemCall();
140 
141 
142  // Member Functions
143 
144  //- Read the system calls
145  virtual bool read(const dictionary&);
146 
147  //- Execute the "executeCalls" at each time-step
148  virtual bool execute();
149 
150  //- Execute the "endCalls" at the final time-loop
151  virtual bool end();
152 
153  //- Write, execute the "writeCalls"
154  virtual bool write();
155 
156 
157  // Member Operators
158 
159  //- Disallow default bitwise assignment
160  void operator=(const systemCall&) = delete;
161 };
162 
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace functionObjects
167 } // End namespace Foam
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 #endif
172 
173 // ************************************************************************* //
dictionary dict
TypeName("systemCall")
Runtime type information.
virtual ~systemCall()
Destructor.
Definition: systemCall.C:69
virtual bool write()
Write, execute the "writeCalls".
Definition: systemCall.C:130
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual bool execute()
Execute the "executeCalls" at each time-step.
Definition: systemCall.C:108
A class for handling words, derived from string.
Definition: word.H:59
stringList endCalls_
List of calls to execute when exiting the time-loop.
Definition: systemCall.H:136
Executes system calls, entered in the form of a string lists.
Definition: systemCall.H:124
void operator=(const systemCall &)=delete
Disallow default bitwise assignment.
List< string > stringList
A List of strings.
Definition: stringList.H:50
virtual bool read(const dictionary &)
Read the system calls.
Definition: systemCall.C:75
systemCall(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: systemCall.C:52
virtual bool end()
Execute the "endCalls" at the final time-loop.
Definition: systemCall.C:119
stringList executeCalls_
List of calls to execute - every step.
Definition: systemCall.H:133
Namespace for OpenFOAM.
stringList writeCalls_
List of calls to execute - write steps.
Definition: systemCall.H:139