Merge branch 'master' of ssh://git.code.sf.net/p/foam-extend/foam-extend-3.2
[foam-extend-3.2.git] / src / lagrangian / intermediate / submodels / Reacting / CompositionModel / SingleMixtureFraction / SingleMixtureFraction.C
blob78476bbd7a8eb46eace84f2dd52c28af175f2abd
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 "SingleMixtureFraction.H"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 template<class CloudType>
31 void Foam::SingleMixtureFraction<CloudType>::constructIds()
33     forAll(this->phaseProps(), phaseI)
34     {
35         switch (this->phaseProps()[phaseI].phase())
36         {
37             case phaseProperties::GAS:
38             {
39                 idGas_ = phaseI;
40                 break;
41             }
42             case phaseProperties::LIQUID:
43             {
44                 idLiquid_ = phaseI;
45                 break;
46             }
47             case phaseProperties::SOLID:
48             {
49                 idSolid_ = phaseI;
50                 break;
51             }
52             default:
53             {
54                 FatalErrorIn
55                 (
56                     "void Foam::SingleMixtureFraction<CloudType>::"
57                     "constructIds()"
58                 )   << "Unknown phase enumeration" << nl << abort(FatalError);
59             }
60         }
61     }
63     if (idGas_ < 0)
64     {
65         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
66             << "No gas phase found in phase list:" << nl
67             << this->phaseTypes() << nl << endl;
68     }
69     if (idLiquid_ < 0)
70     {
71         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
72             << "No liquid phase found in phase list:" << nl
73             << this->phaseTypes() << nl << endl;
74     }
75     if (idSolid_ < 0)
76     {
77         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
78             << "No solid phase found in phase list:" << nl
79             << this->phaseTypes() << nl << endl;
80     }
84 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
86 template<class CloudType>
87 Foam::SingleMixtureFraction<CloudType>::SingleMixtureFraction
89     const dictionary& dict,
90     CloudType& owner
93     CompositionModel<CloudType>(dict, owner, typeName),
95     idGas_(-1),
96     idLiquid_(-1),
97     idSolid_(-1),
99     YMixture0_(3)
101     constructIds();
103     if (this->phaseProps().size() != 3)
104     {
105         FatalErrorIn
106         (
107             "Foam::SingleMixtureFraction<CloudType>::"
108             "SingleMixtureFraction"
109             "("
110                 "const dictionary&, "
111                 "CloudType&"
112             ")"
113         )   << "Incorrect numebr of phases: " << nl
114             << "    Please specify 1 gas, 1 liquid and 1 solid" << nl
115             << exit(FatalError);
116     }
118     this->coeffDict().lookup("YGasTot0") >> YMixture0_[idGas_];
119     this->coeffDict().lookup("YLiquidTot0") >> YMixture0_[idLiquid_];
120     this->coeffDict().lookup("YSolidTot0") >> YMixture0_[idSolid_];
122     if (mag(sum(YMixture0_) - 1.0) > SMALL)
123     {
124         FatalErrorIn
125         (
126             "Foam::SingleMixtureFraction<CloudType>::"
127             "SingleMixtureFraction"
128             "("
129                 "const dictionary&, "
130                 "CloudType&"
131             ")"
132         )   << "Sum of phases should be 1. Phase fractions:" << nl
133             << YMixture0_ << nl << exit(FatalError);
134     }
138 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
140 template<class CloudType>
141 Foam::SingleMixtureFraction<CloudType>::~SingleMixtureFraction()
145 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
147 template<class CloudType>
148 const Foam::scalarField&
149 Foam::SingleMixtureFraction<CloudType>::YGas0() const
151     return this->phaseProps()[idGas_].Y();
155 template<class CloudType>
156 const Foam::scalarField&
157 Foam::SingleMixtureFraction<CloudType>::YLiquid0() const
159     return this->phaseProps()[idLiquid_].Y();
163 template<class CloudType>
164 const Foam::scalarField&
165 Foam::SingleMixtureFraction<CloudType>::YSolid0() const
167     return this->phaseProps()[idSolid_].Y();
171 template<class CloudType>
172 const Foam::scalarField&
173 Foam::SingleMixtureFraction<CloudType>::YMixture0() const
175     return YMixture0_;
179 template<class CloudType>
180 Foam::label Foam::SingleMixtureFraction<CloudType>::idGas() const
182     return idGas_;
186 template<class CloudType>
187 Foam::label Foam::SingleMixtureFraction<CloudType>::idLiquid() const
189     return idLiquid_;
193 template<class CloudType>
194 Foam::label Foam::SingleMixtureFraction<CloudType>::idSolid() const
196     return idSolid_;
200 // ************************************************************************* //