Henry.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 "Henry.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Thermo, class OtherThermo>
34 (
35  const dictionary& dict,
36  const phasePair& pair
37 )
38 :
39  InterfaceCompositionModel<Thermo, OtherThermo>(dict, pair),
40  k_(dict.lookup("k")),
41  YSolvent_
42  (
43  IOobject
44  (
45  IOobject::groupName("YSolvent", pair.name()),
46  pair.phase1().mesh().time().timeName(),
47  pair.phase1().mesh()
48  ),
49  pair.phase1().mesh(),
50  dimensionedScalar("one", dimless, 1)
51  )
52 {
53  if (k_.size() != this->speciesNames_.size())
54  {
56  << "Differing number of species and solubilities"
57  << exit(FatalError);
58  }
59 }
60 
61 
62 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
63 
64 template<class Thermo, class OtherThermo>
66 (
67  const volScalarField& Tf
68 )
69 {
70  YSolvent_ = scalar(1);
71 
72  for (const word& speciesName : this->speciesNames_)
73  {
74  YSolvent_ -= Yf(speciesName, Tf);
75  }
76 }
77 
78 
79 template<class Thermo, class OtherThermo>
82 (
83  const word& speciesName,
84  const volScalarField& Tf
85 ) const
86 {
87  const label index = this->speciesNames_.find(speciesName);
88 
89  if (index >= 0)
90  {
91  return
92  k_[index]
93  *this->otherThermo_.composition().Y(speciesName)
94  *this->otherThermo_.rhoThermo::rho()
95  /this->thermo_.rhoThermo::rho();
96  }
97  else
98  {
99  return
100  YSolvent_
101  *this->thermo_.composition().Y(speciesName);
102  }
103 }
104 
105 
106 template<class Thermo, class OtherThermo>
109 (
110  const word& speciesName,
111  const volScalarField& Tf
112 ) const
113 {
114  return volScalarField::New
115  (
116  IOobject::groupName("YfPrime", this->pair_.name()),
117  this->pair_.phase1().mesh(),
119  );
120 }
121 
122 
123 // ************************************************************************* //
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Base class for interface composition models, templated on the two thermodynamic models either side of...
const dimensionSet dimless
Dimensionless.
Lookup type of boundary radiation properties.
Definition: lookup.H:57
virtual tmp< volScalarField > Yf(const word &speciesName, const volScalarField &Tf) const
The interface species fraction.
Definition: Henry.C:75
word timeName
Definition: getTimeIndex.H:3
static word groupName(StringType base, const word &group)
Create dot-delimited name.group string.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
const dimensionSet dimTemperature(0, 0, 0, 1, 0, 0, 0)
Definition: dimensionSets.H:52
Henry(const dictionary &dict, const phasePair &pair)
Construct from components.
Definition: Henry.C:27
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
phaseModel & phase1
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
virtual void update(const volScalarField &Tf)
Update the composition.
Definition: Henry.C:59
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual tmp< volScalarField > YfPrime(const word &speciesName, const volScalarField &Tf) const
The interface species fraction derivative w.r.t. temperature.
Definition: Henry.C:102
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Description for mass transfer between a pair of phases. The direction of the mass transfer is from th...
Definition: phasePair.H:49