solidChemistryModel.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) 2023 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 
30 #include "reactingMixture.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class CompType, class SolidThermo>
36 (
37  typename CompType::reactionThermo& thermo
38 )
39 :
40  CompType(thermo),
41  ODESystem(),
42  Ys_(this->solidThermo().composition().Y()),
43  reactions_
44  (
45  dynamic_cast<const reactingMixture<SolidThermo>&>
46  (
47  this->solidThermo()
48  )
49  ),
50  solidThermo_
51  (
52  dynamic_cast<const reactingMixture<SolidThermo>&>
53  (
54  this->solidThermo()
55  ).speciesData()
56  ),
57  nSolids_(Ys_.size()),
58  nReaction_(reactions_.size()),
59  RRs_(nSolids_),
60  reactingCells_(this->mesh().nCells(), true)
61 {
62  // create the fields for the chemistry sources
63  forAll(RRs_, fieldi)
64  {
65  RRs_.set
66  (
67  fieldi,
69  (
70  IOobject
71  (
72  "RRs." + Ys_[fieldi].name(),
73  this->mesh().time().timeName(),
74  this->mesh(),
77  ),
78  this->mesh(),
80  )
81  );
82  }
83 }
84 
85 
86 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
87 
88 template<class CompType, class SolidThermo>
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class CompType, class SolidThermo>
98 (
99  const scalarField& deltaT
100 )
101 {
103  return 0;
104 }
105 
106 
107 template<class CompType, class SolidThermo>
110 {
112  return volScalarField::null();
113 }
114 
115 
116 template<class CompType, class SolidThermo>
119 {
120  auto tQdot = volScalarField::New
121  (
122  "Qdot",
124  this->mesh_,
126  );
127  scalarField& Qdot = tQdot.ref();
128 
129  if (this->chemistry_)
130  {
131  forAll(Ys_, i)
132  {
133  forAll(Qdot, celli)
134  {
135  scalar hf = solidThermo_[i].Hc();
136  Qdot[celli] -= hf*RRs_[i][celli];
137  }
138  }
139  }
141  return tQdot;
142 }
143 
144 
145 template<class CompType, class SolidThermo>
147 (
148  const label celli,
149  const bool active
150 )
151 {
152  reactingCells_[celli] = active;
153 }
154 
155 // ************************************************************************* //
Foam::reactingMixture.
Abstract base class for the systems of ordinary differential equations.
Definition: ODESystem.H:43
void setCellReacting(const label celli, const bool active)
Set reacting status of cell, celli.
basicSpecieMixture & composition
Ignore writing from objectRegistry::writeObject()
Extends base solid chemistry model by adding a thermo package, and ODE functions. ...
virtual ~solidChemistryModel()
Destructor.
scalar Qdot
Definition: solveChemistry.H:2
PtrList< volScalarField::Internal > RRs_
List of reaction rate per solid [kg/m3/s].
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
virtual tmp< volScalarField > tc() const
Return the chemical time scale.
word timeName
Definition: getTimeIndex.H:3
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:58
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
virtual scalar solve(const scalar deltaT)=0
Solve the reaction system for the given time step.
static const GeometricField< scalar, fvPatchField, volMesh > & null() noexcept
Return a null GeometricField (reference to a nullObject).
virtual tmp< volScalarField > Qdot() const
Return the heat release rate [kg/m/s3].
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
Fundamental solid thermodynamic properties.
Definition: solidThermo.H:48
const dimensionSet dimEnergy
PtrList< volScalarField > & Ys_
Reference to solid mass fractions.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
PtrList< volScalarField > & Y
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Nothing to be read.
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:49
A class for managing temporary objects.
Definition: HashPtrTable.H:50
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:696
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
Do not request registration (bool: false)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127