maxwellSlipUFvPatchVectorField.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 | Copyright (C) 2011-2012 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 "mathematicalConstants.H"
29 #include "fvPatchFieldMapper.H"
30 #include "volFields.H"
31 #include "fvcGrad.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
36 (
37  const fvPatch& p,
38  const DimensionedField<vector, volMesh>& iF
39 )
40 :
41  mixedFixedValueSlipFvPatchVectorField(p, iF),
42  TName_("T"),
43  rhoName_("rho"),
44  psiName_("thermo:psi"),
45  muName_("thermo:mu"),
46  tauMCName_("tauMC"),
47  accommodationCoeff_(1.0),
48  Uwall_(p.size(), vector(0.0, 0.0, 0.0)),
49  thermalCreep_(true),
50  curvature_(true)
51 {}
52 
53 
55 (
56  const maxwellSlipUFvPatchVectorField& mspvf,
57  const fvPatch& p,
58  const DimensionedField<vector, volMesh>& iF,
59  const fvPatchFieldMapper& mapper
60 )
61 :
62  mixedFixedValueSlipFvPatchVectorField(mspvf, p, iF, mapper),
63  TName_(mspvf.TName_),
64  rhoName_(mspvf.rhoName_),
65  psiName_(mspvf.psiName_),
66  muName_(mspvf.muName_),
67  tauMCName_(mspvf.tauMCName_),
68  accommodationCoeff_(mspvf.accommodationCoeff_),
69  Uwall_(mspvf.Uwall_),
70  thermalCreep_(mspvf.thermalCreep_),
71  curvature_(mspvf.curvature_)
72 {}
73 
74 
76 (
77  const fvPatch& p,
78  const DimensionedField<vector, volMesh>& iF,
79  const dictionary& dict
80 )
81 :
82  mixedFixedValueSlipFvPatchVectorField(p, iF),
83  TName_(dict.lookupOrDefault<word>("T", "T")),
84  rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
85  psiName_(dict.lookupOrDefault<word>("psi", "thermo:psi")),
86  muName_(dict.lookupOrDefault<word>("mu", "thermo:mu")),
87  tauMCName_(dict.lookupOrDefault<word>("tauMC", "tauMC")),
88  accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
89  Uwall_("Uwall", dict, p.size()),
90  thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
91  curvature_(dict.lookupOrDefault("curvature", true))
92 {
93  if
94  (
95  mag(accommodationCoeff_) < SMALL
96  || mag(accommodationCoeff_) > 2.0
97  )
98  {
100  (
101  "maxwellSlipUFvPatchScalarField::maxwellSlipUFvPatchScalarField"
102  "("
103  "const fvPatch&, "
104  "const DimensionedField<vector, volMesh>&, "
105  "const dictionary&"
106  ")",
107  dict
108  ) << "unphysical accommodationCoeff_ specified"
109  << "(0 < accommodationCoeff_ <= 1)" << endl
110  << exit(FatalIOError);
111  }
112 
113  if (dict.found("value"))
114  {
116  (
117  vectorField("value", dict, p.size())
118  );
119 
120  if (dict.found("refValue") && dict.found("valueFraction"))
121  {
122  this->refValue() = vectorField("refValue", dict, p.size());
123  this->valueFraction() =
124  scalarField("valueFraction", dict, p.size());
125  }
126  else
127  {
128  this->refValue() = *this;
129  this->valueFraction() = scalar(1.0);
130  }
131  }
132 }
133 
134 
136 (
137  const maxwellSlipUFvPatchVectorField& mspvf,
138  const DimensionedField<vector, volMesh>& iF
139 )
140 :
141  mixedFixedValueSlipFvPatchVectorField(mspvf, iF),
142  TName_(mspvf.TName_),
143  rhoName_(mspvf.rhoName_),
144  psiName_(mspvf.psiName_),
145  muName_(mspvf.muName_),
146  tauMCName_(mspvf.tauMCName_),
147  accommodationCoeff_(mspvf.accommodationCoeff_),
148  Uwall_(mspvf.Uwall_),
149  thermalCreep_(mspvf.thermalCreep_),
150  curvature_(mspvf.curvature_)
151 {}
152 
153 
154 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
155 
157 {
158  if (updated())
159  {
160  return;
161  }
162 
163  const fvPatchScalarField& pmu =
164  patch().lookupPatchField<volScalarField, scalar>(muName_);
165  const fvPatchScalarField& prho =
166  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
167  const fvPatchField<scalar>& ppsi =
168  patch().lookupPatchField<volScalarField, scalar>(psiName_);
169 
170  Field<scalar> C1
171  (
172  sqrt(ppsi*constant::mathematical::piByTwo)
173  * (2.0 - accommodationCoeff_)/accommodationCoeff_
174  );
175 
176  Field<scalar> pnu(pmu/prho);
177  valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));
178 
179  refValue() = Uwall_;
180 
181  if (thermalCreep_)
182  {
183  const volScalarField& vsfT =
184  this->db().objectRegistry::lookupObject<volScalarField>(TName_);
185  label patchi = this->patch().index();
186  const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
187  Field<vector> gradpT(fvc::grad(vsfT)().boundaryField()[patchi]);
188  vectorField n(patch().nf());
189 
190  refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
191  }
192 
193  if (curvature_)
194  {
195  const fvPatchTensorField& ptauMC =
196  patch().lookupPatchField<volTensorField, tensor>(tauMCName_);
197  vectorField n(patch().nf());
198 
199  refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
200  }
201 
202  mixedFixedValueSlipFvPatchVectorField::updateCoeffs();
203 }
204 
205 
206 void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const
207 {
209  writeEntryIfDifferent<word>(os, "T", "T", TName_);
210  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
211  writeEntryIfDifferent<word>(os, "psi", "thermo:psi", psiName_);
212  writeEntryIfDifferent<word>(os, "mu", "thermo:mu", muName_);
213  writeEntryIfDifferent<word>(os, "tauMC", "tauMC", tauMCName_);
214 
215  os.writeKeyword("accommodationCoeff")
216  << accommodationCoeff_ << token::END_STATEMENT << nl;
217  Uwall_.writeEntry("Uwall", os);
218  os.writeKeyword("thermalCreep")
219  << thermalCreep_ << token::END_STATEMENT << nl;
220  os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
221 
222  refValue().writeEntry("refValue", os);
223  valueFraction().writeEntry("valueFraction", os);
224 
225  writeEntry("value", os);
226 }
227 
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 namespace Foam
232 {
234  (
236  maxwellSlipUFvPatchVectorField
237  );
238 }
239 
240 // ************************************************************************* //
dimensionedScalar sqrt(const dimensionedScalar &ds)
GeometricField< tensor, fvPatchField, volMesh > volTensorField
Definition: volFieldsFwd.H:59
fvPatchField< tensor > fvPatchTensorField
dimensioned< scalar > mag(const dimensioned< Type > &)
Tensor< scalar > tensor
Tensor of scalars.
Definition: tensor.H:51
static const sphericalTensor I(1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
maxwellSlipUFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Calculate the gradient of the given field.
label n
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
stressControl lookup("compactNormalStress") >> compactNormalStress
IOerror FatalIOError
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Field< vector > vectorField
Specialisation of Field<T> for vector.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
Definition: doubleScalar.H:63
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
label patchi
Macros for easy insertion into run-time selection tables.
fvPatchField< scalar > fvPatchScalarField
virtual void write(Ostream &) const
Write.
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
fvPatchField< vector > fvPatchVectorField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
#define FatalIOErrorIn(functionName, ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:325
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)