1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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.
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
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "EulerImplicit.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "simpleMatrix.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 template<class ODEChemistryType>
33 Foam::EulerImplicit<ODEChemistryType>::EulerImplicit
36 const word& ODEModelName,
37 const word& thermoType
40 chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType),
41 coeffsDict_(this->subDict("EulerImplicitCoeffs")),
42 cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
43 eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter"))
47 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
49 template<class ODEChemistryType>
50 Foam::EulerImplicit<ODEChemistryType>::~EulerImplicit()
54 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 template<class ODEChemistryType>
57 Foam::scalar Foam::EulerImplicit<ODEChemistryType>::solve
66 scalar pf, cf, pr, cr;
69 const label nSpecie = this->nSpecie();
70 simpleMatrix<scalar> RR(nSpecie, 0, 0);
72 for (label i = 0; i < nSpecie; i++)
74 c[i] = max(0.0, c[i]);
77 for (label i = 0; i < nSpecie; i++)
79 RR.source()[i] = c[i]/dt;
82 forAll(this->reactions(), i)
84 scalar omegai = this->omegaI(i, c, T, p, pf, cf, lRef, pr, cr, rRef);
91 corr = 1.0/(1.0 + pr*dt);
95 corr = 1.0/(1.0 + pf*dt);
99 this->updateRRInReactionI(i, pr, pf, corr, lRef, rRef, RR);
103 for (label i = 0; i < nSpecie; i++)
109 for (label i = 0; i < nSpecie; i++)
111 c[i] = max(0.0, c[i]);
114 // estimate the next time step
116 const label nEqns = this->nEqns();
117 scalarField c1(nEqns, 0.0);
119 for (label i = 0; i < nSpecie; i++)
126 scalarField dcdt(nEqns, 0.0);
127 this->derivatives(0.0, c1, dcdt);
129 const scalar sumC = sum(c);
131 for (label i = 0; i < nSpecie; i++)
136 tMin = min(tMin, -(c[i] + SMALL)/d);
141 scalar cm = max(sumC - c[i], 1.0e-5);
142 tMin = min(tMin, cm/d);
146 return cTauChem_*tMin;
150 // ************************************************************************* //