alphatPhaseChangeWallFunctionFvPatchScalarField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2022 OpenFOAM Foundation
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 
27 #include "fvPatchFieldMapper.H"
28 #include "volFields.H"
29 #include "phaseInterface.H"
30 #include "phaseSystem.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace compressible
38 {
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 defineTypeNameAndDebug(alphatPhaseChangeWallFunctionFvPatchScalarField, 0);
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
48 (
49  const fvPatch& p,
50  const DimensionedField<scalar, volMesh>& iF
51 )
52 :
53  alphatPhaseJayatillekeWallFunctionFvPatchScalarField(p, iF),
54  otherPhaseName_(word::null),
55  relax_(1),
56  dmdtf_(p.size(), 0)
57 {}
58 
59 
62 (
63  const fvPatch& p,
64  const DimensionedField<scalar, volMesh>& iF,
65  const dictionary& dict
66 )
67 :
69  otherPhaseName_(dict.lookup("otherPhase")),
70  relax_(dict.lookupOrDefault<scalar>("relax", 1)),
71  dmdtf_(p.size(), 0)
72 {
73  // Check that otherPhaseName != this phase
74  if (internalField().group() == otherPhaseName_)
75  {
77  << "otherPhase should be the name of the vapor phase that "
78  << "corresponds to the liquid base or vice versa" << nl
79  << "This phase: " << internalField().group() << nl
80  << "otherPhase: " << otherPhaseName_
81  << abort(FatalError);
82  }
83 
84  if (dict.found("dmdtf"))
85  {
86  dmdtf_ = scalarField("dmdtf", dict, p.size());
87  }
88 }
89 
90 
93 (
95  const fvPatch& p,
96  const DimensionedField<scalar, volMesh>& iF,
97  const fvPatchFieldMapper& mapper
98 )
99 :
102  relax_(ptf.relax_),
103  dmdtf_(mapper(ptf.dmdtf_))
104 {}
105 
106 
109 (
111  const DimensionedField<scalar, volMesh>& iF
112 )
113 :
116  relax_(awfpsf.relax_),
117  dmdtf_(awfpsf.dmdtf_)
118 {}
119 
120 
121 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
122 
124 activeInterface(const phaseInterface& interface) const
125 {
126  const phaseSystem& fluid = interface.fluid();
127 
128  if
129  (
130  interface.contains(fluid.phases()[internalField().group()])
131  && interface.contains(fluid.phases()[otherPhaseName_])
132  )
133  {
134  return true;
135  }
136  else
137  {
138  return false;
139  }
140 }
141 
142 
143 const scalarField&
145 {
146  return dmdtf_;
147 }
148 
149 
151 dmdtf(const phaseInterface& interface) const
152 {
153  if (activeInterface(interface))
154  {
155  return dmdtf_;
156  }
157  else
158  {
160  << "Phase change mass transfer rate requested for interface on "
161  << "which there is no phase change "
162  << abort(FatalError);
163 
164  return dmdtf_;
165  }
166 }
167 
168 
170 (
171  const fvPatchFieldMapper& m
172 )
173 {
174  alphatPhaseJayatillekeWallFunctionFvPatchScalarField::autoMap(m);
175 
176  m(dmdtf_, dmdtf_);
177 }
178 
179 
181 (
182  const fvPatchScalarField& ptf,
183  const labelList& addr
184 )
185 {
186  alphatPhaseJayatillekeWallFunctionFvPatchScalarField::rmap(ptf, addr);
187 
189  refCast<const alphatPhaseChangeWallFunctionFvPatchScalarField>(ptf);
190 
191  dmdtf_.rmap(tiptf.dmdtf_, addr);
192 }
193 
194 
196 (
197  const fvPatchScalarField& ptf
198 )
199 {
200  alphatPhaseJayatillekeWallFunctionFvPatchScalarField::reset(ptf);
201 
203  refCast<const alphatPhaseChangeWallFunctionFvPatchScalarField>(ptf);
204 
205  dmdtf_.reset(tiptf.dmdtf_);
206 }
207 
208 
210 {
212 
213  writeEntry(os, "otherPhase", otherPhaseName_);
214  writeEntry(os, "relax", relax_);
215  writeEntry(os, "dmdtf", dmdtf_);
216 }
217 
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 } // End namespace compressible
222 } // End namespace Foam
223 
224 // ************************************************************************* //
const char *const group
Group name for atomic constants.
virtual void reset(const fvPatchScalarField &)
Reset the fvPatchField to the given fvPatchField.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Macros for easy insertion into run-time selection tables.
stressControl lookup("compactNormalStress") >> compactNormalStress
fvPatchField< scalar > fvPatchScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
Definition: labelList.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
alphatPhaseChangeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
void rmap(const UList< Type > &mapF, const labelUList &mapAddressing)
1 to 1 reverse-map from the given field
Definition: Field.C:362
alphatPhaseJayatillekeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
bool activeInterface(const phaseInterface &) const
Is there phase change mass transfer for this interface?
const scalarField & dmdtf() const
Return the rate of phase-change.
void reset(const Field< Type > &)
Reset the field values to the given field.
Definition: Field.C:432
Namespace for OpenFOAM.