OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

SingleMixtureFraction.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) 2008-2009 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 the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     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, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "SingleMixtureFraction.H"
00028 
00029 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00030 
00031 template<class CloudType>
00032 void Foam::SingleMixtureFraction<CloudType>::constructIds()
00033 {
00034     forAll(this->phaseProps(), phaseI)
00035     {
00036         switch (this->phaseProps()[phaseI].phase())
00037         {
00038             case phaseProperties::GAS:
00039             {
00040                 idGas_ = phaseI;
00041                 break;
00042             }
00043             case phaseProperties::LIQUID:
00044             {
00045                 idLiquid_ = phaseI;
00046                 break;
00047             }
00048             case phaseProperties::SOLID:
00049             {
00050                 idSolid_ = phaseI;
00051                 break;
00052             }
00053             default:
00054             {
00055                 FatalErrorIn
00056                 (
00057                     "void Foam::SingleMixtureFraction<CloudType>::"
00058                     "constructIds()"
00059                 )   << "Unknown phase enumeration" << nl << abort(FatalError);
00060             }
00061         }
00062     }
00063 
00064     if (idGas_ < 0)
00065     {
00066         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
00067             << "No gas phase found in phase list:" << nl
00068             << this->phaseTypes() << nl << endl;
00069     }
00070     if (idLiquid_ < 0)
00071     {
00072         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
00073             << "No liquid phase found in phase list:" << nl
00074             << this->phaseTypes() << nl << endl;
00075     }
00076     if (idSolid_ < 0)
00077     {
00078         FatalErrorIn("Foam::SingleMixtureFraction<CloudType>::constructIds()")
00079             << "No solid phase found in phase list:" << nl
00080             << this->phaseTypes() << nl << endl;
00081     }
00082 }
00083 
00084 
00085 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00086 
00087 template<class CloudType>
00088 Foam::SingleMixtureFraction<CloudType>::SingleMixtureFraction
00089 (
00090     const dictionary& dict,
00091     CloudType& owner
00092 )
00093 :
00094     CompositionModel<CloudType>(dict, owner, typeName),
00095 
00096     idGas_(-1),
00097     idLiquid_(-1),
00098     idSolid_(-1),
00099 
00100     YMixture0_(3)
00101 {
00102     constructIds();
00103 
00104     if (this->phaseProps().size() != 3)
00105     {
00106         FatalErrorIn
00107         (
00108             "Foam::SingleMixtureFraction<CloudType>::"
00109             "SingleMixtureFraction"
00110             "("
00111                 "const dictionary&, "
00112                 "CloudType&"
00113             ")"
00114         )   << "Incorrect numebr of phases: " << nl
00115             << "    Please specify 1 gas, 1 liquid and 1 solid" << nl
00116             << exit(FatalError);
00117     }
00118 
00119     this->coeffDict().lookup("YGasTot0") >> YMixture0_[idGas_];
00120     this->coeffDict().lookup("YLiquidTot0") >> YMixture0_[idLiquid_];
00121     this->coeffDict().lookup("YSolidTot0") >> YMixture0_[idSolid_];
00122 
00123     if (mag(sum(YMixture0_) - 1.0) > SMALL)
00124     {
00125         FatalErrorIn
00126         (
00127             "Foam::SingleMixtureFraction<CloudType>::"
00128             "SingleMixtureFraction"
00129             "("
00130                 "const dictionary&, "
00131                 "CloudType&"
00132             ")"
00133         )   << "Sum of phases should be 1. Phase fractions:" << nl
00134             << YMixture0_ << nl << exit(FatalError);
00135     }
00136 }
00137 
00138 
00139 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00140 
00141 template<class CloudType>
00142 Foam::SingleMixtureFraction<CloudType>::~SingleMixtureFraction()
00143 {}
00144 
00145 
00146 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00147 
00148 template<class CloudType>
00149 const Foam::scalarField&
00150 Foam::SingleMixtureFraction<CloudType>::YGas0() const
00151 {
00152     return this->phaseProps()[idGas_].Y();
00153 }
00154 
00155 
00156 template<class CloudType>
00157 const Foam::scalarField&
00158 Foam::SingleMixtureFraction<CloudType>::YLiquid0() const
00159 {
00160     return this->phaseProps()[idLiquid_].Y();
00161 }
00162 
00163 
00164 template<class CloudType>
00165 const Foam::scalarField&
00166 Foam::SingleMixtureFraction<CloudType>::YSolid0() const
00167 {
00168     return this->phaseProps()[idSolid_].Y();
00169 }
00170 
00171 
00172 template<class CloudType>
00173 const Foam::scalarField&
00174 Foam::SingleMixtureFraction<CloudType>::YMixture0() const
00175 {
00176     return YMixture0_;
00177 }
00178 
00179 
00180 template<class CloudType>
00181 Foam::label Foam::SingleMixtureFraction<CloudType>::idGas() const
00182 {
00183     return idGas_;
00184 }
00185 
00186 
00187 template<class CloudType>
00188 Foam::label Foam::SingleMixtureFraction<CloudType>::idLiquid() const
00189 {
00190     return idLiquid_;
00191 }
00192 
00193 
00194 template<class CloudType>
00195 Foam::label Foam::SingleMixtureFraction<CloudType>::idSolid() const
00196 {
00197     return idSolid_;
00198 }
00199 
00200 
00201 // ************************************************************************* //
00202 
Copyright © 2000-2009 OpenCFD Ltd