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-2020 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"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace compressible
36 {
37 
38 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(alphatPhaseChangeWallFunctionFvPatchScalarField, 0);
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
46 (
47  const fvPatch& p,
48  const DimensionedField<scalar, volMesh>& iF
49 )
50 :
51  alphatPhaseJayatillekeWallFunctionFvPatchScalarField(p, iF),
52  otherPhaseName_(word::null),
53  relax_(1),
54  dmdtf_(p.size(), 0),
55  dmdtLf_(p.size(), 0)
56 {}
57 
58 
61 (
62  const fvPatch& p,
63  const DimensionedField<scalar, volMesh>& iF,
64  const dictionary& dict
65 )
66 :
68  otherPhaseName_(dict.lookup("otherPhase")),
69  relax_(dict.lookupOrDefault<scalar>("relax", 1)),
70  dmdtf_(p.size(), 0),
71  dmdtLf_(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  if (dict.found("dmdtLf"))
90  {
91  dmdtLf_ = scalarField("dmdtLf", dict, p.size());
92  }
93 }
94 
95 
98 (
100  const fvPatch& p,
101  const DimensionedField<scalar, volMesh>& iF,
102  const fvPatchFieldMapper& mapper
103 )
104 :
107  relax_(ptf.relax_),
108  dmdtf_(mapper(ptf.dmdtf_)),
109  dmdtLf_(mapper(ptf.dmdtLf_))
110 {}
111 
112 
115 (
117 )
118 :
121  relax_(awfpsf.relax_),
122  dmdtf_(awfpsf.dmdtf_),
123  dmdtLf_(awfpsf.dmdtLf_)
124 {}
125 
126 
129 (
131  const DimensionedField<scalar, volMesh>& iF
132 )
133 :
136  relax_(awfpsf.relax_),
137  dmdtf_(awfpsf.dmdtf_),
138  dmdtLf_(awfpsf.dmdtLf_)
139 {}
140 
141 
142 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
143 
145 activePhasePair(const phasePairKey& phasePair) const
146 {
147  if (phasePair == phasePairKey(otherPhaseName_, internalField().group()))
148  {
149  return true;
150  }
151  else
152  {
153  return false;
154  }
155 }
156 
157 
158 const scalarField&
160 {
161  return dmdtf_;
162 }
163 
164 
166 dmdtf(const phasePairKey& phasePair) const
167 {
168  if (activePhasePair(phasePair))
169  {
170  return dmdtf_;
171  }
172  else
173  {
175  << " dmdtf requested for invalid phasePair!"
176  << abort(FatalError);
177 
178  return dmdtLf_;
179  }
180 }
181 
182 
183 const scalarField&
185 {
186  return dmdtLf_;
187 }
188 
189 
191 dmdtLf(const phasePairKey& phasePair) const
192 {
193  if (activePhasePair(phasePair))
194  {
195  return dmdtLf_;
196  }
197  else
198  {
200  << " dmdtLf requested for invalid phasePair!"
201  << abort(FatalError);
202 
203  return dmdtLf_;
204  }
205 }
206 
207 
209 (
210  const fvPatchFieldMapper& m
211 )
212 {
213  alphatPhaseJayatillekeWallFunctionFvPatchScalarField::autoMap(m);
214 
215  m(dmdtf_, dmdtf_);
216  m(dmdtLf_, dmdtLf_);
217 }
218 
219 
221 (
222  const fvPatchScalarField& ptf,
223  const labelList& addr
224 )
225 {
226  alphatPhaseJayatillekeWallFunctionFvPatchScalarField::rmap(ptf, addr);
227 
229  refCast<const alphatPhaseChangeWallFunctionFvPatchScalarField>(ptf);
230 
231  dmdtf_.rmap(tiptf.dmdtf_, addr);
232  dmdtLf_.rmap(tiptf.dmdtLf_, addr);
233 }
234 
235 
237 {
239 
240  writeEntry(os, "otherPhase", otherPhaseName_);
241  writeEntry(os, "relax", relax_);
242  writeEntry(os, "dmdtf", dmdtf_);
243  writeEntry(os, "dmdtLf", dmdtLf_);
244 }
245 
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 } // End namespace compressible
250 } // End namespace Foam
251 
252 // ************************************************************************* //
const char *const group
Group name for atomic constants.
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
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.
const scalarField & dmdtLf() const
Return the enthalpy source due to phase-change.
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:381
alphatPhaseJayatillekeWallFunctionFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
bool activePhasePair(const phasePairKey &) const
Is there phase change mass transfer for this phasePair.
const scalarField & dmdtf() const
Return the rate of phase-change.
Namespace for OpenFOAM.