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-2015 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  {
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:
115 
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 // ************************************************************************* //
Foam::functionObject::iNew::time_
const Time & time_
Definition: functionObject.H:111
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::functionObject::read
virtual bool read(const dictionary &)=0
Read and set the function object if its data have changed.
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
typeInfo.H
Foam::functionObject::name_
const word name_
Name.
Definition: functionObject.H:63
Foam::functionObject::movePoints
virtual void movePoints(const polyMesh &mesh)=0
Update for changes of mesh.
Foam::functionObject::operator=
void operator=(const functionObject &)
Disallow default bitwise assignment.
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::functionObject
Abstract base-class for Time/database function objects.
Definition: functionObject.H:58
Foam::functionObject::~functionObject
virtual ~functionObject()
Destructor.
Definition: functionObject.C:99
Foam::functionObject::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)=0
Update for changes of mesh.
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::functionObject::New
static autoPtr< functionObject > New(const word &name, const Time &, const dictionary &)
Select from dictionary, based on its "type" entry.
Definition: functionObject.C:51
Foam::functionObject::iNew
Return a pointer to a new functionObject created on freestore.
Definition: functionObject.H:109
Foam::functionObject::declareRunTimeSelectionTable
declareRunTimeSelectionTable(autoPtr, functionObject, dictionary,(const word &name, const Time &t, const dictionary &dict),(name, t, dict))
Foam::functionObject::clone
autoPtr< functionObject > clone() const
Return clone.
Definition: functionObject.H:101
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::functionObject::adjustTimeStep
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: functionObject.C:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::functionObject::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: functionObject.C:111
Foam::autoPtr
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
Foam::functionObject::timeSet
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
Definition: functionObject.C:117
Foam::functionObject::debug
static int debug
Definition: functionObject.H:80
Foam::functionObject::name
virtual const word & name() const
Name.
Definition: functionObject.C:105
runTimeSelectionTables.H
Macros to ease declaration of run-time selection tables.
Foam::functionObject::type
virtual const word & type() const =0
Runtime type information.
Foam::functionObject::execute
virtual bool execute(const bool forceWrite)=0
Called at each ++ or += of the time-loop. forceWrite overrides the.
Foam::functionObject::functionObject
functionObject(const functionObject &)
Disallow default bitwise copy construct.
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::functionObject::iNew::iNew
iNew(const Time &t)
Definition: functionObject.H:115
Foam::functionObject::start
virtual bool start()=0
Called at the start of the time-loop.
autoPtr.H