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