templated chemistry and chemistry solver on compressibility type

This commit is contained in:
andy
2009-06-11 14:58:31 +01:00
parent 17a78e7392
commit bfb499125b
23 changed files with 469 additions and 222 deletions

View File

@ -1,6 +1,7 @@
chemistryModel/chemistryModel/chemistryModel.C chemistryModel/basicChemistryModel/basicChemistryModel.C
chemistryModel/chemistryModel/newChemistryModel.C chemistryModel/psiChemistryModel/psiChemistryModel.C
chemistryModel/chemistryModel/chemistryModels.C chemistryModel/psiChemistryModel/newPsiChemistryModel.C
chemistryModel/psiChemistryModel/psiChemistryModels.C
chemistrySolver/chemistrySolver/makeChemistrySolvers.C chemistrySolver/chemistrySolver/makeChemistrySolvers.C

View File

@ -30,10 +30,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::ODEChemistryModel<ThermoType>::ODEChemistryModel(const fvMesh& mesh) Foam::ODEChemistryModel<CompType, ThermoType>::ODEChemistryModel
(
const fvMesh& mesh
)
: :
chemistryModel(mesh), CompType(mesh),
ODE(), ODE(),
@ -52,7 +55,7 @@ Foam::ODEChemistryModel<ThermoType>::ODEChemistryModel(const fvMesh& mesh)
nSpecie_(Y_.size()), nSpecie_(Y_.size()),
nReaction_(reactions_.size()), nReaction_(reactions_.size()),
solver_(chemistrySolver<ThermoType>::New(*this)), solver_(chemistrySolver<CompType, ThermoType>::New(*this)),
RR_(nSpecie_) RR_(nSpecie_)
{ {
@ -73,15 +76,15 @@ Foam::ODEChemistryModel<ThermoType>::ODEChemistryModel(const fvMesh& mesh)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::ODEChemistryModel<ThermoType>::~ODEChemistryModel() Foam::ODEChemistryModel<CompType, ThermoType>::~ODEChemistryModel()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalarField Foam::ODEChemistryModel<ThermoType>::omega Foam::scalarField Foam::ODEChemistryModel<CompType, ThermoType>::omega
( (
const scalarField& c, const scalarField& c,
const scalar T, const scalar T,
@ -121,8 +124,8 @@ Foam::scalarField Foam::ODEChemistryModel<ThermoType>::omega
} }
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalar Foam::ODEChemistryModel<ThermoType>::omega Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega
( (
const Reaction<ThermoType>& R, const Reaction<ThermoType>& R,
const scalarField& c, const scalarField& c,
@ -241,8 +244,8 @@ Foam::scalar Foam::ODEChemistryModel<ThermoType>::omega
} }
template<class ThermoType> template<class CompType, class ThermoType>
void Foam::ODEChemistryModel<ThermoType>::derivatives void Foam::ODEChemistryModel<CompType, ThermoType>::derivatives
( (
const scalar time, const scalar time,
const scalarField &c, const scalarField &c,
@ -292,8 +295,8 @@ void Foam::ODEChemistryModel<ThermoType>::derivatives
} }
template<class ThermoType> template<class CompType, class ThermoType>
void Foam::ODEChemistryModel<ThermoType>::jacobian void Foam::ODEChemistryModel<CompType, ThermoType>::jacobian
( (
const scalar t, const scalar t,
const scalarField& c, const scalarField& c,
@ -434,9 +437,9 @@ void Foam::ODEChemistryModel<ThermoType>::jacobian
} }
template<class ThermoType> template<class CompType, class ThermoType>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::ODEChemistryModel<ThermoType>::tc() const Foam::ODEChemistryModel<CompType, ThermoType>::tc() const
{ {
scalar pf,cf,pr,cr; scalar pf,cf,pr,cr;
label lRef, rRef; label lRef, rRef;
@ -446,7 +449,7 @@ Foam::ODEChemistryModel<ThermoType>::tc() const
scalarField t(nCells, SMALL); scalarField t(nCells, SMALL);
if (chemistry_) if (this->chemistry_)
{ {
for (label celli=0; celli<nCells; celli++) for (label celli=0; celli<nCells; celli++)
{ {
@ -507,9 +510,9 @@ Foam::ODEChemistryModel<ThermoType>::tc() const
} }
template<class ThermoType> template<class CompType, class ThermoType>
Foam::tmp<Foam::volScalarField> Foam::tmp<Foam::volScalarField>
Foam::ODEChemistryModel<ThermoType>::dQ() const Foam::ODEChemistryModel<CompType, ThermoType>::dQ() const
{ {
tmp<volScalarField> tdQ tmp<volScalarField> tdQ
( (
@ -533,7 +536,7 @@ Foam::ODEChemistryModel<ThermoType>::dQ() const
) )
); );
if (chemistry_) if (this->chemistry_)
{ {
scalarField& dQ = tdQ(); scalarField& dQ = tdQ();
@ -557,23 +560,23 @@ Foam::ODEChemistryModel<ThermoType>::dQ() const
} }
template<class ThermoType> template<class CompType, class ThermoType>
Foam::label Foam::ODEChemistryModel<ThermoType>::nEqns() const Foam::label Foam::ODEChemistryModel<CompType, ThermoType>::nEqns() const
{ {
// nEqns = number of species + temperature + pressure // nEqns = number of species + temperature + pressure
return nSpecie_ + 2; return nSpecie_ + 2;
} }
template<class ThermoType> template<class CompType, class ThermoType>
void Foam::ODEChemistryModel<ThermoType>::calculate() void Foam::ODEChemistryModel<CompType, ThermoType>::calculate()
{ {
for (label i=0; i<nSpecie_; i++) for (label i=0; i<nSpecie_; i++)
{ {
RR_[i].setSize(this->thermo().rho()().size()); RR_[i].setSize(this->thermo().rho()().size());
} }
if (chemistry_) if (this->chemistry_)
{ {
forAll(this->thermo().rho()(), celli) forAll(this->thermo().rho()(), celli)
{ {
@ -606,8 +609,8 @@ void Foam::ODEChemistryModel<ThermoType>::calculate()
} }
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalar Foam::ODEChemistryModel<ThermoType>::solve Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve
( (
const scalar t0, const scalar t0,
const scalar deltaT const scalar deltaT
@ -618,7 +621,7 @@ Foam::scalar Foam::ODEChemistryModel<ThermoType>::solve
RR_[i].setSize(this->thermo().rho()().size()); RR_[i].setSize(this->thermo().rho()().size());
} }
if (!chemistry_) if (!this->chemistry_)
{ {
return GREAT; return GREAT;
} }
@ -648,7 +651,7 @@ Foam::scalar Foam::ODEChemistryModel<ThermoType>::solve
c0 = c; c0 = c;
scalar t = t0; scalar t = t0;
scalar tauC = deltaTChem_[celli]; scalar tauC = this->deltaTChem_[celli];
scalar dt = min(deltaT, tauC); scalar dt = min(deltaT, tauC);
scalar timeLeft = deltaT; scalar timeLeft = deltaT;
@ -670,7 +673,7 @@ Foam::scalar Foam::ODEChemistryModel<ThermoType>::solve
Ti = mixture.TH(hi, Ti); Ti = mixture.TH(hi, Ti);
timeLeft -= dt; timeLeft -= dt;
deltaTChem_[celli] = tauC; this->deltaTChem_[celli] = tauC;
dt = min(timeLeft, tauC); dt = min(timeLeft, tauC);
dt = max(dt, SMALL); dt = max(dt, SMALL);
} }

View File

@ -41,7 +41,6 @@ SourceFiles
#include "hCombustionThermo.H" #include "hCombustionThermo.H"
#include "Reaction.H" #include "Reaction.H"
#include "chemistryModel.H"
#include "ODE.H" #include "ODE.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,17 +49,17 @@ namespace Foam
{ {
// Forward declaration of classes // Forward declaration of classes
template<class ThermoType> template<class CompType, class ThermoType>
class chemistrySolver; class chemistrySolver;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ODEChemistryModel Declaration Class ODEChemistryModel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ThermoType> template<class CompType, class ThermoType>
class ODEChemistryModel class ODEChemistryModel
: :
public chemistryModel, public CompType,
public ODE public ODE
{ {
// Private Member Functions // Private Member Functions
@ -89,7 +88,7 @@ protected:
label nReaction_; label nReaction_;
//- Chemistry solver //- Chemistry solver
autoPtr<chemistrySolver<ThermoType> > solver_; autoPtr<chemistrySolver<CompType, ThermoType> > solver_;
//- Chemical source term //- Chemical source term
PtrList<scalarField> RR_; PtrList<scalarField> RR_;
@ -133,7 +132,7 @@ public:
inline label nReaction() const; inline label nReaction() const;
//- Return the chemisty solver //- Return the chemisty solver
inline const chemistrySolver<ThermoType>& solver() const; inline const chemistrySolver<CompType, ThermoType>& solver() const;
//- dc/dt = omega, rate of change in concentration, for each species //- dc/dt = omega, rate of change in concentration, for each species
virtual scalarField omega virtual scalarField omega

View File

@ -26,57 +26,59 @@ License
#include "zeroGradientFvPatchFields.H" #include "zeroGradientFvPatchFields.H"
template<class ThermoType> // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class CompType, class ThermoType>
inline Foam::PtrList<Foam::scalarField>& inline Foam::PtrList<Foam::scalarField>&
Foam::ODEChemistryModel<ThermoType>::RR() Foam::ODEChemistryModel<CompType, ThermoType>::RR()
{ {
return RR_; return RR_;
} }
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class CompType, class ThermoType>
template<class ThermoType>
inline const Foam::PtrList<Foam::Reaction<ThermoType> >& inline const Foam::PtrList<Foam::Reaction<ThermoType> >&
Foam::ODEChemistryModel<ThermoType>::reactions() const Foam::ODEChemistryModel<CompType, ThermoType>::reactions() const
{ {
return reactions_; return reactions_;
} }
template<class ThermoType> template<class CompType, class ThermoType>
inline const Foam::PtrList<ThermoType>& inline const Foam::PtrList<ThermoType>&
Foam::ODEChemistryModel<ThermoType>::specieThermo() const Foam::ODEChemistryModel<CompType, ThermoType>::specieThermo() const
{ {
return specieThermo_; return specieThermo_;
} }
template<class ThermoType> template<class CompType, class ThermoType>
inline Foam::label Foam::ODEChemistryModel<ThermoType>::nSpecie() const inline Foam::label
Foam::ODEChemistryModel<CompType, ThermoType>::nSpecie() const
{ {
return nSpecie_; return nSpecie_;
} }
template<class ThermoType> template<class CompType, class ThermoType>
inline Foam::label Foam::ODEChemistryModel<ThermoType>::nReaction() const inline Foam::label
Foam::ODEChemistryModel<CompType, ThermoType>::nReaction() const
{ {
return nReaction_; return nReaction_;
} }
template<class ThermoType> template<class CompType, class ThermoType>
inline const Foam::chemistrySolver<ThermoType>& inline const Foam::chemistrySolver<CompType, ThermoType>&
Foam::ODEChemistryModel<ThermoType>::solver() const Foam::ODEChemistryModel<CompType, ThermoType>::solver() const
{ {
return solver_; return solver_;
} }
template<class ThermoType> template<class CompType, class ThermoType>
inline Foam::tmp<Foam::volScalarField> inline Foam::tmp<Foam::volScalarField>
Foam::ODEChemistryModel<ThermoType>::RR Foam::ODEChemistryModel<CompType, ThermoType>::RR
( (
const label i const label i
) const ) const
@ -99,7 +101,7 @@ Foam::ODEChemistryModel<ThermoType>::RR
) )
); );
if (chemistry_) if (this->chemistry_)
{ {
tRR().internalField() = RR_[i]; tRR().internalField() = RR_[i];
tRR().correctBoundaryConditions(); tRR().correctBoundaryConditions();

View File

@ -24,21 +24,13 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "chemistryModel.H" #include "basicChemistryModel.H"
#include "fvMesh.H" #include "fvMesh.H"
#include "Time.H" #include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(chemistryModel, 0);
defineRunTimeSelectionTable(chemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::chemistryModel::chemistryModel(const fvMesh& mesh) Foam::basicChemistryModel::basicChemistryModel(const fvMesh& mesh)
: :
IOdictionary IOdictionary
( (
@ -52,7 +44,6 @@ Foam::chemistryModel::chemistryModel(const fvMesh& mesh)
) )
), ),
mesh_(mesh), mesh_(mesh),
thermo_(hCombustionThermo::New(mesh)),
chemistry_(lookup("chemistry")), chemistry_(lookup("chemistry")),
deltaTChem_ deltaTChem_
( (
@ -60,13 +51,13 @@ Foam::chemistryModel::chemistryModel(const fvMesh& mesh)
readScalar(lookup("initialChemicalTimeStep")) readScalar(lookup("initialChemicalTimeStep"))
) )
{ {
Info<< "chemistryModel(const fvMesh&)" << endl; Info<< "basicChemistryModel(const fvMesh&)" << endl;
} }
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::chemistryModel::~chemistryModel() Foam::basicChemistryModel::~basicChemistryModel()
{} {}

View File

@ -23,28 +23,24 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::chemistryModel Foam::basicChemistryModel
Description Description
Foam::chemistryModel Base class for chemistry models
SourceFiles SourceFiles
chemistryModelI.H basicChemistryModelI.H
chemistryModel.C basicChemistryModel.C
newChemistryModel.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef chemistryModel_H #ifndef basicChemistryModel_H
#define chemistryModel_H #define basicChemistryModel_H
#include "IOdictionary.H" #include "IOdictionary.H"
#include "Switch.H" #include "Switch.H"
#include "scalarField.H" #include "scalarField.H"
#include "autoPtr.H" #include "volFieldsFwd.H"
#include "runTimeSelectionTables.H"
#include "hCombustionThermo.H"
//#include "basicMultiComponentMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,20 +51,20 @@ namespace Foam
class fvMesh; class fvMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
class chemistryModel Declaration class basicChemistryModel Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class chemistryModel class basicChemistryModel
: :
public IOdictionary public IOdictionary
{ {
// Private Member Functions // Private Member Functions
//- Construct as copy (not implemented) //- Construct as copy (not implemented)
chemistryModel(const chemistryModel&); basicChemistryModel(const basicChemistryModel&);
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const chemistryModel&); void operator=(const basicChemistryModel&);
protected: protected:
@ -78,9 +74,6 @@ protected:
//- Reference to the mesh database //- Reference to the mesh database
const fvMesh& mesh_; const fvMesh& mesh_;
//- Thermo package
autoPtr<hCombustionThermo> thermo_;
//- Chemistry activation switch //- Chemistry activation switch
Switch chemistry_; Switch chemistry_;
@ -98,33 +91,17 @@ protected:
public: public:
//- Runtime type information //- Runtime type information
TypeName("chemistryModel"); TypeName("basicChemistryModel");
//- Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
chemistryModel,
fvMesh,
(
const fvMesh& mesh
),
(mesh)
);
// Constructors // Constructors
//- Construct from mesh //- Construct from mesh
chemistryModel(const fvMesh& mesh); basicChemistryModel(const fvMesh& mesh);
//- Selector
static autoPtr<chemistryModel> New(const fvMesh& mesh);
//- Destructor //- Destructor
virtual ~chemistryModel(); virtual ~basicChemistryModel();
// Member Functions // Member Functions
@ -132,12 +109,6 @@ public:
//- Return const access to the mesh database //- Return const access to the mesh database
inline const fvMesh& mesh() const; inline const fvMesh& mesh() const;
//- Return access to the thermo package
inline hCombustionThermo& thermo();
//- Return const access to the thermo package
inline const hCombustionThermo& thermo() const;
//- Chemistry activation switch //- Chemistry activation switch
inline Switch chemistry() const; inline Switch chemistry() const;
@ -173,7 +144,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "chemistryModelI.H" #include "basicChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -26,37 +26,25 @@ License
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::fvMesh& Foam::chemistryModel::mesh() const inline const Foam::fvMesh& Foam::basicChemistryModel::mesh() const
{ {
return mesh_; return mesh_;
} }
inline Foam::hCombustionThermo& Foam::chemistryModel::thermo() inline Foam::Switch Foam::basicChemistryModel::chemistry() const
{
return thermo_();
}
inline const Foam::hCombustionThermo& Foam::chemistryModel::thermo() const
{
return thermo_();
}
inline Foam::Switch Foam::chemistryModel::chemistry() const
{ {
return chemistry_; return chemistry_;
} }
inline const Foam::scalarField& Foam::chemistryModel::deltaTChem() const inline const Foam::scalarField& Foam::basicChemistryModel::deltaTChem() const
{ {
return deltaTChem_; return deltaTChem_;
} }
inline Foam::scalarField& Foam::chemistryModel::deltaTChem() inline Foam::scalarField& Foam::basicChemistryModel::deltaTChem()
{ {
return deltaTChem_; return deltaTChem_;
} }

View File

@ -23,17 +23,17 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass InClass
Foam::chemistryModel Foam::psiChemistryModel
Description Description
Macros for instantiating chemistry models based on transport type Macros for instantiating chemistry models based on compressibility and
transport types
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef makeChemistryModel_H #ifndef makeChemistryModel_H
#define makeChemistryModel_H #define makeChemistryModel_H
#include "chemistryModel.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -43,21 +43,21 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeChemistryModel(SS, Transport) \ #define makeChemistryModel(SS, Comp, Thermo) \
\ \
typedef SS<Transport> SS##Transport; \ typedef SS<Comp, Thermo> SS##Comp##Thermo; \
\ \
defineTemplateTypeNameAndDebugWithName \ defineTemplateTypeNameAndDebugWithName \
( \ ( \
SS##Transport, \ SS##Comp##Thermo, \
#SS"<"#Transport">", \ #SS"<"#Comp","#Thermo">", \
0 \ 0 \
); \ ); \
\ \
addToRunTimeSelectionTable \ addToRunTimeSelectionTable \
( \ ( \
chemistryModel, \ Comp, \
SS##Transport, \ SS##Comp##Thermo, \
fvMesh \ fvMesh \
); );

View File

@ -24,18 +24,16 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "chemistryModel.H" #include "psiChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::chemistryModel> Foam::chemistryModel::New Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
( (
const fvMesh& mesh const fvMesh& mesh
) )
{ {
word chemistryModelType; word psiChemistryModelType;
// Enclose the creation of the chemistrtyProperties to ensure it is // Enclose the creation of the chemistrtyProperties to ensure it is
// deleted before the chemistrtyProperties is created otherwise the // deleted before the chemistrtyProperties is created otherwise the
@ -53,24 +51,25 @@ Foam::autoPtr<Foam::chemistryModel> Foam::chemistryModel::New
) )
); );
chemistryPropertiesDict.lookup("chemistryModel") >> chemistryModelType; chemistryPropertiesDict.lookup("psiChemistryModel") >>
psiChemistryModelType;
} }
Info<< "Selecting chemistryModel " << chemistryModelType << endl; Info<< "Selecting psiChemistryModel " << psiChemistryModelType << endl;
fvMeshConstructorTable::iterator cstrIter = fvMeshConstructorTable::iterator cstrIter =
fvMeshConstructorTablePtr_->find(chemistryModelType); fvMeshConstructorTablePtr_->find(psiChemistryModelType);
if (cstrIter == fvMeshConstructorTablePtr_->end()) if (cstrIter == fvMeshConstructorTablePtr_->end())
{ {
FatalErrorIn("chemistryModelBase::New(const mesh&)") FatalErrorIn("psiChemistryModelBase::New(const mesh&)")
<< "Unknown chemistryModel type " << chemistryModelType << nl << nl << "Unknown psiChemistryModel type " << psiChemistryModelType
<< "Valid chemistryModel types are:" << nl << nl << nl << "Valid psiChemistryModel types are:" << nl
<< fvMeshConstructorTablePtr_->toc() << nl << fvMeshConstructorTablePtr_->toc() << nl
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<chemistryModel>(cstrIter()(mesh)); return autoPtr<psiChemistryModel>(cstrIter()(mesh));
} }

View File

@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "psiChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(psiChemistryModel, 0);
defineRunTimeSelectionTable(psiChemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::psiChemistryModel::psiChemistryModel(const fvMesh& mesh)
:
basicChemistryModel(mesh),
thermo_(hCombustionThermo::New(mesh))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::psiChemistryModel::~psiChemistryModel()
{}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::psiChemistryModel
Description
Chemistry model for compressibility-based thermodynamics
SourceFiles
psiChemistryModelI.H
psiChemistryModel.C
newChemistryModel.C
\*---------------------------------------------------------------------------*/
#ifndef psiChemistryModel_H
#define psiChemistryModel_H
#include "basicChemistryModel.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "hCombustionThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class fvMesh;
/*---------------------------------------------------------------------------*\
class psiChemistryModel Declaration
\*---------------------------------------------------------------------------*/
class psiChemistryModel
:
public basicChemistryModel
{
// Private Member Functions
//- Construct as copy (not implemented)
psiChemistryModel(const psiChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const psiChemistryModel&);
protected:
// Protected data
//- Thermo package
autoPtr<hCombustionThermo> thermo_;
public:
//- Runtime type information
TypeName("psiChemistryModel");
//- Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
psiChemistryModel,
fvMesh,
(
const fvMesh& mesh
),
(mesh)
);
// Constructors
//- Construct from mesh
psiChemistryModel(const fvMesh& mesh);
//- Selector
static autoPtr<psiChemistryModel> New(const fvMesh& mesh);
//- Destructor
virtual ~psiChemistryModel();
// Member Functions
//- Return access to the thermo package
inline hCombustionThermo& thermo();
//- Return const access to the thermo package
inline const hCombustionThermo& thermo() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "psiChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,41 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::hCombustionThermo& Foam::psiChemistryModel::thermo()
{
return thermo_();
}
inline const Foam::hCombustionThermo& Foam::psiChemistryModel::thermo() const
{
return thermo_();
}
// ************************************************************************* //

View File

@ -23,23 +23,35 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
InClass InClass
Foam::chemistryModel Foam::psiChemistryModel
Description Description
Creates chemistry model instances templated on the type of thermodynamics Creates chemistry model instances templated on the type of thermodynamics
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "thermoPhysicsTypes.H"
#include "makeChemistryModel.H" #include "makeChemistryModel.H"
#include "psiChemistryModel.H"
#include "ODEChemistryModel.H" #include "ODEChemistryModel.H"
#include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
makeChemistryModel(ODEChemistryModel, gasThermoPhysics); makeChemistryModel
makeChemistryModel(ODEChemistryModel, icoPoly8ThermoPhysics); (
ODEChemistryModel,
psiChemistryModel,
gasThermoPhysics
);
makeChemistryModel
(
ODEChemistryModel,
psiChemistryModel,
icoPoly8ThermoPhysics
);
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,13 +30,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::EulerImplicit<ThermoType>::EulerImplicit Foam::EulerImplicit<CompType, ThermoType>::EulerImplicit
( (
ODEChemistryModel<ThermoType>& model ODEChemistryModel<CompType, ThermoType>& model
) )
: :
chemistrySolver<ThermoType>(model), chemistrySolver<CompType, ThermoType>(model),
coeffsDict_(model.subDict(typeName + "Coeffs")), coeffsDict_(model.subDict(typeName + "Coeffs")),
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
equil_(coeffsDict_.lookup("equilibriumRateLimiter")) equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
@ -45,15 +45,15 @@ Foam::EulerImplicit<ThermoType>::EulerImplicit
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::EulerImplicit<ThermoType>::~EulerImplicit() Foam::EulerImplicit<CompType, ThermoType>::~EulerImplicit()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalar Foam::EulerImplicit<ThermoType>::solve Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve
( (
scalarField &c, scalarField &c,
const scalar T, const scalar T,

View File

@ -43,14 +43,18 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class CompType, class ThermoType>
class EulerImplicit;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class EulerImplicit Declaration Class EulerImplicit Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ThermoType> template<class CompType, class ThermoType>
class EulerImplicit class EulerImplicit
: :
public chemistrySolver<ThermoType> public chemistrySolver<CompType, ThermoType>
{ {
// Private data // Private data
@ -71,7 +75,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
EulerImplicit(ODEChemistryModel<ThermoType>& chemistry); EulerImplicit(ODEChemistryModel<CompType, ThermoType>& chemistry);
//- Destructor //- Destructor

View File

@ -31,10 +31,10 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::chemistrySolver<ThermoType>::chemistrySolver Foam::chemistrySolver<CompType, ThermoType>::chemistrySolver
( (
ODEChemistryModel<ThermoType>& model ODEChemistryModel<CompType, ThermoType>& model
) )
: :
model_(model) model_(model)
@ -43,8 +43,8 @@ Foam::chemistrySolver<ThermoType>::chemistrySolver
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::chemistrySolver<ThermoType>::~chemistrySolver() Foam::chemistrySolver<CompType, ThermoType>::~chemistrySolver()
{} {}

View File

@ -26,7 +26,7 @@ Class
Foam::chemistrySolver Foam::chemistrySolver
Description Description
An abstract class for solving chemistry An abstract base class for solving chemistry
SourceFiles SourceFiles
chemistrySolver.C chemistrySolver.C
@ -47,11 +47,15 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class CompType, class ThermoType>
class chemistrySolver;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class chemistrySolver Declaration Class chemistrySolver Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ThermoType> template<class CompType, class ThermoType>
class chemistrySolver class chemistrySolver
{ {
protected: protected:
@ -59,7 +63,7 @@ protected:
// Protected data // Protected data
//- Reference to the chemistry model //- Reference to the chemistry model
ODEChemistryModel<ThermoType>& model_; ODEChemistryModel<CompType, ThermoType>& model_;
public: public:
@ -75,7 +79,7 @@ public:
chemistrySolver, chemistrySolver,
dictionary, dictionary,
( (
ODEChemistryModel<ThermoType>& model ODEChemistryModel<CompType, ThermoType>& model
), ),
(model) (model)
); );
@ -84,13 +88,13 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
chemistrySolver(ODEChemistryModel<ThermoType>& model); chemistrySolver(ODEChemistryModel<CompType, ThermoType>& model);
//- Selector //- Selector
static autoPtr<chemistrySolver> New static autoPtr<chemistrySolver> New
( (
ODEChemistryModel<ThermoType>& model ODEChemistryModel<CompType, ThermoType>& model
); );
@ -118,23 +122,39 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeChemistrySolver(Thermo) \ #define makeChemistrySolver(Comp, Thermo) \
\ \
defineTemplateTypeNameAndDebug \ typedef chemistrySolver<Comp, Thermo> \
( \ chemistrySolver##Comp##Thermo; \
chemistrySolver<Thermo>, \ \
defineTemplateTypeNameAndDebugWithName \
( \
chemistrySolver##Comp##Thermo, \
"chemistryModel<"#Comp","#Thermo">", \
0 \ 0 \
); \ ); \
\ \
defineTemplateRunTimeSelectionTable(chemistrySolver<Thermo>, dictionary); defineTemplateRunTimeSelectionTable \
( \
chemistrySolver##Comp##Thermo, \
dictionary \
);
#define makeChemistrySolverType(SS, Thermo) \ #define makeChemistrySolverType(SS, Comp, Thermo) \
\ \
defineNamedTemplateTypeNameAndDebug(SS<Thermo>, 0); \ typedef SS<Comp, Thermo> SS##Comp##Thermo; \
\ \
chemistrySolver<Thermo>::adddictionaryConstructorToTable<SS<Thermo> > \ defineTemplateTypeNameAndDebugWithName \
add##SS##Thermo##ConstructorToTable_; ( \
SS##Comp##Thermo, \
#SS"<"#Comp","#Thermo">", \
0 \
); \
\
chemistrySolver<Comp, Thermo>:: \
adddictionaryConstructorToTable<SS<Comp, Thermo> > \
add##SS##Comp##Thermo##ConstructorToTable_;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -27,6 +27,9 @@ License
#include "thermoPhysicsTypes.H" #include "thermoPhysicsTypes.H"
#include "chemistrySolver.H" #include "chemistrySolver.H"
#include "psiChemistryModel.H"
//#include "rhoChemistryModel.H"
#include "EulerImplicit.H" #include "EulerImplicit.H"
#include "ode.H" #include "ode.H"
#include "sequential.H" #include "sequential.H"
@ -35,15 +38,26 @@ License
namespace Foam namespace Foam
{ {
makeChemistrySolver(gasThermoPhysics) makeChemistrySolver(psiChemistryModel, gasThermoPhysics)
makeChemistrySolverType(EulerImplicit, gasThermoPhysics) makeChemistrySolverType(EulerImplicit, psiChemistryModel, gasThermoPhysics)
makeChemistrySolverType(ode, gasThermoPhysics) makeChemistrySolverType(ode, psiChemistryModel, gasThermoPhysics)
makeChemistrySolverType(sequential, gasThermoPhysics) makeChemistrySolverType(sequential, psiChemistryModel, gasThermoPhysics)
makeChemistrySolver(icoPoly8ThermoPhysics) makeChemistrySolver(psiChemistryModel, icoPoly8ThermoPhysics)
makeChemistrySolverType(EulerImplicit, icoPoly8ThermoPhysics) makeChemistrySolverType
makeChemistrySolverType(ode, icoPoly8ThermoPhysics) (
makeChemistrySolverType(sequential, icoPoly8ThermoPhysics) EulerImplicit,
psiChemistryModel,
icoPoly8ThermoPhysics
)
makeChemistrySolverType(ode, psiChemistryModel, icoPoly8ThermoPhysics)
makeChemistrySolverType
(
sequential,
psiChemistryModel,
icoPoly8ThermoPhysics
)
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -28,14 +28,14 @@ License
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::autoPtr<Foam::chemistrySolver<ThermoType> > Foam::autoPtr<Foam::chemistrySolver<CompType, ThermoType> >
Foam::chemistrySolver<ThermoType>::New Foam::chemistrySolver<CompType, ThermoType>::New
( (
ODEChemistryModel<ThermoType>& model ODEChemistryModel<CompType, ThermoType>& model
) )
{ {
word chemistrySolverType(model.chemistryModel::lookup("chemistrySolver")); word chemistrySolverType(model.CompType::lookup("chemistrySolver"));
typename dictionaryConstructorTable::iterator cstrIter = typename dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(chemistrySolverType); dictionaryConstructorTablePtr_->find(chemistrySolverType);
@ -52,7 +52,7 @@ Foam::chemistrySolver<ThermoType>::New
<< exit(FatalError); << exit(FatalError);
} }
return autoPtr<chemistrySolver<ThermoType> >(cstrIter()(model)); return autoPtr<chemistrySolver<CompType, ThermoType> >(cstrIter()(model));
} }

View File

@ -29,10 +29,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::ode<ThermoType>::ode(ODEChemistryModel<ThermoType>& model) Foam::ode<CompType, ThermoType>::ode
(
ODEChemistryModel<CompType, ThermoType>& model
)
: :
chemistrySolver<ThermoType>(model), chemistrySolver<CompType, ThermoType>(model),
coeffsDict_(model.subDict(typeName + "Coeffs")), coeffsDict_(model.subDict(typeName + "Coeffs")),
solverName_(coeffsDict_.lookup("ODESolver")), solverName_(coeffsDict_.lookup("ODESolver")),
odeSolver_(ODESolver::New(solverName_, model)), odeSolver_(ODESolver::New(solverName_, model)),
@ -43,15 +46,15 @@ Foam::ode<ThermoType>::ode(ODEChemistryModel<ThermoType>& model)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::ode<ThermoType>::~ode() Foam::ode<CompType, ThermoType>::~ode()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalar Foam::ode<ThermoType>::solve Foam::scalar Foam::ode<CompType, ThermoType>::solve
( (
scalarField& c, scalarField& c,
const scalar T, const scalar T,

View File

@ -44,14 +44,18 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class CompType, class ThermoType>
class ode;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ode Declaration Class ode Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ThermoType> template<class CompType, class ThermoType>
class ode class ode
: :
public chemistrySolver<ThermoType> public chemistrySolver<CompType, ThermoType>
{ {
// Private data // Private data
@ -74,7 +78,7 @@ public:
// Constructors // Constructors
//- Construct from components //- Construct from components
ode(ODEChemistryModel<ThermoType>& model); ode(ODEChemistryModel<CompType, ThermoType>& model);
//- Destructor //- Destructor

View File

@ -29,10 +29,13 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::sequential<ThermoType>::sequential(ODEChemistryModel<ThermoType>& model) Foam::sequential<CompType, ThermoType>::sequential
(
ODEChemistryModel<CompType, ThermoType>& model
)
: :
chemistrySolver<ThermoType>(model), chemistrySolver<CompType, ThermoType>(model),
coeffsDict_(model.subDict(typeName + "Coeffs")), coeffsDict_(model.subDict(typeName + "Coeffs")),
cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))),
equil_(coeffsDict_.lookup("equilibriumRateLimiter")) equil_(coeffsDict_.lookup("equilibriumRateLimiter"))
@ -41,15 +44,15 @@ Foam::sequential<ThermoType>::sequential(ODEChemistryModel<ThermoType>& model)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::sequential<ThermoType>::~sequential() Foam::sequential<CompType, ThermoType>::~sequential()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ThermoType> template<class CompType, class ThermoType>
Foam::scalar Foam::sequential<ThermoType>::solve Foam::scalar Foam::sequential<CompType, ThermoType>::solve
( (
scalarField &c, scalarField &c,
const scalar T, const scalar T,

View File

@ -45,14 +45,18 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class CompType, class ThermoType>
class sequential;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sequential Declaration Class sequential Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class ThermoType> template<class CompType, class ThermoType>
class sequential class sequential
: :
public chemistrySolver<ThermoType> public chemistrySolver<CompType, ThermoType>
{ {
// Private data // Private data
@ -74,7 +78,7 @@ public:
//- Construct from components //- Construct from components
sequential(ODEChemistryModel<ThermoType>& model); sequential(ODEChemistryModel<CompType, ThermoType>& model);
//- Destructor //- Destructor