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

multiComponentMixture.C

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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "multiComponentMixture.H"
00027 
00028 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00029 
00030 template<class ThermoType>
00031 const ThermoType& Foam::multiComponentMixture<ThermoType>::constructSpeciesData
00032 (
00033     const dictionary& thermoDict
00034 )
00035 {
00036     forAll(species_, i)
00037     {
00038         speciesData_.set
00039         (
00040             i,
00041             new ThermoType(thermoDict.lookup(species_[i]))
00042         );
00043     }
00044 
00045     return speciesData_[0];
00046 }
00047 
00048 
00049 template<class ThermoType>
00050 void Foam::multiComponentMixture<ThermoType>::correctMassFractions()
00051 {
00052     volScalarField Yt = Y_[0];
00053 
00054     for (label n=1; n<Y_.size(); n++)
00055     {
00056         Yt += Y_[n];
00057     }
00058 
00059     forAll (Y_, n)
00060     {
00061         Y_[n] /= Yt;
00062     }
00063 }
00064 
00065 
00066 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00067 
00068 template<class ThermoType>
00069 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
00070 (
00071     const dictionary& thermoDict,
00072     const wordList& specieNames,
00073     const HashPtrTable<ThermoType>& specieThermoData,
00074     const fvMesh& mesh
00075 )
00076 :
00077     basicMultiComponentMixture(thermoDict, specieNames, mesh),
00078     speciesData_(species_.size()),
00079     mixture_("mixture", *specieThermoData[specieNames[0]])
00080 {
00081     forAll(species_, i)
00082     {
00083         speciesData_.set
00084         (
00085             i,
00086             new ThermoType(*specieThermoData[species_[i]])
00087         );
00088     }
00089 
00090     correctMassFractions();
00091 }
00092 
00093 
00094 template<class ThermoType>
00095 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
00096 (
00097     const dictionary& thermoDict,
00098     const fvMesh& mesh
00099 )
00100 :
00101     basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh),
00102     speciesData_(species_.size()),
00103     mixture_("mixture", constructSpeciesData(thermoDict))
00104 {
00105     correctMassFractions();
00106 }
00107 
00108 
00109 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00110 
00111 template<class ThermoType>
00112 const ThermoType& Foam::multiComponentMixture<ThermoType>::cellMixture
00113 (
00114     const label celli
00115 ) const
00116 {
00117     mixture_ = Y_[0][celli]/speciesData_[0].W()*speciesData_[0];
00118 
00119     for (label n=1; n<Y_.size(); n++)
00120     {
00121         mixture_ += Y_[n][celli]/speciesData_[n].W()*speciesData_[n];
00122     }
00123 
00124     return mixture_;
00125 }
00126 
00127 
00128 template<class ThermoType>
00129 const ThermoType& Foam::multiComponentMixture<ThermoType>::patchFaceMixture
00130 (
00131     const label patchi,
00132     const label facei
00133 ) const
00134 {
00135     mixture_ =
00136         Y_[0].boundaryField()[patchi][facei]
00137        /speciesData_[0].W()*speciesData_[0];
00138 
00139     for (label n=1; n<Y_.size(); n++)
00140     {
00141         mixture_ +=
00142             Y_[n].boundaryField()[patchi][facei]
00143            /speciesData_[n].W()*speciesData_[n];
00144     }
00145 
00146     return mixture_;
00147 }
00148 
00149 
00150 template<class ThermoType>
00151 void Foam::multiComponentMixture<ThermoType>::read
00152 (
00153     const dictionary& thermoDict
00154 )
00155 {
00156     forAll(species_, i)
00157     {
00158         speciesData_[i] = ThermoType(thermoDict.lookup(species_[i]));
00159     }
00160 }
00161 
00162 
00163 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines