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