ode.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-------------------------------------------------------------------------------
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 "ode.H"
29
30// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31
32template<class ChemistryModel>
34:
35 chemistrySolver<ChemistryModel>(thermo),
36 coeffsDict_(this->subDict("odeCoeffs")),
37 odeSolver_(ODESolver::New(*this, coeffsDict_)),
38 cTp_(this->nEqns())
39{}
40
41
42// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43
44template<class ChemistryModel>
46{}
47
48
49// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50
51template<class ChemistryModel>
53(
54 scalarField& c,
55 scalar& T,
56 scalar& p,
57 scalar& deltaT,
58 scalar& subDeltaT
59) const
60{
61 // Reset the size of the ODE system to the simplified size when mechanism
62 // reduction is active
63 if (odeSolver_->resize())
64 {
65 odeSolver_->resizeField(cTp_);
66 }
67
68 const label nSpecie = this->nSpecie();
69
70 // Copy the concentration, T and P to the total solve-vector
71 for (int i=0; i<nSpecie; i++)
72 {
73 cTp_[i] = c[i];
74 }
75 cTp_[nSpecie] = T;
76 cTp_[nSpecie+1] = p;
77
78 odeSolver_->solve(0, deltaT, cTp_, subDeltaT);
79
80 for (int i=0; i<nSpecie; i++)
81 {
82 c[i] = max(0.0, cTp_[i]);
83 }
84 T = cTp_[nSpecie];
85 p = cTp_[nSpecie+1];
86}
87
88
89// ************************************************************************* //
ReactionThermo reactionThermo
Thermo type.
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:57
An abstract base class for solving chemistry.
An ODE solver for chemistry.
Definition: ode.H:55
virtual ~ode()
Destructor.
Definition: ode.C:45
Basic thermodynamics type based on the use of fitting functions for cp, h, s obtained from the templa...
volScalarField & p
const volScalarField & T
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
label nSpecie
CEqn solve()