Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / thermophysicalModels / reactionThermo / mixtures / multiComponentMixture / multiComponentMixture.C
blobbe9f794116f37bd9fa6a38e1b299c1e2d1b6bcd1
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "multiComponentMixture.H"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 template<class ThermoType>
31 const ThermoType& Foam::multiComponentMixture<ThermoType>::constructSpeciesData
33     const dictionary& thermoDict
36     forAll(species_, i)
37     {
38         speciesData_.set
39         (
40             i,
41             new ThermoType(thermoDict.lookup(species_[i]))
42         );
43     }
45     return speciesData_[0];
49 template<class ThermoType>
50 void Foam::multiComponentMixture<ThermoType>::correctMassFractions()
52     volScalarField Yt
53     (
54         "Yt",
55         Y_[0]
56     );
58     for (label n=1; n<Y_.size(); n++)
59     {
60         Yt += Y_[n];
61     }
63     forAll (Y_, n)
64     {
65         Y_[n] /= Yt;
66     }
70 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
72 template<class ThermoType>
73 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
75     const dictionary& thermoDict,
76     const wordList& specieNames,
77     const HashPtrTable<ThermoType>& specieThermoData,
78     const fvMesh& mesh,
79     const objectRegistry& obj
82     basicMultiComponentMixture(thermoDict, specieNames, mesh, obj),
83     speciesData_(species_.size()),
84     mixture_("mixture", *specieThermoData[specieNames[0]])
86     forAll(species_, i)
87     {
88         speciesData_.set
89         (
90             i,
91             new ThermoType(*specieThermoData[species_[i]])
92         );
93     }
95     correctMassFractions();
99 template<class ThermoType>
100 Foam::multiComponentMixture<ThermoType>::multiComponentMixture
102     const dictionary& thermoDict,
103     const fvMesh& mesh,
104     const objectRegistry& obj
107     basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh, obj),
108     speciesData_(species_.size()),
109     mixture_("mixture", constructSpeciesData(thermoDict))
111     correctMassFractions();
115 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
117 template<class ThermoType>
118 const ThermoType& Foam::multiComponentMixture<ThermoType>::cellMixture
120     const label celli
121 ) const
123     mixture_ = Y_[0][celli]/speciesData_[0].W()*speciesData_[0];
125     for (label n=1; n<Y_.size(); n++)
126     {
127         mixture_ += Y_[n][celli]/speciesData_[n].W()*speciesData_[n];
128     }
130     return mixture_;
134 template<class ThermoType>
135 const ThermoType& Foam::multiComponentMixture<ThermoType>::patchFaceMixture
137     const label patchi,
138     const label facei
139 ) const
141     mixture_ =
142         Y_[0].boundaryField()[patchi][facei]
143        /speciesData_[0].W()*speciesData_[0];
145     for (label n=1; n<Y_.size(); n++)
146     {
147         mixture_ +=
148             Y_[n].boundaryField()[patchi][facei]
149            /speciesData_[n].W()*speciesData_[n];
150     }
152     return mixture_;
156 template<class ThermoType>
157 void Foam::multiComponentMixture<ThermoType>::read
159     const dictionary& thermoDict
162     forAll(species_, i)
163     {
164         speciesData_[i] = ThermoType(thermoDict.lookup(species_[i]));
165     }
169 // ************************************************************************* //