Loading...
Searching...
No Matches
thermoPyrolysis.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) 2016-2019 OpenCFD Ltd
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "thermoPyrolysis.H"
30#include "volFields.H"
32#include "fvm.H"
33#include "fvcLaplacian.H"
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace regionModels
42{
43
44// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
46defineTypeNameAndDebug(thermo, 0);
47addToRunTimeSelectionTable(pyrolysisModel, thermo, mesh);
48addToRunTimeSelectionTable(pyrolysisModel, thermo, dictionary);
49
50// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
51
54 const dictionary& solution = this->solution().subDict("SIMPLE");
55 solution.readEntry("nNonOrthCorr", nNonOrthCorr_);
56 time().controlDict().readEntry("maxDi", maxDiff_);
57}
58
59
60bool thermo::read()
61{
63 {
65 return true;
66 }
67
68 return false;
69}
70
71
72bool thermo::read(const dictionary& dict)
73{
75 {
77 return true;
78 }
80 return false;
81}
82
83
84// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
85
86thermo::thermo
87(
88 const word& modelType,
89 const fvMesh& mesh,
90 const word& regionType
91)
92:
93 pyrolysisModel(modelType, mesh, regionType),
94 solidThermo_(solidThermo::New(regionMesh())),
95 radiation_(radiation::radiationModel::New(solidThermo_->T())),
96 nNonOrthCorr_(-1),
97 maxDiff_(10)
98{
99 if (active())
100 {
101 readControls();
102 }
103}
104
105
106thermo::thermo
107(
108 const word& modelType,
109 const fvMesh& mesh,
110 const dictionary& dict,
111 const word& regionType
112)
113:
114 pyrolysisModel(modelType, mesh, dict, regionType),
115 solidThermo_(solidThermo::New(regionMesh())),
116 radiation_(radiation::radiationModel::New(solidThermo_->T())),
117 nNonOrthCorr_(-1),
118 maxDiff_(10)
119{
120 if (active())
121 {
123 }
124}
125
126
127// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
130{}
131
132
133// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
134
136{
137 if (active())
138 {
140 }
141}
142
143
145{
146 if (active())
147 {
148 Info<< "\nEvolving energy in region: " << regionMesh().name() << endl;
149
151
152 for (int nonOrth=0; nonOrth<=nNonOrthCorr_; nonOrth++)
153 {
155 fvScalarMatrix hEqn
156 (
157 fvm::ddt(rho(), h)
160 - fvc::laplacian(solidThermo_->kappa(), T())
161 );
162
163 hEqn.relax();
164 hEqn.solve();
166
167 solidThermo_->correct();
168 }
169}
170
172const volScalarField& thermo::rho() const
173{
174 return solidThermo_->rho();
175}
176
178const volScalarField& thermo::T() const
179{
180 return solidThermo_->T();
181}
182
185{
186 return solidThermo_->Cp();
187}
188
191{
192 return radiation_->absorptionEmission().a();
193}
194
197{
198 return solidThermo_->kappa();
199}
200
201
203{
205 << "phiGas field not available for " << type() << abort(FatalError);
207}
208
209
210// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211
212} // End namespace surfaceFilmModels
213} // End namespace regionModels
214} // End namespace Foam
215
216// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const dictionary & controlDict() const noexcept
Return read access to the controlDict dictionary.
Definition Time.H:539
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
void relax(const scalar alpha)
Relax matrix (for steady-state solution).
Definition fvMatrix.C:1094
SolverPerformance< Type > solve(const dictionary &)
Solve returning the solution statistics.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const word & name() const
Return reference to name.
Definition fvMesh.H:387
Top level model for radiation modelling.
static autoPtr< pyrolysisModel > New(const fvMesh &mesh, const word &regionType="pyrolysis")
Return a reference to the selected pyrolysis model.
virtual bool read()
Read control parameters.
Pyrolysis model which solves only the energy equation in the region.
virtual const volScalarField & rho() const
Return density [kg/m3].
virtual tmp< volScalarField > kappa() const
Return the region thermal conductivity [W/m/k].
virtual const volScalarField & T() const
Return const temperature [K].
virtual tmp< volScalarField > kappaRad() const
Return the region absorptivity [1/m].
virtual const tmp< volScalarField > Cp() const
Return specific heat capacity [J/kg/K].
virtual void preEvolveRegion()
Pre-evolve region.
autoPtr< radiation::radiationModel > radiation_
Pointer to radiation model.
autoPtr< solidThermo > solidThermo_
Pointer to the solid chemistry model.
virtual const surfaceScalarField & phiGas() const
Return the total gas mass flux to primary region [kg/m2/s].
label nNonOrthCorr_
Number of non-orthogonal correctors.
virtual bool read()
Read control parameters from dictionary.
virtual void evolveRegion()
Evolve the pyrolysis equations.
const dictionary & solution() const
Return the solution dictionary.
Switch active() const noexcept
Return the active flag.
const Time & time() const noexcept
Return the reference to the time database.
const fvMesh & regionMesh() const
Return the region mesh database.
virtual void preEvolveRegion()
Pre-evolve region.
Fundamental solid thermodynamic properties.
Definition solidThermo.H:51
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
Calculate the laplacian of the given field.
tmp< GeometricField< Type, fvPatchField, volMesh > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
tmp< fvMatrix< Type > > ddt(const GeometricField< Type, fvPatchField, volMesh > &vf)
Definition fvmDdt.C:41
Namespace for radiation modelling.
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
fvMatrix< scalar > fvScalarMatrix
GeometricField< scalar, fvPatchField, volMesh > volScalarField
messageStream Info
Information stream (stdout output on master, null elsewhere).
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition POSIX.C:801
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
volScalarField & alpha
dictionary dict
volScalarField & h