flowRateInletVelocityFvPatchVectorField.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "flowRateInletVelocityFvPatchVectorField.H"
00028 #include "volFields.H"
00029 #include "addToRunTimeSelectionTable.H"
00030 #include "fvPatchFieldMapper.H"
00031 #include "surfaceFields.H"
00032
00033
00034
00035 Foam::
00036 flowRateInletVelocityFvPatchVectorField::
00037 flowRateInletVelocityFvPatchVectorField
00038 (
00039 const fvPatch& p,
00040 const DimensionedField<vector, volMesh>& iF
00041 )
00042 :
00043 fixedValueFvPatchField<vector>(p, iF),
00044 flowRate_(0),
00045 phiName_("phi"),
00046 rhoName_("rho")
00047 {}
00048
00049
00050 Foam::
00051 flowRateInletVelocityFvPatchVectorField::
00052 flowRateInletVelocityFvPatchVectorField
00053 (
00054 const flowRateInletVelocityFvPatchVectorField& ptf,
00055 const fvPatch& p,
00056 const DimensionedField<vector, volMesh>& iF,
00057 const fvPatchFieldMapper& mapper
00058 )
00059 :
00060 fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
00061 flowRate_(ptf.flowRate_),
00062 phiName_(ptf.phiName_),
00063 rhoName_(ptf.rhoName_)
00064 {}
00065
00066
00067 Foam::
00068 flowRateInletVelocityFvPatchVectorField::
00069 flowRateInletVelocityFvPatchVectorField
00070 (
00071 const fvPatch& p,
00072 const DimensionedField<vector, volMesh>& iF,
00073 const dictionary& dict
00074 )
00075 :
00076 fixedValueFvPatchField<vector>(p, iF, dict),
00077 flowRate_(readScalar(dict.lookup("flowRate"))),
00078 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00079 rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
00080 {}
00081
00082
00083 Foam::
00084 flowRateInletVelocityFvPatchVectorField::
00085 flowRateInletVelocityFvPatchVectorField
00086 (
00087 const flowRateInletVelocityFvPatchVectorField& ptf
00088 )
00089 :
00090 fixedValueFvPatchField<vector>(ptf),
00091 flowRate_(ptf.flowRate_),
00092 phiName_(ptf.phiName_),
00093 rhoName_(ptf.rhoName_)
00094 {}
00095
00096
00097 Foam::
00098 flowRateInletVelocityFvPatchVectorField::
00099 flowRateInletVelocityFvPatchVectorField
00100 (
00101 const flowRateInletVelocityFvPatchVectorField& ptf,
00102 const DimensionedField<vector, volMesh>& iF
00103 )
00104 :
00105 fixedValueFvPatchField<vector>(ptf, iF),
00106 flowRate_(ptf.flowRate_),
00107 phiName_(ptf.phiName_),
00108 rhoName_(ptf.rhoName_)
00109 {}
00110
00111
00112
00113
00114 void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
00115 {
00116 if (updated())
00117 {
00118 return;
00119 }
00120
00121
00122 scalar avgU = -flowRate_/gSum(patch().magSf());
00123
00124 vectorField n = patch().nf();
00125
00126 const surfaceScalarField& phi =
00127 db().lookupObject<surfaceScalarField>(phiName_);
00128
00129 if (phi.dimensions() == dimVelocity*dimArea)
00130 {
00131
00132 operator==(n*avgU);
00133 }
00134 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00135 {
00136 const fvPatchField<scalar>& rhop =
00137 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00138
00139
00140 operator==(n*avgU/rhop);
00141 }
00142 else
00143 {
00144 FatalErrorIn
00145 (
00146 "flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
00147 ) << "dimensions of " << phiName_ << " are incorrect" << nl
00148 << " on patch " << this->patch().name()
00149 << " of field " << this->dimensionedInternalField().name()
00150 << " in file " << this->dimensionedInternalField().objectPath()
00151 << nl << exit(FatalError);
00152 }
00153
00154 fixedValueFvPatchField<vector>::updateCoeffs();
00155 }
00156
00157
00158 void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
00159 {
00160 fvPatchField<vector>::write(os);
00161 os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
00162 if (phiName_ != "phi")
00163 {
00164 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00165 }
00166 if (rhoName_ != "rho")
00167 {
00168 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00169 }
00170 writeEntry("value", os);
00171 }
00172
00173
00174
00175
00176 namespace Foam
00177 {
00178 makePatchTypeField
00179 (
00180 fvPatchVectorField,
00181 flowRateInletVelocityFvPatchVectorField
00182 );
00183 }
00184
00185
00186
Copyright © 2000-2009 OpenCFD Ltd