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 #include "swirlFlowRateInletVelocityFvPatchVectorField.H"
00027 #include <finiteVolume/volFields.H>
00028 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00029 #include <finiteVolume/fvPatchFieldMapper.H>
00030 #include <finiteVolume/surfaceFields.H>
00031 #include <OpenFOAM/mathematicalConstants.H>
00032
00033
00034
00035 Foam::
00036 swirlFlowRateInletVelocityFvPatchVectorField::
00037 swirlFlowRateInletVelocityFvPatchVectorField
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 rpm_(0)
00048 {}
00049
00050
00051 Foam::
00052 swirlFlowRateInletVelocityFvPatchVectorField::
00053 swirlFlowRateInletVelocityFvPatchVectorField
00054 (
00055 const swirlFlowRateInletVelocityFvPatchVectorField& ptf,
00056 const fvPatch& p,
00057 const DimensionedField<vector, volMesh>& iF,
00058 const fvPatchFieldMapper& mapper
00059 )
00060 :
00061 fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
00062 flowRate_(ptf.flowRate_),
00063 phiName_(ptf.phiName_),
00064 rhoName_(ptf.rhoName_),
00065 rpm_(ptf.rpm_)
00066 {}
00067
00068
00069 Foam::
00070 swirlFlowRateInletVelocityFvPatchVectorField::
00071 swirlFlowRateInletVelocityFvPatchVectorField
00072 (
00073 const fvPatch& p,
00074 const DimensionedField<vector, volMesh>& iF,
00075 const dictionary& dict
00076 )
00077 :
00078 fixedValueFvPatchField<vector>(p, iF, dict),
00079 flowRate_(readScalar(dict.lookup("flowRate"))),
00080 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00081 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00082 rpm_(readScalar(dict.lookup("rpm")))
00083 {}
00084
00085
00086 Foam::
00087 swirlFlowRateInletVelocityFvPatchVectorField::
00088 swirlFlowRateInletVelocityFvPatchVectorField
00089 (
00090 const swirlFlowRateInletVelocityFvPatchVectorField& ptf
00091 )
00092 :
00093 fixedValueFvPatchField<vector>(ptf),
00094 flowRate_(ptf.flowRate_),
00095 phiName_(ptf.phiName_),
00096 rhoName_(ptf.rhoName_),
00097 rpm_(ptf.rpm_)
00098 {}
00099
00100
00101 Foam::
00102 swirlFlowRateInletVelocityFvPatchVectorField::
00103 swirlFlowRateInletVelocityFvPatchVectorField
00104 (
00105 const swirlFlowRateInletVelocityFvPatchVectorField& ptf,
00106 const DimensionedField<vector, volMesh>& iF
00107 )
00108 :
00109 fixedValueFvPatchField<vector>(ptf, iF),
00110 flowRate_(ptf.flowRate_),
00111 phiName_(ptf.phiName_),
00112 rhoName_(ptf.rhoName_),
00113 rpm_(ptf.rpm_)
00114 {}
00115
00116
00117
00118
00119 void Foam::swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
00120 {
00121 if (updated())
00122 {
00123 return;
00124 }
00125
00126 const scalar totArea = gSum(patch().magSf());
00127
00128 const scalar avgU = -flowRate_/totArea;
00129
00130 const vector avgCenter = gSum(patch().Cf()*patch().magSf())/totArea;
00131 const vector avgNormal = gSum(patch().Sf())/totArea;
00132
00133
00134 vectorField tangentialVelocity =
00135 (
00136 (rpm_*mathematicalConstant::pi/30.0)
00137 * (patch().Cf() - avgCenter) ^ avgNormal
00138 );
00139
00140 tmp<vectorField> n = patch().nf();
00141
00142 const surfaceScalarField& phi =
00143 db().lookupObject<surfaceScalarField>(phiName_);
00144
00145 if (phi.dimensions() == dimVelocity*dimArea)
00146 {
00147
00148 operator==(tangentialVelocity + n*avgU);
00149 }
00150 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00151 {
00152 const fvPatchField<scalar>& rhop =
00153 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00154
00155
00156 operator==(tangentialVelocity + n*avgU/rhop);
00157 }
00158 else
00159 {
00160 FatalErrorIn
00161 (
00162 "swirlFlowRateInletVelocityFvPatchVectorField::updateCoeffs()"
00163 ) << "dimensions of " << phiName_ << " are incorrect" << nl
00164 << " on patch " << this->patch().name()
00165 << " of field " << this->dimensionedInternalField().name()
00166 << " in file " << this->dimensionedInternalField().objectPath()
00167 << nl << exit(FatalError);
00168 }
00169
00170 fixedValueFvPatchField<vector>::updateCoeffs();
00171 }
00172
00173
00174 void Foam::swirlFlowRateInletVelocityFvPatchVectorField::write
00175 (
00176 Ostream& os
00177 ) const
00178 {
00179 fvPatchField<vector>::write(os);
00180 os.writeKeyword("flowRate") << flowRate_ << token::END_STATEMENT << nl;
00181 writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
00182 writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_);
00183 os.writeKeyword("rpm") << rpm_ << token::END_STATEMENT << nl;
00184 writeEntry("value", os);
00185 }
00186
00187
00188
00189
00190 namespace Foam
00191 {
00192 makePatchTypeField
00193 (
00194 fvPatchVectorField,
00195 swirlFlowRateInletVelocityFvPatchVectorField
00196 );
00197 }
00198
00199
00200