systemCall.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object executes system calls, entered in the form of a
32  string lists. Calls can be made at the following points in the
33  calculation:
34  - every time step
35  - every output time
36  - end of the calculation
37 
38  Example of function object specification:
39  \verbatim
40  systemCall1
41  {
42  type systemCall;
43  libs ("libutilityFunctionObjects.so");
44  ...
45  executeCalls
46  (
47  "echo execute"
48  );
49  writeCalls
50  (
51  "echo \*\*\* writing data \*\*\*"
52  );
53  endCalls
54  (
55  "echo \*\*\* writing .bashrc \*\*\*"
56  "cat ~/.bashrc"
57  "echo \*\*\* done \*\*\*"
58  );
59  }
60  \endverbatim
61 
62 Usage
63  \table
64  Property | Description | Required | Default value
65  type | type name: systemCall | yes |
66  executeCalls | list of calls on execute | yes |
67  writeCalls | list of calls on write | yes |
68  endCalls | list of calls on end | yes |
69  \endtable
70 
71 Note
72  Since this function object executes system calls, there is a potential
73  security risk. In order to use the \c systemCall function object, the
74  \c allowSystemOperations must be set to '1'; otherwise, system calls will
75  not be allowed.
76 
77 See also
78  Foam::functionObject
79  Foam::functionObjects::timeControl
80 
81 SourceFiles
82  systemCall.C
83 
84 \*---------------------------------------------------------------------------*/
85 
86 #ifndef functionObjects_systemCall_H
87 #define functionObjects_systemCall_H
88 
89 #include "functionObject.H"
90 #include "stringList.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 namespace functionObjects
97 {
98 
99 /*---------------------------------------------------------------------------*\
100  Class systemCall Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 class systemCall
104 :
105  public functionObject
106 {
107 protected:
108 
109  // Private data
110 
111  //- List of calls to execute - every step
113 
114  //- List of calls to execute when exiting the time-loop
116 
117  //- List of calls to execute - write steps
119 
120 
121 private:
122 
123  // Private member functions
124 
125  //- Disallow default bitwise copy construct
126  systemCall(const systemCall&);
128  //- Disallow default bitwise assignment
129  void operator=(const systemCall&);
130 
131 
132 public:
133 
134  //- Runtime type information
135  TypeName("systemCall");
137 
138  // Constructors
140  //- Construct from Time and dictionary
141  systemCall
142  (
143  const word& name,
144  const Time& runTime,
145  const dictionary& dict
146  );
147 
148 
149  //- Destructor
150  virtual ~systemCall();
151 
152 
153  // Member Functions
154 
155  //- Read the system calls
156  virtual bool read(const dictionary&);
157 
158  //- Execute the "executeCalls" at each time-step
159  virtual bool execute();
160 
161  //- Execute the "endCalls" at the final time-loop
162  virtual bool end();
163 
164  //- Write, execute the "writeCalls"
165  virtual bool write();
166 };
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 } // End namespace functionObjects
172 } // End namespace Foam
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 #endif
177 
178 // ************************************************************************* //
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
const word & name() const
Return the name of this functionObject.
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:139
This function object executes system calls, entered in the form of a string lists. Calls can be made at the following points in the calculation:
Definition: systemCall.H:127
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:136
Namespace for OpenFOAM.
stringList writeCalls_
List of calls to execute - write steps.
Definition: systemCall.H:142