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 | Copyright (C) 2011-2015 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 #include "chemistryModel.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class ChemistryModel>
33 (
34  const fvMesh& mesh,
35  const word& phaseName
36 )
37 :
39  coeffsDict_(this->subDict("odeCoeffs")),
40  odeSolver_(ODESolver::New(*this, coeffsDict_)),
41  cTp_(this->nEqns())
42 {}
43 
44 
45 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
46 
47 template<class ChemistryModel>
49 {}
50 
51 
52 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
53 
54 template<class ChemistryModel>
56 (
57  scalarField& c,
58  scalar& T,
59  scalar& p,
60  scalar& deltaT,
61  scalar& subDeltaT
62 ) const
63 {
64  label nSpecie = this->nSpecie();
65 
66  // Copy the concentration, T and P to the total solve-vector
67  for (int i=0; i<nSpecie; i++)
68  {
69  cTp_[i] = c[i];
70  }
71  cTp_[nSpecie] = T;
72  cTp_[nSpecie+1] = p;
73 
74  odeSolver_->solve(0, deltaT, cTp_, subDeltaT);
75 
76  for (int i=0; i<nSpecie; i++)
77  {
78  c[i] = max(0.0, cTp_[i]);
79  }
80  T = cTp_[nSpecie];
81  p = cTp_[nSpecie+1];
82 }
83 
84 
85 // ************************************************************************* //
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::ode::ode
ode(const fvMesh &mesh, const word &phaseName)
Construct from mesh and phase name.
Definition: ode.C:33
Foam::chemistrySolver
An abstract base class for solving chemistry.
Definition: chemistrySolver.H:51
nSpecie
label nSpecie
Definition: readInitialConditions.H:17
Foam::ode::~ode
virtual ~ode()
Destructor.
Definition: ode.C:48
ode.H
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
chemistryModel.H
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
T
const volScalarField & T
Definition: createFields.H:25
Foam::ode::solve
virtual void solve(scalarField &c, scalar &T, scalar &p, scalar &deltaT, scalar &subDeltaT) const
Update the concentrations and return the chemical time.
Definition: ode.C:56
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.