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/chemistryModel/newChemistryModel.C
chemistryModel/chemistryModel/chemistryModels.C
chemistryModel/basicChemistryModel/basicChemistryModel.C
chemistryModel/psiChemistryModel/psiChemistryModel.C
chemistryModel/psiChemistryModel/newPsiChemistryModel.C
chemistryModel/psiChemistryModel/psiChemistryModels.C
chemistrySolver/chemistrySolver/makeChemistrySolvers.C

View File

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

View File

@ -41,7 +41,6 @@ SourceFiles
#include "hCombustionThermo.H"
#include "Reaction.H"
#include "chemistryModel.H"
#include "ODE.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,17 +49,17 @@ namespace Foam
{
// Forward declaration of classes
template<class ThermoType>
template<class CompType, class ThermoType>
class chemistrySolver;
/*---------------------------------------------------------------------------*\
Class ODEChemistryModel Declaration
\*---------------------------------------------------------------------------*/
template<class ThermoType>
template<class CompType, class ThermoType>
class ODEChemistryModel
:
public chemistryModel,
public CompType,
public ODE
{
// Private Member Functions
@ -89,7 +88,7 @@ protected:
label nReaction_;
//- Chemistry solver
autoPtr<chemistrySolver<ThermoType> > solver_;
autoPtr<chemistrySolver<CompType, ThermoType> > solver_;
//- Chemical source term
PtrList<scalarField> RR_;
@ -133,7 +132,7 @@ public:
inline label nReaction() const;
//- 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
virtual scalarField omega

View File

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

View File

@ -24,21 +24,13 @@ License
\*---------------------------------------------------------------------------*/
#include "chemistryModel.H"
#include "basicChemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(chemistryModel, 0);
defineRunTimeSelectionTable(chemistryModel, fvMesh);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::chemistryModel::chemistryModel(const fvMesh& mesh)
Foam::basicChemistryModel::basicChemistryModel(const fvMesh& mesh)
:
IOdictionary
(
@ -52,7 +44,6 @@ Foam::chemistryModel::chemistryModel(const fvMesh& mesh)
)
),
mesh_(mesh),
thermo_(hCombustionThermo::New(mesh)),
chemistry_(lookup("chemistry")),
deltaTChem_
(
@ -60,13 +51,13 @@ Foam::chemistryModel::chemistryModel(const fvMesh& mesh)
readScalar(lookup("initialChemicalTimeStep"))
)
{
Info<< "chemistryModel(const fvMesh&)" << endl;
Info<< "basicChemistryModel(const fvMesh&)" << endl;
}
// * * * * * * * * * * * * * * * * 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
Class
Foam::chemistryModel
Foam::basicChemistryModel
Description
Foam::chemistryModel
Base class for chemistry models
SourceFiles
chemistryModelI.H
chemistryModel.C
newChemistryModel.C
basicChemistryModelI.H
basicChemistryModel.C
\*---------------------------------------------------------------------------*/
#ifndef chemistryModel_H
#define chemistryModel_H
#ifndef basicChemistryModel_H
#define basicChemistryModel_H
#include "IOdictionary.H"
#include "Switch.H"
#include "scalarField.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
#include "hCombustionThermo.H"
//#include "basicMultiComponentMixture.H"
#include "volFieldsFwd.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,20 +51,20 @@ namespace Foam
class fvMesh;
/*---------------------------------------------------------------------------*\
class chemistryModel Declaration
class basicChemistryModel Declaration
\*---------------------------------------------------------------------------*/
class chemistryModel
class basicChemistryModel
:
public IOdictionary
{
// Private Member Functions
//- Construct as copy (not implemented)
chemistryModel(const chemistryModel&);
basicChemistryModel(const basicChemistryModel&);
//- Disallow default bitwise assignment
void operator=(const chemistryModel&);
void operator=(const basicChemistryModel&);
protected:
@ -78,9 +74,6 @@ protected:
//- Reference to the mesh database
const fvMesh& mesh_;
//- Thermo package
autoPtr<hCombustionThermo> thermo_;
//- Chemistry activation switch
Switch chemistry_;
@ -98,33 +91,17 @@ protected:
public:
//- Runtime type information
TypeName("chemistryModel");
//- Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
chemistryModel,
fvMesh,
(
const fvMesh& mesh
),
(mesh)
);
TypeName("basicChemistryModel");
// Constructors
//- Construct from mesh
chemistryModel(const fvMesh& mesh);
basicChemistryModel(const fvMesh& mesh);
//- Selector
static autoPtr<chemistryModel> New(const fvMesh& mesh);
//- Destructor
virtual ~chemistryModel();
virtual ~basicChemistryModel();
// Member Functions
@ -132,12 +109,6 @@ public:
//- Return const access to the mesh database
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
inline Switch chemistry() const;
@ -173,7 +144,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "chemistryModelI.H"
#include "basicChemistryModelI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

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

View File

@ -24,18 +24,16 @@ License
\*---------------------------------------------------------------------------*/
#include "chemistryModel.H"
#include "fvMesh.H"
#include "Time.H"
#include "psiChemistryModel.H"
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::chemistryModel> Foam::chemistryModel::New
Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New
(
const fvMesh& mesh
)
{
word chemistryModelType;
word psiChemistryModelType;
// Enclose the creation of the chemistrtyProperties to ensure it is
// 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 =
fvMeshConstructorTablePtr_->find(chemistryModelType);
fvMeshConstructorTablePtr_->find(psiChemistryModelType);
if (cstrIter == fvMeshConstructorTablePtr_->end())
{
FatalErrorIn("chemistryModelBase::New(const mesh&)")
<< "Unknown chemistryModel type " << chemistryModelType << nl << nl
<< "Valid chemistryModel types are:" << nl
FatalErrorIn("psiChemistryModelBase::New(const mesh&)")
<< "Unknown psiChemistryModel type " << psiChemistryModelType
<< nl << nl << "Valid psiChemistryModel types are:" << nl
<< fvMeshConstructorTablePtr_->toc() << nl
<< 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
InClass
Foam::chemistryModel
Foam::psiChemistryModel
Description
Creates chemistry model instances templated on the type of thermodynamics
\*---------------------------------------------------------------------------*/
#include "thermoPhysicsTypes.H"
#include "makeChemistryModel.H"
#include "psiChemistryModel.H"
#include "ODEChemistryModel.H"
#include "thermoPhysicsTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makeChemistryModel(ODEChemistryModel, gasThermoPhysics);
makeChemistryModel(ODEChemistryModel, icoPoly8ThermoPhysics);
makeChemistryModel
(
ODEChemistryModel,
psiChemistryModel,
gasThermoPhysics
);
makeChemistryModel
(
ODEChemistryModel,
psiChemistryModel,
icoPoly8ThermoPhysics
);
}
// ************************************************************************* //

View File

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

View File

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

View File

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

View File

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

View File

@ -28,14 +28,14 @@ License
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class ThermoType>
Foam::autoPtr<Foam::chemistrySolver<ThermoType> >
Foam::chemistrySolver<ThermoType>::New
template<class CompType, class ThermoType>
Foam::autoPtr<Foam::chemistrySolver<CompType, ThermoType> >
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 =
dictionaryConstructorTablePtr_->find(chemistrySolverType);
@ -52,7 +52,7 @@ Foam::chemistrySolver<ThermoType>::New
<< exit(FatalError);
}
return autoPtr<chemistrySolver<ThermoType> >(cstrIter()(model));
return autoPtr<chemistrySolver<CompType, ThermoType> >(cstrIter()(model));
}

View File

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

View File

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

View File

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

View File

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