1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2006-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "flowRateInletVelocityFvPatchVectorField.H"
27 #include "volFields.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "fvPatchFieldMapper.H"
30 #include "surfaceFields.H"
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 flowRateInletVelocityFvPatchVectorField::
36 flowRateInletVelocityFvPatchVectorField
39 const DimensionedField<vector, volMesh>& iF
42 fixedValueFvPatchField<vector>(p, iF),
50 flowRateInletVelocityFvPatchVectorField::
51 flowRateInletVelocityFvPatchVectorField
53 const flowRateInletVelocityFvPatchVectorField& ptf,
55 const DimensionedField<vector, volMesh>& iF,
56 const fvPatchFieldMapper& mapper
59 fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
60 flowRate_(ptf.flowRate_),
61 phiName_(ptf.phiName_),
62 rhoName_(ptf.rhoName_)
67 flowRateInletVelocityFvPatchVectorField::
68 flowRateInletVelocityFvPatchVectorField
71 const DimensionedField<vector, volMesh>& iF,
72 const dictionary& dict
75 fixedValueFvPatchField<vector>(p, iF, dict),
76 flowRate_(readScalar(dict.lookup("flowRate"))),
77 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
78 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
83 flowRateInletVelocityFvPatchVectorField::
84 flowRateInletVelocityFvPatchVectorField
86 const flowRateInletVelocityFvPatchVectorField& ptf
89 fixedValueFvPatchField<vector>(ptf),
90 flowRate_(ptf.flowRate_),
91 phiName_(ptf.phiName_),
92 rhoName_(ptf.rhoName_)
97 flowRateInletVelocityFvPatchVectorField::
98 flowRateInletVelocityFvPatchVectorField
100 const flowRateInletVelocityFvPatchVectorField& ptf,
101 const DimensionedField<vector, volMesh>& iF
104 fixedValueFvPatchField<vector>(ptf, iF),
105 flowRate_(ptf.flowRate_),
106 phiName_(ptf.phiName_),
107 rhoName_(ptf.rhoName_)
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
113 void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
120 // a simpler way of doing this would be nice
121 const scalar avgU = -flowRate_/gSum(patch().magSf());
123 tmp<vectorField> n = patch().nf();
125 const surfaceScalarField& phi =
126 db().lookupObject<surfaceScalarField>(phiName_);
128 if (phi.dimensions() == dimVelocity*dimArea)
130 // volumetric flow-rate
133 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
135 const fvPatchField<scalar>& rhop =
136 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
139 operator==(n*avgU/rhop);
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);
153 fixedValueFvPatchField<vector>::updateCoeffs();
157 void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
159 fvPatchField<vector>::write(os);
160 os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
161 writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
162 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
163 writeEntry("value", os);
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 flowRateInletVelocityFvPatchVectorField
179 // ************************************************************************* //