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 "pressureDirectedInletVelocityFvPatchVectorField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 #include <finiteVolume/surfaceFields.H>
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 pressureDirectedInletVelocityFvPatchVectorField::
00040 pressureDirectedInletVelocityFvPatchVectorField
00041 (
00042 const fvPatch& p,
00043 const DimensionedField<vector, volMesh>& iF
00044 )
00045 :
00046 fixedValueFvPatchVectorField(p, iF),
00047 phiName_("phi"),
00048 rhoName_("rho"),
00049 inletDir_(p.size())
00050 {}
00051
00052
00053 pressureDirectedInletVelocityFvPatchVectorField::
00054 pressureDirectedInletVelocityFvPatchVectorField
00055 (
00056 const pressureDirectedInletVelocityFvPatchVectorField& ptf,
00057 const fvPatch& p,
00058 const DimensionedField<vector, volMesh>& iF,
00059 const fvPatchFieldMapper& mapper
00060 )
00061 :
00062 fixedValueFvPatchVectorField(ptf, p, iF, mapper),
00063 phiName_(ptf.phiName_),
00064 rhoName_(ptf.rhoName_),
00065 inletDir_(ptf.inletDir_, mapper)
00066 {}
00067
00068
00069 pressureDirectedInletVelocityFvPatchVectorField::
00070 pressureDirectedInletVelocityFvPatchVectorField
00071 (
00072 const fvPatch& p,
00073 const DimensionedField<vector, volMesh>& iF,
00074 const dictionary& dict
00075 )
00076 :
00077 fixedValueFvPatchVectorField(p, iF),
00078 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00079 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00080 inletDir_("inletDirection", dict, p.size())
00081 {
00082 fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
00083 }
00084
00085
00086 pressureDirectedInletVelocityFvPatchVectorField::
00087 pressureDirectedInletVelocityFvPatchVectorField
00088 (
00089 const pressureDirectedInletVelocityFvPatchVectorField& pivpvf
00090 )
00091 :
00092 fixedValueFvPatchVectorField(pivpvf),
00093 phiName_(pivpvf.phiName_),
00094 rhoName_(pivpvf.rhoName_),
00095 inletDir_(pivpvf.inletDir_)
00096 {}
00097
00098
00099 pressureDirectedInletVelocityFvPatchVectorField::
00100 pressureDirectedInletVelocityFvPatchVectorField
00101 (
00102 const pressureDirectedInletVelocityFvPatchVectorField& pivpvf,
00103 const DimensionedField<vector, volMesh>& iF
00104 )
00105 :
00106 fixedValueFvPatchVectorField(pivpvf, iF),
00107 phiName_(pivpvf.phiName_),
00108 rhoName_(pivpvf.rhoName_),
00109 inletDir_(pivpvf.inletDir_)
00110 {}
00111
00112
00113
00114
00115 void pressureDirectedInletVelocityFvPatchVectorField::autoMap
00116 (
00117 const fvPatchFieldMapper& m
00118 )
00119 {
00120 fixedValueFvPatchVectorField::autoMap(m);
00121 inletDir_.autoMap(m);
00122 }
00123
00124
00125 void pressureDirectedInletVelocityFvPatchVectorField::rmap
00126 (
00127 const fvPatchVectorField& ptf,
00128 const labelList& addr
00129 )
00130 {
00131 fixedValueFvPatchVectorField::rmap(ptf, addr);
00132
00133 const pressureDirectedInletVelocityFvPatchVectorField& tiptf =
00134 refCast<const pressureDirectedInletVelocityFvPatchVectorField>(ptf);
00135
00136 inletDir_.rmap(tiptf.inletDir_, addr);
00137 }
00138
00139
00140 void pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()
00141 {
00142 if (updated())
00143 {
00144 return;
00145 }
00146
00147 const surfaceScalarField& phi =
00148 db().lookupObject<surfaceScalarField>(phiName_);
00149
00150 const fvsPatchField<scalar>& phip =
00151 patch().patchField<surfaceScalarField, scalar>(phi);
00152
00153 vectorField n = patch().nf();
00154 scalarField ndmagS = (n & inletDir_)*patch().magSf();
00155
00156 if (phi.dimensions() == dimVelocity*dimArea)
00157 {
00158 operator==(inletDir_*phip/ndmagS);
00159 }
00160 else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00161 {
00162 const fvPatchField<scalar>& rhop =
00163 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00164
00165 operator==(inletDir_*phip/(rhop*ndmagS));
00166 }
00167 else
00168 {
00169 FatalErrorIn
00170 (
00171 "pressureDirectedInletVelocityFvPatchVectorField::updateCoeffs()"
00172 ) << "dimensions of phi are not correct"
00173 << "\n on patch " << this->patch().name()
00174 << " of field " << this->dimensionedInternalField().name()
00175 << " in file " << this->dimensionedInternalField().objectPath()
00176 << exit(FatalError);
00177 }
00178
00179 fixedValueFvPatchVectorField::updateCoeffs();
00180 }
00181
00182
00183 void pressureDirectedInletVelocityFvPatchVectorField::write(Ostream& os) const
00184 {
00185 fvPatchVectorField::write(os);
00186 if (phiName_ != "phi")
00187 {
00188 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00189 }
00190 if (rhoName_ != "rho")
00191 {
00192 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00193 }
00194 inletDir_.writeEntry("inletDirection", os);
00195 writeEntry("value", os);
00196 }
00197
00198
00199
00200
00201 void pressureDirectedInletVelocityFvPatchVectorField::operator=
00202 (
00203 const fvPatchField<vector>& pvf
00204 )
00205 {
00206 fvPatchField<vector>::operator=(inletDir_*(inletDir_ & pvf));
00207 }
00208
00209
00210
00211
00212 makePatchTypeField
00213 (
00214 fvPatchVectorField,
00215 pressureDirectedInletVelocityFvPatchVectorField
00216 );
00217
00218
00219
00220
00221 }
00222
00223