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-2018 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 private:
119 
120  // Private member functions
121 
122  //- Disallow default bitwise copy construct
123  systemCall(const systemCall&);
125  //- Disallow default bitwise assignment
126  void operator=(const systemCall&);
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName("systemCall");
134 
135  // Constructors
137  //- Construct from Time and dictionary
138  systemCall
139  (
140  const word& name,
141  const Time& runTime,
142  const dictionary& dict
143  );
144 
145 
146  //- Destructor
147  virtual ~systemCall();
148 
149 
150  // Member Functions
151 
152  //- Read the system calls
153  virtual bool read(const dictionary&);
154 
155  //- Execute the "executeCalls" at each time-step
156  virtual bool execute();
157 
158  //- Execute the "endCalls" at the final time-loop
159  virtual bool end();
160 
161  //- Write, execute the "writeCalls"
162  virtual bool write();
163 };
164 
165 
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
167 
168 } // End namespace functionObjects
169 } // End namespace Foam
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 #endif
174 
175 // ************************************************************************* //
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:137
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
List< string > stringList
A List of strings.
Definition: stringList.H:50
virtual bool read(const dictionary &)
Read the system calls.
Definition: systemCall.C:75
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