diff --git a/src/thermophysicalModels/chemistryModel/Make/files b/src/thermophysicalModels/chemistryModel/Make/files index d0782c33b909ac78530eb1376593b10c7c43b562..19e704dcfc5f9fd7a5c8fe2af563f0212874f255 100644 --- a/src/thermophysicalModels/chemistryModel/Make/files +++ b/src/thermophysicalModels/chemistryModel/Make/files @@ -11,4 +11,6 @@ chemistryModel/TDACChemistryModel/tabulation/makeChemistryTabulationMethods.C chemistrySolver/chemistrySolver/makeChemistrySolvers.C +functionObjects/specieReactionRates/specieReactionRates.C + LIB = $(FOAM_LIBBIN)/libchemistryModel diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H index c91c2975fdeca6d3b00722d58806a5fab78641aa..17b64f542b6fbf41cfbbe9c973020fa060c3d1e0 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H @@ -124,6 +124,12 @@ public: //- Chemistry activation switch inline Switch chemistry() const; + //- The number of species + virtual label nSpecie() const = 0; + + //- The number of reactions + virtual label nReaction() const = 0; + //- Return the latest estimation of integration step inline const volScalarField::Internal& deltaTChem() const; diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H index f5ee5f6f3d705d8cf6a912213b6561ed49ea80d7..98b2ec2a91544c5401a11ba4772a0f37a90f588d 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H @@ -141,10 +141,10 @@ public: inline const PtrList<ThermoType>& specieThermo() const; //- The number of species - inline label nSpecie() const; + virtual inline label nSpecie() const; //- The number of reactions - inline label nReaction() const; + virtual inline label nReaction() const; //- Temperature below which the reaction rates are assumed 0 inline scalar Treact() const; diff --git a/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.C b/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.C new file mode 100644 index 0000000000000000000000000000000000000000..5c141767714d3102f978cd150a4f04009fa7214d --- /dev/null +++ b/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.C @@ -0,0 +1,202 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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 "specieReactionRates.H" +#include "volFields.H" +#include "fvcVolumeIntegrate.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class ChemistryModelType> +void Foam::functionObjects::specieReactionRates<ChemistryModelType>:: +writeFileHeader +( + const label i +) +{ + writeHeader(file(), "Specie reaction rates"); + writeHeaderValue(file(), "nSpecie", chemistryModel_.nSpecie()); + writeHeaderValue(file(), "nReaction", chemistryModel_.nReaction()); + + writeCommented(file(), "Time"); + writeTabbed(file(), "Reaction"); + + const wordList& speciesNames = + chemistryModel_.thermo().composition().species(); + + forAll (speciesNames, si) + { + writeTabbed(file(), speciesNames[si]); + } + + file() << endl; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class ChemistryModelType> +Foam::functionObjects::specieReactionRates<ChemistryModelType>:: +specieReactionRates +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + logFiles(obr_, name), + chemistryModel_ + ( + mesh_.lookupObject<ChemistryModelType>("chemistryProperties") + ) +{ + resetName("specieReactionRates"); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class ChemistryModelType> +Foam::functionObjects::specieReactionRates<ChemistryModelType>:: +~specieReactionRates() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class ChemistryModelType> +bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::read +( + const dictionary& dict +) +{ + regionFunctionObject::read(dict); + + return true; +} + + +template<class ChemistryModelType> +bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::execute() +{ + return true; +} + + +template<class ChemistryModelType> +bool Foam::functionObjects::specieReactionRates<ChemistryModelType>::write() +{ + logFiles::write(); + + const label nSpecie = chemistryModel_.nSpecie(); + const label nReaction = chemistryModel_.nReaction(); + + // Domain volume + const scalar V = gSum(mesh_.V()); + + for (label ri=0; ri<nReaction; ri++) + { + if (Pstream::master()) + { + writeTime(file()); + file() << token::TAB << ri; + } + + for (label si=0; si<nSpecie; si++) + { + volScalarField::Internal RR + ( + chemistryModel_.calculateRR(ri, si) + ); + + if (Pstream::master()) + { + file() << token::TAB << fvc::domainIntegrate(RR).value()/V; + } + } + + if (Pstream::master()) + { + file() << nl; + } + } + + if (Pstream::master()) + { + file() << nl << endl; + } + + return true; +} + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +#include "addToRunTimeSelectionTable.H" +#include "rhoChemistryModel.H" +#include "psiChemistryModel.H" + +namespace Foam +{ +namespace functionObjects +{ + typedef specieReactionRates<psiChemistryModel> psiSpecieReactionRates; + + defineTemplateTypeNameAndDebugWithName + ( + psiSpecieReactionRates, + "psiSpecieReactionRates", + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + psiSpecieReactionRates, + dictionary + ); + + + typedef specieReactionRates<rhoChemistryModel> rhoSpecieReactionRates; + + defineTemplateTypeNameAndDebugWithName + ( + rhoSpecieReactionRates, + "rhoSpecieReactionRates", + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + rhoSpecieReactionRates, + dictionary + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.H b/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.H new file mode 100644 index 0000000000000000000000000000000000000000..65bd964553518d2e5bbe04a987aa3678e7c91770 --- /dev/null +++ b/src/thermophysicalModels/chemistryModel/functionObjects/specieReactionRates/specieReactionRates.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 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::functionObjects::specieReactionRates + +Group + grpFieldFunctionObjects + +Description + Writes the domain averaged reaction rates for each specie for each reaction + into the file \<timeDir\>/specieReactionRates.dat + +See also + Foam::functionObjects::fvMeshFunctionObject + Foam::functionObjects::logFiles + +SourceFiles + specieReactionRates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef functionObjects_specieReactionRates_H +#define functionObjects_specieReactionRates_H + +#include "fvMeshFunctionObject.H" +#include "logFiles.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionObjects +{ + +/*---------------------------------------------------------------------------*\ + Class specieReactionRates Declaration +\*---------------------------------------------------------------------------*/ + +template<class ChemistryModelType> +class specieReactionRates +: + public fvMeshFunctionObject, + public logFiles +{ + // Private Member Data + + const ChemistryModelType& chemistryModel_; + + + // Private Member Functions + + //- File header information + virtual void writeFileHeader(const label i); + + //- Disallow default bitwise copy construct + specieReactionRates(const specieReactionRates&); + + //- Disallow default bitwise assignment + void operator=(const specieReactionRates&); + + +public: + + //- Runtime type information + TypeName("specieReactionRates"); + + + // Constructors + + //- Construct from Time and dictionary + specieReactionRates + ( + const word& name, + const Time& runTime, + const dictionary& dict + ); + + + //- Destructor + virtual ~specieReactionRates(); + + + // Member Functions + + //- Read the specieReactionRates data + virtual bool read(const dictionary&); + + //- Do nothing + virtual bool execute(); + + //- Write the specie reaction rates + virtual bool write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionObjects +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //