OpenFOAM logo
Open Source CFD Toolkit

janafThermo.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-2005 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     janafThermo
00027 
00028 Description
00029     JANAF tables based thermodynamics package
00030     templated ito the equationOfState.
00031 
00032 SourceFiles
00033     janafThermoI.H
00034     janafThermo.C
00035 
00036 \*---------------------------------------------------------------------------*/
00037 
00038 #ifndef janafThermo2_H
00039 #define janafThermo2_H
00040 
00041 #include "scalar.H"
00042 
00043 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00044 
00045 namespace Foam
00046 {
00047 
00048 // * * * * * * Forward declaration of template friend fuctions * * * * * * * //
00049 
00050 template<class equationOfState> class janafThermo;
00051 
00052 template<class equationOfState>
00053 inline janafThermo<equationOfState> operator+
00054 (
00055     const janafThermo<equationOfState>&,
00056     const janafThermo<equationOfState>&
00057 );
00058 
00059 template<class equationOfState>
00060 inline janafThermo<equationOfState> operator-
00061 (
00062     const janafThermo<equationOfState>&,
00063     const janafThermo<equationOfState>&
00064 );
00065 
00066 template<class equationOfState>
00067 inline janafThermo<equationOfState> operator*
00068 (
00069     const scalar,
00070     const janafThermo<equationOfState>&
00071 );
00072 
00073 template<class equationOfState>
00074 inline janafThermo<equationOfState> operator==
00075 (
00076     const janafThermo<equationOfState>&,
00077     const janafThermo<equationOfState>&
00078 );
00079 
00080 template<class equationOfState>
00081 Ostream& operator<<
00082 (
00083     Ostream&,
00084     const janafThermo<equationOfState>&
00085 );
00086 
00087 
00088 #ifdef __GNUC__
00089 typedef scalar coeffArray2[7];
00090 #endif
00091 
00092 
00093 /*---------------------------------------------------------------------------*\
00094                            Class janafThermo Declaration
00095 \*---------------------------------------------------------------------------*/
00096 
00097 template<class equationOfState>
00098 class janafThermo
00099 :
00100     public equationOfState
00101 {
00102 
00103 public:
00104 
00105         static const int nCoeffs_ = 7;
00106         typedef scalar coeffArray[7];
00107 
00108 private:
00109 
00110     // Private data
00111 
00112         // Temperature limits of applicability of functions
00113         scalar Tlow_, Thigh_, Tcommon_;
00114 
00115         coeffArray highCpCoeffs_;
00116         coeffArray lowCpCoeffs_;
00117 
00118 
00119     // Private member functions
00120 
00121         //- Check given temperature is within the range of the fitted coeffs
00122         inline void checkT(const scalar T) const;
00123 
00124         //- Return the coefficients corresponding to the given temperature
00125         inline const 
00126 #       ifdef __GNUC__
00127         coeffArray2&
00128 #       else
00129         coeffArray&
00130 #       endif
00131         coeffs(const scalar T) const;
00132 
00133 
00134 public:
00135 
00136     // Constructors
00137 
00138         //- Construct from components
00139         inline janafThermo
00140         (
00141             const equationOfState& st,
00142             const scalar Tlow,
00143             const scalar Thigh,
00144             const scalar Tcommon,
00145             const coeffArray& highCpCoeffs,
00146             const coeffArray& lowCpCoeffs
00147         );
00148 
00149         //- Construct from Istream
00150         janafThermo(Istream&);
00151 
00152         //- Construct as a named copy
00153         inline janafThermo(const word&, const janafThermo&);
00154 
00155 
00156     // Member Functions
00157 
00158         //- Heat capacity at constant pressure [J/(kmol K)]
00159         inline scalar cp(const scalar T) const;
00160 
00161         //- Enthalpy [J/kmol]
00162         inline scalar h(const scalar T) const;
00163 
00164         //- Entropy [J/(kmol K)]
00165         inline scalar s(const scalar T) const;
00166 
00167 
00168     // Member operators
00169 
00170         inline void operator+=(const janafThermo&);
00171         inline void operator-=(const janafThermo&);
00172 
00173         inline void operator*=(const scalar);
00174 
00175 
00176     // Friend operators
00177 
00178         friend janafThermo operator+ <equationOfState>
00179         (
00180             const janafThermo&,
00181             const janafThermo&
00182         );
00183 
00184         friend janafThermo operator- <equationOfState>
00185         (
00186             const janafThermo&,
00187             const janafThermo&
00188         );
00189 
00190         friend janafThermo operator* <equationOfState>
00191         (
00192             const scalar,
00193             const janafThermo&
00194         );
00195 
00196         friend janafThermo operator== <equationOfState>
00197         (
00198             const janafThermo&,
00199             const janafThermo&
00200         );
00201 
00202 
00203     // Ostream Operator
00204 
00205         friend Ostream& operator<< <equationOfState>
00206         (
00207             Ostream&,
00208             const janafThermo&
00209         );
00210 };
00211 
00212 
00213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00214 
00215 } // End namespace Foam
00216 
00217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00218 
00219 #include "janafThermoI.H"
00220 
00221 #ifdef NoRepository
00222 #   include "janafThermo.C"
00223 #endif
00224 
00225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00226 
00227 #endif
00228 
00229 // ************************************************************************* //
For further information go to www.openfoam.org