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

radiativeIntensityRay.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) 2008-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 "radiativeIntensityRay.H"
00028 #include "fvm.H"
00029 #include "fvDOM.H"
00030 
00031 #include "absorptionEmissionModel.H"
00032 #include "scatterModel.H"
00033 #include "mathematicalConstants.H"
00034 #include "radiationConstants.H"
00035 #include "radiationModel.H"
00036 #include "Vector2D.H"
00037 
00038 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00039 
00040 Foam::label Foam::radiation::radiativeIntensityRay::rayId(0);
00041 
00042 const Foam::word
00043 Foam::radiation::radiativeIntensityRay::intensityPrefix("ILambda");
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
00049 (
00050     const fvDOM& dom,
00051     const fvMesh& mesh,
00052     const scalar phi,
00053     const scalar theta,
00054     const scalar deltaPhi,
00055     const scalar deltaTheta,
00056     const label nLambda,
00057     const absorptionEmissionModel& absorptionEmission,
00058     const blackBodyEmission& blackBody
00059 )
00060 :
00061     dom_(dom),
00062     mesh_(mesh),
00063     absorptionEmission_(absorptionEmission),
00064     blackBody_(blackBody),
00065     I_
00066     (
00067         IOobject
00068         (
00069             "I" + name(rayId),
00070             mesh_.time().timeName(),
00071             mesh_,
00072             IOobject::NO_READ,
00073             IOobject::NO_WRITE
00074         ),
00075         mesh_,
00076         dimensionedScalar("I", dimMass/pow3(dimTime), 0.0)
00077     ),
00078     Qr_
00079     (
00080         IOobject
00081         (
00082             "Qr" + name(rayId),
00083             mesh_.time().timeName(),
00084             mesh_,
00085             IOobject::NO_READ,
00086             IOobject::NO_WRITE
00087         ),
00088         mesh_,
00089         dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
00090     ),
00091     d_(vector::zero),
00092     dAve_(vector::zero),
00093     theta_(theta),
00094     phi_(phi),
00095     omega_(0.0),
00096     nLambda_(nLambda),
00097     ILambda_(nLambda)
00098 {
00099     scalar sinTheta = Foam::sin(theta);
00100     scalar cosTheta = Foam::cos(theta);
00101     scalar sinPhi = Foam::sin(phi);
00102     scalar cosPhi = Foam::cos(phi);
00103 
00104     omega_ = 2.0*sinTheta*Foam::sin(deltaTheta/2.0)*deltaPhi;
00105     d_ = vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
00106     dAve_ = vector
00107     (
00108         sinPhi
00109        *Foam::sin(0.5*deltaPhi)
00110        *(deltaTheta - Foam::cos(2.0*theta)
00111        *Foam::sin(deltaTheta)),
00112         cosPhi
00113        *Foam::sin(0.5*deltaPhi)
00114        *(deltaTheta - Foam::cos(2.0*theta)
00115        *Foam::sin(deltaTheta)),
00116         0.5*deltaPhi*Foam::sin(2.0*theta)*Foam::sin(deltaTheta)
00117     );
00118 
00119 
00120     autoPtr<volScalarField> IDefaultPtr;
00121 
00122     forAll(ILambda_, lambdaI)
00123     {
00124         IOobject IHeader
00125         (
00126             intensityPrefix + "_" + name(rayId) + "_" + name(lambdaI),
00127             mesh_.time().timeName(),
00128             mesh_,
00129             IOobject::MUST_READ,
00130             IOobject::AUTO_WRITE
00131         );
00132 
00133         // check if field exists and can be read
00134         if (IHeader.headerOk())
00135         {
00136             ILambda_.set
00137             (
00138                 lambdaI,
00139                 new volScalarField(IHeader, mesh_)
00140             );
00141         }
00142         else
00143         {
00144             // Demand driven load the IDefault field
00145             if (!IDefaultPtr.valid())
00146             {
00147                 IDefaultPtr.reset
00148                 (
00149                     new volScalarField
00150                     (
00151                         IOobject
00152                         (
00153                             "IDefault",
00154                             mesh_.time().timeName(),
00155                             mesh_,
00156                             IOobject::MUST_READ,
00157                             IOobject::NO_WRITE
00158                         ),
00159                         mesh_
00160                     )
00161                 );
00162             }
00163 
00164             // Reset the MUST_READ flag
00165             IOobject noReadHeader(IHeader);
00166             noReadHeader.readOpt() = IOobject::NO_READ;
00167 
00168             ILambda_.set
00169             (
00170                 lambdaI,
00171                 new volScalarField(noReadHeader, IDefaultPtr())
00172             );
00173         }
00174     }
00175     rayId++;
00176 }
00177 
00178 
00179 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00180 
00181 Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay()
00182 {}
00183 
00184 
00185 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00186 
00187 Foam::scalar Foam::radiation::radiativeIntensityRay::correct()
00188 {
00189     // reset boundary heat flux to zero
00190     //Qr_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
00191     Qr_.boundaryField() = 0.0;
00192 
00193     scalar maxResidual = -GREAT;
00194 
00195     forAll(ILambda_, lambdaI)
00196     {
00197         const volScalarField& k = dom_.aLambda(lambdaI);
00198 
00199         surfaceScalarField Ji = dAve_ & mesh_.Sf();
00200 
00201         fvScalarMatrix IiEq
00202         (
00203             fvm::div(Ji, ILambda_[lambdaI], "div(Ji,Ii_h)")
00204           + fvm::Sp(k*omega_, ILambda_[lambdaI])
00205          ==
00206             1.0/Foam::mathematicalConstant::pi
00207            *(
00208                 k*omega_*blackBody_.bLambda(lambdaI)
00209               + absorptionEmission_.ECont(lambdaI)
00210             )
00211         );
00212 
00213         IiEq.relax();
00214 
00215         scalar eqnResidual = solve
00216         (
00217             IiEq,
00218             mesh_.solver("Ii")
00219         ).initialResidual();
00220 
00221         maxResidual = max(eqnResidual, maxResidual);
00222     }
00223 
00224     return maxResidual;
00225 }
00226 
00227 
00228 void Foam::radiation::radiativeIntensityRay::addIntensity()
00229 {
00230     I_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
00231 
00232     forAll(ILambda_, lambdaI)
00233     {
00234         I_ += absorptionEmission_.addIntensity(lambdaI, ILambda_[lambdaI]);
00235     }
00236 }
00237 
00238 
00239 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd