Fix tutorials: coupled/conjugateHeatFoam/conjugateCavity: fix Allrun file
[OpenFOAM-1.6-ext.git] / src / finiteVolume / fields / fvPatchFields / derived / flowRateInletVelocity / flowRateInletVelocityFvPatchVectorField.C
blobddfccba4ce140550d68c8fea70ebb856e31a1003
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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  * * * * * * * * * * * * * * //
35 Foam::
36 flowRateInletVelocityFvPatchVectorField::
37 flowRateInletVelocityFvPatchVectorField
39     const fvPatch& p,
40     const DimensionedField<vector, volMesh>& iF
43     fixedValueFvPatchField<vector>(p, iF),
44     flowRate_(0),
45     phiName_("phi"),
46     rhoName_("rho")
50 Foam::
51 flowRateInletVelocityFvPatchVectorField::
52 flowRateInletVelocityFvPatchVectorField
54     const flowRateInletVelocityFvPatchVectorField& ptf,
55     const fvPatch& p,
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_)
67 Foam::
68 flowRateInletVelocityFvPatchVectorField::
69 flowRateInletVelocityFvPatchVectorField
71     const fvPatch& p,
72     const DimensionedField<vector, volMesh>& iF,
73     const dictionary& dict
76     fixedValueFvPatchField<vector>(p, iF, dict),
77     flowRate_(readScalar(dict.lookup("flowRate"))),
78     phiName_(dict.lookupOrDefault<word>("phi", "phi")),
79     rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
83 Foam::
84 flowRateInletVelocityFvPatchVectorField::
85 flowRateInletVelocityFvPatchVectorField
87     const flowRateInletVelocityFvPatchVectorField& ptf
90     fixedValueFvPatchField<vector>(ptf),
91     flowRate_(ptf.flowRate_),
92     phiName_(ptf.phiName_),
93     rhoName_(ptf.rhoName_)
97 Foam::
98 flowRateInletVelocityFvPatchVectorField::
99 flowRateInletVelocityFvPatchVectorField
101     const flowRateInletVelocityFvPatchVectorField& ptf,
102     const DimensionedField<vector, volMesh>& iF
105     fixedValueFvPatchField<vector>(ptf, iF),
106     flowRate_(ptf.flowRate_),
107     phiName_(ptf.phiName_),
108     rhoName_(ptf.rhoName_)
112 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
114 void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
116     if (updated())
117     {
118         return;
119     }
121     // a simpler way of doing this would be nice
122     scalar avgU = -flowRate_/gSum(patch().magSf());
124     vectorField n = patch().nf();
126     const surfaceScalarField& phi =
127         db().lookupObject<surfaceScalarField>(phiName_);
129     if (phi.dimensions() == dimVelocity*dimArea)
130     {
131         // volumetric flow-rate
132         operator==(n*avgU);
133     }
134     else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
135     {
136         const fvPatchField<scalar>& rhop =
137             patch().lookupPatchField<volScalarField, scalar>(rhoName_);
139         // mass flow-rate
140         operator==(n*avgU/rhop);
141     }
142     else
143     {
144         FatalErrorIn
145         (
146             "flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
147         )   << "dimensions of " << phiName_ << " are incorrect" << nl
148             << "    on patch " << this->patch().name()
149             << " of field " << this->dimensionedInternalField().name()
150             << " in file " << this->dimensionedInternalField().objectPath()
151             << nl << exit(FatalError);
152     }
154     fixedValueFvPatchField<vector>::updateCoeffs();
158 void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
160     fvPatchField<vector>::write(os);
161     os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
162     if (phiName_ != "phi")
163     {
164         os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
165     }
166     if (rhoName_ != "rho")
167     {
168         os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
169     }
170     writeEntry("value", os);
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 namespace Foam
178    makePatchTypeField
179    (
180        fvPatchVectorField,
181        flowRateInletVelocityFvPatchVectorField
182    );
186 // ************************************************************************* //