JohnsonJacksonParticleSlipFvPatchVectorField.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) 2014-2015 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 
26 #include "JohnsonJacksonParticleSlipFvPatchVectorField.H"
28 #include "twoPhaseSystem.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
35  (
37  JohnsonJacksonParticleSlipFvPatchVectorField
38  );
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
46 (
47  const fvPatch& p,
48  const DimensionedField<vector, volMesh>& iF
49 )
50 :
51  partialSlipFvPatchVectorField(p, iF),
52  specularityCoefficient_(p.size())
53 {}
54 
55 
58 (
59  const JohnsonJacksonParticleSlipFvPatchVectorField& ptf,
60  const fvPatch& p,
61  const DimensionedField<vector, volMesh>& iF,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  partialSlipFvPatchVectorField(ptf, p, iF, mapper),
66  specularityCoefficient_(ptf.specularityCoefficient_)
67 {}
68 
69 
72 (
73  const fvPatch& p,
74  const DimensionedField<vector, volMesh>& iF,
75  const dictionary& dict
76 )
77 :
78  partialSlipFvPatchVectorField(p, iF),
79  specularityCoefficient_
80  (
81  "specularityCoefficient",
82  dimless,
83  dict.lookup("specularityCoefficient")
84  )
85 {
86  if
87  (
88  (specularityCoefficient_.value() < 0)
89  || (specularityCoefficient_.value() > 1)
90  )
91  {
93  (
94  "("
95  "Foam::JohnsonJacksonParticleSlipFvPatchVectorField::"
96  "JohnsonJacksonParticleSlipFvPatchVectorField"
97  "const fvPatch& p,"
98  "const DimensionedField<scalar, volMesh>& iF,"
99  "const dictionary& dict"
100  ")"
101  ) << "The specularity coefficient has to be between 0 and 1"
102  << abort(FatalError);
103  }
104 
106  (
107  vectorField("value", dict, p.size())
108  );
109 }
110 
111 
114 (
115  const JohnsonJacksonParticleSlipFvPatchVectorField& ptf
116 )
117 :
118  partialSlipFvPatchVectorField(ptf),
119  specularityCoefficient_(ptf.specularityCoefficient_)
120 {}
121 
122 
125 (
126  const JohnsonJacksonParticleSlipFvPatchVectorField& ptf,
127  const DimensionedField<vector, volMesh>& iF
128 )
129 :
130  partialSlipFvPatchVectorField(ptf, iF),
131  specularityCoefficient_(ptf.specularityCoefficient_)
132 {}
133 
134 
135 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
136 
138 (
139  const fvPatchFieldMapper& m
140 )
141 {
142  partialSlipFvPatchVectorField::autoMap(m);
143 }
144 
145 
147 (
148  const fvPatchVectorField& ptf,
149  const labelList& addr
150 )
151 {
152  partialSlipFvPatchVectorField::rmap(ptf, addr);
153 }
154 
155 
157 {
158  if (updated())
159  {
160  return;
161  }
162 
163  // lookup the fluid model and the phase
164  const twoPhaseSystem& fluid = db().lookupObject<twoPhaseSystem>
165  (
166  "phaseProperties"
167  );
168 
169  const phaseModel& phased
170  (
171  fluid.phase1().name() == dimensionedInternalField().group()
172  ? fluid.phase1()
173  : fluid.phase2()
174  );
175 
176  // lookup all the fields on this patch
178  (
179  patch().lookupPatchField<volScalarField, scalar>
180  (
181  phased.volScalarField::name()
182  )
183  );
184 
185  const fvPatchScalarField& gs0
186  (
187  patch().lookupPatchField<volScalarField, scalar>
188  (
189  IOobject::groupName("gs0", phased.name())
190  )
191  );
192 
193  const scalarField nu
194  (
195  patch().lookupPatchField<volScalarField, scalar>
196  (
197  IOobject::groupName("nut", phased.name())
198  )
199  );
200 
201  word ThetaName(IOobject::groupName("Theta", phased.name()));
202 
203  const fvPatchScalarField& Theta
204  (
205  db().foundObject<volScalarField>(ThetaName)
206  ? patch().lookupPatchField<volScalarField, scalar>(ThetaName)
207  : alpha
208  );
209 
210  // lookup the packed volume fraction
212  (
213  "alphaMax",
214  dimless,
215  db()
216  .lookupObject<IOdictionary>
217  (
218  IOobject::groupName("turbulenceProperties", phased.name())
219  )
220  .subDict("RAS")
221  .subDict("kineticTheoryCoeffs")
222  .lookup("alphaMax")
223  );
224 
225  // calculate the slip value fraction
226  scalarField c
227  (
229  *alpha
230  *gs0
231  *specularityCoefficient_.value()
232  *sqrt(3.0*Theta)
233  /max(6.0*nu*alphaMax.value(), SMALL)
234  );
235 
236  this->valueFraction() = c/(c + patch().deltaCoeffs());
237 
238  partialSlipFvPatchVectorField::updateCoeffs();
239 }
240 
241 
243 (
244  Ostream& os
245 ) const
246 {
248  os.writeKeyword("specularityCoefficient")
249  << specularityCoefficient_ << token::END_STATEMENT << nl;
250  writeEntry("value", os);
251 }
252 
253 
254 // ************************************************************************* //
dimensionedScalar sqrt(const dimensionedScalar &ds)
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
static word groupName(Name name, const word &group)
static const char nl
Definition: Ostream.H:260
stressControl lookup("compactNormalStress") >> compactNormalStress
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
Macros for easy insertion into run-time selection tables.
virtual void write(Ostream &) const
Write.
fvPatchField< scalar > fvPatchScalarField
errorManip< error > abort(error &err)
Definition: errorManip.H:131
dimensionedScalar alphaMax(laminarTransport.lookup("alphaMax"))
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
JohnsonJacksonParticleSlipFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
rDeltaT dimensionedInternalField()
error FatalError
List< label > labelList
A List of labels.
Definition: labelList.H:56
const dimensionedScalar c
Speed of light in a vacuum.
volScalarField & nu
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
fvPatchField< vector > fvPatchVectorField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
const Type & value() const
Return const reference to value.