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-2013 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::systemCall
26 
27 Group
28  grpFunctionObjects
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  functionObjectLibs ("libsystemCall.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  \heading Function object 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 SeeAlso
78  Foam::functionObject
79  Foam::OutputFilterFunctionObject
80 
81 SourceFiles
82  systemCall.C
83  IOsystemCall.H
84 
85 \*---------------------------------------------------------------------------*/
86 
87 #ifndef systemCall_H
88 #define systemCall_H
89 
90 #include "stringList.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 
97 // Forward declaration of classes
98 class objectRegistry;
99 class dictionary;
100 class polyMesh;
101 class mapPolyMesh;
102 
103 /*---------------------------------------------------------------------------*\
104  Class systemCall Declaration
105 \*---------------------------------------------------------------------------*/
106 
107 class systemCall
108 {
109 protected:
110 
111  // Private data
112 
113  //- Name of this set of system calls
114  word name_;
115 
116  //- List of calls to execute - every step
118 
119  //- List of calls to execute when exiting the time-loop
121 
122  //- List of calls to execute - write steps
124 
125 
126  // Private Member Functions
127 
128  //- Disallow default bitwise copy construct
129  systemCall(const systemCall&);
130 
131  //- Disallow default bitwise assignment
132  void operator=(const systemCall&);
133 
134 
135 public:
136 
137  //- Runtime type information
138  TypeName("systemCall");
139 
140 
141  // Constructors
142 
143  //- Construct for given objectRegistry and dictionary.
144  // Allow the possibility to load fields from files
145  systemCall
146  (
147  const word& name,
148  const objectRegistry& unused,
149  const dictionary&,
150  const bool loadFromFilesUnused = false
151  );
152 
153 
154  //- Destructor
155  virtual ~systemCall();
156 
157 
158  // Member Functions
159 
160  //- Return name of the system call set
161  virtual const word& name() const
162  {
163  return name_;
164  }
165 
166  //- Read the system calls
167  virtual void read(const dictionary&);
168 
169  //- Execute the "executeCalls" at each time-step
170  virtual void execute();
171 
172  //- Execute the "endCalls" at the final time-loop
173  virtual void end();
174 
175  //- Called when time was set at the end of the Time::operator++
176  virtual void timeSet();
177 
178  //- Write, execute the "writeCalls"
179  virtual void write();
180 
181  //- Update for changes of mesh
182  virtual void updateMesh(const mapPolyMesh&)
183  {}
184 
185  //- Update for changes of mesh
186  virtual void movePoints(const polyMesh&)
187  {}
188 };
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace Foam
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 #endif
198 
199 // ************************************************************************* //
Foam::systemCall::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: systemCall.H:206
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::systemCall::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: systemCall.H:210
Foam::systemCall::TypeName
TypeName("systemCall")
Runtime type information.
Foam::stringList
List< string > stringList
A List of strings.
Definition: stringList.H:50
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::systemCall::~systemCall
virtual ~systemCall()
Destructor.
Definition: systemCall.C:59
Foam::systemCall::systemCall
systemCall(const systemCall &)
Disallow default bitwise copy construct.
Foam::systemCall
This function object executes system calls, entered in the form of a string lists....
Definition: systemCall.H:131
Foam::systemCall::writeCalls_
stringList writeCalls_
List of calls to execute - write steps.
Definition: systemCall.H:147
Foam::systemCall::endCalls_
stringList endCalls_
List of calls to execute when exiting the time-loop.
Definition: systemCall.H:144
Foam::systemCall::read
virtual void read(const dictionary &)
Read the system calls.
Definition: systemCall.C:65
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::systemCall::write
virtual void write()
Write, execute the "writeCalls".
Definition: systemCall.C:120
Foam::systemCall::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: systemCall.C:114
Foam::systemCall::end
virtual void end()
Execute the "endCalls" at the final time-loop.
Definition: systemCall.C:105
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::systemCall::operator=
void operator=(const systemCall &)
Disallow default bitwise assignment.
Foam::systemCall::name
virtual const word & name() const
Return name of the system call set.
Definition: systemCall.H:185
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
stringList.H
Foam::systemCall::execute
virtual void execute()
Execute the "executeCalls" at each time-step.
Definition: systemCall.C:96
Foam::systemCall::executeCalls_
stringList executeCalls_
List of calls to execute - every step.
Definition: systemCall.H:141
Foam::systemCall::name_
word name_
Name of this set of system calls.
Definition: systemCall.H:138