FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 <OpenFOAM/typeInfo.H>
42 #include <OpenFOAM/autoPtr.H>
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class Time;
52 
53 /*---------------------------------------------------------------------------*\
54  Class functionObject Declaration
55 \*---------------------------------------------------------------------------*/
56 
58 {
59  // Private data
60 
61  //- Name
62  const word name_;
63 
64 
65  // Private Member Functions
66 
67  //- Disallow default bitwise copy construct
69 
70  //- Disallow default bitwise assignment
71  void operator=(const functionObject&);
72 
73 
74 public:
75 
76  //- Runtime type information
77  virtual const word& type() const = 0;
78 
79  static int debug;
80 
81 
82  // Declare run-time constructor selection tables
83 
85  (
86  autoPtr,
88  dictionary,
89  (const word& name, const Time& t, const dictionary& dict),
90  (name, t, dict)
91  );
92 
93 
94  // Constructors
95 
96  //- Construct from components
97  functionObject(const word& name);
98 
99  //- Return clone
101  {
102  notImplemented("functionObject::clone() const");
103  return autoPtr<functionObject>(NULL);
104  }
105 
106  //- Return a pointer to a new functionObject created on freestore
107  // from Istream
108  class iNew
109  {
110  const Time& time_;
111 
112  public:
113 
114  iNew(const Time& t)
115  :
116  time_(t)
117  {}
118 
119  autoPtr<functionObject> operator()
120  (
121  const word& name,
122  Istream& is
123  ) const;
124  };
125 
126 
127  // Selectors
128 
129  //- Select from dictionary, based on its "type" entry
131  (
132  const word& name,
133  const Time&,
134  const dictionary&
135  );
136 
137 
138  // Destructor
139 
140  virtual ~functionObject();
141 
142 
143  // Member Functions
144 
145  //- Name
146  virtual const word& name() const;
147 
148  //- Called at the start of the time-loop
149  virtual bool start() = 0;
150 
151  //- Called at each ++ or += of the time-loop
152  virtual bool execute() = 0;
153 
154  //- Called when Time::run() determines that the time-loop exits.
155  // By default it simply calls execute().
156  virtual bool end();
157 
158  //- Read and set the function object if its data have changed
159  virtual bool read(const dictionary&) = 0;
160 };
161 
162 
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
164 
165 } // End namespace Foam
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 #endif
170 
171 // ************************ vim: set sw=4 sts=4 et: ************************ //