ibSwirlFlowRateInletVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | foam-extend: Open Source CFD
4  \\ / O peration | Version: 3.2
5  \\ / A nd | Web: http://www.foam-extend.org
6  \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9  This file is part of foam-extend.
10 
11  foam-extend is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation, either version 3 of the License, or (at your
14  option) any later version.
15 
16  foam-extend is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "volFields.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
31 #include "mathematicalConstants.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 Foam::
38 (
39  const fvPatch& p,
41 )
42 :
44  flowRate_(0),
45  phiName_("phi"),
46  rhoName_("rho"),
47  rpm_(0)
48 {
49  calcGeom();
50 }
51 
52 
53 Foam::
56 (
58  const fvPatch& p,
60  const fvPatchFieldMapper& mapper
61 )
62 :
63  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
64  flowRate_(ptf.flowRate_),
65  phiName_(ptf.phiName_),
66  rhoName_(ptf.rhoName_),
67  rpm_(ptf.rpm_)
68 {
69  calcGeom();
70 }
71 
72 
73 Foam::
76 (
77  const fvPatch& p,
79  const dictionary& dict
80 )
81 :
83  flowRate_(readScalar(dict.lookup("flowRate"))),
84  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
85  rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
86  rpm_(readScalar(dict.lookup("rpm")))
87 {
88  calcGeom();
89 }
90 
91 
92 Foam::
95 (
97 )
98 :
100  flowRate_(ptf.flowRate_),
101  phiName_(ptf.phiName_),
102  rhoName_(ptf.rhoName_),
103  rpm_(ptf.rpm_)
104 {
105  calcGeom();
106 }
107 
108 
109 Foam::
112 (
115 )
116 :
118  flowRate_(ptf.flowRate_),
119  phiName_(ptf.phiName_),
120  rhoName_(ptf.rhoName_),
121  rpm_(ptf.rpm_)
122 {
123  calcGeom();
124 }
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
130 {
131  // Lookup cellIbMask
132  const fvPatchScalarField& patchCellIbMask =
133  lookupPatchField<volScalarField, scalar>("cellIbMask");
134 
135  scalarField faceMask = patchCellIbMask.patchInternalField();
136 
137  totArea_ = gSum(faceMask*patch().magSf());
138  avgCenter_ = gSum(faceMask*patch().Cf()*patch().magSf())/totArea_;
139  avgNormal_ = gSum(faceMask*patch().Sf())/totArea_;
140 }
141 
142 
144 {
145  if (updated())
146  {
147  return;
148  }
149 
150  const scalar avgU = -flowRate_/totArea_;
151 
152  // Update angular velocity - convert [rpm] to [rad/s]
153  vectorField tangentialVelocity =
154  (rpm_*mathematicalConstant::pi/30.0)
155  * ((patch().Cf() - avgCenter_) ^ avgNormal_);
156 
157  vectorField n = patch().nf();
158 
159  vectorField& U = *this;
160 
161  const surfaceScalarField& phi =
162  db().lookupObject<surfaceScalarField>(phiName_);
163 
164  // Lookup cellIbMask
165  const fvPatchScalarField& patchCellIbMask =
166  lookupPatchField<volScalarField, scalar>("cellIbMask");
167 
168  scalarField faceMask = patchCellIbMask.patchInternalField();
169 
170  if (phi.dimensions() == dimVelocity*dimArea)
171  {
172  // Volumetric flow-rate
173  U = faceMask*(tangentialVelocity + n*avgU);
174  }
175  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
176  {
177  const fvPatchField<scalar>& rhop =
178  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
179 
180  // Mass flow-rate
181  U = faceMask*(tangentialVelocity + n*avgU/rhop);
182  }
183  else
184  {
186  (
187  "ibSwirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()"
188  ) << "dimensions of " << phiName_ << " are incorrect" << nl
189  << " on patch " << this->patch().name()
190  << " of field " << this->dimensionedInternalField().name()
191  << " in file " << this->dimensionedInternalField().objectPath()
192  << nl << exit(FatalError);
193  }
194 
196 }
197 
198 
200 (
201  Ostream& os
202 ) const
203 {
205  os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
206  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
207  writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
208  os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl;
209  writeEntry("value", os);
210 }
211 
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 namespace Foam
216 {
218  (
221  );
222 }
223 
224 
225 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
mathematicalConstants.H
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dimVelocity
const dimensionSet dimVelocity
Foam::dimDensity
const dimensionSet dimDensity
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::ibSwirlFlowRateInletVelocityFvPatchVectorField
ibSwirlFlowRateInletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.C:38
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::totArea_
scalar totArea_
Total area of inlet patch.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:90
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.C:200
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
dimensionedInternalField
rDeltaT dimensionedInternalField()
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
U
U
Definition: pEqn.H:46
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.C:143
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::dimArea
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::avgCenter_
vector avgCenter_
Average centre.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:93
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::phiName_
const word phiName_
Name of the flux transporting the field.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:79
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::calcGeom
void calcGeom()
Calculate geometrical characteristics of the patch.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.C:129
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::fvPatchField::patchInternalField
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:208
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::avgNormal_
vector avgNormal_
Average normal.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:96
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField
Describes a volumetric/mass flow normal vector boundary condition by its magnitude as an integral ove...
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:69
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::fvPatchField< Type >::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:296
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::constant::mathematical::pi
const scalar pi(M_PI)
ibSwirlFlowRateInletVelocityFvPatchVectorField.H
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::flowRate_
const scalar flowRate_
Inlet integral flow rate.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:76
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::rhoName_
const word rhoName_
Name of the density field used to normalize the mass flux.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:82
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::ibSwirlFlowRateInletVelocityFvPatchVectorField::rpm_
const scalar rpm_
RPM.
Definition: ibSwirlFlowRateInletVelocityFvPatchVectorField.H:85