diff --git a/src/thermophysicalModels/chemistryModel/Make/files b/src/thermophysicalModels/chemistryModel/Make/files index d0782c33b..19e704dcf 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 c91c2975f..17b64f542 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 f5ee5f6f3..98b2ec2a9 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& 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 000000000..5c1417677 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "specieReactionRates.H" +#include "volFields.H" +#include "fvcVolumeIntegrate.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::functionObjects::specieReactionRates:: +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 +Foam::functionObjects::specieReactionRates:: +specieReactionRates +( + const word& name, + const Time& runTime, + const dictionary& dict +) +: + fvMeshFunctionObject(name, runTime, dict), + logFiles(obr_, name), + chemistryModel_ + ( + mesh_.lookupObject("chemistryProperties") + ) +{ + resetName("specieReactionRates"); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::functionObjects::specieReactionRates:: +~specieReactionRates() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +bool Foam::functionObjects::specieReactionRates::read +( + const dictionary& dict +) +{ + regionFunctionObject::read(dict); + + return true; +} + + +template +bool Foam::functionObjects::specieReactionRates::execute() +{ + return true; +} + + +template +bool Foam::functionObjects::specieReactionRates::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 psiSpecieReactionRates; + + defineTemplateTypeNameAndDebugWithName + ( + psiSpecieReactionRates, + "psiSpecieReactionRates", + 0 + ); + + addToRunTimeSelectionTable + ( + functionObject, + psiSpecieReactionRates, + dictionary + ); + + + typedef specieReactionRates 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 000000000..65bd96455 --- /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 . + +Class + Foam::functionObjects::specieReactionRates + +Group + grpFieldFunctionObjects + +Description + Writes the domain averaged reaction rates for each specie for each reaction + into the file \/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 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 + +// ************************************************************************* //