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

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-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 "MarshakRadiationMixedFvPatchScalarField.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::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00038 (
00039     const fvPatch& p,
00040     const DimensionedField<scalar, volMesh>& iF
00041 )
00042 :
00043     mixedFvPatchScalarField(p, iF),
00044     TName_("undefined"),
00045     emissivity_(0.0)
00046 {
00047     refValue() = 0.0;
00048     refGrad() = 0.0;
00049     valueFraction() = 0.0;
00050 }
00051 
00052 
00053 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00054 (
00055     const MarshakRadiationFvPatchScalarField& ptf,
00056     const fvPatch& p,
00057     const DimensionedField<scalar, volMesh>& iF,
00058     const fvPatchFieldMapper& mapper
00059 )
00060 :
00061     mixedFvPatchScalarField(ptf, p, iF, mapper),
00062     TName_(ptf.TName_),
00063     emissivity_(ptf.emissivity_)
00064 {}
00065 
00066 
00067 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00068 (
00069     const fvPatch& p,
00070     const DimensionedField<scalar, volMesh>& iF,
00071     const dictionary& dict
00072 )
00073 :
00074     mixedFvPatchScalarField(p, iF),
00075     TName_(dict.lookup("T")),
00076     emissivity_(readScalar(dict.lookup("emissivity")))
00077 {
00078     const scalarField& Tp =
00079         patch().lookupPatchField<volScalarField, scalar>(TName_);
00080 
00081     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Tp);
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::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00099 (
00100     const MarshakRadiationFvPatchScalarField& ptf
00101 )
00102 :
00103     mixedFvPatchScalarField(ptf),
00104     TName_(ptf.TName_),
00105     emissivity_(ptf.emissivity_)
00106 {}
00107 
00108 
00109 Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
00110 (
00111     const MarshakRadiationFvPatchScalarField& ptf,
00112     const DimensionedField<scalar, volMesh>& iF
00113 )
00114 :
00115     mixedFvPatchScalarField(ptf, iF),
00116     TName_(ptf.TName_),
00117     emissivity_(ptf.emissivity_)
00118 {}
00119 
00120 
00121 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00122 
00123 void Foam::MarshakRadiationFvPatchScalarField::autoMap
00124 (
00125     const fvPatchFieldMapper& m
00126 )
00127 {
00128     scalarField::autoMap(m);
00129 }
00130 
00131 
00132 void Foam::MarshakRadiationFvPatchScalarField::rmap
00133 (
00134     const fvPatchScalarField& ptf,
00135     const labelList& addr
00136 )
00137 {
00138     mixedFvPatchScalarField::rmap(ptf, addr);
00139 }
00140 
00141 
00142 void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
00143 {
00144     if (this->updated())
00145     {
00146         return;
00147     }
00148 
00149     // Temperature field
00150     const scalarField& Tp =
00151         patch().lookupPatchField<volScalarField, scalar>(TName_);
00152 
00153     // Re-calc reference value
00154     refValue() = 4.0*radiation::sigmaSB.value()*pow4(Tp);
00155 
00156     // Diffusion coefficient - created by radiation model's ::updateCoeffs()
00157     const scalarField& gamma =
00158         patch().lookupPatchField<volScalarField, scalar>("gammaRad");
00159 
00160     const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
00161 
00162     // Set value fraction
00163     valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
00164 
00165     mixedFvPatchScalarField::updateCoeffs();
00166 }
00167 
00168 
00169 void Foam::MarshakRadiationFvPatchScalarField::write(Ostream& os) const
00170 {
00171     fvPatchScalarField::write(os);
00172     os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
00173     os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
00174     writeEntry("value", os);
00175 }
00176 
00177 
00178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00179 
00180 namespace Foam
00181 {
00182     makePatchTypeField
00183     (
00184         fvPatchScalarField,
00185         MarshakRadiationFvPatchScalarField
00186     );
00187 }
00188 
00189 
00190 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines