P1.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "P1.H"
30 #include "fvmLaplacian.H"
31 #include "fvmSup.H"
33 #include "scatterModel.H"
34 #include "constants.H"
36 
37 using namespace Foam::constant;
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43  namespace radiation
44  {
47  }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
53 Foam::radiation::P1::P1(const volScalarField& T)
54 :
55  radiationModel(typeName, T),
56  G_
57  (
58  IOobject
59  (
60  "G",
61  mesh_.time().timeName(),
62  mesh_,
63  IOobject::MUST_READ,
64  IOobject::AUTO_WRITE
65  ),
66  mesh_
67  ),
68  qr_
69  (
70  IOobject
71  (
72  "qr",
73  mesh_.time().timeName(),
74  mesh_,
75  IOobject::READ_IF_PRESENT,
76  IOobject::AUTO_WRITE
77  ),
78  mesh_,
80  ),
81  a_
82  (
83  IOobject
84  (
85  "a",
86  mesh_.time().timeName(),
87  mesh_,
88  IOobject::NO_READ,
89  IOobject::AUTO_WRITE
90  ),
91  mesh_,
93  ),
94  e_
95  (
96  IOobject
97  (
98  "e",
99  mesh_.time().timeName(),
100  mesh_,
101  IOobject::NO_READ,
102  IOobject::NO_WRITE
103  ),
104  mesh_,
106  ),
107  E_
108  (
109  IOobject
110  (
111  "E",
112  mesh_.time().timeName(),
113  mesh_,
114  IOobject::NO_READ,
115  IOobject::NO_WRITE
116  ),
117  mesh_,
119  )
120 {}
121 
122 
123 Foam::radiation::P1::P1(const dictionary& dict, const volScalarField& T)
124 :
125  radiationModel(typeName, dict, T),
126  G_
127  (
128  IOobject
129  (
130  "G",
131  mesh_.time().timeName(),
132  mesh_,
133  IOobject::MUST_READ,
134  IOobject::AUTO_WRITE
135  ),
136  mesh_
137  ),
138  qr_
139  (
140  IOobject
141  (
142  "qr",
143  mesh_.time().timeName(),
144  mesh_,
145  IOobject::READ_IF_PRESENT,
146  IOobject::AUTO_WRITE
147  ),
148  mesh_,
150  ),
151  a_
152  (
153  IOobject
154  (
155  "a",
156  mesh_.time().timeName(),
157  mesh_,
158  IOobject::NO_READ,
159  IOobject::AUTO_WRITE
160  ),
161  mesh_,
163  ),
164  e_
165  (
166  IOobject
167  (
168  "e",
169  mesh_.time().timeName(),
170  mesh_,
171  IOobject::NO_READ,
172  IOobject::NO_WRITE
173  ),
174  mesh_,
176  ),
177  E_
178  (
179  IOobject
180  (
181  "E",
182  mesh_.time().timeName(),
183  mesh_,
184  IOobject::NO_READ,
185  IOobject::NO_WRITE
186  ),
187  mesh_,
189  )
190 {}
191 
192 
193 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
194 
196 {
197  if (radiationModel::read())
198  {
199  // nothing to read
200 
201  return true;
202  }
203 
204  return false;
205 }
206 
207 
209 {
210  a_ = absorptionEmission_->a();
211  e_ = absorptionEmission_->e();
212  E_ = absorptionEmission_->E();
213  const volScalarField sigmaEff(scatter_->sigmaEff());
214 
215  const dimensionedScalar a0("a0", a_.dimensions(), ROOTVSMALL);
216 
217  // Construct diffusion
218  const volScalarField gamma
219  (
220  IOobject
221  (
222  "gammaRad",
223  G_.mesh().time().timeName(),
224  G_.mesh(),
227  ),
228  1.0/(3.0*a_ + sigmaEff + a0)
229  );
230 
231  // Solve G transport equation
232  solve
233  (
234  fvm::laplacian(gamma, G_)
235  - fvm::Sp(a_, G_)
236  ==
237  - 4.0*(e_*physicoChemical::sigma*pow4(T_)) - E_
238  );
239 
240  // Calculate radiative heat flux on boundaries.
241  volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
242  const volScalarField::Boundary& GBf = G_.boundaryField();
243  const volScalarField::Boundary& gammaBf = gamma.boundaryField();
244 
245  forAll(mesh_.boundaryMesh(), patchi)
246  {
247  if (!GBf[patchi].coupled())
248  {
249  qrBf[patchi] = -gammaBf[patchi]*GBf[patchi].snGrad();
250  }
251  }
252 }
253 
254 
256 {
257  return tmp<volScalarField>
258  (
259  new volScalarField
260  (
261  IOobject
262  (
263  "Rp",
264  mesh_.time().timeName(),
265  mesh_,
268  false
269  ),
270  4.0*absorptionEmission_->eCont()*physicoChemical::sigma
271  )
272  );
273 }
274 
275 
278 {
279  const volScalarField::Internal& G = G_();
280  const volScalarField::Internal E = absorptionEmission_->ECont()()();
281  const volScalarField::Internal a = absorptionEmission_->aCont()()();
282 
283  return a*G - E;
284 }
285 
286 
287 Foam::label Foam::radiation::P1::nBands() const
288 {
289  return absorptionEmission_->nBands();
290 }
291 
292 
293 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:195
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
scatterModel.H
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::constant::universal::G
const dimensionedScalar G
Newtonian constant of gravitation.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::constant
Different types of constants.
Definition: atomicConstants.C:38
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
Foam::pow4
dimensionedScalar pow4(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:100
Foam::radiation::P1::read
bool read()
Read radiation properties dictionary.
Definition: P1.C:195
Foam::radiation::radiationModel::read
virtual bool read()=0
Read radiationProperties dictionary.
Definition: radiationModel.C:210
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::pow3
dimensionedScalar pow3(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:89
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:48
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
Foam::radiation::P1::Rp
virtual tmp< volScalarField > Rp() const
Source term component (for power of T^4)
Definition: P1.C:255
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:58
Foam::solve
SolverPerformance< Type > solve(faMatrix< Type > &, Istream &)
Solve returning the solution statistics given convergence tolerance.
radiation
autoPtr< radiation::radiationModel > radiation(radiation::radiationModel::New(T))
timeName
word timeName
Definition: getTimeIndex.H:3
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned< scalar >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Foam::radiation::P1::Ru
virtual tmp< volScalarField::Internal > Ru() const
Source term component (constant)
Definition: P1.C:277
constants.H
fvmSup.H
Calculate the matrix for implicit and explicit sources.
Foam::constant::atomic::a0
const dimensionedScalar a0
Bohr radius: default SI units: [m].
absorptionEmissionModel.H
Foam::radiation::radiationModel
Top level model for radiation modelling.
Definition: radiationModel.H:75
Foam::radiation::P1::calculate
void calculate()
Solve radiation equation(s)
Definition: P1.C:208
gamma
const scalar gamma
Definition: EEqn.H:9
Foam::radiation::P1::nBands
label nBands() const
Number of bands.
Definition: P1.C:287
addToRadiationRunTimeSelectionTables
#define addToRadiationRunTimeSelectionTables(model)
Definition: radiationModel.H:288
coupled
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
sigma
dimensionedScalar sigma("sigma", dimMass/sqr(dimTime), transportProperties)
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::IOobject::NO_READ
Definition: IOobject.H:188
P1.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::dimless
const dimensionSet dimless
Dimensionless.
Definition: dimensionSets.C:189