smoluchowskiJumpTFvPatchScalarField.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) 2011-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 
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "basicThermo.H"
31 #include "mathematicalConstants.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const fvPatch& p,
38  const DimensionedField<scalar, volMesh>& iF
39 )
40 :
41  mixedFvPatchScalarField(p, iF),
42  UName_("U"),
43  rhoName_("rho"),
44  psiName_("thermo:psi"),
45  muName_("thermo:mu"),
46  accommodationCoeff_(1.0),
47  Twall_(p.size(), 0.0),
48  gamma_(1.4)
49 {
50  refValue() = 0.0;
51  refGrad() = 0.0;
52  valueFraction() = 0.0;
53 }
54 
55 
57 (
58  const fvPatch& p,
59  const DimensionedField<scalar, volMesh>& iF,
60  const dictionary& dict
61 )
62 :
63  mixedFvPatchScalarField(p, iF),
64  UName_(dict.lookupOrDefault<word>("U", "U")),
65  rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
66  psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
67  muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")),
68  accommodationCoeff_(dict.lookup<scalar>("accommodationCoeff")),
69  Twall_("Twall", dict, p.size()),
70  gamma_(dict.lookupOrDefault<scalar>("gamma", 1.4))
71 {
72  if
73  (
74  mag(accommodationCoeff_) < small
75  || mag(accommodationCoeff_) > 2.0
76  )
77  {
79  (
80  dict
81  ) << "unphysical accommodationCoeff specified"
82  << "(0 < accommodationCoeff <= 1)" << endl
83  << exit(FatalIOError);
84  }
85 
86  if (dict.found("value"))
87  {
89  (
90  scalarField("value", dict, p.size())
91  );
92  }
93  else
94  {
95  fvPatchField<scalar>::operator=(patchInternalField());
96  }
97 
98  refValue() = *this;
99  refGrad() = 0.0;
100  valueFraction() = 0.0;
101 }
102 
103 
105 (
106  const smoluchowskiJumpTFvPatchScalarField& ptf,
107  const fvPatch& p,
108  const DimensionedField<scalar, volMesh>& iF,
109  const fvPatchFieldMapper& mapper
110 )
111 :
112  mixedFvPatchScalarField(ptf, p, iF, mapper),
113  UName_(ptf.UName_),
114  rhoName_(ptf.rhoName_),
115  psiName_(ptf.psiName_),
116  muName_(ptf.muName_),
117  accommodationCoeff_(ptf.accommodationCoeff_),
118  Twall_(mapper(ptf.Twall_)),
119  gamma_(ptf.gamma_)
120 {}
121 
122 
124 (
125  const smoluchowskiJumpTFvPatchScalarField& ptpsf,
126  const DimensionedField<scalar, volMesh>& iF
127 )
128 :
129  mixedFvPatchScalarField(ptpsf, iF),
130  accommodationCoeff_(ptpsf.accommodationCoeff_),
131  Twall_(ptpsf.Twall_),
132  gamma_(ptpsf.gamma_)
133 {}
134 
135 
136 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
137 
139 (
140  const fvPatchFieldMapper& m
141 )
142 {
143  mixedFvPatchScalarField::autoMap(m);
144  m(Twall_, Twall_);
145 }
146 
147 
149 (
150  const fvPatchField<scalar>& ptf,
151  const labelList& addr
152 )
153 {
155 
156  const smoluchowskiJumpTFvPatchScalarField& ptpsf =
157  refCast<const smoluchowskiJumpTFvPatchScalarField>(ptf);
158 
159  Twall_.rmap(ptpsf.Twall_, addr);
160 }
161 
162 
164 (
165  const fvPatchField<scalar>& ptf
166 )
167 {
169 
170  const smoluchowskiJumpTFvPatchScalarField& ptpsf =
171  refCast<const smoluchowskiJumpTFvPatchScalarField>(ptf);
172 
173  Twall_.reset(ptpsf.Twall_);
174 }
175 
176 
178 {
179  if (updated())
180  {
181  return;
182  }
183 
184  const fvPatchScalarField& pmu =
185  patch().lookupPatchField<volScalarField, scalar>(muName_);
186  const fvPatchScalarField& prho =
187  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
188  const fvPatchField<scalar>& ppsi =
189  patch().lookupPatchField<volScalarField, scalar>(psiName_);
190  const fvPatchVectorField& pU =
191  patch().lookupPatchField<volVectorField, vector>(UName_);
192 
193  // Prandtl number reading consistent with rhoCentralFoam
194  const dictionary& thermophysicalProperties =
195  db().lookupObject<IOdictionary>(physicalProperties::typeName);
196 
198  (
199  "Pr",
200  dimless,
201  thermophysicalProperties.subDict("mixture").subDict("transport")
202  .lookup("Pr")
203  );
204 
205  Field<scalar> C2
206  (
207  pmu/prho
209  *2.0*gamma_/Pr.value()/(gamma_ + 1.0)
210  *(2.0 - accommodationCoeff_)/accommodationCoeff_
211  );
212 
213  Field<scalar> aCoeff(prho.snGrad() - prho/C2);
214  Field<scalar> KEbyRho(0.5*magSqr(pU));
215 
216  valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C2));
217  refValue() = Twall_;
218  refGrad() = 0.0;
219 
220  mixedFvPatchScalarField::updateCoeffs();
221 }
222 
223 
225 {
227 
228  writeEntryIfDifferent<word>(os, "U", "U", UName_);
229  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
230  writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
231  writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_);
232 
233  writeEntry(os, "accommodationCoeff", accommodationCoeff_);
234  writeEntry(os, "Twall", Twall_);
235  writeEntry(os, "gamma", gamma_);
236  writeEntry(os, "value", *this);
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 namespace Foam
243 {
245  (
247  smoluchowskiJumpTFvPatchScalarField
248  );
249 }
250 
251 
252 // ************************************************************************* //
virtual void write(Ostream &) const
Write.
fvPatchField< vector > fvPatchVectorField
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
const dimensionSet dimless
virtual void rmap(const fvPatchScalarField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
virtual void reset(const fvPatchScalarField &)
Reset the fvPatchField to the given fvPatchField.
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:59
Macros for easy insertion into run-time selection tables.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:58
stressControl lookup("compactNormalStress") >> compactNormalStress
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
fvPatchField< scalar > fvPatchScalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Type & value() const
Return const reference to value.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
List< label > labelList
A List of labels.
Definition: labelList.H:56
dimensioned< scalar > magSqr(const dimensioned< Type > &)
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
smoluchowskiJumpTFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:258
dimensioned< scalar > mag(const dimensioned< Type > &)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const scalar piByTwo(0.5 *pi)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
IOerror FatalIOError