FreeFOAM The Cross-Platform CFD Toolkit
flowRateInletVelocityFvPatchVectorField.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) 2006-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 \*---------------------------------------------------------------------------*/
25 
27 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 Foam::
37 (
38  const fvPatch& p,
40 )
41 :
43  flowRate_(0),
44  phiName_("phi"),
45  rhoName_("rho")
46 {}
47 
48 
49 Foam::
52 (
54  const fvPatch& p,
56  const fvPatchFieldMapper& mapper
57 )
58 :
59  fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
60  flowRate_(ptf.flowRate_),
61  phiName_(ptf.phiName_),
62  rhoName_(ptf.rhoName_)
63 {}
64 
65 
66 Foam::
69 (
70  const fvPatch& p,
72  const dictionary& dict
73 )
74 :
76  flowRate_(readScalar(dict.lookup("flowRate"))),
77  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
78  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
79 {}
80 
81 
82 Foam::
85 (
87 )
88 :
90  flowRate_(ptf.flowRate_),
91  phiName_(ptf.phiName_),
92  rhoName_(ptf.rhoName_)
93 {}
94 
95 
96 Foam::
99 (
102 )
103 :
105  flowRate_(ptf.flowRate_),
106  phiName_(ptf.phiName_),
107  rhoName_(ptf.rhoName_)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 
114 {
115  if (updated())
116  {
117  return;
118  }
119 
120  // a simpler way of doing this would be nice
121  scalar avgU = -flowRate_/gSum(patch().magSf());
122 
123  vectorField n = patch().nf();
124 
125  const surfaceScalarField& phi =
126  db().lookupObject<surfaceScalarField>(phiName_);
127 
128  if (phi.dimensions() == dimVelocity*dimArea)
129  {
130  // volumetric flow-rate
131  operator==(n*avgU);
132  }
133  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
134  {
135  const fvPatchField<scalar>& rhop =
136  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
137 
138  // mass flow-rate
139  operator==(n*avgU/rhop);
140  }
141  else
142  {
144  (
145  "flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
146  ) << "dimensions of " << phiName_ << " are incorrect" << nl
147  << " on patch " << this->patch().name()
148  << " of field " << this->dimensionedInternalField().name()
149  << " in file " << this->dimensionedInternalField().objectPath()
150  << nl << exit(FatalError);
151  }
152 
154 }
155 
156 
158 {
160  os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
161  if (phiName_ != "phi")
162  {
163  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
164  }
165  if (rhoName_ != "rho")
166  {
167  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
168  }
169  writeEntry("value", os);
170 }
171 
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 namespace Foam
176 {
178  (
181  );
182 }
183 
184 
185 // ************************ vim: set sw=4 sts=4 et: ************************ //