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 "inletOutletTotalTemperatureFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 #include "surfaceFields.H"
00032
00033
00034
00035
00036
00037 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00038 inletOutletTotalTemperatureFvPatchScalarField
00039 (
00040 const fvPatch& p,
00041 const DimensionedField<scalar, volMesh>& iF
00042 )
00043 :
00044 mixedFvPatchScalarField(p, iF),
00045 UName_("U"),
00046 phiName_("phi"),
00047 psiName_("psi"),
00048 gamma_(0.0),
00049 T0_(p.size(), 0.0)
00050 {
00051 this->refValue() = pTraits<scalar>::zero;
00052 this->refGrad() = pTraits<scalar>::zero;
00053 this->valueFraction() = 0.0;
00054 }
00055
00056
00057 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00058 inletOutletTotalTemperatureFvPatchScalarField
00059 (
00060 const inletOutletTotalTemperatureFvPatchScalarField& ptf,
00061 const fvPatch& p,
00062 const DimensionedField<scalar, volMesh>& iF,
00063 const fvPatchFieldMapper& mapper
00064 )
00065 :
00066 mixedFvPatchScalarField(ptf, p, iF, mapper),
00067 UName_(ptf.UName_),
00068 phiName_(ptf.phiName_),
00069 psiName_(ptf.psiName_),
00070 gamma_(ptf.gamma_),
00071 T0_(ptf.T0_, mapper)
00072 {}
00073
00074
00075 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00076 inletOutletTotalTemperatureFvPatchScalarField
00077 (
00078 const fvPatch& p,
00079 const DimensionedField<scalar, volMesh>& iF,
00080 const dictionary& dict
00081 )
00082 :
00083 mixedFvPatchScalarField(p, iF),
00084 UName_(dict.lookupOrDefault<word>("U", "U")),
00085 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00086 psiName_(dict.lookupOrDefault<word>("psi", "psi")),
00087 gamma_(readScalar(dict.lookup("gamma"))),
00088 T0_("T0", dict, p.size())
00089 {
00090 this->refValue() = pTraits<scalar>::zero;
00091 if (dict.found("value"))
00092 {
00093 fvPatchField<scalar>::operator=
00094 (
00095 scalarField("value", dict, p.size())
00096 );
00097 }
00098 else
00099 {
00100 fvPatchField<scalar>::operator=(T0_);
00101 }
00102
00103 this->refGrad() = pTraits<scalar>::zero;
00104 this->valueFraction() = 0.0;
00105 }
00106
00107
00108 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00109 inletOutletTotalTemperatureFvPatchScalarField
00110 (
00111 const inletOutletTotalTemperatureFvPatchScalarField& tppsf
00112 )
00113 :
00114 mixedFvPatchScalarField(tppsf),
00115 UName_(tppsf.UName_),
00116 phiName_(tppsf.phiName_),
00117 psiName_(tppsf.psiName_),
00118 gamma_(tppsf.gamma_),
00119 T0_(tppsf.T0_)
00120 {}
00121
00122
00123 Foam::inletOutletTotalTemperatureFvPatchScalarField::
00124 inletOutletTotalTemperatureFvPatchScalarField
00125 (
00126 const inletOutletTotalTemperatureFvPatchScalarField& tppsf,
00127 const DimensionedField<scalar, volMesh>& iF
00128 )
00129 :
00130 mixedFvPatchScalarField(tppsf, iF),
00131 UName_(tppsf.UName_),
00132 phiName_(tppsf.phiName_),
00133 psiName_(tppsf.psiName_),
00134 gamma_(tppsf.gamma_),
00135 T0_(tppsf.T0_)
00136 {}
00137
00138
00139
00140
00141 void Foam::inletOutletTotalTemperatureFvPatchScalarField::autoMap
00142 (
00143 const fvPatchFieldMapper& m
00144 )
00145 {
00146 mixedFvPatchScalarField::autoMap(m);
00147 T0_.autoMap(m);
00148 }
00149
00150
00151 void Foam::inletOutletTotalTemperatureFvPatchScalarField::rmap
00152 (
00153 const fvPatchScalarField& ptf,
00154 const labelList& addr
00155 )
00156 {
00157 mixedFvPatchScalarField::rmap(ptf, addr);
00158
00159 const inletOutletTotalTemperatureFvPatchScalarField& tiptf =
00160 refCast<const inletOutletTotalTemperatureFvPatchScalarField>(ptf);
00161
00162 T0_.rmap(tiptf.T0_, addr);
00163 }
00164
00165
00166 void Foam::inletOutletTotalTemperatureFvPatchScalarField::updateCoeffs()
00167 {
00168 if (updated())
00169 {
00170 return;
00171 }
00172
00173 const fvPatchVectorField& Up =
00174 patch().lookupPatchField<volVectorField, vector>(UName_);
00175
00176 const fvsPatchField<scalar>& phip =
00177 patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
00178
00179 const fvPatchField<scalar>& psip =
00180 patch().lookupPatchField<volScalarField, scalar>(psiName_);
00181
00182 scalar gM1ByG = (gamma_ - 1.0)/gamma_;
00183
00184 this->refValue() =
00185 T0_/(1.0 + 0.5*psip*gM1ByG*(1.0 - pos(phip))*magSqr(Up));
00186 this->valueFraction() = 1.0 - pos(phip);
00187
00188 mixedFvPatchScalarField::updateCoeffs();
00189 }
00190
00191
00192 void Foam::inletOutletTotalTemperatureFvPatchScalarField::write(Ostream& os)
00193 const
00194 {
00195 fvPatchScalarField::write(os);
00196 if (UName_ != "U")
00197 {
00198 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
00199 }
00200 if (phiName_ != "phi")
00201 {
00202 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00203 }
00204 if (phiName_ != "psi")
00205 {
00206 os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
00207 }
00208 os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
00209 T0_.writeEntry("T0", os);
00210 writeEntry("value", os);
00211 }
00212
00213
00214
00215
00216 namespace Foam
00217 {
00218 makePatchTypeField
00219 (
00220 fvPatchScalarField,
00221 inletOutletTotalTemperatureFvPatchScalarField
00222 );
00223 }
00224
00225