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 "fixedFluxPressureFvPatchScalarField.H"
00028 #include "fvPatchFieldMapper.H"
00029 #include "volFields.H"
00030 #include "surfaceFields.H"
00031 #include "addToRunTimeSelectionTable.H"
00032
00033
00034
00035 Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
00036 (
00037 const fvPatch& p,
00038 const DimensionedField<scalar, volMesh>& iF
00039 )
00040 :
00041 fixedGradientFvPatchScalarField(p, iF),
00042 UName_("U"),
00043 phiName_("phi"),
00044 rhoName_("rho"),
00045 adjoint_(false)
00046 {}
00047
00048
00049 Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
00050 (
00051 const fixedFluxPressureFvPatchScalarField& ptf,
00052 const fvPatch& p,
00053 const DimensionedField<scalar, volMesh>& iF,
00054 const fvPatchFieldMapper& mapper
00055 )
00056 :
00057 fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
00058 UName_(ptf.UName_),
00059 phiName_(ptf.phiName_),
00060 rhoName_(ptf.rhoName_),
00061 adjoint_(ptf.adjoint_)
00062 {}
00063
00064
00065 Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
00066 (
00067 const fvPatch& p,
00068 const DimensionedField<scalar, volMesh>& iF,
00069 const dictionary& dict
00070 )
00071 :
00072 fixedGradientFvPatchScalarField(p, iF),
00073 UName_(dict.lookupOrDefault<word>("U", "U")),
00074 phiName_(dict.lookupOrDefault<word>("phi", "phi")),
00075 rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
00076 adjoint_(dict.lookup("adjoint"))
00077 {
00078 if (dict.found("gradient"))
00079 {
00080 gradient() = scalarField("gradient", dict, p.size());
00081 fixedGradientFvPatchScalarField::updateCoeffs();
00082 fixedGradientFvPatchScalarField::evaluate();
00083 }
00084 else
00085 {
00086 fvPatchField<scalar>::operator=(patchInternalField());
00087 gradient() = 0.0;
00088 }
00089 }
00090
00091
00092 Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
00093 (
00094 const fixedFluxPressureFvPatchScalarField& wbppsf
00095 )
00096 :
00097 fixedGradientFvPatchScalarField(wbppsf),
00098 UName_(wbppsf.UName_),
00099 phiName_(wbppsf.phiName_),
00100 rhoName_(wbppsf.rhoName_),
00101 adjoint_(wbppsf.adjoint_)
00102 {}
00103
00104
00105 Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField
00106 (
00107 const fixedFluxPressureFvPatchScalarField& wbppsf,
00108 const DimensionedField<scalar, volMesh>& iF
00109 )
00110 :
00111 fixedGradientFvPatchScalarField(wbppsf, iF),
00112 UName_(wbppsf.UName_),
00113 phiName_(wbppsf.phiName_),
00114 rhoName_(wbppsf.rhoName_),
00115 adjoint_(wbppsf.adjoint_)
00116 {}
00117
00118
00119
00120
00121 void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs()
00122 {
00123 if (updated())
00124 {
00125 return;
00126 }
00127
00128 const fvPatchField<vector>& Up =
00129 patch().lookupPatchField<volVectorField, vector>(UName_);
00130
00131 const surfaceScalarField& phi =
00132 db().lookupObject<surfaceScalarField>(phiName_);
00133
00134 fvsPatchField<scalar> phip =
00135 patch().patchField<surfaceScalarField, scalar>(phi);
00136
00137 if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
00138 {
00139 const fvPatchField<scalar>& rhop =
00140 patch().lookupPatchField<volScalarField, scalar>(rhoName_);
00141
00142 phip /= rhop;
00143 }
00144
00145 const fvPatchField<scalar>& rAp =
00146 patch().lookupPatchField<volScalarField, scalar>("(1|A("+UName_+"))");
00147
00148 if (adjoint_)
00149 {
00150 gradient() = ((patch().Sf() & Up) - phip)/patch().magSf()/rAp;
00151 }
00152 else
00153 {
00154 gradient() = (phip - (patch().Sf() & Up))/patch().magSf()/rAp;
00155 }
00156
00157 fixedGradientFvPatchScalarField::updateCoeffs();
00158 }
00159
00160
00161 void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const
00162 {
00163 fvPatchScalarField::write(os);
00164 if (UName_ != "U")
00165 {
00166 os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
00167 }
00168 if (phiName_ != "phi")
00169 {
00170 os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
00171 }
00172 if (rhoName_ != "rho")
00173 {
00174 os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
00175 }
00176 os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
00177 gradient().writeEntry("gradient", os);
00178 }
00179
00180
00181
00182
00183 namespace Foam
00184 {
00185 makePatchTypeField
00186 (
00187 fvPatchScalarField,
00188 fixedFluxPressureFvPatchScalarField
00189 );
00190 }
00191
00192