FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

MarshakRadiationFixedTMixedFvPatchScalarField.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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "MarshakRadiationFixedTMixedFvPatchScalarField.H"
00027 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00028 #include <finiteVolume/fvPatchFieldMapper.H>
00029 #include <finiteVolume/volFields.H>
00030 
00031 #include <finiteVolume/fvc.H>
00032 #include <radiation/radiationModel.H>
00033 #include <radiation/radiationConstants.H>
00034 
00035 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00036 
00037 Foam::MarshakRadiationFixedTMixedFvPatchScalarField::
00038 MarshakRadiationFixedTMixedFvPatchScalarField
00039 (
00040     const fvPatch& p,
00041     const DimensionedField<scalar, volMesh>& iF
00042 )
00043 :
00044     mixedFvPatchScalarField(p, iF),
00045     Trad_(p.size()),
00046     emissivity_(0.0)
00047 {
00048     refValue() = 0.0;
00049     refGrad() = 0.0;
00050     valueFraction() = 0.0;
00051 }
00052 
00053 
00054 Foam::MarshakRadiationFixedTMixedFvPatchScalarField::
00055 MarshakRadiationFixedTMixedFvPatchScalarField
00056 (
00057     const MarshakRadiationFixedTMixedFvPatchScalarField& ptf,
00058     const fvPatch& p,
00059     const DimensionedField<scalar, volMesh>& iF,
00060     const fvPatchFieldMapper& mapper
00061 )
00062 :
00063     mixedFvPatchScalarField(ptf, p, iF, mapper),
00064     Trad_(ptf.Trad_, mapper),
00065     emissivity_(ptf.emissivity_)
00066 {}
00067 
00068 
00069 Foam::MarshakRadiationFixedTMixedFvPatchScalarField::
00070 MarshakRadiationFixedTMixedFvPatchScalarField
00071 (
00072     const fvPatch& p,
00073     const DimensionedField<scalar, volMesh>& iF,
00074     const dictionary& dict
00075 )
00076 :
00077     mixedFvPatchScalarField(p, iF),
00078     Trad_("Trad", dict, p.size()),
00079     emissivity_(readScalar(dict.lookup("emissivity")))
00080 {
00081     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Trad_);
00082     refGrad() = 0.0;
00083 
00084     if (dict.found("value"))
00085     {
00086         fvPatchScalarField::operator=
00087         (
00088             scalarField("value", dict, p.size())
00089         );
00090     }
00091     else
00092     {
00093         fvPatchScalarField::operator=(refValue());
00094     }
00095 }
00096 
00097 
00098 Foam::MarshakRadiationFixedTMixedFvPatchScalarField::
00099 MarshakRadiationFixedTMixedFvPatchScalarField
00100 (
00101     const MarshakRadiationFixedTMixedFvPatchScalarField& ptf
00102 )
00103 :
00104     mixedFvPatchScalarField(ptf),
00105     Trad_(ptf.Trad_),
00106     emissivity_(ptf.emissivity_)
00107 {}
00108 
00109 
00110 Foam::MarshakRadiationFixedTMixedFvPatchScalarField::
00111 MarshakRadiationFixedTMixedFvPatchScalarField
00112 (
00113     const MarshakRadiationFixedTMixedFvPatchScalarField& ptf,
00114     const DimensionedField<scalar, volMesh>& iF
00115 )
00116 :
00117     mixedFvPatchScalarField(ptf, iF),
00118     Trad_(ptf.Trad_),
00119     emissivity_(ptf.emissivity_)
00120 {}
00121 
00122 
00123 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00124 
00125 void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::autoMap
00126 (
00127     const fvPatchFieldMapper& m
00128 )
00129 {
00130     scalarField::autoMap(m);
00131     Trad_.autoMap(m);
00132 }
00133 
00134 
00135 void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::rmap
00136 (
00137     const fvPatchScalarField& ptf,
00138     const labelList& addr
00139 )
00140 {
00141     mixedFvPatchScalarField::rmap(ptf, addr);
00142 
00143     const MarshakRadiationFixedTMixedFvPatchScalarField& mrptf =
00144         refCast<const MarshakRadiationFixedTMixedFvPatchScalarField>(ptf);
00145 
00146     Trad_.rmap(mrptf.Trad_, addr);
00147 }
00148 
00149 
00150 void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::updateCoeffs()
00151 {
00152     if (this->updated())
00153     {
00154         return;
00155     }
00156 
00157     // Re-calc reference value
00158     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Trad_);
00159 
00160     // Diffusion coefficient - created by radiation model's ::updateCoeffs()
00161     const scalarField& gamma =
00162         patch().lookupPatchField<volScalarField, scalar>("gammaRad");
00163 
00164     const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
00165 
00166     // Set value fraction
00167     valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
00168 
00169     mixedFvPatchScalarField::updateCoeffs();
00170 }
00171 
00172 
00173 void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::write(Ostream& os) const
00174 {
00175     fvPatchScalarField::write(os);
00176     Trad_.writeEntry("Trad", os);
00177     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00178     writeEntry("value", os);
00179 }
00180 
00181 
00182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00183 
00184 namespace Foam
00185 {
00186     makePatchTypeField
00187     (
00188         fvPatchScalarField,
00189         MarshakRadiationFixedTMixedFvPatchScalarField
00190     );
00191 }
00192 
00193 
00194 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines