functionObject.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 Namespace
25  Foam::functionObjects
26 
27 Description
28  Namespace for functionObjects.
29 
30  OpenFOAM includes a collection of functionObjects selected by the user at
31  run-time to manipulate the simulation and provide mechanisms to extract
32  field and derived quantities. Alternatively, the same actions can be
33  executed after the simulation using the \c -postProcess command-line option.
34 
35  \subsection secFunctionObjects Using function objects
36 
37  FunctionObjects are selected by additional entries in the
38  $FOAM_CASE/system/controlDict dictionary. Each object is listed in the \c
39  functions sub-dictionary, e.g. to select the \c functionObjectType
40  functionObject the following entry would be specified:
41 
42  \verbatim
43  functions
44  {
45  <functionObjectName>
46  {
47  type functionObjectType;
48  libs ("libMyFunctionObjectlib.so");
49  region defaultRegion;
50  enabled yes;
51  timeStart 0;
52  timeEnd 10;
53  writeControl writeTime;
54  writeInterval 1;
55  ...
56  }
57  }
58  \endverbatim
59 
60  Where:
61  \table
62  Property | Description | Required | Default value
63  type | Type of function object | yes |
64  libs | Libraries containing implementation | yes |
65  region | Name of region for multi-region cases | no |
66  enabled | On/off switch | no | yes
67  timeStart| Start time | no |
68  timeEnd | End time | no |
69  evaluateControl | See time controls below | no | timeStep
70  evaluateInterval | Steps between output | no |
71  writeControl | See time controls below | no | timeStep
72  writeInterval | Steps between output | no |
73  \endtable
74 
75  Time controls:
76  \table
77  Option | Description
78  timeStep | Execute/write every 'writeInterval' time-steps
79  writeTime | Execute/write every 'writeInterval' output times
80  adjustableRunTime | Execute/write every 'writeInterval' run time period
81  runTime | Execute/write every 'writeInterval' run time period
82  clockTime | Execute/write every 'writeInterval' clock time period
83  cpuTime | Execute/write every 'writeInterval' CPU time period
84  none | Execute/write every time-step
85  \endtable
86 
87  The sub-dictionary name \c <functionObjectName> is chosen by the user, and
88  is typically used as the name of the output directory for any data written
89  by the functionObject. The \c type entry defines the type of function
90  object properties that follow. FunctionObjects are packaged into separate
91  libraries and the \c libs entry is used to specify which library should be
92  loaded.
93 
94 Class
95  Foam::functionObject
96 
97 Description
98  Abstract base-class for Time/database function objects.
99 
100 See also
101  Foam::functionObjectList
102  Foam::functionObjects::timeControl
103 
104 SourceFiles
105  functionObject.C
106 
107 \*---------------------------------------------------------------------------*/
108 
109 #ifndef functionObject_H
110 #define functionObject_H
111 
112 #include "typeInfo.H"
113 #include "autoPtr.H"
114 #include "Switch.H"
115 #include "runTimeSelectionTables.H"
116 
117 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
118 
119 namespace Foam
120 {
121 
122 // Forward declaration of classes
123 class Time;
124 class polyMesh;
125 class mapPolyMesh;
126 
127 /*---------------------------------------------------------------------------*\
128  Class functionObject Declaration
129 \*---------------------------------------------------------------------------*/
130 
131 class functionObject
132 {
133  // Private data
134 
135  //- Name
136  const word name_;
137 
138 
139  // Private Member Functions
140 
141  //- Disallow default bitwise copy construct
142  functionObject(const functionObject&);
143 
144  //- Disallow default bitwise assignment
145  void operator=(const functionObject&);
146 
147 
148 public:
149 
150  //- Runtime type information
151  virtual const word& type() const = 0;
152 
153  static int debug;
154 
155  //- Global post-processing mode switch
156  static bool postProcess;
157 
158  //- Switch write log to Info
159  Switch log;
160 
161 
162  // Declare run-time constructor selection tables
163 
165  (
166  autoPtr,
167  functionObject,
168  dictionary,
169  (const word& name, const Time& runTime, const dictionary& dict),
170  (name, runTime, dict)
171  );
172 
173 
174  // Constructors
175 
176  //- Construct from components
177  functionObject(const word& name);
178 
179  //- Return clone
180  autoPtr<functionObject> clone() const
181  {
183  return autoPtr<functionObject>(NULL);
184  }
185 
186 
187  // Selectors
188 
189  //- Select from dictionary, based on its "type" entry
190  static autoPtr<functionObject> New
191  (
192  const word& name,
193  const Time&,
194  const dictionary&
195  );
196 
197 
198  //- Destructor
199  virtual ~functionObject();
200 
201 
202  // Member Functions
203 
204  //- Return the name of this functionObject
205  const word& name() const;
206 
207  //- Read and set the function object if its data have changed
208  virtual bool read(const dictionary&);
210  //- Called at each ++ or += of the time-loop.
211  // postProcess overrides the usual executeControl behaviour and
212  // forces execution (used in post-processing mode)
213  virtual bool execute() = 0;
214 
215  //- Called at each ++ or += of the time-loop.
216  // postProcess overrides the usual writeControl behaviour and
217  // forces writing always (used in post-processing mode)
218  virtual bool write() = 0;
219 
220  //- Called when Time::run() determines that the time-loop exits.
221  // By default it simply calls execute().
222  virtual bool end();
223 
224  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
225  virtual bool adjustTimeStep();
226 
227  //- Update for changes of mesh
228  virtual void updateMesh(const mapPolyMesh& mpm);
229 
230  //- Update for changes of mesh
231  virtual void movePoints(const polyMesh& mesh);
232 };
233 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
dictionary dict
virtual ~functionObject()
Destructor.
static bool postProcess
Global post-processing mode switch.
virtual bool execute()=0
Called at each ++ or += of the time-loop.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool end()
Called when Time::run() determines that the time-loop exits.
dynamicFvMesh & mesh
const word & name() const
Return the name of this functionObject.
virtual const word & type() const =0
Runtime type information.
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
autoPtr< functionObject > clone() const
Return clone.
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
virtual bool write()=0
Called at each ++ or += of the time-loop.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Macros to ease declaration of run-time selection tables.
Switch log
Switch write log to Info.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Namespace for OpenFOAM.
declareRunTimeSelectionTable(autoPtr, functionObject, dictionary,(const word &name, const Time &runTime, const dictionary &dict),(name, runTime, dict))