FreeFOAM The Cross-Platform CFD Toolkit
OutputFilterFunctionObject.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::OutputFilterFunctionObject
26 
27 Description
28  A functionObject wrapper around OutputFilter to allow them to be
29  created via the functions list within controlDict.
30 
31 Note
32  Since the timeIndex is used directly from Foam::Time, it is unaffected
33  by user-time conversions. For example, Foam::engineTime might cause @a
34  writeInterval to be degrees crank angle, but the functionObject
35  execution @a interval would still be in timestep.
36 
37 SourceFiles
38  OutputFilterFunctionObject.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef OutputFilterFunctionObject_H
43 #define OutputFilterFunctionObject_H
44 
46 #include <OpenFOAM/dictionary.H>
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class OutputFilterFunctionObject Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 template<class OutputFilter>
60 :
61  public functionObject
62 {
63  // Private data
64 
65  //- Reference to the time database
66  const Time& time_;
67 
68  //- Input dictionary
69  dictionary dict_;
70 
71  //- Name of region
72  word regionName_;
73 
74  //- Optional dictionary name to supply required inputs
75  word dictName_;
76 
77  //- Switch for the execution of the functionObject
78  bool enabled_;
79 
80  //- Switch to store filter in between writes or use on-the-fly
81  // construction
82  bool storeFilter_;
83 
84  //- Output controls
85  outputFilterOutputControl outputControl_;
86 
87  //- Pointer to the output filter
89 
90 
91  // Private Member Functions
92 
93  //- Read relevant dictionary entries
94  void readDict();
95 
96  //- Creates most of the data associated with this object.
97  void allocateFilter();
98 
99  //- Destroys most of the data associated with this object.
100  void destroyFilter();
101 
102  //- Disallow default bitwise copy construct
104 
105  //- Disallow default bitwise assignment
106  void operator=(const OutputFilterFunctionObject&);
107 
108 
109 public:
110 
111  //- Runtime type information
112  TypeName(OutputFilter::typeName_());
113 
114 
115  // Constructors
116 
117  //- Construct from components
119  (
120  const word& name,
121  const Time&,
122  const dictionary&
123  );
124 
125 
126  // Member Functions
127 
128  // Access
129 
130  //- Return time database
131  virtual const Time& time() const
132  {
133  return time_;
134  }
135 
136  //- Return the input dictionary
137  virtual const dictionary& dict() const
138  {
139  return dict_;
140  }
141 
142  //- Return the region name
143  virtual const word& regionName() const
144  {
145  return regionName_;
146  }
147 
148  //- Return the optional dictionary name
149  virtual const word& dictName() const
150  {
151  return dictName_;
152  }
153 
154  //- Return the enabled flag
155  virtual bool enabled() const
156  {
157  return enabled_;
158  }
159 
160  //- Return the output control object
162  {
163  return outputControl_;
164  }
165 
166  //- Return the output filter
167  virtual const OutputFilter& outputFilter() const
168  {
169  return ptr_();
170  }
171 
172 
173  // Function object control
174 
175  //- Switch the function object on
176  virtual void on();
177 
178  //- Switch the function object off
179  virtual void off();
180 
181 
182  //- Called at the start of the time-loop
183  virtual bool start();
184 
185  //- Called at each ++ or += of the time-loop
186  virtual bool execute();
187 
188  //- Called when Time::run() determines that the time-loop exits
189  virtual bool end();
190 
191 
192  //- Read and set the function object if its data have changed
193  virtual bool read(const dictionary&);
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #ifdef NoRepository
205 #endif
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************ vim: set sw=4 sts=4 et: ************************ //