FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

OutputFilterFunctionObject.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2010 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software: you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
00023 
00024 Class
00025     Foam::OutputFilterFunctionObject
00026 
00027 Description
00028     A functionObject wrapper around OutputFilter to allow them to be
00029     created via the functions list within controlDict.
00030 
00031 Note
00032     Since the timeIndex is used directly from Foam::Time, it is unaffected
00033     by user-time conversions. For example, Foam::engineTime might cause @a
00034     writeInterval to be degrees crank angle, but the functionObject
00035     execution @a interval would still be in timestep.
00036 
00037 SourceFiles
00038     OutputFilterFunctionObject.C
00039 
00040 \*---------------------------------------------------------------------------*/
00041 
00042 #ifndef OutputFilterFunctionObject_H
00043 #define OutputFilterFunctionObject_H
00044 
00045 #include <OpenFOAM/functionObject.H>
00046 #include <OpenFOAM/dictionary.H>
00047 #include <OpenFOAM/outputFilterOutputControl.H>
00048 
00049 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00050 
00051 namespace Foam
00052 {
00053 
00054 /*---------------------------------------------------------------------------*\
00055                  Class OutputFilterFunctionObject Declaration
00056 \*---------------------------------------------------------------------------*/
00057 
00058 template<class OutputFilter>
00059 class OutputFilterFunctionObject
00060 :
00061     public functionObject
00062 {
00063     // Private data
00064 
00065         //- Reference to the time database
00066         const Time& time_;
00067 
00068         //- Input dictionary
00069         dictionary dict_;
00070 
00071         //- Name of region
00072         word regionName_;
00073 
00074         //- Optional dictionary name to supply required inputs
00075         word dictName_;
00076 
00077         //- Switch for the execution of the functionObject
00078         bool enabled_;
00079 
00080         //- Switch to store filter in between writes or use on-the-fly
00081         //  construction
00082         bool storeFilter_;
00083 
00084         //- Output controls
00085         outputFilterOutputControl outputControl_;
00086 
00087         //- Pointer to the output filter
00088         autoPtr<OutputFilter> ptr_;
00089 
00090 
00091     // Private Member Functions
00092 
00093         //- Read relevant dictionary entries
00094         void readDict();
00095  
00096         //- Creates most of the data associated with this object.
00097         void allocateFilter();
00098 
00099         //- Destroys most of the data associated with this object.
00100         void destroyFilter();
00101 
00102         //- Disallow default bitwise copy construct
00103         OutputFilterFunctionObject(const OutputFilterFunctionObject&);
00104 
00105         //- Disallow default bitwise assignment
00106         void operator=(const OutputFilterFunctionObject&);
00107 
00108 
00109 public:
00110 
00111     //- Runtime type information
00112     TypeName(OutputFilter::typeName_());
00113 
00114 
00115     // Constructors
00116 
00117         //- Construct from components
00118         OutputFilterFunctionObject
00119         (
00120             const word& name,
00121             const Time&,
00122             const dictionary&
00123         );
00124 
00125 
00126     // Member Functions
00127 
00128         // Access
00129 
00130             //- Return time database
00131             virtual const Time& time() const
00132             {
00133                 return time_;
00134             }
00135 
00136             //- Return the input dictionary
00137             virtual const dictionary& dict() const
00138             {
00139                 return dict_;
00140             }
00141 
00142             //- Return the region name
00143             virtual const word& regionName() const
00144             {
00145                 return regionName_;
00146             }
00147 
00148             //- Return the optional dictionary name
00149             virtual const word& dictName() const
00150             {
00151                 return dictName_;
00152             }
00153 
00154             //- Return the enabled flag
00155             virtual bool enabled() const
00156             {
00157                 return enabled_;
00158             }
00159 
00160             //- Return the output control object
00161             virtual const outputFilterOutputControl& outputControl() const
00162             {
00163                 return outputControl_;
00164             }
00165 
00166             //- Return the output filter
00167             virtual const OutputFilter& outputFilter() const
00168             {
00169                 return ptr_();
00170             }
00171 
00172 
00173         // Function object control
00174 
00175             //- Switch the function object on
00176             virtual void on();
00177 
00178             //- Switch the function object off
00179             virtual void off();
00180 
00181 
00182             //- Called at the start of the time-loop
00183             virtual bool start();
00184 
00185             //- Called at each ++ or += of the time-loop
00186             virtual bool execute();
00187 
00188             //- Called when Time::run() determines that the time-loop exits
00189             virtual bool end();
00190 
00191 
00192             //- Read and set the function object if its data have changed
00193             virtual bool read(const dictionary&);
00194 };
00195 
00196 
00197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00198 
00199 } // End namespace Foam
00200 
00201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00202 
00203 #ifdef NoRepository
00204 #   include "OutputFilterFunctionObject.C"
00205 #endif
00206 
00207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00208 
00209 #endif
00210 
00211 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines