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