OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

Constant.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-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::Constant
00027 
00028 Description
00029     Templated basic entry that holds a constant value.
00030 
00031     Usage - for entry <entryName> having the value <value>:
00032     @verbatim
00033         <entryName>    constant  <value>
00034     @endverbatim
00035 
00036 SourceFiles
00037     Constant.C
00038 
00039 \*---------------------------------------------------------------------------*/
00040 
00041 #ifndef Constant_H
00042 #define Constant_H
00043 
00044 #include "DataEntry.H"
00045 
00046 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00047 
00048 namespace Foam
00049 {
00050 
00051 template<class Type>
00052 class Constant;
00053 
00054 template<class Type>
00055 Ostream& operator<<
00056 (
00057     Ostream&,
00058     const Constant<Type>&
00059 );
00060 
00061 /*---------------------------------------------------------------------------*\
00062                            Class Constant Declaration
00063 \*---------------------------------------------------------------------------*/
00064 
00065 template<class Type>
00066 class Constant
00067 :
00068     public DataEntry<Type>
00069 {
00070     // Private data
00071 
00072         //- Constant value
00073         Type value_;
00074 
00075 
00076     // Private Member Functions
00077 
00078         //- Disallow default bitwise assignment
00079         void operator=(const Constant<Type>&);
00080 
00081 
00082 public:
00083 
00084     // Runtime type information
00085     TypeName("constant");
00086 
00087 
00088     // Constructors
00089 
00090         //- Construct from entry name and Istream
00091         Constant(const word& entryName, Istream& is);
00092 
00093         //- Copy constructor
00094         Constant(const Constant<Type>& cnst);
00095 
00096 
00097     //- Destructor
00098     virtual ~Constant();
00099 
00100 
00101     // Member Functions
00102 
00103         //- Return constant value
00104         Type value(const scalar) const;
00105 
00106         //- Integrate between two values
00107         Type integrate(const scalar x1, const scalar x2) const;
00108 
00109 
00110     //- Ostream Operator
00111     friend Ostream& operator<< <Type>
00112     (
00113         Ostream&,
00114         const Constant<Type>&
00115     );
00116 };
00117 
00118 
00119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00120 
00121 template<>
00122 Constant<label>::Constant(const word& entryName, Istream& is);
00123 
00124 template<>
00125 Constant<scalar>::Constant(const word& entryName, Istream& is);
00126 
00127 
00128 } // End namespace Foam
00129 
00130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00131 
00132 #ifdef NoRepository
00133 #   include "Constant.C"
00134 #endif
00135 
00136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00137 
00138 #endif
00139 
00140 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd