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 "totalPressureFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032
00033
00034
00035
00036 Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
00037 (
00038 const fvPatch& p,
00039 const DimensionedField<scalar, volMesh>& iF
00040 )
00041 :
00042 fixedValueFvPatchScalarField(p, iF),
00043 UName_("U"),
00044 phiName_("phi"),
00045 rhoName_("none"),
00046 psiName_("none"),
00047 gamma_(0.0),
00048 p0_(p.size(), 0.0)
00049 {}
00050
00051
00052 Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
00053 (
00054 const fvPatch& p,
00055 const DimensionedField<scalar, volMesh>& iF,
00056 const dictionary& dict
00057 )
00058 :
00059 fixedValueFvPatchScalarField(p, iF),
00060 UName_(dict.lookupOrDefault<word>("U", "U")),
00061 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00062 rhoName_(dict.lookupOrDefault<word>("rho", "none")),
00063 psiName_(dict.lookupOrDefault<word>("psi", "none")),
00064 gamma_(readScalar(dict.lookup("gamma"))),
00065 p0_("p0", dict, p.size())
00066 {
00067 if (dict.found("value"))
00068 {
00069 fvPatchField<scalar>::operator=
00070 (
00071 scalarField("value", dict, p.size())
00072 );
00073 }
00074 else
00075 {
00076 fvPatchField<scalar>::operator=(p0_);
00077 }
00078 }
00079
00080
00081 Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
00082 (
00083 const totalPressureFvPatchScalarField& ptf,
00084 const fvPatch& p,
00085 const DimensionedField<scalar, volMesh>& iF,
00086 const fvPatchFieldMapper& mapper
00087 )
00088 :
00089 fixedValueFvPatchScalarField(ptf, p, iF, mapper),
00090 UName_(ptf.UName_),
00091 phiName_(ptf.phiName_),
00092 rhoName_(ptf.rhoName_),
00093 psiName_(ptf.psiName_),
00094 gamma_(ptf.gamma_),
00095 p0_(ptf.p0_, mapper)
00096 {}
00097
00098
00099 Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
00100 (
00101 const totalPressureFvPatchScalarField& tppsf
00102 )
00103 :
00104 fixedValueFvPatchScalarField(tppsf),
00105 UName_(tppsf.UName_),
00106 phiName_(tppsf.phiName_),
00107 rhoName_(tppsf.rhoName_),
00108 psiName_(tppsf.psiName_),
00109 gamma_(tppsf.gamma_),
00110 p0_(tppsf.p0_)
00111 {}
00112
00113
00114 Foam::totalPressureFvPatchScalarField::totalPressureFvPatchScalarField
00115 (
00116 const totalPressureFvPatchScalarField& tppsf,
00117 const DimensionedField<scalar, volMesh>& iF
00118 )
00119 :
00120 fixedValueFvPatchScalarField(tppsf, iF),
00121 UName_(tppsf.UName_),
00122 phiName_(tppsf.phiName_),
00123 rhoName_(tppsf.rhoName_),
00124 psiName_(tppsf.psiName_),
00125 gamma_(tppsf.gamma_),
00126 p0_(tppsf.p0_)
00127 {}
00128
00129
00130
00131
00132 void Foam::totalPressureFvPatchScalarField::autoMap
00133 (
00134 const fvPatchFieldMapper& m
00135 )
00136 {
00137 fixedValueFvPatchScalarField::autoMap(m);
00138 p0_.autoMap(m);
00139 }
00140
00141
00142 void Foam::totalPressureFvPatchScalarField::rmap
00143 (
00144 const fvPatchScalarField& ptf,
00145 const labelList& addr
00146 )
00147 {
00148 fixedValueFvPatchScalarField::rmap(ptf, addr);
00149
00150 const totalPressureFvPatchScalarField& tiptf =
00151 refCast<const totalPressureFvPatchScalarField>(ptf);
00152
00153 p0_.rmap(tiptf.p0_, addr);
00154 }
00155
00156
00157 void Foam::totalPressureFvPatchScalarField::updateCoeffs(const vectorField& Up)
00158 {
00159 if (updated())
00160 {
00161 return;
00162 }
00163
00164 const fvsPatchField<scalar>& phip =
00165 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
00166
00167 if (psiName_ == "none" && rhoName_ == "none")
00168 {
00169 operator==(p0_ - 0.5*(1.0 - pos(phip))*magSqr(Up));
00170 }
00171 else if (rhoName_ == "none")
00172 {
00173 const fvPatchField<scalar>& psip =
00174 patch().lookupPatchField<volScalarField, scalar>(psiName_);
00175
00176 if (gamma_ > 1.0)
00177 {
00178 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
00179
00180 operator==
00181 (
00182 p0_
00183 /pow
00184 (
00185 (1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up)),
00186 1.0/gM1ByG
00187 )
00188 );
00189 }
00190 else
00191 {
00192 operator==(p0_/(1.0 + 0.5*psip*(1.0 - pos(phip))*magSqr(Up)));
00193 }
00194 }
00195 else if (psiName_ == "none")
00196 {
00197 const fvPatchField<scalar>& rho =
00198 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00199
00200 operator==(p0_ - 0.5*rho*(1.0 - pos(phip))*magSqr(Up));
00201 }
00202 else
00203 {
00204 FatalErrorIn
00205 (
00206 "totalPressureFvPatchScalarField::updateCoeffs()"
00207 ) << " rho or psi set inconsistently, rho = " << rhoName_
00208 << ", psi = " << psiName_ << ".\n"
00209 << " Set either rho or psi or neither depending on the "
00210 "definition of total pressure." << nl
00211 << " Set the unused variable(s) to 'none'.\n"
00212 << " on patch " << this->patch().name()
00213 << " of field " << this->dimensionedInternalField().name()
00214 << " in file " << this->dimensionedInternalField().objectPath()
00215 << exit(FatalError);
00216 }
00217
00218 fixedValueFvPatchScalarField::updateCoeffs();
00219 }
00220
00221
00222 void Foam::totalPressureFvPatchScalarField::updateCoeffs()
00223 {
00224 updateCoeffs(patch().lookupPatchField<volVectorField, vector>(UName_));
00225 }
00226
00227
00228 void Foam::totalPressureFvPatchScalarField::write(Ostream& os) const
00229 {
00230 fvPatchScalarField::write(os);
00231 writeEntryIfDifferent<word>(os, "U", "U", UName_);
00232 writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
00233 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00234 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
00235 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
00236 p0_.writeEntry("p0", os);
00237 writeEntry("value", os);
00238 }
00239
00240
00241
00242
00243 namespace Foam
00244 {
00245 makePatchTypeField
00246 (
00247 fvPatchScalarField,
00248 totalPressureFvPatchScalarField
00249 );
00250 }
00251
00252