singleStepCombustion.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 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 "singleStepCombustion.H"
30 #include "fvmSup.H"
31 
32 namespace Foam
33 {
34 namespace combustionModels
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
39 template<class ReactionThermo, class ThermoType>
40 singleStepCombustion<ReactionThermo, ThermoType>::singleStepCombustion
41 (
42  const word& modelType,
43  ReactionThermo& thermo,
45  const word& combustionProperties
46 )
47 :
49  singleMixturePtr_(nullptr),
50  wFuel_
51  (
52  IOobject
53  (
54  this->thermo().phasePropertyName("wFuel"),
55  this->mesh().time().timeName(),
56  this->mesh(),
59  ),
60  this->mesh(),
62  ),
63  semiImplicit_(this->coeffs_.getBool("semiImplicit"))
64 {
66  {
67  singleMixturePtr_ =
69  (
70  this->thermo()
71  );
72  }
73  else
74  {
76  << "Inconsistent thermo package for " << this->type() << " model:\n"
77  << " " << this->thermo().type() << nl << nl
78  << "Please select a thermo package based on "
79  << "singleStepReactingMixture" << exit(FatalError);
80  }
81 
82  if (semiImplicit_)
83  {
84  Info<< "Combustion mode: semi-implicit" << endl;
85  }
86  else
87  {
88  Info<< "Combustion mode: explicit" << endl;
89  }
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
95 template<class ReactionThermo, class ThermoType>
97 {}
98 
99 
100 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
101 
102 template<class ReactionThermo, class ThermoType>
104 (
106 ) const
107 {
108  const label specieI =
109  this->thermo().composition().species()[Y.member()];
110 
111  volScalarField wSpecie
112  (
113  wFuel_*singleMixturePtr_->specieStoichCoeffs()[specieI]
114  );
115 
116  if (semiImplicit_)
117  {
118  const label fNorm = singleMixturePtr_->specieProd()[specieI];
119  const volScalarField fres(singleMixturePtr_->fres(specieI));
120  wSpecie /= max(fNorm*(Y - fres), scalar(1e-2));
121 
122  return -fNorm*wSpecie*fres + scalar(fNorm)*fvm::Sp(wSpecie, Y);
123  }
124 
125  return wSpecie + fvm::Sp(0.0*wSpecie, Y);
126 }
127 
128 
129 template<class ReactionThermo, class ThermoType>
132 {
133  const label fuelI = singleMixturePtr_->fuelIndex();
134  volScalarField& YFuel =
135  const_cast<volScalarField&>(this->thermo().composition().Y(fuelI));
136 
137  return -singleMixturePtr_->qFuel()*(R(YFuel) & YFuel);
138 }
139 
140 
141 template<class ReactionThermo, class ThermoType>
143 {
145  {
146  return true;
147  }
148 
149  return false;
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace combustionModels
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
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
singleStepCombustion.H
thermo
psiReactionThermo & thermo
Definition: createFields.H:28
thermo
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
Foam::ThermoCombustion
Thermo model wrapper for combustion models.
Definition: ThermoCombustion.H:52
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::combustionModels::singleStepCombustion::Qdot
virtual tmp< volScalarField > Qdot() const
Heat release rate [kg/m/s3].
Definition: singleStepCombustion.C:131
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:53
R
#define R(A, B, C, D, E, F, K, M)
Foam::fvm::Sp
tmp< fvMatrix< Type > > Sp(const volScalarField::Internal &, const GeometricField< Type, fvPatchField, volMesh > &)
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dimMass
const dimensionSet dimMass(1, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:51
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
fvmSup.H
Calculate the matrix for implicit and explicit sources.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::isA
const TargetType * isA(const Type &t)
Check if dynamic_cast to TargetType is possible.
Definition: typeInfo.H:197
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::singleStepReactingMixture
Single step reacting mixture.
Definition: singleStepReactingMixture.H:55
Foam::combustionModels::singleStepCombustion::~singleStepCombustion
virtual ~singleStepCombustion()
Destructor.
Definition: singleStepCombustion.C:96
Foam::combustionModels::singleStepCombustion::read
virtual bool read()
Update properties from given dictionary.
Definition: singleStepCombustion.C:142
Foam::dimVolume
const dimensionSet dimVolume(pow3(dimLength))
Definition: dimensionSets.H:60
Foam::GeometricField< scalar, fvPatchField, volMesh >
turb
compressible::turbulenceModel & turb
Definition: setRegionFluidFields.H:10
Foam::IOobject::NO_READ
Definition: IOobject.H:188
Foam::compressibleTurbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: compressibleTurbulenceModel.H:54
Foam::combustionModels::singleStepCombustion::R
virtual tmp< fvScalarMatrix > R(volScalarField &Y) const
Fuel consumption rate matrix.
Definition: singleStepCombustion.C:104