chemistryTabulationMethods: Untemplated to simply the code and reduce compilation time
With the changes to chemistryModel to evaluate and integrate reaction rates mass-fraction based rather than mole-fraction based ISAT is now independent of the thermodynamics and with some restructuring of chemistryModel and the addition of the non-templated base-class odeChemistryModel is has been possible to un-template chemistryTabulationMethods and ISAT in particular. This simplifies the ISAT code and hence maintenance as well as reducing the compilation time of chemistryModel on the various thermo packages.
This commit is contained in:
@ -91,12 +91,10 @@ namespace Foam
|
||||
#if ${method}CppTest == chemistryModelCppTest
|
||||
|
||||
#include "makeChemistryReductionMethod.H"
|
||||
#include "makeChemistryTabulationMethod.H"
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineChemistryReductionMethod(nullArg, ThermoPhysics);
|
||||
defineChemistryTabulationMethod(nullArg, ThermoPhysics);
|
||||
}
|
||||
|
||||
#include "noChemistryReduction.H"
|
||||
@ -116,14 +114,6 @@ namespace Foam
|
||||
makeChemistryReductionMethod(PFA, ThermoPhysics);
|
||||
}
|
||||
|
||||
#include "noChemistryTabulation.H"
|
||||
#include "ISAT.H"
|
||||
namespace Foam
|
||||
{
|
||||
makeChemistryTabulationMethod(none, ThermoPhysics);
|
||||
makeChemistryTabulationMethod(ISAT, ThermoPhysics);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@ -6,6 +6,8 @@ chemistrySolver/noChemistrySolver/noChemistrySolvers.C
|
||||
chemistrySolver/EulerImplicit/EulerImplicitChemistrySolvers.C
|
||||
chemistrySolver/ode/odeChemistrySolvers.C
|
||||
|
||||
odeChemistryModel/odeChemistryModel.C
|
||||
|
||||
chemistryModel/reduction/chemistryReductionMethod/chemistryReductionMethods.C
|
||||
chemistryModel/reduction/noChemistryReduction/noChemistryReductionMethods.C
|
||||
chemistryModel/reduction/DAC/DACChemistryReductionMethods.C
|
||||
@ -14,9 +16,13 @@ chemistryModel/reduction/DRGEP/DRGEPChemistryReductionMethods.C
|
||||
chemistryModel/reduction/EFA/EFAChemistryReductionMethods.C
|
||||
chemistryModel/reduction/PFA/PFAChemistryReductionMethods.C
|
||||
|
||||
chemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethods.C
|
||||
chemistryModel/tabulation/noChemistryTabulation/noChemistryTabulationMethods.C
|
||||
chemistryModel/tabulation/ISAT/ISATChemistryTabulationMethods.C
|
||||
chemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethod.C
|
||||
chemistryModel/tabulation/chemistryTabulationMethod/chemistryTabulationMethodNew.C
|
||||
chemistryModel/tabulation/noChemistryTabulation/noChemistryTabulation.C
|
||||
chemistryModel/tabulation/ISAT/ISAT.C
|
||||
chemistryModel/tabulation/ISAT/chemPointISAT/chemPointISAT.C
|
||||
chemistryModel/tabulation/ISAT/binaryNode/binaryNode.C
|
||||
chemistryModel/tabulation/ISAT/binaryTree/binaryTree.C
|
||||
|
||||
reactions/makeReactions.C
|
||||
|
||||
|
||||
@ -36,8 +36,7 @@ Foam::chemistryModel<ThermoType>::chemistryModel
|
||||
const fluidReactionThermo& thermo
|
||||
)
|
||||
:
|
||||
basicChemistryModel(thermo),
|
||||
ODESystem(),
|
||||
odeChemistryModel(thermo),
|
||||
log_(this->lookupOrDefault("log", false)),
|
||||
loadBalancing_(this->lookupOrDefault("loadBalancing", false)),
|
||||
jacobianType_
|
||||
@ -46,18 +45,14 @@ Foam::chemistryModel<ThermoType>::chemistryModel
|
||||
? jacobianTypeNames_.read(this->lookup("jacobian"))
|
||||
: jacobianType::fast
|
||||
),
|
||||
Yvf_(this->thermo().composition().Y()),
|
||||
mixture_(refCast<const multiComponentMixture<ThermoType>>(this->thermo())),
|
||||
specieThermos_(mixture_.specieThermos()),
|
||||
reactions_(mixture_.species(), specieThermos_, this->mesh(), *this),
|
||||
nSpecie_(Yvf_.size()),
|
||||
RR_(nSpecie_),
|
||||
Y_(nSpecie_),
|
||||
c_(nSpecie_),
|
||||
YTpWork_(scalarField(nSpecie_ + 2)),
|
||||
YTpYTpWork_(scalarSquareMatrix(nSpecie_ + 2)),
|
||||
cTos_(nSpecie_, -1),
|
||||
sToc_(nSpecie_),
|
||||
mechRedPtr_
|
||||
(
|
||||
chemistryReductionMethod<ThermoType>::New
|
||||
@ -67,15 +62,7 @@ Foam::chemistryModel<ThermoType>::chemistryModel
|
||||
)
|
||||
),
|
||||
mechRed_(*mechRedPtr_),
|
||||
mechRedActive_(mechRed_.active()),
|
||||
tabulationPtr_
|
||||
(
|
||||
chemistryTabulationMethod<ThermoType>::New
|
||||
(
|
||||
*this,
|
||||
*this
|
||||
)
|
||||
),
|
||||
tabulationPtr_(chemistryTabulationMethod::New(*this, *this)),
|
||||
tabulation_(*tabulationPtr_)
|
||||
{
|
||||
// Create the fields for the chemistry sources
|
||||
@ -105,7 +92,7 @@ Foam::chemistryModel<ThermoType>::chemistryModel
|
||||
|
||||
// When the mechanism reduction method is used, the 'active' flag for every
|
||||
// species should be initialised (by default 'active' is true)
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
const basicSpecieMixture& composition = this->thermo().composition();
|
||||
|
||||
@ -153,7 +140,7 @@ void Foam::chemistryModel<ThermoType>::derivatives
|
||||
scalarField& dYTpdt
|
||||
) const
|
||||
{
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
forAll(sToc_, i)
|
||||
{
|
||||
@ -198,7 +185,7 @@ void Foam::chemistryModel<ThermoType>::derivatives
|
||||
c_,
|
||||
li,
|
||||
dYTpdt,
|
||||
mechRedActive_,
|
||||
reduction_,
|
||||
cTos_,
|
||||
0
|
||||
);
|
||||
@ -246,7 +233,7 @@ void Foam::chemistryModel<ThermoType>::jacobian
|
||||
scalarSquareMatrix& J
|
||||
) const
|
||||
{
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
forAll(sToc_, i)
|
||||
{
|
||||
@ -334,7 +321,7 @@ void Foam::chemistryModel<ThermoType>::jacobian
|
||||
li,
|
||||
dYTpdt,
|
||||
ddNdtByVdcTp,
|
||||
mechRedActive_,
|
||||
reduction_,
|
||||
cTos_,
|
||||
0,
|
||||
nSpecie_,
|
||||
@ -688,7 +675,7 @@ void Foam::chemistryModel<ThermoType>::calculate()
|
||||
c_,
|
||||
celli,
|
||||
dNdtByV,
|
||||
mechRedActive_,
|
||||
reduction_,
|
||||
cTos_,
|
||||
0
|
||||
);
|
||||
@ -796,7 +783,7 @@ Foam::scalar Foam::chemistryModel<ThermoType>::solve
|
||||
// (it will either expand the current data or add a new stored point).
|
||||
else
|
||||
{
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
// Compute concentrations
|
||||
for (label i=0; i<nSpecie_; i++)
|
||||
@ -825,7 +812,7 @@ Foam::scalar Foam::chemistryModel<ThermoType>::solve
|
||||
while (timeLeft > small)
|
||||
{
|
||||
scalar dt = timeLeft;
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
// Solve the reduced set of ODE
|
||||
solve
|
||||
@ -880,7 +867,7 @@ Foam::scalar Foam::chemistryModel<ThermoType>::solve
|
||||
// When operations are done and if mechanism reduction is active,
|
||||
// the number of species (which also affects nEqns) is set back
|
||||
// to the total number of species (stored in the mechRed object)
|
||||
if (mechRedActive_)
|
||||
if (reduction_)
|
||||
{
|
||||
setNSpecie(mechRed_.nSpecie());
|
||||
}
|
||||
@ -911,7 +898,7 @@ Foam::scalar Foam::chemistryModel<ThermoType>::solve
|
||||
mechRed_.update();
|
||||
tabulation_.update();
|
||||
|
||||
if (mechRedActive_ && Pstream::parRun())
|
||||
if (reduction_ && Pstream::parRun())
|
||||
{
|
||||
List<bool> active(composition.active());
|
||||
Pstream::listCombineGather(active, orEqOp<bool>());
|
||||
|
||||
@ -66,7 +66,7 @@ SourceFiles
|
||||
#ifndef chemistryModel_H
|
||||
#define chemistryModel_H
|
||||
|
||||
#include "basicChemistryModel.H"
|
||||
#include "odeChemistryModel.H"
|
||||
#include "ReactionList.H"
|
||||
#include "ODESystem.H"
|
||||
#include "volFields.H"
|
||||
@ -74,7 +74,6 @@ SourceFiles
|
||||
#include "chemistryReductionMethod.H"
|
||||
#include "chemistryTabulationMethod.H"
|
||||
#include "DynamicField.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -88,8 +87,7 @@ namespace Foam
|
||||
template<class ThermoType>
|
||||
class chemistryModel
|
||||
:
|
||||
public basicChemistryModel,
|
||||
public ODESystem
|
||||
public odeChemistryModel
|
||||
{
|
||||
// Private classes
|
||||
|
||||
@ -136,9 +134,6 @@ class chemistryModel
|
||||
//- Type of the Jacobian to be calculated
|
||||
const jacobianType jacobianType_;
|
||||
|
||||
//- Reference to the field of specie mass fractions
|
||||
const PtrList<volScalarField>& Yvf_;
|
||||
|
||||
//- Reference to the multi component mixture
|
||||
const multiComponentMixture<ThermoType>& mixture_;
|
||||
|
||||
@ -148,9 +143,6 @@ class chemistryModel
|
||||
//- Reactions
|
||||
const ReactionList<ThermoType> reactions_;
|
||||
|
||||
//- Number of species
|
||||
label nSpecie_;
|
||||
|
||||
//- List of reaction rate per specie [kg/m^3/s]
|
||||
PtrList<volScalarField::Internal> RR_;
|
||||
|
||||
@ -172,27 +164,17 @@ class chemistryModel
|
||||
//- Specie-temperature-pressure workspace matrices
|
||||
mutable FixedList<scalarSquareMatrix, 2> YTpYTpWork_;
|
||||
|
||||
//- Temporary map from complete to simplified concentration fields
|
||||
// c -> sc
|
||||
List<label> cTos_;
|
||||
|
||||
//- Temporary map from simplified to complete concentration fields
|
||||
// sc -> c
|
||||
DynamicList<label> sToc_;
|
||||
|
||||
//- Mechanism reduction method
|
||||
autoPtr<chemistryReductionMethod<ThermoType>> mechRedPtr_;
|
||||
|
||||
//- Mechanism reduction method reference
|
||||
chemistryReductionMethod<ThermoType>& mechRed_;
|
||||
|
||||
bool mechRedActive_;
|
||||
|
||||
//- Tabulation method
|
||||
autoPtr<chemistryTabulationMethod<ThermoType>> tabulationPtr_;
|
||||
autoPtr<chemistryTabulationMethod> tabulationPtr_;
|
||||
|
||||
//- Tabulation method reference
|
||||
chemistryTabulationMethod<ThermoType>& tabulation_;
|
||||
chemistryTabulationMethod& tabulation_;
|
||||
|
||||
//- Log file for average time spent solving the chemistry
|
||||
autoPtr<OFstream> cpuSolveFile_;
|
||||
@ -232,9 +214,6 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Create and return a TDAC log file of the given name
|
||||
inline autoPtr<OFstream> logFile(const word& name) const;
|
||||
|
||||
//- Return reference to the mixture
|
||||
inline const multiComponentMixture<ThermoType>& mixture() const;
|
||||
|
||||
@ -244,9 +223,6 @@ public:
|
||||
//- Thermodynamic data of the species
|
||||
inline const PtrList<ThermoType>& specieThermos() const;
|
||||
|
||||
//- The number of species
|
||||
virtual inline label nSpecie() const;
|
||||
|
||||
//- The number of reactions
|
||||
virtual inline label nReaction() const;
|
||||
|
||||
@ -293,9 +269,6 @@ public:
|
||||
|
||||
// ODE functions (overriding abstract functions in ODE.H)
|
||||
|
||||
//- Number of ODE's to solve
|
||||
inline virtual label nEqns() const;
|
||||
|
||||
virtual void derivatives
|
||||
(
|
||||
const scalar t,
|
||||
@ -324,32 +297,14 @@ public:
|
||||
) const = 0;
|
||||
|
||||
|
||||
//- Return a reference to the list of mass fraction fields
|
||||
inline const PtrList<volScalarField>& Y() const;
|
||||
|
||||
|
||||
// Mechanism reduction access functions
|
||||
|
||||
//- Return true if mechanism reduction is active
|
||||
inline bool reduction() const;
|
||||
|
||||
//- Allow the reduction method to reset the number of species
|
||||
inline void setNSpecie(const label newNs);
|
||||
|
||||
//- Return true if specie i is active
|
||||
inline bool active(const label i) const;
|
||||
|
||||
//- Set specie i active
|
||||
inline void setActive(const label i);
|
||||
|
||||
//- Return the index in the complete set of species
|
||||
// corresponding to the index si in the simplified set of species
|
||||
inline label sToc(const label si) const;
|
||||
|
||||
//- Return the index in the simplified set of species
|
||||
// corresponding to the index si in the complete set of species
|
||||
inline label cTos(const label ci) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -23,32 +23,8 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::autoPtr<Foam::OFstream>
|
||||
Foam::chemistryModel<ThermoType>::logFile(const word& name) const
|
||||
{
|
||||
mkDir(this->mesh().time().path()/"TDAC"/this->group());
|
||||
return autoPtr<OFstream>
|
||||
(
|
||||
new OFstream
|
||||
(
|
||||
this->mesh().time().path()/"TDAC"/this->group()/name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::label Foam::chemistryModel<ThermoType>::nEqns() const
|
||||
{
|
||||
// nEqns = number of species + temperature + pressure
|
||||
return nSpecie_ + 2;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::PtrList<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>&
|
||||
Foam::chemistryModel<ThermoType>::RR()
|
||||
@ -81,13 +57,6 @@ Foam::chemistryModel<ThermoType>::specieThermos() const
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::label Foam::chemistryModel<ThermoType>::nSpecie() const
|
||||
{
|
||||
return nSpecie_;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::label Foam::chemistryModel<ThermoType>::nReaction() const
|
||||
{
|
||||
@ -102,6 +71,7 @@ Foam::chemistryModel<ThermoType>::RR(const label i) const
|
||||
return RR_[i];
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::DimensionedField<Foam::scalar, Foam::volMesh>&
|
||||
Foam::chemistryModel<ThermoType>::RR(const label i)
|
||||
@ -110,21 +80,6 @@ Foam::chemistryModel<ThermoType>::RR(const label i)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline const Foam::PtrList<Foam::volScalarField>&
|
||||
Foam::chemistryModel<ThermoType>::Y() const
|
||||
{
|
||||
return this->Yvf_;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline bool Foam::chemistryModel<ThermoType>::reduction() const
|
||||
{
|
||||
return mechRedActive_;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline void Foam::chemistryModel<ThermoType>::setActive(const label i)
|
||||
{
|
||||
@ -139,45 +94,4 @@ inline bool Foam::chemistryModel<ThermoType>::active(const label i) const
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline void Foam::chemistryModel<ThermoType>::setNSpecie(const label newNs)
|
||||
{
|
||||
this->nSpecie_ = newNs;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::label Foam::chemistryModel<ThermoType>::sToc
|
||||
(
|
||||
const label si
|
||||
) const
|
||||
{
|
||||
if (mechRedActive_)
|
||||
{
|
||||
return sToc_[si];
|
||||
}
|
||||
else
|
||||
{
|
||||
return si;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
inline Foam::label Foam::chemistryModel<ThermoType>::cTos
|
||||
(
|
||||
const label ci
|
||||
) const
|
||||
{
|
||||
if (mechRedActive_)
|
||||
{
|
||||
return cTos_[ci];
|
||||
}
|
||||
else
|
||||
{
|
||||
return ci;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -86,10 +86,14 @@ Foam::chemistryReductionMethod<ThermoType>::New
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<chemistryReductionMethod<ThermoType>>
|
||||
autoPtr<chemistryReductionMethod<ThermoType>> crmPtr
|
||||
(
|
||||
cstrIter()(dict, chemistry)
|
||||
);
|
||||
|
||||
chemistry.reduction_ = crmPtr->active();
|
||||
|
||||
return crmPtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -24,18 +24,32 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ISAT.H"
|
||||
#include "odeChemistryModel.H"
|
||||
#include "LUscalarMatrix.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace chemistryTabulationMethods
|
||||
{
|
||||
defineTypeNameAndDebug(ISAT, 0);
|
||||
addToRunTimeSelectionTable(chemistryTabulationMethod, ISAT, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethods::ISAT<ThermoType>::ISAT
|
||||
Foam::chemistryTabulationMethods::ISAT::ISAT
|
||||
(
|
||||
const dictionary& chemistryProperties,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
)
|
||||
:
|
||||
chemistryTabulationMethod<ThermoType>
|
||||
chemistryTabulationMethod
|
||||
(
|
||||
chemistryProperties,
|
||||
chemistry
|
||||
@ -135,24 +149,22 @@ Foam::chemistryTabulationMethods::ISAT<ThermoType>::ISAT
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethods::ISAT<ThermoType>::~ISAT()
|
||||
Foam::chemistryTabulationMethods::ISAT::~ISAT()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemistryTabulationMethods::ISAT<ThermoType>::addToMRU
|
||||
void Foam::chemistryTabulationMethods::ISAT::addToMRU
|
||||
(
|
||||
chemPointISAT<ThermoType>* phi0
|
||||
chemPointISAT* phi0
|
||||
)
|
||||
{
|
||||
if (maxMRUSize_ > 0 && MRURetrieve_)
|
||||
{
|
||||
// First search if the chemPoint is already in the list
|
||||
bool isInList = false;
|
||||
typename SLList <chemPointISAT<ThermoType>*>::iterator iter =
|
||||
typename SLList <chemPointISAT*>::iterator iter =
|
||||
MRUList_.begin();
|
||||
for ( ; iter != MRUList_.end(); ++iter)
|
||||
{
|
||||
@ -190,10 +202,9 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::addToMRU
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemistryTabulationMethods::ISAT<ThermoType>::calcNewC
|
||||
void Foam::chemistryTabulationMethods::ISAT::calcNewC
|
||||
(
|
||||
chemPointISAT<ThermoType>* phi0,
|
||||
chemPointISAT* phi0,
|
||||
const scalarField& phiq,
|
||||
scalarField& Rphiq
|
||||
)
|
||||
@ -258,10 +269,9 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::calcNewC
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::grow
|
||||
bool Foam::chemistryTabulationMethods::ISAT::grow
|
||||
(
|
||||
chemPointISAT<ThermoType>* phi0,
|
||||
chemPointISAT* phi0,
|
||||
const scalarField& phiq,
|
||||
const scalarField& Rphiq
|
||||
)
|
||||
@ -296,18 +306,16 @@ bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::grow
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool
|
||||
Foam::chemistryTabulationMethods::ISAT<ThermoType>::cleanAndBalance()
|
||||
bool Foam::chemistryTabulationMethods::ISAT::cleanAndBalance()
|
||||
{
|
||||
bool treeModified(false);
|
||||
|
||||
// Check all chemPoints to see if we need to delete some of the chemPoints
|
||||
// according to the elapsed time and number of growths
|
||||
chemPointISAT<ThermoType>* x = chemisTree_.treeMin();
|
||||
chemPointISAT* x = chemisTree_.treeMin();
|
||||
while(x != nullptr)
|
||||
{
|
||||
chemPointISAT<ThermoType>* xtmp = chemisTree_.treeSuccessor(x);
|
||||
chemPointISAT* xtmp = chemisTree_.treeSuccessor(x);
|
||||
|
||||
const scalar elapsedTimeSteps = timeSteps() - x->timeTag();
|
||||
|
||||
@ -341,8 +349,7 @@ Foam::chemistryTabulationMethods::ISAT<ThermoType>::cleanAndBalance()
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemistryTabulationMethods::ISAT<ThermoType>::computeA
|
||||
void Foam::chemistryTabulationMethods::ISAT::computeA
|
||||
(
|
||||
scalarSquareMatrix& A,
|
||||
const scalarField& Rphiq,
|
||||
@ -400,8 +407,7 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::computeA
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::retrieve
|
||||
bool Foam::chemistryTabulationMethods::ISAT::retrieve
|
||||
(
|
||||
const Foam::scalarField& phiq,
|
||||
scalarField& Rphiq
|
||||
@ -413,7 +419,7 @@ bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::retrieve
|
||||
}
|
||||
|
||||
bool retrieved(false);
|
||||
chemPointISAT<ThermoType>* phi0;
|
||||
chemPointISAT* phi0;
|
||||
|
||||
// If the tree is not empty
|
||||
if (chemisTree_.size())
|
||||
@ -437,7 +443,7 @@ bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::retrieve
|
||||
{
|
||||
typename SLList
|
||||
<
|
||||
chemPointISAT<ThermoType>*
|
||||
chemPointISAT*
|
||||
>::iterator iter = MRUList_.begin();
|
||||
|
||||
for ( ; iter != MRUList_.end(); ++iter)
|
||||
@ -485,8 +491,7 @@ bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::retrieve
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
|
||||
Foam::label Foam::chemistryTabulationMethods::ISAT::add
|
||||
(
|
||||
const scalarField& phiq,
|
||||
const scalarField& Rphiq,
|
||||
@ -534,20 +539,20 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
|
||||
// It can be partially rebuild with the MRU list if this is used.
|
||||
if (!cleanAndBalance())
|
||||
{
|
||||
DynamicList<chemPointISAT<ThermoType>*> tempList;
|
||||
DynamicList<chemPointISAT*> tempList;
|
||||
if (maxMRUSize_>0)
|
||||
{
|
||||
// Create a copy of each chemPointISAT of the MRUList_ before
|
||||
// they are deleted
|
||||
typename SLList
|
||||
<
|
||||
chemPointISAT<ThermoType>*
|
||||
chemPointISAT*
|
||||
>::iterator iter = MRUList_.begin();
|
||||
for ( ; iter != MRUList_.end(); ++iter)
|
||||
{
|
||||
tempList.append
|
||||
(
|
||||
new chemPointISAT<ThermoType>(*iter())
|
||||
new chemPointISAT(*iter())
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -558,7 +563,7 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
|
||||
|
||||
// Construct the tree without giving a reference to attach to it
|
||||
// since the structure has been completely discarded
|
||||
chemPointISAT<ThermoType>* nulPhi = 0;
|
||||
chemPointISAT* nulPhi = 0;
|
||||
forAll(tempList, i)
|
||||
{
|
||||
chemisTree().insertNewLeaf
|
||||
@ -614,8 +619,7 @@ Foam::label Foam::chemistryTabulationMethods::ISAT<ThermoType>::add
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemistryTabulationMethods::ISAT<ThermoType>::writePerformance()
|
||||
void Foam::chemistryTabulationMethods::ISAT::writePerformance()
|
||||
{
|
||||
if (log_)
|
||||
{
|
||||
@ -653,8 +657,7 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::writePerformance()
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemistryTabulationMethods::ISAT<ThermoType>::reset()
|
||||
void Foam::chemistryTabulationMethods::ISAT::reset()
|
||||
{
|
||||
// Increment counter of time-step
|
||||
timeSteps_++;
|
||||
@ -666,8 +669,7 @@ void Foam::chemistryTabulationMethods::ISAT<ThermoType>::reset()
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemistryTabulationMethods::ISAT<ThermoType>::update()
|
||||
bool Foam::chemistryTabulationMethods::ISAT::update()
|
||||
{
|
||||
bool updated = cleanAndBalance();
|
||||
writePerformance();
|
||||
|
||||
@ -41,7 +41,11 @@ Description
|
||||
#ifndef ISAT_H
|
||||
#define ISAT_H
|
||||
|
||||
#include "chemistryTabulationMethod.H"
|
||||
#include "binaryTree.H"
|
||||
#include "volFields.H"
|
||||
#include "OFstream.H"
|
||||
#include "cpuTime.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -54,16 +58,15 @@ namespace chemistryTabulationMethods
|
||||
Class ISAT Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class ISAT
|
||||
:
|
||||
public chemistryTabulationMethod<ThermoType>
|
||||
public chemistryTabulationMethod
|
||||
{
|
||||
// Private Data
|
||||
|
||||
const dictionary coeffsDict_;
|
||||
|
||||
const chemistryModel<ThermoType>& chemistry_;
|
||||
const odeChemistryModel& chemistry_;
|
||||
|
||||
//- Switch to select performance logging
|
||||
Switch log_;
|
||||
@ -72,7 +75,7 @@ class ISAT
|
||||
const bool reduction_;
|
||||
|
||||
//- List of the stored 'points' organised in a binary tree
|
||||
binaryTree<ThermoType> chemisTree_;
|
||||
binaryTree chemisTree_;
|
||||
|
||||
//- List of scale factors for species, temperature and pressure
|
||||
scalarField scaleFactor_;
|
||||
@ -101,13 +104,13 @@ class ISAT
|
||||
Switch MRURetrieve_;
|
||||
|
||||
//- Most Recently Used (MRU) list of chemPoint
|
||||
SLList<chemPointISAT<ThermoType>*> MRUList_;
|
||||
SLList<chemPointISAT*> MRUList_;
|
||||
|
||||
//- Maximum size of the MRU list
|
||||
label maxMRUSize_;
|
||||
|
||||
//- Store a pointer to the last chemPointISAT found
|
||||
chemPointISAT<ThermoType>* lastSearch_;
|
||||
chemPointISAT* lastSearch_;
|
||||
|
||||
//- Switch to allow growth (on by default)
|
||||
Switch growPoints_;
|
||||
@ -150,7 +153,7 @@ class ISAT
|
||||
// Private Member Functions
|
||||
|
||||
//- Add a chemPoint to the MRU list
|
||||
void addToMRU(chemPointISAT<ThermoType>* phi0);
|
||||
void addToMRU(chemPointISAT* phi0);
|
||||
|
||||
//- Compute and return the mapping of the composition phiq
|
||||
// Input : phi0 the nearest chemPoint used in the linear interpolation
|
||||
@ -161,7 +164,7 @@ class ISAT
|
||||
// Rphiq = Rphi0 + A * (phiq-phi0)
|
||||
void calcNewC
|
||||
(
|
||||
chemPointISAT<ThermoType>* phi0,
|
||||
chemPointISAT* phi0,
|
||||
const scalarField& phiq,
|
||||
scalarField& Rphiq
|
||||
);
|
||||
@ -175,7 +178,7 @@ class ISAT
|
||||
// Output: true if phiq is in the EOA, false if not
|
||||
bool grow
|
||||
(
|
||||
chemPointISAT<ThermoType>* phi0,
|
||||
chemPointISAT* phi0,
|
||||
const scalarField& phiq,
|
||||
const scalarField& Rphiq
|
||||
);
|
||||
@ -216,7 +219,7 @@ public:
|
||||
ISAT
|
||||
(
|
||||
const dictionary& chemistryProperties,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
@ -241,12 +244,12 @@ public:
|
||||
return reduction_;
|
||||
}
|
||||
|
||||
const chemistryModel<ThermoType>& chemistry()
|
||||
const odeChemistryModel& chemistry()
|
||||
{
|
||||
return chemistry_;
|
||||
}
|
||||
|
||||
inline binaryTree<ThermoType>& chemisTree()
|
||||
inline binaryTree& chemisTree()
|
||||
{
|
||||
return chemisTree_;
|
||||
}
|
||||
@ -298,12 +301,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ISAT.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -24,11 +24,11 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "binaryNode.H"
|
||||
#include "ISAT.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::binaryNode<ThermoType>::binaryNode()
|
||||
Foam::binaryNode::binaryNode()
|
||||
:
|
||||
leafLeft_(nullptr),
|
||||
leafRight_(nullptr),
|
||||
@ -38,12 +38,11 @@ Foam::binaryNode<ThermoType>::binaryNode()
|
||||
{}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::binaryNode<ThermoType>::binaryNode
|
||||
Foam::binaryNode::binaryNode
|
||||
(
|
||||
chemPointISAT<ThermoType>* elementLeft,
|
||||
chemPointISAT<ThermoType>* elementRight,
|
||||
binaryNode<ThermoType>* parent
|
||||
chemPointISAT* elementLeft,
|
||||
chemPointISAT* elementRight,
|
||||
binaryNode* parent
|
||||
)
|
||||
:
|
||||
leafLeft_(elementLeft),
|
||||
@ -60,11 +59,10 @@ Foam::binaryNode<ThermoType>::binaryNode
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryNode<ThermoType>::calcV
|
||||
void Foam::binaryNode::calcV
|
||||
(
|
||||
chemPointISAT<ThermoType>*& elementLeft,
|
||||
chemPointISAT<ThermoType>*& elementRight,
|
||||
chemPointISAT*& elementLeft,
|
||||
chemPointISAT*& elementRight,
|
||||
scalarField& v
|
||||
)
|
||||
{
|
||||
@ -140,11 +138,10 @@ void Foam::binaryNode<ThermoType>::calcV
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::scalar Foam::binaryNode<ThermoType>::calcA
|
||||
Foam::scalar Foam::binaryNode::calcA
|
||||
(
|
||||
chemPointISAT<ThermoType>* elementLeft,
|
||||
chemPointISAT<ThermoType>* elementRight
|
||||
chemPointISAT* elementLeft,
|
||||
chemPointISAT* elementRight
|
||||
)
|
||||
{
|
||||
scalarField phih((elementLeft->phi() + elementRight->phi())/2);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -46,26 +46,25 @@ namespace Foam
|
||||
Class binaryNode Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class binaryNode
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//- Element on the left
|
||||
chemPointISAT<ThermoType>* leafLeft_;
|
||||
chemPointISAT* leafLeft_;
|
||||
|
||||
//- Element on the right
|
||||
chemPointISAT<ThermoType>* leafRight_;
|
||||
chemPointISAT* leafRight_;
|
||||
|
||||
//- Node which follows on the left
|
||||
binaryNode<ThermoType>* nodeLeft_;
|
||||
binaryNode* nodeLeft_;
|
||||
|
||||
//- Node which follows on the right
|
||||
binaryNode<ThermoType>* nodeRight_;
|
||||
binaryNode* nodeRight_;
|
||||
|
||||
//- Parent node
|
||||
binaryNode<ThermoType>* parent_;
|
||||
binaryNode* parent_;
|
||||
|
||||
scalarField v_;
|
||||
|
||||
@ -102,8 +101,8 @@ public:
|
||||
// Returnq: void (v is stored in the empty scalarField)
|
||||
void calcV
|
||||
(
|
||||
chemPointISAT<ThermoType>*& elementLeft,
|
||||
chemPointISAT<ThermoType>*& elementRight,
|
||||
chemPointISAT*& elementLeft,
|
||||
chemPointISAT*& elementRight,
|
||||
scalarField& v
|
||||
);
|
||||
|
||||
@ -115,8 +114,8 @@ public:
|
||||
// part (where phi0 is).
|
||||
scalar calcA
|
||||
(
|
||||
chemPointISAT<ThermoType>* elementLeft,
|
||||
chemPointISAT<ThermoType>* elementRight
|
||||
chemPointISAT* elementLeft,
|
||||
chemPointISAT* elementRight
|
||||
);
|
||||
|
||||
// Constructors
|
||||
@ -127,9 +126,9 @@ public:
|
||||
//- Construct from components
|
||||
binaryNode
|
||||
(
|
||||
chemPointISAT<ThermoType>* elementLeft,
|
||||
chemPointISAT<ThermoType>* elementRight,
|
||||
binaryNode<ThermoType>* parent
|
||||
chemPointISAT* elementLeft,
|
||||
chemPointISAT* elementRight,
|
||||
binaryNode* parent
|
||||
);
|
||||
|
||||
|
||||
@ -137,27 +136,27 @@ public:
|
||||
|
||||
//- Access
|
||||
|
||||
inline chemPointISAT<ThermoType>*& leafLeft()
|
||||
inline chemPointISAT*& leafLeft()
|
||||
{
|
||||
return leafLeft_;
|
||||
}
|
||||
|
||||
inline chemPointISAT<ThermoType>*& leafRight()
|
||||
inline chemPointISAT*& leafRight()
|
||||
{
|
||||
return leafRight_;
|
||||
}
|
||||
|
||||
inline binaryNode<ThermoType>*& nodeLeft()
|
||||
inline binaryNode*& nodeLeft()
|
||||
{
|
||||
return nodeLeft_;
|
||||
}
|
||||
|
||||
inline binaryNode<ThermoType>*& nodeRight()
|
||||
inline binaryNode*& nodeRight()
|
||||
{
|
||||
return nodeRight_;
|
||||
}
|
||||
|
||||
inline binaryNode<ThermoType>*& parent()
|
||||
inline binaryNode*& parent()
|
||||
{
|
||||
return parent_;
|
||||
}
|
||||
@ -192,12 +191,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "binaryNode.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -25,11 +25,11 @@ License
|
||||
|
||||
#include "binaryTree.H"
|
||||
#include "SortableList.H"
|
||||
#include "demandDrivenData.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::insertNode(chP*& phi0, bn*& newNode)
|
||||
void Foam::binaryTree::insertNode(chP*& phi0, bn*& newNode)
|
||||
{
|
||||
if (phi0 == phi0->node()->leafRight())// phi0 is on the right
|
||||
{
|
||||
@ -52,8 +52,7 @@ void Foam::binaryTree<ThermoType>::insertNode(chP*& phi0, bn*& newNode)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::binaryTree<ThermoType>::inSubTree
|
||||
bool Foam::binaryTree::inSubTree
|
||||
(
|
||||
const scalarField& phiq,
|
||||
bn* y,
|
||||
@ -157,8 +156,7 @@ bool Foam::binaryTree<ThermoType>::inSubTree
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::deleteSubTree(bn* subTreeRoot)
|
||||
void Foam::binaryTree::deleteSubTree(bn* subTreeRoot)
|
||||
{
|
||||
if (subTreeRoot != nullptr)
|
||||
{
|
||||
@ -171,8 +169,7 @@ void Foam::binaryTree<ThermoType>::deleteSubTree(bn* subTreeRoot)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::transplant(bn* u, bn* v)
|
||||
void Foam::binaryTree::transplant(bn* u, bn* v)
|
||||
{
|
||||
if (v != nullptr)
|
||||
{
|
||||
@ -208,9 +205,7 @@ void Foam::binaryTree<ThermoType>::transplant(bn* u, bn* v)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>*
|
||||
Foam::binaryTree<ThermoType>::chemPSibling(bn* y)
|
||||
Foam::chemPointISAT* Foam::binaryTree::chemPSibling(bn* y)
|
||||
{
|
||||
if (y->parent() != nullptr)
|
||||
{
|
||||
@ -237,9 +232,7 @@ Foam::binaryTree<ThermoType>::chemPSibling(bn* y)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>*
|
||||
Foam::binaryTree<ThermoType>::chemPSibling(chP* x)
|
||||
Foam::chemPointISAT* Foam::binaryTree::chemPSibling(chP* x)
|
||||
{
|
||||
if (size_>1)
|
||||
{
|
||||
@ -267,8 +260,7 @@ Foam::binaryTree<ThermoType>::chemPSibling(chP* x)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::binaryNode<ThermoType>* Foam::binaryTree<ThermoType>::nodeSibling(bn* y)
|
||||
Foam::binaryNode* Foam::binaryTree::nodeSibling(bn* y)
|
||||
{
|
||||
if (y->parent()!=nullptr)
|
||||
{
|
||||
@ -293,8 +285,7 @@ Foam::binaryNode<ThermoType>* Foam::binaryTree<ThermoType>::nodeSibling(bn* y)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::binaryNode<ThermoType>* Foam::binaryTree<ThermoType>::nodeSibling(chP* x)
|
||||
Foam::binaryNode* Foam::binaryTree::nodeSibling(chP* x)
|
||||
{
|
||||
if (size_>1)
|
||||
{
|
||||
@ -320,8 +311,7 @@ Foam::binaryNode<ThermoType>* Foam::binaryTree<ThermoType>::nodeSibling(chP* x)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::deleteAllNode(bn* subTreeRoot)
|
||||
void Foam::binaryTree::deleteAllNode(bn* subTreeRoot)
|
||||
{
|
||||
if (subTreeRoot != nullptr)
|
||||
{
|
||||
@ -334,10 +324,9 @@ void Foam::binaryTree<ThermoType>::deleteAllNode(bn* subTreeRoot)
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::binaryTree<ThermoType>::binaryTree
|
||||
Foam::binaryTree::binaryTree
|
||||
(
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table,
|
||||
chemistryTabulationMethods::ISAT& table,
|
||||
dictionary coeffsDict
|
||||
)
|
||||
:
|
||||
@ -352,8 +341,7 @@ Foam::binaryTree<ThermoType>::binaryTree
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::label Foam::binaryTree<ThermoType>::depth(bn* subTreeRoot)
|
||||
Foam::label Foam::binaryTree::depth(bn* subTreeRoot)
|
||||
{
|
||||
// when we reach the leaf, we return 0
|
||||
if (subTreeRoot == nullptr)
|
||||
@ -373,8 +361,7 @@ Foam::label Foam::binaryTree<ThermoType>::depth(bn* subTreeRoot)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::insertNewLeaf
|
||||
void Foam::binaryTree::insertNewLeaf
|
||||
(
|
||||
const scalarField& phiq,
|
||||
const scalarField& Rphiq,
|
||||
@ -459,8 +446,7 @@ void Foam::binaryTree<ThermoType>::insertNewLeaf
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::binaryTreeSearch
|
||||
void Foam::binaryTree::binaryTreeSearch
|
||||
(
|
||||
const scalarField& phiq,
|
||||
bn* node,
|
||||
@ -513,8 +499,7 @@ void Foam::binaryTree<ThermoType>::binaryTreeSearch
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::binaryTree<ThermoType>::secondaryBTSearch
|
||||
bool Foam::binaryTree::secondaryBTSearch
|
||||
(
|
||||
const scalarField& phiq,
|
||||
chP*& x
|
||||
@ -571,8 +556,7 @@ bool Foam::binaryTree<ThermoType>::secondaryBTSearch
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::deleteLeaf(chP*& phi0)
|
||||
void Foam::binaryTree::deleteLeaf(chP*& phi0)
|
||||
{
|
||||
if (size_ == 1) // only one point is stored
|
||||
{
|
||||
@ -634,8 +618,7 @@ void Foam::binaryTree<ThermoType>::deleteLeaf(chP*& phi0)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::balance()
|
||||
void Foam::binaryTree::balance()
|
||||
{
|
||||
//1) walk through the entire tree by starting with the tree's most left
|
||||
// chemPoint
|
||||
@ -727,9 +710,7 @@ void Foam::binaryTree<ThermoType>::balance()
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>*
|
||||
Foam::binaryTree<ThermoType>::treeMin(bn* subTreeRoot)
|
||||
Foam::chemPointISAT* Foam::binaryTree::treeMin(bn* subTreeRoot)
|
||||
{
|
||||
if (subTreeRoot!=nullptr)
|
||||
{
|
||||
@ -746,9 +727,7 @@ Foam::binaryTree<ThermoType>::treeMin(bn* subTreeRoot)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>*
|
||||
Foam::binaryTree<ThermoType>::treeSuccessor(chP* x)
|
||||
Foam::chemPointISAT* Foam::binaryTree::treeSuccessor(chP* x)
|
||||
{
|
||||
if (size_>1)
|
||||
{
|
||||
@ -799,8 +778,7 @@ Foam::binaryTree<ThermoType>::treeSuccessor(chP* x)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::clear()
|
||||
void Foam::binaryTree::clear()
|
||||
{
|
||||
// Recursively delete the element in the subTree
|
||||
deleteSubTree();
|
||||
@ -813,15 +791,13 @@ void Foam::binaryTree<ThermoType>::clear()
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::binaryTree<ThermoType>::isFull()
|
||||
bool Foam::binaryTree::isFull()
|
||||
{
|
||||
return size_ >= maxNLeafs_;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::binaryTree<ThermoType>::resetNumRetrieve()
|
||||
void Foam::binaryTree::resetNumRetrieve()
|
||||
{
|
||||
// Has to go along each chP of the tree
|
||||
if (size_ > 0)
|
||||
|
||||
@ -55,15 +55,14 @@ namespace Foam
|
||||
Class binaryTree Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class binaryTree
|
||||
{
|
||||
public:
|
||||
|
||||
// Public Typedefs
|
||||
|
||||
typedef binaryNode<ThermoType> bn;
|
||||
typedef chemPointISAT<ThermoType> chP;
|
||||
typedef binaryNode bn;
|
||||
typedef chemPointISAT chP;
|
||||
|
||||
|
||||
private:
|
||||
@ -71,7 +70,7 @@ private:
|
||||
// Private Data
|
||||
|
||||
//- Reference to the ISAT table
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table_;
|
||||
chemistryTabulationMethods::ISAT& table_;
|
||||
|
||||
//- Root node of the binary tree
|
||||
bn *root_;
|
||||
@ -105,7 +104,7 @@ private:
|
||||
chP* x
|
||||
);
|
||||
|
||||
void deleteSubTree(binaryNode<ThermoType>* subTreeRoot);
|
||||
void deleteSubTree(binaryNode* subTreeRoot);
|
||||
|
||||
inline void deleteSubTree()
|
||||
{
|
||||
@ -135,7 +134,7 @@ public:
|
||||
//- Construct from dictionary and chemistryOnLineLibrary
|
||||
binaryTree
|
||||
(
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table,
|
||||
chemistryTabulationMethods::ISAT& table,
|
||||
dictionary coeffsDict
|
||||
);
|
||||
|
||||
@ -251,12 +250,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "binaryTree.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -24,19 +24,19 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "chemPointISAT.H"
|
||||
#include "ISAT.H"
|
||||
#include "odeChemistryModel.H"
|
||||
#include "SVD.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// Defined as static to be able to dynamically change it during simulations
|
||||
// (all chemPoints refer to the same object)
|
||||
template<class ThermoType>
|
||||
Foam::scalar Foam::chemPointISAT<ThermoType>::tolerance_;
|
||||
Foam::scalar Foam::chemPointISAT::tolerance_;
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::qrDecompose
|
||||
void Foam::chemPointISAT::qrDecompose
|
||||
(
|
||||
const label nCols,
|
||||
scalarSquareMatrix& R
|
||||
@ -102,8 +102,7 @@ void Foam::chemPointISAT<ThermoType>::qrDecompose
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::qrUpdate
|
||||
void Foam::chemPointISAT::qrUpdate
|
||||
(
|
||||
scalarSquareMatrix& R,
|
||||
const label n,
|
||||
@ -156,8 +155,7 @@ void Foam::chemPointISAT<ThermoType>::qrUpdate
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::rotate
|
||||
void Foam::chemPointISAT::rotate
|
||||
(
|
||||
scalarSquareMatrix& R,
|
||||
const label i,
|
||||
@ -196,10 +194,9 @@ void Foam::chemPointISAT<ThermoType>::rotate
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>::chemPointISAT
|
||||
Foam::chemPointISAT::chemPointISAT
|
||||
(
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table,
|
||||
chemistryTabulationMethods::ISAT& table,
|
||||
const scalarField& phi,
|
||||
const scalarField& Rphi,
|
||||
const scalarSquareMatrix& A,
|
||||
@ -208,7 +205,7 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
|
||||
const label completeSpaceSize,
|
||||
const label nActive,
|
||||
const dictionary& coeffsDict,
|
||||
binaryNode<ThermoType>* node
|
||||
binaryNode* node
|
||||
)
|
||||
:
|
||||
table_(table),
|
||||
@ -299,10 +296,9 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemPointISAT<ThermoType>::chemPointISAT
|
||||
Foam::chemPointISAT::chemPointISAT
|
||||
(
|
||||
Foam::chemPointISAT<ThermoType>& p
|
||||
Foam::chemPointISAT& p
|
||||
)
|
||||
:
|
||||
table_(p.table_),
|
||||
@ -334,8 +330,7 @@ Foam::chemPointISAT<ThermoType>::chemPointISAT
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemPointISAT<ThermoType>::inEOA(const scalarField& phiq)
|
||||
bool Foam::chemPointISAT::inEOA(const scalarField& phiq)
|
||||
{
|
||||
const scalarField dphi(phiq - phi());
|
||||
|
||||
@ -474,8 +469,7 @@ bool Foam::chemPointISAT<ThermoType>::inEOA(const scalarField& phiq)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemPointISAT<ThermoType>::checkSolution
|
||||
bool Foam::chemPointISAT::checkSolution
|
||||
(
|
||||
const scalarField& phiq,
|
||||
const scalarField& Rphiq
|
||||
@ -540,8 +534,7 @@ bool Foam::chemPointISAT<ThermoType>::checkSolution
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
|
||||
bool Foam::chemPointISAT::grow(const scalarField& phiq)
|
||||
{
|
||||
const scalarField dphi(phiq - phi());
|
||||
const label initNActiveSpecies(nActive_);
|
||||
@ -717,29 +710,25 @@ bool Foam::chemPointISAT<ThermoType>::grow(const scalarField& phiq)
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::increaseNumRetrieve()
|
||||
void Foam::chemPointISAT::increaseNumRetrieve()
|
||||
{
|
||||
this->numRetrieve_++;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::resetNumRetrieve()
|
||||
void Foam::chemPointISAT::resetNumRetrieve()
|
||||
{
|
||||
this->numRetrieve_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
void Foam::chemPointISAT<ThermoType>::increaseNLifeTime()
|
||||
void Foam::chemPointISAT::increaseNLifeTime()
|
||||
{
|
||||
this->nLifeTime_++;
|
||||
}
|
||||
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::label Foam::chemPointISAT<ThermoType>::simplifiedToCompleteIndex
|
||||
Foam::label Foam::chemPointISAT::simplifiedToCompleteIndex
|
||||
(
|
||||
const label i
|
||||
)
|
||||
|
||||
@ -122,6 +122,10 @@ Description
|
||||
#ifndef chemPointISAT_H
|
||||
#define chemPointISAT_H
|
||||
|
||||
#include "scalarField.H"
|
||||
#include "LUscalarMatrix.H"
|
||||
#include "Switch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -129,15 +133,10 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
class binaryNode;
|
||||
|
||||
template<class ThermoType>
|
||||
class chemistryModel;
|
||||
|
||||
namespace chemistryTabulationMethods
|
||||
{
|
||||
template<class ThermoType>
|
||||
class ISAT;
|
||||
}
|
||||
|
||||
@ -146,13 +145,12 @@ namespace chemistryTabulationMethods
|
||||
Class chemPointISAT Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class chemPointISAT
|
||||
{
|
||||
// Private Data
|
||||
|
||||
//- Reference to the ISAT table
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table_;
|
||||
chemistryTabulationMethods::ISAT& table_;
|
||||
|
||||
//- Vector storing the composition, temperature and pressure
|
||||
// and deltaT if a variable time step is set on
|
||||
@ -172,7 +170,7 @@ class chemPointISAT
|
||||
scalarField scaleFactor_;
|
||||
|
||||
//- Reference to the node in the binary tree holding this chemPoint
|
||||
binaryNode<ThermoType>* node_;
|
||||
binaryNode* node_;
|
||||
|
||||
//- The size of the composition space (size of the vector phi)
|
||||
label completeSpaceSize_;
|
||||
@ -251,7 +249,7 @@ public:
|
||||
//- Construct from components
|
||||
chemPointISAT
|
||||
(
|
||||
chemistryTabulationMethods::ISAT<ThermoType>& table,
|
||||
chemistryTabulationMethods::ISAT& table,
|
||||
const scalarField& phi,
|
||||
const scalarField& Rphi,
|
||||
const scalarSquareMatrix& A,
|
||||
@ -260,24 +258,24 @@ public:
|
||||
const label completeSpaceSize,
|
||||
const label nActive,
|
||||
const dictionary& coeffsDict,
|
||||
binaryNode<ThermoType>* node = nullptr
|
||||
binaryNode* node = nullptr
|
||||
);
|
||||
|
||||
//- Construct from another chemPoint and reference to a binary node
|
||||
chemPointISAT
|
||||
(
|
||||
const chemPointISAT<ThermoType>& p,
|
||||
binaryNode<ThermoType>* node
|
||||
const chemPointISAT& p,
|
||||
binaryNode* node
|
||||
);
|
||||
|
||||
//- Construct from another chemPoint
|
||||
chemPointISAT(chemPointISAT<ThermoType>& p);
|
||||
chemPointISAT(chemPointISAT& p);
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Access to the ISAT table
|
||||
inline const chemistryTabulationMethods::ISAT<ThermoType>& table() const
|
||||
inline const chemistryTabulationMethods::ISAT& table() const
|
||||
{
|
||||
return table_;
|
||||
}
|
||||
@ -317,7 +315,7 @@ public:
|
||||
tolerance_ = newTol;
|
||||
}
|
||||
|
||||
inline binaryNode<ThermoType>*& node()
|
||||
inline binaryNode*& node()
|
||||
{
|
||||
return node_;
|
||||
}
|
||||
@ -448,12 +446,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "chemPointISAT.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,23 +24,30 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "chemistryTabulationMethod.H"
|
||||
#include "chemistryModel.H"
|
||||
#include "odeChemistryModel.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
defineTypeNameAndDebug(chemistryTabulationMethod, 0);
|
||||
defineRunTimeSelectionTable(chemistryTabulationMethod, dictionary);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethod<ThermoType>::chemistryTabulationMethod
|
||||
Foam::chemistryTabulationMethod::chemistryTabulationMethod
|
||||
(
|
||||
const dictionary& dict,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethod<ThermoType>::~chemistryTabulationMethod()
|
||||
Foam::chemistryTabulationMethod::~chemistryTabulationMethod()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -46,14 +46,12 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
class chemistryModel;
|
||||
class odeChemistryModel;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class chemistryTabulationMethod Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class chemistryTabulationMethod
|
||||
{
|
||||
public:
|
||||
@ -70,7 +68,7 @@ public:
|
||||
dictionary,
|
||||
(
|
||||
const dictionary& dict,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
),
|
||||
(dict, chemistry)
|
||||
);
|
||||
@ -82,7 +80,7 @@ public:
|
||||
chemistryTabulationMethod
|
||||
(
|
||||
const dictionary& dict,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
);
|
||||
|
||||
|
||||
@ -91,7 +89,7 @@ public:
|
||||
static autoPtr<chemistryTabulationMethod> New
|
||||
(
|
||||
const IOdictionary& dict,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
);
|
||||
|
||||
|
||||
@ -142,13 +140,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "chemistryTabulationMethod.C"
|
||||
#include "chemistryTabulationMethodNew.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -29,12 +29,11 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::autoPtr<Foam::chemistryTabulationMethod<ThermoType>>
|
||||
Foam::chemistryTabulationMethod<ThermoType>::New
|
||||
Foam::autoPtr<Foam::chemistryTabulationMethod>
|
||||
Foam::chemistryTabulationMethod::New
|
||||
(
|
||||
const IOdictionary& dict,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
)
|
||||
{
|
||||
if (dict.found("tabulation"))
|
||||
@ -45,57 +44,28 @@ Foam::chemistryTabulationMethod<ThermoType>::New
|
||||
|
||||
Info<< "Selecting chemistry tabulation method " << methodName << endl;
|
||||
|
||||
const word methodTypeName =
|
||||
methodName + '<' + ThermoType::typeName() + '>';
|
||||
|
||||
typename dictionaryConstructorTable::iterator cstrIter =
|
||||
dictionaryConstructorTablePtr_->find(methodTypeName);
|
||||
dictionaryConstructorTablePtr_->find(methodName);
|
||||
|
||||
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown " << typeName_() << " type " << methodName << endl
|
||||
<< endl;
|
||||
|
||||
const wordList names(dictionaryConstructorTablePtr_->sortedToc());
|
||||
|
||||
wordList thisCmpts;
|
||||
thisCmpts.append(word::null);
|
||||
thisCmpts.append
|
||||
(
|
||||
basicThermo::splitThermoName(ThermoType::typeName(), 5)
|
||||
);
|
||||
|
||||
wordList validNames;
|
||||
forAll(names, i)
|
||||
{
|
||||
const wordList cmpts(basicThermo::splitThermoName(names[i], 6));
|
||||
|
||||
if
|
||||
(
|
||||
SubList<word>(cmpts, 5, 1) == SubList<word>(thisCmpts, 5, 1)
|
||||
)
|
||||
{
|
||||
validNames.append(cmpts[0]);
|
||||
}
|
||||
}
|
||||
|
||||
FatalErrorInFunction
|
||||
<< "Valid " << typeName_()
|
||||
<< " types are:" << validNames << endl
|
||||
<< "Valid " << typeName_() << " types are:"
|
||||
<< dictionaryConstructorTablePtr_->sortedToc() << endl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return autoPtr<chemistryTabulationMethod<ThermoType>>
|
||||
return autoPtr<chemistryTabulationMethod>
|
||||
(
|
||||
cstrIter()(dict, chemistry)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
return autoPtr<chemistryTabulationMethod<ThermoType>>
|
||||
return autoPtr<chemistryTabulationMethod>
|
||||
(
|
||||
new chemistryTabulationMethods::none<ThermoType>(dict, chemistry)
|
||||
new chemistryTabulationMethods::none(dict, chemistry)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,41 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "chemistryTabulationMethod.H"
|
||||
|
||||
#include "forGases.H"
|
||||
#include "forLiquids.H"
|
||||
#include "makeChemistryTabulationMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
forCoeffGases(defineChemistryTabulationMethod, nullArg);
|
||||
forCoeffLiquids(defineChemistryTabulationMethod, nullArg);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,84 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef makeChemistryTabulationMethod_H
|
||||
#define makeChemistryTabulationMethod_H
|
||||
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#define defineChemistryTabulationMethod(nullArg, ThermoPhysics) \
|
||||
\
|
||||
typedef chemistryTabulationMethod<ThermoPhysics> \
|
||||
chemistryTabulationMethod##ThermoPhysics; \
|
||||
\
|
||||
defineTemplateTypeNameAndDebugWithName \
|
||||
( \
|
||||
chemistryTabulationMethod##ThermoPhysics, \
|
||||
( \
|
||||
word(chemistryTabulationMethod##ThermoPhysics::typeName_()) \
|
||||
+ "<" + ThermoPhysics::typeName() + ">" \
|
||||
).c_str(), \
|
||||
0 \
|
||||
); \
|
||||
\
|
||||
defineTemplateRunTimeSelectionTable \
|
||||
( \
|
||||
chemistryTabulationMethod##ThermoPhysics, \
|
||||
dictionary \
|
||||
)
|
||||
|
||||
#define makeChemistryTabulationMethod(Method, ThermoPhysics) \
|
||||
\
|
||||
typedef chemistryTabulationMethod<ThermoPhysics> \
|
||||
chemistryTabulationMethod##ThermoPhysics; \
|
||||
\
|
||||
typedef chemistryTabulationMethods::Method<ThermoPhysics> \
|
||||
chemistryTabulationMethod##Method##ThermoPhysics; \
|
||||
\
|
||||
defineTemplateTypeNameAndDebugWithName \
|
||||
( \
|
||||
chemistryTabulationMethod##Method##ThermoPhysics, \
|
||||
( \
|
||||
word(chemistryTabulationMethod##Method##ThermoPhysics::typeName_())\
|
||||
+ "<" + ThermoPhysics::typeName() + ">" \
|
||||
).c_str(), \
|
||||
0 \
|
||||
); \
|
||||
\
|
||||
addToRunTimeSelectionTable \
|
||||
( \
|
||||
chemistryTabulationMethod##ThermoPhysics, \
|
||||
chemistryTabulationMethod##Method##ThermoPhysics, \
|
||||
dictionary \
|
||||
)
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -24,17 +24,30 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "noChemistryTabulation.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace chemistryTabulationMethods
|
||||
{
|
||||
defineTypeNameAndDebug(none, 0);
|
||||
addToRunTimeSelectionTable(chemistryTabulationMethod, none, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethods::none<ThermoType>::none
|
||||
Foam::chemistryTabulationMethods::none::none
|
||||
(
|
||||
const dictionary& chemistryProperties,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
)
|
||||
:
|
||||
chemistryTabulationMethod<ThermoType>
|
||||
chemistryTabulationMethod
|
||||
(
|
||||
chemistryProperties,
|
||||
chemistry
|
||||
@ -44,8 +57,7 @@ Foam::chemistryTabulationMethods::none<ThermoType>::none
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class ThermoType>
|
||||
Foam::chemistryTabulationMethods::none<ThermoType>::~none()
|
||||
Foam::chemistryTabulationMethods::none::~none()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
@ -49,10 +49,9 @@ namespace chemistryTabulationMethods
|
||||
Class none Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class ThermoType>
|
||||
class none
|
||||
:
|
||||
public chemistryTabulationMethod<ThermoType>
|
||||
public chemistryTabulationMethod
|
||||
{
|
||||
public:
|
||||
|
||||
@ -65,7 +64,7 @@ public:
|
||||
none
|
||||
(
|
||||
const dictionary& chemistryProperties,
|
||||
const chemistryModel<ThermoType>& chemistry
|
||||
const odeChemistryModel& chemistry
|
||||
);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
@ -128,12 +127,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "noChemistryTabulation.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,43 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "chemistryTabulationMethod.H"
|
||||
|
||||
#include "noChemistryTabulation.H"
|
||||
|
||||
#include "forGases.H"
|
||||
#include "forLiquids.H"
|
||||
#include "makeChemistryTabulationMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
forCoeffGases(makeChemistryTabulationMethod, none);
|
||||
forCoeffLiquids(makeChemistryTabulationMethod, none);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -23,21 +23,43 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "chemistryTabulationMethod.H"
|
||||
#include "odeChemistryModel.H"
|
||||
|
||||
#include "ISAT.H"
|
||||
|
||||
#include "forGases.H"
|
||||
#include "forLiquids.H"
|
||||
#include "makeChemistryTabulationMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
forCoeffGases(makeChemistryTabulationMethod, ISAT);
|
||||
forCoeffLiquids(makeChemistryTabulationMethod, ISAT);
|
||||
defineTypeNameAndDebug(odeChemistryModel, 0);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::odeChemistryModel::odeChemistryModel
|
||||
(
|
||||
const fluidReactionThermo& thermo
|
||||
)
|
||||
:
|
||||
basicChemistryModel(thermo),
|
||||
ODESystem(),
|
||||
Yvf_(this->thermo().composition().Y()),
|
||||
nSpecie_(Yvf_.size()),
|
||||
reduction_(false),
|
||||
cTos_(nSpecie_, -1),
|
||||
sToc_(nSpecie_)
|
||||
{
|
||||
Info<< "odeChemistryModel: Number of species = " << nSpecie_ << endl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::odeChemistryModel::~odeChemistryModel()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,158 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::odeChemistryModel
|
||||
|
||||
Description
|
||||
Extends base chemistry model adding an ODESystem and the reduction maps
|
||||
needed for tabulation.
|
||||
|
||||
SourceFiles
|
||||
odeChemistryModelI.H
|
||||
odeChemistryModel.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef odeChemistryModel_H
|
||||
#define odeChemistryModel_H
|
||||
|
||||
#include "basicChemistryModel.H"
|
||||
#include "ODESystem.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
template<class ThermoType>
|
||||
class chemistryModel;
|
||||
|
||||
template<class ThermoType>
|
||||
class chemistryReductionMethod;
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class odeChemistryModel Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class odeChemistryModel
|
||||
:
|
||||
public basicChemistryModel,
|
||||
public ODESystem
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Reference to the field of specie mass fractions
|
||||
const PtrList<volScalarField>& Yvf_;
|
||||
|
||||
//- Number of species
|
||||
label nSpecie_;
|
||||
|
||||
//- Is chemistry reduction active
|
||||
bool reduction_;
|
||||
|
||||
//- Temporary map from complete to simplified concentration fields
|
||||
// c -> sc
|
||||
List<label> cTos_;
|
||||
|
||||
//- Temporary map from simplified to complete concentration fields
|
||||
// sc -> c
|
||||
DynamicList<label> sToc_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
template<class ThermoType>
|
||||
friend class chemistryModel;
|
||||
|
||||
template<class ThermoType>
|
||||
friend class chemistryReductionMethod;
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("odeChemistryModel");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from thermo
|
||||
odeChemistryModel(const fluidReactionThermo& thermo);
|
||||
|
||||
//- Disallow default bitwise copy construction
|
||||
odeChemistryModel(const odeChemistryModel&) = delete;
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~odeChemistryModel();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Create and return a TDAC log file of the given name
|
||||
inline autoPtr<OFstream> logFile(const word& name) const;
|
||||
|
||||
//- The number of species
|
||||
inline virtual label nSpecie() const;
|
||||
|
||||
//- Allow the reduction method to reset the number of species
|
||||
inline void setNSpecie(const label newNs);
|
||||
|
||||
//- Number of ODE's to solve
|
||||
inline virtual label nEqns() const;
|
||||
|
||||
//- Return a reference to the list of mass fraction fields
|
||||
inline const PtrList<volScalarField>& Y() const;
|
||||
|
||||
//- Return true if mechanism reduction is active
|
||||
inline bool reduction() const;
|
||||
|
||||
//- Return the index in the complete set of species
|
||||
// corresponding to the index si in the simplified set of species
|
||||
inline label sToc(const label si) const;
|
||||
|
||||
//- Return the index in the simplified set of species
|
||||
// corresponding to the index si in the complete set of species
|
||||
inline label cTos(const label ci) const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const odeChemistryModel&) = delete;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "odeChemistryModelI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,108 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::autoPtr<Foam::OFstream>
|
||||
Foam::odeChemistryModel::logFile(const word& name) const
|
||||
{
|
||||
mkDir(this->mesh().time().path()/"TDAC"/this->group());
|
||||
return autoPtr<OFstream>
|
||||
(
|
||||
new OFstream
|
||||
(
|
||||
this->mesh().time().path()/"TDAC"/this->group()/name
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::odeChemistryModel::nSpecie() const
|
||||
{
|
||||
return nSpecie_;
|
||||
}
|
||||
|
||||
|
||||
inline void Foam::odeChemistryModel::setNSpecie(const label newNs)
|
||||
{
|
||||
nSpecie_ = newNs;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::odeChemistryModel::nEqns() const
|
||||
{
|
||||
// nEqns = number of species + temperature + pressure
|
||||
return nSpecie_ + 2;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::PtrList<Foam::volScalarField>&
|
||||
Foam::odeChemistryModel::Y() const
|
||||
{
|
||||
return Yvf_;
|
||||
}
|
||||
|
||||
|
||||
inline bool Foam::odeChemistryModel::reduction() const
|
||||
{
|
||||
return reduction_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::odeChemistryModel::sToc
|
||||
(
|
||||
const label si
|
||||
) const
|
||||
{
|
||||
if (reduction_)
|
||||
{
|
||||
return sToc_[si];
|
||||
}
|
||||
else
|
||||
{
|
||||
return si;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::odeChemistryModel::cTos
|
||||
(
|
||||
const label ci
|
||||
) const
|
||||
{
|
||||
if (reduction_)
|
||||
{
|
||||
return cTos_[ci];
|
||||
}
|
||||
else
|
||||
{
|
||||
return ci;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user