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) 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::OutputFilterFunctionObject
26 
27 Description
28  A functionObject wrapper around OutputFilter to allow them to be
29  created via the functions entry 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 
45 #include "functionObject.H"
46 #include "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 
72  // Optional user inputs
73 
74  //- Name of region - defaults to name of polyMesh::defaultRegion
75  word regionName_;
76 
77  //- Dictionary name to supply required inputs
78  word dictName_;
79 
80  //- Switch for the execution - defaults to 'yes/on'
81  bool enabled_;
82 
83  //- Switch to store filter in between writes or use on-the-fly
84  // construction - defaults to true
85  bool storeFilter_;
86 
87  //- Activation time - defaults to -VGREAT
88  scalar timeStart_;
89 
90  //- De-activation time - defaults to VGREAT
91  scalar timeEnd_;
92 
93  //- Number of steps before the dumping time in which the deltaT
94  // will start to change (valid for ocAdjustableTime)
95  label nStepsToStartTimeChange_;
96 
97 
98  //- Output controls
99  outputFilterOutputControl outputControl_;
100 
101  //- Evaluate controls
102  outputFilterOutputControl evaluateControl_;
103 
104  //- Pointer to the output filter
106 
107 
108  // Private Member Functions
109 
110  //- Read relevant dictionary entries
111  void readDict();
112 
113  //- Creates most of the data associated with this object.
114  void allocateFilter();
115 
116  //- Destroys most of the data associated with this object.
117  void destroyFilter();
118 
119  //- Returns true if active (enabled and within time bounds)
120  bool active() const;
121 
122  //- Disallow default bitwise copy construct
124 
125  //- Disallow default bitwise assignment
126  void operator=(const OutputFilterFunctionObject&);
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName(OutputFilter::typeName_());
133 
134 
135  // Constructors
136 
137  //- Construct from components
139  (
140  const word& name,
141  const Time&,
142  const dictionary&
143  );
144 
145 
146  // Member Functions
147 
148  // Access
149 
150  //- Return time database
151  virtual const Time& time() const
152  {
153  return time_;
154  }
155 
156  //- Return the input dictionary
157  virtual const dictionary& dict() const
158  {
159  return dict_;
160  }
161 
162  //- Return the region name
163  virtual const word& regionName() const
164  {
165  return regionName_;
166  }
167 
168  //- Return the optional dictionary name
169  virtual const word& dictName() const
170  {
171  return dictName_;
172  }
173 
174  //- Return the enabled flag
175  virtual bool enabled() const
176  {
177  return enabled_;
178  }
179 
180  //- Return the output control object
181  virtual const outputFilterOutputControl& outputControl() const
182  {
183  return outputControl_;
184  }
185 
186  //- Return the output filter
187  virtual const OutputFilter& outputFilter() const
188  {
189  return ptr_();
190  }
191 
192 
193  // Function object control
194 
195  //- Switch the function object on
196  virtual void on();
197 
198  //- Switch the function object off
199  virtual void off();
200 
201 
202  //- Called at the start of the time-loop
203  virtual bool start();
204 
205  //- Called at each ++ or += of the time-loop
206  virtual bool execute(const bool forceWrite);
207 
208  //- Called when Time::run() determines that the time-loop exits
209  virtual bool end();
210 
211  //- Called when time was set at the end of the Time::operator++
212  virtual bool timeSet();
213 
214  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
215  virtual bool adjustTimeStep();
216 
217  //- Read and set the function object if its data have changed
218  virtual bool read(const dictionary&);
219 
220  //- Update for changes of mesh
221  virtual void updateMesh(const mapPolyMesh& mpm);
222 
223  //- Update for changes of mesh
224  virtual void movePoints(const polyMesh& mesh);
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #ifdef NoRepository
236 #endif
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 #endif
241 
242 // ************************************************************************* //
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
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.
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
An output control for function objects. The default is time-step execution at every interval...
dynamicFvMesh & mesh
virtual const OutputFilter & outputFilter() const
Return the output filter.
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)
Called at each ++ or += of the time-loop.
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
virtual const word & regionName() const
Return the region name.
virtual const Time & time() const
Return time database.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
virtual const word & dictName() const
Return the optional dictionary name.
A functionObject wrapper around OutputFilter to allow them to be created via the functions entry with...
virtual const dictionary & dict() const
Return the input dictionary.
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
virtual const outputFilterOutputControl & outputControl() const
Return the output control object.
virtual bool start()
Called at the start of the time-loop.
virtual bool enabled() const
Return the enabled flag.
virtual void on()
Switch the function object on.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual void off()
Switch the function object off.
TypeName(OutputFilter::typeName_())
Runtime type information.
virtual bool end()
Called when Time::run() determines that the time-loop exits.
virtual const word & name() const
Name.