1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "flowRateInletVelocityFvPatchVectorField.H"
28 #include "volFields.H"
29 #include "addToRunTimeSelectionTable.H"
30 #include "fvPatchFieldMapper.H"
31 #include "surfaceFields.H"
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 flowRateInletVelocityFvPatchVectorField::
37 flowRateInletVelocityFvPatchVectorField
40 const DimensionedField<vector, volMesh>& iF
43 fixedValueFvPatchField<vector>(p, iF),
51 flowRateInletVelocityFvPatchVectorField::
52 flowRateInletVelocityFvPatchVectorField
54 const flowRateInletVelocityFvPatchVectorField& ptf,
56 const DimensionedField<vector, volMesh>& iF,
57 const fvPatchFieldMapper& mapper
60 fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
61 flowRate_(ptf.flowRate_),
62 phiName_(ptf.phiName_),
63 rhoName_(ptf.rhoName_)
68 flowRateInletVelocityFvPatchVectorField::
69 flowRateInletVelocityFvPatchVectorField
72 const DimensionedField<vector, volMesh>& iF,
73 const dictionary& dict
76 fixedValueFvPatchField<vector>(p, iF, dict),
77 flowRate_(readScalar(dict.lookup("flowRate"))),
81 if (dict.found("phi"))
83 dict.lookup("phi") >> phiName_;
86 if (dict.found("rho"))
88 dict.lookup("rho") >> rhoName_;
94 flowRateInletVelocityFvPatchVectorField::
95 flowRateInletVelocityFvPatchVectorField
97 const flowRateInletVelocityFvPatchVectorField& ptf
100 fixedValueFvPatchField<vector>(ptf),
101 flowRate_(ptf.flowRate_),
102 phiName_(ptf.phiName_),
103 rhoName_(ptf.rhoName_)
108 flowRateInletVelocityFvPatchVectorField::
109 flowRateInletVelocityFvPatchVectorField
111 const flowRateInletVelocityFvPatchVectorField& ptf,
112 const DimensionedField<vector, volMesh>& iF
115 fixedValueFvPatchField<vector>(ptf, iF),
116 flowRate_(ptf.flowRate_),
117 phiName_(ptf.phiName_),
118 rhoName_(ptf.rhoName_)
122 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
131 // a simpler way of doing this would be nice
132 scalar avgU = -flowRate_/gSum(patch().magSf());
134 vectorField n = patch().nf();
136 const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>
141 if (phi.dimensions() == dimVelocity*dimArea)
143 // volumetric flow-rate
146 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
148 const fvPatchField<scalar>& rhop =
149 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
152 operator==(n*avgU/rhop);
158 "flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
159 ) << "dimensions of " << phiName_ << " are incorrect" << nl
160 << " on patch " << this->patch().name()
161 << " of field " << this->dimensionedInternalField().name()
162 << " in file " << this->dimensionedInternalField().objectPath()
163 << nl << exit(FatalError);
166 fixedValueFvPatchField<vector>::updateCoeffs();
170 void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
172 fvPatchField<vector>::write(os);
174 os.writeKeyword("flowRate") << flowRate_
175 << token::END_STATEMENT << nl;
177 if (phiName_ != "phi")
179 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
182 if (rhoName_ != "rho")
184 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
187 writeEntry("value", os);
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 flowRateInletVelocityFvPatchVectorField
203 // ************************************************************************* //