FreeFOAM The Cross-Platform CFD Toolkit
multiComponentMixture.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "multiComponentMixture.H"
27 
28 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
29 
30 template<class ThermoType>
32 (
33  const dictionary& thermoDict
34 )
35 {
36  forAll(species_, i)
37  {
38  speciesData_.set
39  (
40  i,
41  new ThermoType(thermoDict.lookup(species_[i]))
42  );
43  }
44 
45  return speciesData_[0];
46 }
47 
48 
49 template<class ThermoType>
51 {
52  volScalarField Yt = Y_[0];
53 
54  for (label n=1; n<Y_.size(); n++)
55  {
56  Yt += Y_[n];
57  }
58 
59  forAll (Y_, n)
60  {
61  Y_[n] /= Yt;
62  }
63 }
64 
65 
66 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 
68 template<class ThermoType>
70 (
71  const dictionary& thermoDict,
72  const wordList& specieNames,
73  const HashPtrTable<ThermoType>& specieThermoData,
74  const fvMesh& mesh
75 )
76 :
77  basicMultiComponentMixture(thermoDict, specieNames, mesh),
78  speciesData_(species_.size()),
79  mixture_("mixture", *specieThermoData[specieNames[0]])
80 {
81  forAll(species_, i)
82  {
83  speciesData_.set
84  (
85  i,
86  new ThermoType(*specieThermoData[species_[i]])
87  );
88  }
89 
90  correctMassFractions();
91 }
92 
93 
94 template<class ThermoType>
96 (
97  const dictionary& thermoDict,
98  const fvMesh& mesh
99 )
100 :
101  basicMultiComponentMixture(thermoDict, thermoDict.lookup("species"), mesh),
102  speciesData_(species_.size()),
103  mixture_("mixture", constructSpeciesData(thermoDict))
104 {
105  correctMassFractions();
106 }
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class ThermoType>
113 (
114  const label celli
115 ) const
116 {
117  mixture_ = Y_[0][celli]/speciesData_[0].W()*speciesData_[0];
118 
119  for (label n=1; n<Y_.size(); n++)
120  {
121  mixture_ += Y_[n][celli]/speciesData_[n].W()*speciesData_[n];
122  }
123 
124  return mixture_;
125 }
126 
127 
128 template<class ThermoType>
130 (
131  const label patchi,
132  const label facei
133 ) const
134 {
135  mixture_ =
136  Y_[0].boundaryField()[patchi][facei]
137  /speciesData_[0].W()*speciesData_[0];
138 
139  for (label n=1; n<Y_.size(); n++)
140  {
141  mixture_ +=
142  Y_[n].boundaryField()[patchi][facei]
143  /speciesData_[n].W()*speciesData_[n];
144  }
145 
146  return mixture_;
147 }
148 
149 
150 template<class ThermoType>
152 (
153  const dictionary& thermoDict
154 )
155 {
156  forAll(species_, i)
157  {
158  speciesData_[i] = ThermoType(thermoDict.lookup(species_[i]));
159  }
160 }
161 
162 
163 // ************************ vim: set sw=4 sts=4 et: ************************ //