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-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::functionObject
26 
27 Description
28  Abstract base-class for Time/database function objects.
29 
30 See Also
31  Foam::OutputFilterFunctionObject
32 
33 SourceFiles
34  functionObject.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef functionObject_H
39 #define functionObject_H
40 
41 #include "typeInfo.H"
42 #include "autoPtr.H"
43 #include "runTimeSelectionTables.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class Time;
52 class polyMesh;
53 class mapPolyMesh;
54 
55 /*---------------------------------------------------------------------------*\
56  Class functionObject Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class functionObject
60 {
61  // Private data
62 
63  //- Name
64  const word name_;
65 
66 
67  // Private Member Functions
68 
69  //- Disallow default bitwise copy construct
71 
72  //- Disallow default bitwise assignment
73  void operator=(const functionObject&);
74 
75 
76 public:
77 
78  //- Runtime type information
79  virtual const word& type() const = 0;
80 
81  static int debug;
82 
83 
84  // Declare run-time constructor selection tables
85 
87  (
88  autoPtr,
90  dictionary,
91  (const word& name, const Time& t, const dictionary& dict),
92  (name, t, dict)
93  );
94 
95 
96  // Constructors
97 
98  //- Construct from components
99  functionObject(const word& name);
100 
101  //- Return clone
103  {
104  notImplemented("functionObject::clone() const");
105  return autoPtr<functionObject>(NULL);
106  }
107 
108  //- Return a pointer to a new functionObject created on freestore
109  // from Istream
110  class iNew
111  {
112  const Time& time_;
113 
114  public:
116  iNew(const Time& t)
117  :
118  time_(t)
119  {}
120 
121  autoPtr<functionObject> operator()
122  (
123  const word& name,
124  Istream& is
125  ) const;
126  };
127 
128 
129  // Selectors
130 
131  //- Select from dictionary, based on its "type" entry
133  (
134  const word& name,
135  const Time&,
136  const dictionary&
137  );
138 
139 
140  //- Destructor
141  virtual ~functionObject();
142 
143 
144  // Member Functions
145 
146  //- Name
147  virtual const word& name() const;
148 
149  //- Called at the start of the time-loop
150  virtual bool start() = 0;
151 
152  //- Called at each ++ or += of the time-loop. forceWrite overrides the
153  // outputControl behaviour.
154  virtual bool execute(const bool forceWrite) = 0;
155 
156  //- Called when Time::run() determines that the time-loop exits.
157  // By default it simply calls execute().
158  virtual bool end();
159 
160  //- Called when time was set at the end of the Time::operator++
161  virtual bool timeSet();
162 
163  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
164  virtual bool adjustTimeStep();
165 
166  //- Read and set the function object if its data have changed
167  virtual bool read(const dictionary&) = 0;
168 
169  //- Update for changes of mesh
170  virtual void updateMesh(const mapPolyMesh& mpm) = 0;
171 
172  //- Update for changes of mesh
173  virtual void movePoints(const polyMesh& mesh) = 0;
174 };
175 
176 
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
178 
179 } // End namespace Foam
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 #endif
184 
185 // ************************************************************************* //
virtual void updateMesh(const mapPolyMesh &mpm)=0
Update for changes of mesh.
virtual const word & type() const =0
Runtime type information.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Abstract base-class for Time/database function objects.
Macros to ease declaration of run-time selection tables.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
declareRunTimeSelectionTable(autoPtr, functionObject, dictionary,(const word &name, const Time &t, const dictionary &dict),(name, t, dict))
Return a pointer to a new functionObject created on freestore.
dynamicFvMesh & mesh
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual bool execute(const bool forceWrite)=0
Called at each ++ or += of the time-loop. forceWrite overrides the.
virtual bool end()
Called when Time::run() determines that the time-loop exits.
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
dictionary dict
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual bool start()=0
Called at the start of the time-loop.
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
virtual void movePoints(const polyMesh &mesh)=0
Update for changes of mesh.
autoPtr< functionObject > clone() const
Return clone.
virtual const word & name() const
Name.
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
virtual bool read(const dictionary &)=0
Read and set the function object if its data have changed.
virtual ~functionObject()
Destructor.