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

functionObject.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::functionObject
00026 
00027 Description
00028     Abstract base-class for Time/database function objects.
00029 
00030 See Also
00031     Foam::OutputFilterFunctionObject
00032 
00033 SourceFiles
00034     functionObject.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef functionObject_H
00039 #define functionObject_H
00040 
00041 #include <OpenFOAM/typeInfo.H>
00042 #include <OpenFOAM/autoPtr.H>
00043 #include <OpenFOAM/runTimeSelectionTables.H>
00044 
00045 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00046 
00047 namespace Foam
00048 {
00049 
00050 // Forward declaration of classes
00051 class Time;
00052 
00053 /*---------------------------------------------------------------------------*\
00054                            Class functionObject Declaration
00055 \*---------------------------------------------------------------------------*/
00056 
00057 class functionObject
00058 {
00059     // Private data
00060 
00061         //- Name
00062         const word name_;
00063 
00064 
00065     // Private Member Functions
00066 
00067         //- Disallow default bitwise copy construct
00068         functionObject(const functionObject&);
00069 
00070         //- Disallow default bitwise assignment
00071         void operator=(const functionObject&);
00072 
00073 
00074 public:
00075 
00076     //- Runtime type information
00077     virtual const word& type() const = 0;
00078 
00079     static int debug;
00080 
00081 
00082     // Declare run-time constructor selection tables
00083 
00084         declareRunTimeSelectionTable
00085         (
00086             autoPtr,
00087             functionObject,
00088             dictionary,
00089             (const word& name, const Time& t, const dictionary& dict),
00090             (name, t, dict)
00091         );
00092 
00093 
00094     // Constructors
00095 
00096         //- Construct from components
00097         functionObject(const word& name);
00098 
00099         //- Return clone
00100         autoPtr<functionObject> clone() const
00101         {
00102             notImplemented("functionObject::clone() const");
00103             return autoPtr<functionObject>(NULL);
00104         }
00105 
00106         //- Return a pointer to a new functionObject created on freestore
00107         //  from Istream
00108         class iNew
00109         {
00110             const Time& time_;
00111 
00112         public:
00113 
00114             iNew(const Time& t)
00115             :
00116                 time_(t)
00117             {}
00118 
00119             autoPtr<functionObject> operator()
00120             (
00121                 const word& name,
00122                 Istream& is
00123             ) const;
00124         };
00125 
00126 
00127     // Selectors
00128 
00129         //- Select from dictionary, based on its "type" entry
00130         static autoPtr<functionObject> New
00131         (
00132             const word& name,
00133             const Time&,
00134             const dictionary&
00135         );
00136 
00137 
00138     // Destructor
00139 
00140         virtual ~functionObject();
00141 
00142 
00143     // Member Functions
00144 
00145         //- Name
00146         virtual const word& name() const;
00147 
00148         //- Called at the start of the time-loop
00149         virtual bool start() = 0;
00150 
00151         //- Called at each ++ or += of the time-loop
00152         virtual bool execute() = 0;
00153 
00154         //- Called when Time::run() determines that the time-loop exits.
00155         //  By default it simply calls execute().
00156         virtual bool end();
00157 
00158         //- Read and set the function object if its data have changed
00159         virtual bool read(const dictionary&) = 0;
00160 };
00161 
00162 
00163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00164 
00165 } // End namespace Foam
00166 
00167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00168 
00169 #endif
00170 
00171 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines