initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / src / thermophysicalModels / combustion / mixtureThermos / mixtures / multiComponentMixture / multiComponentMixture.C
blob2f7906f39ced4694bb695e7b6fe58dc30a309c8f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "multiComponentMixture.H"
28 #include "fvMesh.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 namespace Foam
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 template<class ThermoType>
38 const ThermoType& multiComponentMixture<ThermoType>::constructSpeciesData
40     const dictionary& thermoDict
43     forAll(species_, i)
44     {
45         speciesData_.set
46         (
47             i,
48             new ThermoType(thermoDict.lookup(species_[i]))
49         );
50     }
52     return speciesData_[0];
56 template<class ThermoType>
57 void multiComponentMixture<ThermoType>::correctMassFractions()
59     volScalarField Yt = Y_[0];
61     for(label n=1; n<Y_.size(); n++)
62     {
63         Yt += Y_[n];
64     }
66     forAll (Y_, n)
67     {
68         Y_[n] /= Yt;
69     }
73 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
75 template<class ThermoType>
76 multiComponentMixture<ThermoType>::multiComponentMixture
78     const dictionary& thermoDict,
79     const wordList& specieNames,
80     const HashPtrTable<ThermoType>& specieThermoData,
81     const fvMesh& mesh
84     combustionMixture(thermoDict, specieNames, mesh),
85     speciesData_(species_.size()),
86     mixture_("mixture", *specieThermoData[specieNames[0]])
88     forAll(species_, i)
89     {
90         speciesData_.set
91         (
92             i,
93             new ThermoType(*specieThermoData[species_[i]])
94         );
95     }
97     correctMassFractions();
101 template<class ThermoType>
102 multiComponentMixture<ThermoType>::multiComponentMixture
104     const dictionary& thermoDict,
105     const fvMesh& mesh
108     combustionMixture(thermoDict, thermoDict.lookup("species"), mesh),
109     speciesData_(species_.size()),
110     mixture_("mixture", constructSpeciesData(thermoDict))
112     correctMassFractions();
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 template<class ThermoType>
119 const ThermoType& multiComponentMixture<ThermoType>::cellMixture
121     const label celli
122 ) const
124     mixture_ = Y_[0][celli]/speciesData_[0].W()*speciesData_[0];
126     for (label n=1; n<Y_.size(); n++)
127     {
128         mixture_ += Y_[n][celli]/speciesData_[n].W()*speciesData_[n];
129     }
130         
131     return mixture_;
135 template<class ThermoType>
136 const ThermoType& multiComponentMixture<ThermoType>::patchFaceMixture
138     const label patchi,
139     const label facei
140 ) const
142     mixture_ =
143         Y_[0].boundaryField()[patchi][facei]
144        /speciesData_[0].W()*speciesData_[0];
146     for (label n=1; n<Y_.size(); n++)
147     {
148         mixture_ +=
149             Y_[n].boundaryField()[patchi][facei]
150            /speciesData_[n].W()*speciesData_[n];
151     }
152         
153     return mixture_;
157 template<class ThermoType>
158 void multiComponentMixture<ThermoType>::read(const dictionary& thermoDict)
160     forAll(species_, i)
161     {
162         speciesData_[i] = ThermoType(thermoDict.lookup(species_[i]));
163     }
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 } // End namespace Foam
171 // ************************************************************************* //