OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

MarshakRadiationMixedFvPatchScalarField.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "MarshakRadiationMixedFvPatchScalarField.H"
00028 #include "addToRunTimeSelectionTable.H"
00029 #include "fvPatchFieldMapper.H"
00030 #include "volFields.H"
00031 
00032 #include "fvc.H"
00033 #include "radiationModel.H"
00034 #include "radiationConstants.H"
00035 
00036 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00037 
00038 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<scalar, volMesh>& iF
00042 )
00043 :
00044     mixedFvPatchScalarField(p, iF),
00045     TName_("undefined"),
00046     emissivity_(0.0)
00047 {
00048     refValue() = 0.0;
00049     refGrad() = 0.0;
00050     valueFraction() = 0.0;
00051 }
00052 
00053 
00054 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00055 (
00056     const MarshakRadiationFvPatchScalarField& ptf,
00057     const fvPatch& p,
00058     const DimensionedField<scalar, volMesh>& iF,
00059     const fvPatchFieldMapper& mapper
00060 )
00061 :
00062     mixedFvPatchScalarField(ptf, p, iF, mapper),
00063     TName_(ptf.TName_),
00064     emissivity_(ptf.emissivity_)
00065 {}
00066 
00067 
00068 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00069 (
00070     const fvPatch& p,
00071     const DimensionedField<scalar, volMesh>& iF,
00072     const dictionary& dict
00073 )
00074 :
00075     mixedFvPatchScalarField(p, iF),
00076     TName_(dict.lookup("T")),
00077     emissivity_(readScalar(dict.lookup("emissivity")))
00078 {
00079     const scalarField& Tp =
00080         patch().lookupPatchField<volScalarField, scalar>(TName_);
00081 
00082     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Tp);
00083     refGrad() = 0.0;
00084 
00085     if (dict.found("value"))
00086     {
00087         fvPatchScalarField::operator=
00088         (
00089             scalarField("value", dict, p.size())
00090         );
00091     }
00092     else
00093     {
00094         fvPatchScalarField::operator=(refValue());
00095     }
00096 }
00097 
00098 
00099 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00100 (
00101     const MarshakRadiationFvPatchScalarField& ptf
00102 )
00103 :
00104     mixedFvPatchScalarField(ptf),
00105     TName_(ptf.TName_),
00106     emissivity_(ptf.emissivity_)
00107 {}
00108 
00109 
00110 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00111 (
00112     const MarshakRadiationFvPatchScalarField& ptf,
00113     const DimensionedField<scalar, volMesh>& iF
00114 )
00115 :
00116     mixedFvPatchScalarField(ptf, iF),
00117     TName_(ptf.TName_),
00118     emissivity_(ptf.emissivity_)
00119 {}
00120 
00121 
00122 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00123 
00124 void Foam::MarshakRadiationFvPatchScalarField::autoMap
00125 (
00126     const fvPatchFieldMapper& m
00127 )
00128 {
00129     scalarField::autoMap(m);
00130 }
00131 
00132 
00133 void Foam::MarshakRadiationFvPatchScalarField::rmap
00134 (
00135     const fvPatchScalarField& ptf,
00136     const labelList& addr
00137 )
00138 {
00139     mixedFvPatchScalarField::rmap(ptf, addr);
00140 }
00141 
00142 
00143 void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
00144 {
00145     if (this->updated())
00146     {
00147         return;
00148     }
00149 
00150     // Temperature field
00151     const scalarField& Tp =
00152         patch().lookupPatchField<volScalarField, scalar>(TName_);
00153 
00154     // Re-calc reference value
00155     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Tp);
00156 
00157     // Diffusion coefficient - created by radiation model's ::updateCoeffs()
00158     const scalarField& gamma =
00159         patch().lookupPatchField<volScalarField, scalar>("gammaRad");
00160 
00161     const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
00162 
00163     // Set value fraction
00164     valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
00165 
00166     mixedFvPatchScalarField::updateCoeffs();
00167 }
00168 
00169 
00170 void Foam::MarshakRadiationFvPatchScalarField::write(Ostream& os) const
00171 {
00172     fvPatchScalarField::write(os);
00173     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
00174     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00175     writeEntry("value", os);
00176 }
00177 
00178 
00179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00180 
00181 namespace Foam
00182 {
00183     makePatchTypeField
00184     (
00185         fvPatchScalarField,
00186         MarshakRadiationFvPatchScalarField
00187     );
00188 }
00189 
00190 
00191 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd