/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
    \\  /    A nd           | Copyright (C) 2011-2013 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/>.

Typedefs
    Foam::thermoPhysicsTypes

Description
    Type definitions for thermo-physics models

\*---------------------------------------------------------------------------*/

#include "specie.H"
#include "perfectGas.H"
#include "janafThermo.H"

#include "absoluteEnthalpy.H"
#include "absoluteInternalEnergy.H"
#include "thermo.H"
#include "sutherlandTransport.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    // thermo physics types based on absoluteEnthalpy

    typedef
    sutherlandTransport
    <
        species::thermo
        <
            janafThermo
            <
                perfectGas<specie>
            >,
            absoluteEnthalpy
        >
    > gasHaThermoPhysics;


    // thermo physics types based on absoluteInternalEnergy

    typedef
    sutherlandTransport
    <
        species::thermo
        <
            janafThermo
            <
                perfectGas<specie>
            >,
            absoluteInternalEnergy
        >
    > gasEaThermoPhysics;

} // End namespace Foam

/*---------------------------------------------------------------------------*\
Typedefs
    Foam::reactionTypes

Description
    Type definitions for reactions
\*---------------------------------------------------------------------------*/

#include "Reaction.H"

namespace Foam
{
    // absolute enthalpy based reactions
    typedef Reaction<gasHaThermoPhysics> gasHaReaction;

    // absolute internal ennergy based reactions
    typedef Reaction<gasEaThermoPhysics> gasEaReaction;

}

// ************************************************************************* //

#include "makeReactionThermo.H"

#include "chemistryReader.H"
#include "foamChemistryReader.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// Gas chemistry readers based on absoluteEnthalpy

makeChemistryReader(gasHaThermoPhysics);

makeChemistryReaderType(foamChemistryReader, gasHaThermoPhysics);



// Gas chemistry readers based on absoluteInternalEnergy

makeChemistryReader(gasEaThermoPhysics);

makeChemistryReaderType(foamChemistryReader, gasEaThermoPhysics);


} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "makeReaction.H"

#include "ArrheniusReactionRate.H"
#include "infiniteReactionRate.H"
#include "LandauTellerReactionRate.H"
#include "thirdBodyArrheniusReactionRate.H"

#include "ChemicallyActivatedReactionRate.H"
#include "JanevReactionRate.H"
#include "powerSeriesReactionRate.H"

#include "FallOffReactionRate.H"
#include "LindemannFallOffFunction.H"
#include "SRIFallOffFunction.H"
#include "TroeFallOffFunction.H"


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#define makeReactions(Thermo, Reaction)                                        \
                                                                               \
    defineTemplateTypeNameAndDebug(Reaction, 0);                               \
    defineTemplateRunTimeSelectionTable(Reaction, Istream);                    \
    defineTemplateRunTimeSelectionTable(Reaction, dictionary);                 \
                                                                               \
    makeIRNReactions(Thermo, ArrheniusReactionRate)                            \
    makeIRNReactions(Thermo, infiniteReactionRate)                             \
    makeIRNReactions(Thermo, LandauTellerReactionRate)                         \
    makeIRNReactions(Thermo, thirdBodyArrheniusReactionRate)                   \
                                                                               \
    makeIRReactions(Thermo, JanevReactionRate)                                 \
    makeIRReactions(Thermo, powerSeriesReactionRate)                           \
                                                                               \
    makePressureDependentReactions                                             \
    (                                                                          \
       Thermo,                                                                 \
       ArrheniusReactionRate,                                                  \
       LindemannFallOffFunction                                                \
    )                                                                          \
                                                                               \
    makePressureDependentReactions                                             \
    (                                                                          \
       Thermo,                                                                 \
       ArrheniusReactionRate,                                                  \
       TroeFallOffFunction                                                     \
    )                                                                          \
                                                                               \
    makePressureDependentReactions                                             \
    (                                                                          \
       Thermo,                                                                 \
       ArrheniusReactionRate,                                                  \
       SRIFallOffFunction                                                      \
    )


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    // absolute enthalpy based reactions
    makeReactions(gasHaThermoPhysics, gasHaReaction)
    makeReactions(gasEaThermoPhysics, gasEaReaction)
}

// ************************************************************************* //

#include "makeReactionThermo.H"

#include "psiReactionThermo.H"
#include "hePsiThermo.H"

#include "specie.H"
#include "perfectGas.H"
#include "janafThermo.H"
#include "absoluteEnthalpy.H"
#include "thermo.H"
#include "sutherlandTransport.H"

#include "homogeneousMixture.H"
#include "inhomogeneousMixture.H"
#include "veryInhomogeneousMixture.H"
#include "multiComponentMixture.H"
#include "reactingMixture.H"
#include "singleStepReactingMixture.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{

// sutherlandTransport, janafThermo

makeReactionThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    homogeneousMixture,
    sutherlandTransport,
    absoluteEnthalpy,
    janafThermo,
    perfectGas,
    specie
);

makeReactionThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    inhomogeneousMixture,
    sutherlandTransport,
    absoluteEnthalpy,
    janafThermo,
    perfectGas,
    specie
);

makeReactionThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    veryInhomogeneousMixture,
    sutherlandTransport,
    absoluteEnthalpy,
    janafThermo,
    perfectGas,
    specie
);


// Multi-component thermo for absolute enthalpy

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    multiComponentMixture,
    gasHaThermoPhysics
);


// Multi-component thermo for internal energy

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    multiComponentMixture,
    gasEaThermoPhysics
);


// Multi-component reaction thermo for absolute enthalpy

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    reactingMixture,
    gasHaThermoPhysics
);

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    singleStepReactingMixture,
    gasHaThermoPhysics
);


// Multi-component reaction thermo for internal energy

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    reactingMixture,
    gasEaThermoPhysics
);

makeReactionMixtureThermo
(
    psiThermo,
    psiReactionThermo,
    hePsiThermo,
    singleStepReactingMixture,
    gasEaThermoPhysics
);

} // End namespace Foam

/*---------------------------------------------------------------------------*\
InClass
    Foam::psiChemistryModel

Description
    Creates chemistry model instances templated on the type of thermodynamics
\*---------------------------------------------------------------------------*/

#include "makeChemistryModel.H"

#include "psiChemistryModel.H"
#include "chemistryModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    // Chemistry moldels based on absoluteEnthalpy
    makeChemistryModel
    (
        chemistryModel,
        psiChemistryModel,
        gasHaThermoPhysics
    );

    // Chemistry moldels based on absoluteInternalEnergy
    makeChemistryModel
    (
        chemistryModel,
        psiChemistryModel,
        gasEaThermoPhysics
    );
}

// ************************************************************************* //

#include "makeChemistrySolverTypes.H"

#include "psiChemistryModel.H"
#include "rhoChemistryModel.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    // Chemistry solvers based on absoluteEnthalpy
    makeChemistrySolverTypes(psiChemistryModel, gasHaThermoPhysics);
    // makeChemistrySolverTypes(rhoChemistryModel, gasHaThermoPhysics);

    // Chemistry solvers based on absoluteInternalEnergy
    makeChemistrySolverTypes(psiChemistryModel, gasEaThermoPhysics);
    // makeChemistrySolverTypes(rhoChemistryModel, gasEaThermoPhysics);
}


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

