FreeFOAM The Cross-Platform CFD Toolkit
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) 1991-2010 OpenCFD Ltd.
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
32 #include <finiteVolume/volFields.H>
34 #include <finiteVolume/fvCFD.H>
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const fvPatch& p,
47 )
48 :
49  mixedFixedValueSlipFvPatchVectorField(p, iF),
50  accommodationCoeff_(1.0),
51  Uwall_(p.size(), vector(0.0, 0.0, 0.0)),
52  thermalCreep_(true),
53  curvature_(true)
54 {}
55 
56 
58 (
59  const maxwellSlipUFvPatchVectorField& tdpvf,
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  mixedFixedValueSlipFvPatchVectorField(tdpvf, p, iF, mapper),
66  accommodationCoeff_(tdpvf.accommodationCoeff_),
67  Uwall_(tdpvf.Uwall_),
68  thermalCreep_(tdpvf.thermalCreep_),
69  curvature_(tdpvf.curvature_)
70 {}
71 
72 
74 (
75  const fvPatch& p,
77  const dictionary& dict
78 )
79 :
80  mixedFixedValueSlipFvPatchVectorField(p, iF),
81  accommodationCoeff_(readScalar(dict.lookup("accommodationCoeff"))),
82  Uwall_("Uwall", dict, p.size()),
83  thermalCreep_(dict.lookupOrDefault("thermalCreep", true)),
84  curvature_(dict.lookupOrDefault("curvature", true))
85 {
86  if
87  (
88  mag(accommodationCoeff_) < SMALL
89  ||
90  mag(accommodationCoeff_) > 2.0
91  )
92  {
94  (
95  "maxwellSlipUFvPatchScalarField::"
96  "maxwellSlipUFvPatchScalarField"
97  "(const fvPatch&, const scalarField&, const dictionary&)",
98  dict
99  ) << "unphysical accommodationCoeff_ specified"
100  << "(0 < accommodationCoeff_ <= 1)" << endl
101  << exit(FatalError);
102  }
103 
104  if (dict.found("value"))
105  {
107  (
108  vectorField("value", dict, p.size())
109  );
110  refValue() = vectorField("refValue", dict, p.size());
111  valueFraction() = scalarField("valueFraction", dict, p.size());
112  }
113  else
114  {
115  mixedFixedValueSlipFvPatchVectorField::evaluate();
116  }
117 }
118 
119 
121 (
122  const maxwellSlipUFvPatchVectorField& tdpvf,
124 )
125 :
126  mixedFixedValueSlipFvPatchVectorField(tdpvf, iF),
127  accommodationCoeff_(tdpvf.accommodationCoeff_),
128  Uwall_(tdpvf.Uwall_),
129  thermalCreep_(tdpvf.thermalCreep_),
130  curvature_(tdpvf.curvature_)
131 {}
132 
133 
134 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 
136 // Update the coefficients associated with the patch field
138 {
139  if (updated())
140  {
141  return;
142  }
143 
144  const fvPatchScalarField& pmu =
145  patch().lookupPatchField<volScalarField, scalar>("mu");
146  const fvPatchScalarField& prho =
147  patch().lookupPatchField<volScalarField, scalar>("rho");
148  const fvPatchField<scalar>& ppsi =
149  patch().lookupPatchField<volScalarField, scalar>("psi");
150 
152  *(2.0 - accommodationCoeff_)/accommodationCoeff_;
153 
154  Field<scalar> pnu = pmu/prho;
155  valueFraction() = (1.0/(1.0 + patch().deltaCoeffs()*C1*pnu));
156 
157  refValue() = Uwall_;
158 
159  if(thermalCreep_)
160  {
161  const volScalarField& vsfT =
162  this->db().objectRegistry::lookupObject<volScalarField>("T");
163  label patchi = this->patch().index();
164  const fvPatchScalarField& pT = vsfT.boundaryField()[patchi];
165  Field<vector> gradpT = fvc::grad(vsfT)().boundaryField()[patchi];
166  vectorField n = patch().nf();
167 
168  refValue() -= 3.0*pnu/(4.0*pT)*transform(I - n*n, gradpT);
169  }
170 
171  if(curvature_)
172  {
173  const fvPatchTensorField& ptauMC =
174  patch().lookupPatchField<volTensorField, tensor>("tauMC");
175  vectorField n = patch().nf();
176 
177  refValue() -= C1/prho*transform(I - n*n, (n & ptauMC));
178  }
179 
181 }
182 
183 
184 // Write
186 {
188  os.writeKeyword("accommodationCoeff")
189  << accommodationCoeff_ << token::END_STATEMENT << nl;
190  Uwall_.writeEntry("Uwall", os);
191  os.writeKeyword("thermalCreep")
192  << thermalCreep_ << token::END_STATEMENT << nl;
193  os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl;
194 
195  refValue().writeEntry("refValue", os);
196  valueFraction().writeEntry("valueFraction", os);
197 
198  writeEntry("value", os);
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // ************************ vim: set sw=4 sts=4 et: ************************ //