ode.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "ode.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class ChemistryModel>
32 :
33  chemistrySolver<ChemistryModel>(thermo),
34  odeSolver_(ODESolver::New(*this, this->subDict("odeCoeffs"))),
35  cTp_(this->nEqns())
36 {}
37 
38 
39 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
40 
41 template<class ChemistryModel>
43 {}
44 
45 
46 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47 
48 template<class ChemistryModel>
50 (
51  scalar& p,
52  scalar& T,
53  scalarField& c,
54  const label li,
55  scalar& deltaT,
56  scalar& subDeltaT
57 ) const
58 {
59  // Reset the size of the ODE system to the simplified size when mechanism
60  // reduction is active
61  if (odeSolver_->resize())
62  {
63  odeSolver_->resizeField(cTp_);
64  }
65 
66  const label nSpecie = this->nSpecie();
67 
68  // Copy the concentration, T and P to the total solve-vector
69  for (int i=0; i<nSpecie; i++)
70  {
71  cTp_[i] = c[i];
72  }
73  cTp_[nSpecie] = T;
74  cTp_[nSpecie+1] = p;
75 
76  if (debug)
77  {
78  scalarField dcTp(this->nEqns(), rootSmall);
79  dcTp[nSpecie] = T*rootSmall;
80  dcTp[nSpecie+1] = p*rootSmall;
81  this->check(0, cTp_, dcTp, li);
82  }
83 
84  odeSolver_->solve(0, deltaT, cTp_, li, subDeltaT);
85 
86  for (int i=0; i<nSpecie; i++)
87  {
88  c[i] = max(0.0, cTp_[i]);
89  }
90  T = cTp_[nSpecie];
91  p = cTp_[nSpecie+1];
92 }
93 
94 
95 // ************************************************************************* //
Abstract base-class for ODE system solvers.
Definition: ODESolver.H:51
An abstract base class for solving chemistry.
Base-class for multi-component fluid thermodynamic properties.
virtual void solve(scalar &p, scalar &T, scalarField &c, const label li, scalar &deltaT, scalar &subDeltaT) const
Update the concentrations and return the chemical time.
Definition: ode.C:50
ode(const fluidMulticomponentThermo &thermo)
Construct from thermo.
Definition: ode.C:31
virtual ~ode()
Destructor.
Definition: ode.C:42
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
const dimensionedScalar c
Speed of light in a vacuum.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const label nSpecie
volScalarField & p
fluidMulticomponentThermo & thermo
Definition: createFields.H:31