Saturated.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2015-2018 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "Saturated.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class Thermo, class OtherThermo>
35 wRatioByP() const
36 {
37  const dimensionedScalar Wi
38  (
39  "W",
41  this->thermo_.composition().W(saturatedIndex_)
42  );
43 
44  return Wi/this->thermo_.W()/this->thermo_.p();
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 template<class Thermo, class OtherThermo>
52 (
53  const dictionary& dict,
54  const phasePair& pair
55 )
56 :
58  saturatedName_(this->speciesNames_[0]),
59  saturatedIndex_
60  (
61  this->thermo_.composition().species()[saturatedName_]
62  ),
63  saturationModel_
64  (
66  (
67  dict.subDict("saturationPressure"),
68  pair.phase1().mesh()
69  )
70  )
71 {
72  if (this->speciesNames_.size() != 1)
73  {
75  << "Saturated model is suitable for one species only."
76  << exit(FatalError);
77  }
78 }
79 
80 
81 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
82 
83 template<class Thermo, class OtherThermo>
85 {}
86 
87 
88 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
89 
90 template<class Thermo, class OtherThermo>
91 void
93 (
94  const volScalarField& Tf
95 )
96 {}
97 
98 
99 template<class Thermo, class OtherThermo>
102 (
103  const word& speciesName,
104  const volScalarField& Tf
105 ) const
106 {
107  if (saturatedName_ == speciesName)
108  {
109  return wRatioByP()*saturationModel_->pSat(Tf);
110  }
111  else
112  {
113  const label speciesIndex
114  (
115  this->thermo_.composition().species()[speciesName]
116  );
117 
118  return
119  this->thermo_.Y()[speciesIndex]
120  *(scalar(1) - wRatioByP()*saturationModel_->pSat(Tf))
121  /max(scalar(1) - this->thermo_.Y()[saturatedIndex_], SMALL);
122  }
123 }
124 
125 
126 template<class Thermo, class OtherThermo>
129 (
130  const word& speciesName,
131  const volScalarField& Tf
132 ) const
133 {
134  if (saturatedName_ == speciesName)
135  {
136  return wRatioByP()*saturationModel_->pSatPrime(Tf);
137  }
138  else
139  {
140  const label speciesIndex
141  (
142  this->thermo_.composition().species()[speciesName]
143  );
144 
145  return
146  - this->thermo_.Y()[speciesIndex]
147  *wRatioByP()*saturationModel_->pSatPrime(Tf)
148  /max(scalar(1) - this->thermo_.Y()[saturatedIndex_], SMALL);
149  }
150 }
151 
152 
153 // ************************************************************************* //
Foam::phasePair
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:53
Foam::InterfaceCompositionModel
Base class for interface composition models, templated on the two thermodynamic models either side of...
Definition: InterfaceCompositionModel.H:58
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::interfaceCompositionModels::Saturated::YfPrime
virtual tmp< volScalarField > YfPrime(const word &speciesName, const volScalarField &Tf) const
The interface species fraction derivative w.r.t. temperature.
Definition: Saturated.C:129
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dimMoles
const dimensionSet dimMoles(0, 0, 0, 0, 1, 0, 0)
Definition: dimensionSets.H:56
Foam::interfaceCompositionModels::Saturated::update
virtual void update(const volScalarField &Tf)
Update the composition.
Definition: Saturated.C:93
Foam::interfaceCompositionModels::Saturated::Saturated
Saturated(const dictionary &dict, const phasePair &pair)
Construct from components.
Definition: Saturated.C:52
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::dimensioned< scalar >
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::interfaceCompositionModels::Saturated::Yf
virtual tmp< volScalarField > Yf(const word &speciesName, const volScalarField &Tf) const
The interface species fraction.
Definition: Saturated.C:102
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Saturated.H
Foam::interfaceCompositionModels::Saturated::wRatioByP
tmp< volScalarField > wRatioByP() const
Constant of proportionality between partial pressure and mass.
Definition: Saturated.C:35
Foam::phasePair::phase1
const phaseModel & phase1() const
Definition: phasePairI.H:30
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::interfaceCompositionModels::Saturated::~Saturated
virtual ~Saturated()
Destructor.
Definition: Saturated.C:84