1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "radiativeIntensityRay.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 Foam::label Foam::radiation::radiativeIntensityRay::rayId(0);
36 Foam::radiation::radiativeIntensityRay::intensityPrefix("ILambda");
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
47 const scalar deltaPhi,
48 const scalar deltaTheta,
50 const absorptionEmissionModel& absorptionEmission,
51 const blackBodyEmission& blackBody
56 absorptionEmission_(absorptionEmission),
57 blackBody_(blackBody),
63 mesh_.time().timeName(),
69 dimensionedScalar("I", dimMass/pow3(dimTime), 0.0)
76 mesh_.time().timeName(),
82 dimensionedScalar("Qr", dimMass/pow3(dimTime), 0.0)
92 scalar sinTheta = Foam::sin(theta);
93 scalar cosTheta = Foam::cos(theta);
94 scalar sinPhi = Foam::sin(phi);
95 scalar cosPhi = Foam::cos(phi);
97 omega_ = 2.0*sinTheta*Foam::sin(deltaTheta/2.0)*deltaPhi;
98 d_ = vector(sinTheta*sinPhi, sinTheta*cosPhi, cosTheta);
102 *Foam::sin(0.5*deltaPhi)
103 *(deltaTheta - Foam::cos(2.0*theta)
104 *Foam::sin(deltaTheta)),
106 *Foam::sin(0.5*deltaPhi)
107 *(deltaTheta - Foam::cos(2.0*theta)
108 *Foam::sin(deltaTheta)),
109 0.5*deltaPhi*Foam::sin(2.0*theta)*Foam::sin(deltaTheta)
113 autoPtr<volScalarField> IDefaultPtr;
115 forAll(ILambda_, lambdaI)
119 intensityPrefix + "_" + name(rayId) + "_" + name(lambdaI),
120 mesh_.time().timeName(),
126 // check if field exists and can be read
127 if (IHeader.headerOk())
132 new volScalarField(IHeader, mesh_)
137 // Demand driven load the IDefault field
138 if (!IDefaultPtr.valid())
147 mesh_.time().timeName(),
157 // Reset the MUST_READ flag
158 IOobject noReadHeader(IHeader);
159 noReadHeader.readOpt() = IOobject::NO_READ;
164 new volScalarField(noReadHeader, IDefaultPtr())
172 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
174 Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay()
178 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
180 Foam::scalar Foam::radiation::radiativeIntensityRay::correct()
182 // reset boundary heat flux to zero
183 //Qr_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
184 Qr_.boundaryField() = 0.0;
186 scalar maxResidual = -GREAT;
188 forAll(ILambda_, lambdaI)
190 const volScalarField& k = dom_.aLambda(lambdaI);
192 surfaceScalarField Ji = dAve_ & mesh_.Sf();
196 fvm::div(Ji, ILambda_[lambdaI], "div(Ji,Ii_h)")
197 + fvm::Sp(k*omega_, ILambda_[lambdaI])
199 1.0/Foam::mathematicalConstant::pi*omega_
201 k*blackBody_.bLambda(lambdaI)
202 + absorptionEmission_.ECont(lambdaI)
208 scalar eqnResidual = solve
214 maxResidual = max(eqnResidual, maxResidual);
221 void Foam::radiation::radiativeIntensityRay::addIntensity()
223 I_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
225 forAll(ILambda_, lambdaI)
227 I_ += absorptionEmission_.addIntensity(lambdaI, ILambda_[lambdaI]);
232 // ************************************************************************* //