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-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::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  The function object can be limited to operate within a time range using
38  the timeStart and timEnd options. All objects are read (and the
39  OutputFilter allocated) on construction. However, if a timeEnd is
40  supplied, the object will call the 'end' function of the filter
41  at the timeEnd time and destroy the filter.
42  Any other callback (execute(), write(), timeSet() etc) will only operate
43  if within the timeStart, timeEnd time range. Note that the time range
44  uses 0.5 * deltaT as a comparison tolerance to account for precision errors.
45 
46 SourceFiles
47  OutputFilterFunctionObject.C
48 
49 \*---------------------------------------------------------------------------*/
50 
51 #ifndef OutputFilterFunctionObject_H
52 #define OutputFilterFunctionObject_H
53 
54 #include "functionObject.H"
55 #include "dictionary.H"
57 
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 
60 namespace Foam
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class OutputFilterFunctionObject Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template<class OutputFilter>
69 :
70  public functionObject
71 {
72  // Private data
73 
74  //- Reference to the time database
75  const Time& time_;
76 
77  //- Input dictionary
79 
80 
81  // Optional user inputs
82 
83  //- Name of region - defaults to name of polyMesh::defaultRegion
85 
86  //- Dictionary name to supply required inputs
88 
89  //- Switch for the execution - defaults to 'yes/on'
90  bool enabled_;
91 
92  //- Switch to store filter in between writes or use on-the-fly
93  // construction - defaults to true
94  bool storeFilter_;
95 
96  //- Activation time - defaults to -VGREAT
97  scalar timeStart_;
98 
99  //- De-activation time - defaults to VGREAT
100  scalar timeEnd_;
101 
102  //- Number of steps before the dumping time in which the deltaT
103  // will start to change (valid for ocAdjustableTime)
105 
106 
107  //- Output controls
109 
110  //- Evaluate controls
112 
113  //- Pointer to the output filter
115 
116 
117  // Private Member Functions
118 
119  //- Read relevant dictionary entries
120  void readDict();
121 
122  //- Creates most of the data associated with this object.
123  void allocateFilter();
124 
125  //- Destroys most of the data associated with this object.
126  void destroyFilter();
127 
128  //- Returns true if active (enabled and within time bounds)
129  bool active() const;
130 
131  //- Disallow default bitwise copy construct
133 
134  //- Disallow default bitwise assignment
136 
137 
138 public:
139 
140  //- Runtime type information
141  TypeName(OutputFilter::typeName_());
142 
143 
144  // Constructors
145 
146  //- Construct from components
148  (
149  const word& name,
150  const Time&,
151  const dictionary&
152  );
153 
154 
155  // Member Functions
156 
157  // Access
158 
159  //- Return time database
160  virtual const Time& time() const
161  {
162  return time_;
163  }
164 
165  //- Return the input dictionary
166  virtual const dictionary& dict() const
167  {
168  return dict_;
169  }
170 
171  //- Return the region name
172  virtual const word& regionName() const
173  {
174  return regionName_;
175  }
176 
177  //- Return the optional dictionary name
178  virtual const word& dictName() const
179  {
180  return dictName_;
181  }
182 
183  //- Return the enabled flag
184  virtual bool enabled() const
185  {
186  return enabled_;
187  }
188 
189  //- Return the output control object
190  virtual const outputFilterOutputControl& outputControl() const
191  {
192  return outputControl_;
193  }
194 
195  //- Return the output filter
196  virtual const OutputFilter& outputFilter() const
197  {
198  return ptr_();
199  }
200 
201 
202  // Function object control
203 
204  //- Switch the function object on
205  virtual void on();
206 
207  //- Switch the function object off
208  virtual void off();
209 
210 
211  //- Called at the start of the time-loop
212  virtual bool start();
213 
214  //- Called at each ++ or += of the time-loop
215  virtual bool execute(const bool forceWrite);
216 
217  //- Called when Time::run() determines that the time-loop exits
218  virtual bool end();
219 
220  //- Called when time was set at the end of the Time::operator++
221  virtual bool timeSet();
222 
223  //- Called at the end of Time::adjustDeltaT() if adjustTime is true
224  virtual bool adjustTimeStep();
225 
226  //- Read and set the function object if its data have changed
227  virtual bool read(const dictionary&);
228 
229  //- Update for changes of mesh
230  virtual void updateMesh(const mapPolyMesh& mpm);
231 
232  //- Update for changes of mesh
233  virtual void movePoints(const polyMesh& mesh);
234 };
235 
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 } // End namespace Foam
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 #ifdef NoRepository
245 #endif
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
Foam::OutputFilterFunctionObject::enabled
virtual bool enabled() const
Return the enabled flag.
Definition: OutputFilterFunctionObject.H:183
Foam::OutputFilterFunctionObject::dict
virtual const dictionary & dict() const
Return the input dictionary.
Definition: OutputFilterFunctionObject.H:165
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Foam::OutputFilterFunctionObject::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update for changes of mesh.
Definition: OutputFilterFunctionObject.C:303
Foam::OutputFilterFunctionObject
A functionObject wrapper around OutputFilter to allow them to be created via the functions entry with...
Definition: OutputFilterFunctionObject.H:67
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::OutputFilterFunctionObject::time
virtual const Time & time() const
Return time database.
Definition: OutputFilterFunctionObject.H:159
Foam::OutputFilterFunctionObject::execute
virtual bool execute(const bool forceWrite)
Called at each ++ or += of the time-loop.
Definition: OutputFilterFunctionObject.C:160
Foam::OutputFilterFunctionObject::regionName_
word regionName_
Name of region - defaults to name of polyMesh::defaultRegion.
Definition: OutputFilterFunctionObject.H:83
Foam::OutputFilterFunctionObject::operator=
void operator=(const OutputFilterFunctionObject &)
Disallow default bitwise assignment.
Foam::OutputFilterFunctionObject::outputFilter
virtual const OutputFilter & outputFilter() const
Return the output filter.
Definition: OutputFilterFunctionObject.H:195
Foam::OutputFilterFunctionObject::readDict
void readDict()
Read relevant dictionary entries.
Definition: OutputFilterFunctionObject.C:35
Foam::OutputFilterFunctionObject::start
virtual bool start()
Called at the start of the time-loop.
Definition: OutputFilterFunctionObject.C:145
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::OutputFilterFunctionObject::timeSet
virtual bool timeSet()
Called when time was set at the end of the Time::operator++.
Definition: OutputFilterFunctionObject.C:221
Foam::OutputFilterFunctionObject::outputControl_
outputFilterOutputControl outputControl_
Output controls.
Definition: OutputFilterFunctionObject.H:107
OutputFilterFunctionObject.C
Foam::OutputFilterFunctionObject::evaluateControl_
outputFilterOutputControl evaluateControl_
Evaluate controls.
Definition: OutputFilterFunctionObject.H:110
Foam::OutputFilterFunctionObject::timeEnd_
scalar timeEnd_
De-activation time - defaults to VGREAT.
Definition: OutputFilterFunctionObject.H:99
Foam::OutputFilterFunctionObject::storeFilter_
bool storeFilter_
Switch to store filter in between writes or use on-the-fly.
Definition: OutputFilterFunctionObject.H:93
Foam::OutputFilterFunctionObject::TypeName
TypeName(OutputFilter::typeName_())
Runtime type information.
Foam::label
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
Foam::OutputFilterFunctionObject::end
virtual bool end()
Called when Time::run() determines that the time-loop exits.
Definition: OutputFilterFunctionObject.C:199
Foam::OutputFilterFunctionObject::nStepsToStartTimeChange_
label nStepsToStartTimeChange_
Number of steps before the dumping time in which the deltaT.
Definition: OutputFilterFunctionObject.H:103
Foam::OutputFilterFunctionObject::off
virtual void off()
Switch the function object off.
Definition: OutputFilterFunctionObject.C:138
Foam::OutputFilterFunctionObject::destroyFilter
void destroyFilter()
Destroys most of the data associated with this object.
Definition: OutputFilterFunctionObject.C:92
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::OutputFilterFunctionObject::outputControl
virtual const outputFilterOutputControl & outputControl() const
Return the output control object.
Definition: OutputFilterFunctionObject.H:189
Foam::OutputFilterFunctionObject::dictName
virtual const word & dictName() const
Return the optional dictionary name.
Definition: OutputFilterFunctionObject.H:177
Foam::OutputFilterFunctionObject::movePoints
virtual void movePoints(const polyMesh &mesh)
Update for changes of mesh.
Definition: OutputFilterFunctionObject.C:316
Foam::OutputFilterFunctionObject::dict_
dictionary dict_
Input dictionary.
Definition: OutputFilterFunctionObject.H:77
Foam::OutputFilterFunctionObject::timeStart_
scalar timeStart_
Activation time - defaults to -VGREAT.
Definition: OutputFilterFunctionObject.H:96
Foam::OutputFilterFunctionObject::active
bool active() const
Returns true if active (enabled and within time bounds)
Definition: OutputFilterFunctionObject.C:48
Foam::OutputFilterFunctionObject::adjustTimeStep
virtual bool adjustTimeStep()
Called at the end of Time::adjustDeltaT() if adjustTime is true.
Definition: OutputFilterFunctionObject.C:233
Foam::autoPtr< OutputFilter >
Foam::OutputFilterFunctionObject::enabled_
bool enabled_
Switch for the execution - defaults to 'yes/on'.
Definition: OutputFilterFunctionObject.H:89
outputFilterOutputControl.H
Foam::outputFilterOutputControl
An output control for function objects. The default is time-step execution at every interval.
Definition: outputFilterOutputControl.H:51
Foam::OutputFilterFunctionObject::read
virtual bool read(const dictionary &)
Read and set the function object if its data have changed.
Definition: OutputFilterFunctionObject.C:283
Foam::OutputFilterFunctionObject::regionName
virtual const word & regionName() const
Return the region name.
Definition: OutputFilterFunctionObject.H:171
Foam::functionObject::name
virtual const word & name() const
Name.
Definition: functionObject.C:105
Foam::OutputFilterFunctionObject::OutputFilterFunctionObject
OutputFilterFunctionObject(const OutputFilterFunctionObject &)
Disallow default bitwise copy construct.
dictionary.H
Foam::OutputFilterFunctionObject::time_
const Time & time_
Reference to the time database.
Definition: OutputFilterFunctionObject.H:74
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::OutputFilterFunctionObject::ptr_
autoPtr< OutputFilter > ptr_
Pointer to the output filter.
Definition: OutputFilterFunctionObject.H:113
functionObject.H
Foam::OutputFilterFunctionObject::on
virtual void on()
Switch the function object on.
Definition: OutputFilterFunctionObject.C:131
Foam::OutputFilterFunctionObject::allocateFilter
void allocateFilter()
Creates most of the data associated with this object.
Definition: OutputFilterFunctionObject.C:62
Foam::OutputFilterFunctionObject::dictName_
word dictName_
Dictionary name to supply required inputs.
Definition: OutputFilterFunctionObject.H:86