greyDiffusiveRadiationMixedFvPatchScalarField.C
Go to the documentation of this file.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 "greyDiffusiveRadiationMixedFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031
00032 #include "fvDOM.H"
00033 #include "radiationConstants.H"
00034 #include "mathematicalConstants.H"
00035
00036
00037
00038
00039 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00040 greyDiffusiveRadiationMixedFvPatchScalarField
00041 (
00042 const fvPatch& p,
00043 const DimensionedField<scalar, volMesh>& iF
00044 )
00045 :
00046 mixedFvPatchScalarField(p, iF),
00047 TName_("undefinedT"),
00048 emissivity_(0.0)
00049 {
00050 refValue() = 0.0;
00051 refGrad() = 0.0;
00052 valueFraction() = 1.0;
00053 }
00054
00055
00056 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00057 greyDiffusiveRadiationMixedFvPatchScalarField
00058 (
00059 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
00060 const fvPatch& p,
00061 const DimensionedField<scalar, volMesh>& iF,
00062 const fvPatchFieldMapper& mapper
00063 )
00064 :
00065 mixedFvPatchScalarField(ptf, p, iF, mapper),
00066 TName_(ptf.TName_),
00067 emissivity_(ptf.emissivity_)
00068 {}
00069
00070
00071 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00072 greyDiffusiveRadiationMixedFvPatchScalarField
00073 (
00074 const fvPatch& p,
00075 const DimensionedField<scalar, volMesh>& iF,
00076 const dictionary& dict
00077 )
00078 :
00079 mixedFvPatchScalarField(p, iF),
00080 TName_(dict.lookup("T")),
00081 emissivity_(readScalar(dict.lookup("emissivity")))
00082 {
00083 const scalarField& Tp =
00084 patch().lookupPatchField<volScalarField, scalar>(TName_);
00085
00086 refValue() =
00087 emissivity_*4.0*radiation::sigmaSB.value()*pow4(Tp)
00088 /Foam::mathematicalConstant::pi;
00089
00090 refGrad() = 0.0;
00091
00092 if (dict.found("value"))
00093 {
00094 fvPatchScalarField::operator=
00095 (
00096 scalarField("value", dict, p.size())
00097 );
00098 }
00099 else
00100 {
00101 fvPatchScalarField::operator=(refValue());
00102 }
00103 }
00104
00105
00106 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00107 greyDiffusiveRadiationMixedFvPatchScalarField
00108 (
00109 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf
00110 )
00111 :
00112 mixedFvPatchScalarField(ptf),
00113 TName_(ptf.TName_),
00114 emissivity_(ptf.emissivity_)
00115 {}
00116
00117
00118 Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00119 greyDiffusiveRadiationMixedFvPatchScalarField
00120 (
00121 const greyDiffusiveRadiationMixedFvPatchScalarField& ptf,
00122 const DimensionedField<scalar, volMesh>& iF
00123 )
00124 :
00125 mixedFvPatchScalarField(ptf, iF),
00126 TName_(ptf.TName_),
00127 emissivity_(ptf.emissivity_)
00128 {}
00129
00130
00131
00132
00133 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::
00134 updateCoeffs()
00135 {
00136 if (this->updated())
00137 {
00138 return;
00139 }
00140
00141 const scalarField& Tp =
00142 patch().lookupPatchField<volScalarField, scalar>(TName_);
00143
00144 const radiationModel& radiation =
00145 db().lookupObject<radiationModel>("radiationProperties");
00146
00147 const fvDOM& dom(refCast<const fvDOM>(radiation));
00148
00149 label rayId = -1;
00150 label lambdaId = -1;
00151 dom.setRayIdLambdaId(dimensionedInternalField().name(), rayId, lambdaId);
00152
00153 const label patchI = patch().index();
00154
00155 if (dom.nLambda() != 1)
00156 {
00157 FatalErrorIn
00158 (
00159 "Foam::radiation::"
00160 "greyDiffusiveRadiationMixedFvPatchScalarField::updateCoeffs"
00161 ) << " a grey boundary condition is used with a non-grey "
00162 << "absorption model" << nl << exit(FatalError);
00163 }
00164
00165 scalarField& Iw = *this;
00166 vectorField n = patch().Sf()/patch().magSf();
00167
00168 radiativeIntensityRay& ray =
00169 const_cast<radiativeIntensityRay&>(dom.IRay(rayId));
00170
00171 ray.Qr().boundaryField()[patchI] += Iw*(-n & ray.dAve());
00172
00173 forAll(Iw, faceI)
00174 {
00175 scalar Ir = 0.0;
00176
00177 for (label rayI=0; rayI < dom.nRay(); rayI++)
00178 {
00179 const vector& d = dom.IRay(rayI).d();
00180
00181 const scalarField& IFace =
00182 dom.IRay(rayI).ILambda(lambdaId).boundaryField()[patchI];
00183
00184 if ((-n[faceI] & d) < 0.0)
00185 {
00186
00187 const vector& dAve = dom.IRay(rayI).dAve();
00188 Ir += IFace[faceI]*mag(n[faceI] & dAve);
00189 }
00190 }
00191
00192 const vector& d = dom.IRay(rayId).d();
00193
00194 if ((-n[faceI] & d) > 0.0)
00195 {
00196
00197 refGrad()[faceI] = 0.0;
00198 valueFraction()[faceI] = 1.0;
00199 refValue()[faceI] =
00200 (
00201 Ir*(1.0 - emissivity_)
00202 + emissivity_*radiation::sigmaSB.value()*pow4(Tp[faceI])
00203 )
00204 /mathematicalConstant::pi;
00205
00206 }
00207 else
00208 {
00209
00210 valueFraction()[faceI] = 0.0;
00211 refGrad()[faceI] = 0.0;
00212 refValue()[faceI] = 0.0;
00213 }
00214 }
00215
00216 mixedFvPatchScalarField::updateCoeffs();
00217 }
00218
00219
00220 void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
00221 (
00222 Ostream& os
00223 ) const
00224 {
00225 fvPatchScalarField::write(os);
00226 os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
00227 os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00228 writeEntry("value", os);
00229 }
00230
00231
00232
00233
00234 namespace Foam
00235 {
00236 namespace radiation
00237 {
00238 makePatchTypeField
00239 (
00240 fvPatchScalarField,
00241 greyDiffusiveRadiationMixedFvPatchScalarField
00242 );
00243 }
00244 }
00245
00246
00247
Copyright © 2000-2009 OpenCFD Ltd