From d204ebfc356201d06316f1d967d830d2e56717f0 Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Thu, 2 Jun 2011 15:06:01 +0100 Subject: [PATCH] ENH: Initial check-in of updated pyrolysis models + supporting libs --- src/regionModels/Allwmake | 2 +- src/regionModels/pyrolysisModels/Make/files | 15 + src/regionModels/pyrolysisModels/Make/options | 25 + ...teInletVelocityCoupledFvPatchVectorField.C | 223 +++++ ...teInletVelocityCoupledFvPatchVectorField.H | 180 ++++ ...RateAdvectiveDiffusiveFvPatchScalarField.C | 211 +++++ ...RateAdvectiveDiffusiveFvPatchScalarField.H | 186 ++++ ...ureCoupledBaffleMixedFvPatchScalarField2.C | 327 +++++++ ...ureCoupledBaffleMixedFvPatchScalarField2.H | 188 ++++ ...adiationCoupledMixedSTFvPatchScalarField.C | 539 ++++++++++++ ...adiationCoupledMixedSTFvPatchScalarField.H | 218 +++++ .../pyrolysisModels/noPyrolysis/noPyrolysis.C | 147 ++++ .../pyrolysisModels/noPyrolysis/noPyrolysis.H | 127 +++ .../pyrolysisModel/pyrolysisModel.C | 182 ++++ .../pyrolysisModel/pyrolysisModel.H | 199 +++++ .../pyrolysisModel/pyrolysisModelI.H | 44 + .../pyrolysisModel/pyrolysisModelNew.C | 84 ++ .../reactingOneDim/reactingOneDim.C | 609 +++++++++++++ .../reactingOneDim/reactingOneDim.H | 284 ++++++ .../reactingOneDim/reactingOneDimI.H | 44 + src/thermophysicalModels/Allwmake | 3 + .../ODEChemistryModel/ODEChemistryModel.C | 122 ++- .../ODEChemistryModel/ODEChemistryModel.H | 65 +- .../ODEChemistryModel/ODEChemistryModelI.H | 10 +- .../chemistryModel/makeChemistryModel.H | 88 ++ .../EulerImplicit/EulerImplicit.C | 58 +- .../EulerImplicit/EulerImplicit.H | 17 +- .../chemistrySolver/chemistrySolver.C | 17 +- .../chemistrySolver/chemistrySolver.H | 80 +- .../chemistrySolver/chemistrySolverNew.C | 80 -- .../makeChemistrySolverTypes.H | 83 ++ .../chemistrySolver/makeChemistrySolvers.C | 79 +- .../noChemistrySolver/noChemistrySolver.C | 21 +- .../noChemistrySolver/noChemistrySolver.H | 19 +- .../chemistryModel/chemistrySolver/ode/ode.C | 31 +- .../chemistryModel/chemistrySolver/ode/ode.H | 17 +- .../chemistrySolver/sequential/sequential.C | 50 +- .../chemistrySolver/sequential/sequential.H | 17 +- .../combustionModels/Make/files | 9 + .../combustionModels/Make/options | 9 + .../combustionModel/combustionModel.C | 153 ++++ .../combustionModel/combustionModel.H | 201 +++++ .../combustionModel/combustionModelNew.C | 65 ++ .../infinitelyFastChemistry.C | 151 ++++ .../infinitelyFastChemistry.H | 135 +++ .../noCombustion/noCombustion.C | 66 ++ .../noCombustion/noCombustion.H | 96 +++ .../hCombustionThermo/hCombustionThermos.C | 24 + .../hsCombustionThermo/hsCombustionThermos.C | 29 +- .../singleStepReactingMixture.C | 259 ++++++ .../singleStepReactingMixture.H | 181 ++++ .../singleStepReactingMixtureI.H | 97 +++ .../hReactionThermo/hReactionThermos.C | 25 + .../hsReactionThermo/hsReactionThermos.C | 25 + .../solidChemistryModel/Make/files | 8 + .../solidChemistryModel/Make/options | 15 + .../ODESolidChemistryModel.C | 812 ++++++++++++++++++ .../ODESolidChemistryModel.H | 290 +++++++ .../ODESolidChemistryModelI.H | 237 +++++ .../solidChemistryModel/solidChemistryModel.C | 57 ++ .../solidChemistryModel/solidChemistryModel.H | 168 ++++ .../solidChemistryModelI.H | 51 ++ .../solidChemistryModelNew.C | 112 +++ .../solidChemistryModels.C | 61 ++ .../makeSolidChemistrySolverType.H} | 43 +- .../makeSolidChemistrySolvers.C | 73 ++ 66 files changed, 7748 insertions(+), 395 deletions(-) create mode 100644 src/regionModels/pyrolysisModels/Make/files create mode 100644 src/regionModels/pyrolysisModels/Make/options create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.H create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C create mode 100644 src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H create mode 100644 src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C create mode 100644 src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H create mode 100644 src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C create mode 100644 src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H create mode 100644 src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelI.H create mode 100644 src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C create mode 100644 src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C create mode 100644 src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H create mode 100644 src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDimI.H create mode 100644 src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H delete mode 100644 src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolverNew.C create mode 100644 src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolverTypes.H create mode 100644 src/thermophysicalModels/combustionModels/Make/files create mode 100644 src/thermophysicalModels/combustionModels/Make/options create mode 100644 src/thermophysicalModels/combustionModels/combustionModel/combustionModel.C create mode 100644 src/thermophysicalModels/combustionModels/combustionModel/combustionModel.H create mode 100644 src/thermophysicalModels/combustionModels/combustionModel/combustionModelNew.C create mode 100644 src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C create mode 100644 src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H create mode 100644 src/thermophysicalModels/combustionModels/noCombustion/noCombustion.C create mode 100644 src/thermophysicalModels/combustionModels/noCombustion/noCombustion.H create mode 100644 src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C create mode 100644 src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H create mode 100644 src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixtureI.H create mode 100644 src/thermophysicalModels/solidChemistryModel/Make/files create mode 100644 src/thermophysicalModels/solidChemistryModel/Make/options create mode 100644 src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C create mode 100644 src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H create mode 100644 src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModels.C rename src/thermophysicalModels/{chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H => solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H} (63%) create mode 100644 src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C diff --git a/src/regionModels/Allwmake b/src/regionModels/Allwmake index 86638a3ff37..b5074c50013 100755 --- a/src/regionModels/Allwmake +++ b/src/regionModels/Allwmake @@ -4,7 +4,7 @@ makeType=${1:-libso} set -x wmake $makeType regionModel -#wmake $makeType pyrolysisModels +wmake $makeType pyrolysisModels wmake $makeType surfaceFilmModels wmake $makeType thermoBaffleModels #wmake $makeType regionCoupling diff --git a/src/regionModels/pyrolysisModels/Make/files b/src/regionModels/pyrolysisModels/Make/files new file mode 100644 index 00000000000..cc875c46ca7 --- /dev/null +++ b/src/regionModels/pyrolysisModels/Make/files @@ -0,0 +1,15 @@ +/* derived patches */ + +derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C +derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C +derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C +derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C + + +/* Pyrolysis models */ +pyrolysisModel/pyrolysisModel.C +pyrolysisModel/pyrolysisModelNew.C +reactingOneDim/reactingOneDim.C +noPyrolysis/noPyrolysis.C + +LIB = $(FOAM_LIBBIN)/libpyrolysisModels diff --git a/src/regionModels/pyrolysisModels/Make/options b/src/regionModels/pyrolysisModels/Make/options new file mode 100644 index 00000000000..4b69dbaac21 --- /dev/null +++ b/src/regionModels/pyrolysisModels/Make/options @@ -0,0 +1,25 @@ + +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solid/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/LES/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/LES/LESdeltas/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude + + +EXE_LIBS = \ + -lregionModels \ + -lsolidChemistryModel \ + -lsolidThermo \ + -lfiniteVolume \ + -lmeshTools \ + -lcompressibleLESModels diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C new file mode 100644 index 00000000000..2e0afc81da4 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C @@ -0,0 +1,223 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2011 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 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 "flowRateInletVelocityCoupledFvPatchVectorField.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "directMappedPatchBase.H" +#include "mapDistribute.H" +#include "regionProperties.H" +#include "basicThermo.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchField<vector>(p, iF), + nbrPhiName_("none"), + phiName_("phi"), + rhoName_("rho") +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField<vector>(ptf, p, iF, mapper), + nbrPhiName_(ptf.nbrPhiName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchField<vector>(p, iF, dict), + nbrPhiName_(dict.lookupOrDefault<word>("nbrPhi", "phi")), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + rhoName_(dict.lookupOrDefault<word>("rho", "rho")) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf +) +: + fixedValueFvPatchField<vector>(ptf), + nbrPhiName_(ptf.nbrPhiName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchField<vector>(ptf, iF), + nbrPhiName_(ptf.nbrPhiName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::flowRateInletVelocityCoupledFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast<const fvMesh> + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + + scalarList phi = + nbrPatch.lookupPatchField<surfaceScalarField, scalar>(nbrPhiName_); + + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + phi + ); + + const surfaceScalarField& phiName = + db().lookupObject<surfaceScalarField>(phiName_); + + + // a simpler way of doing this would be nice + //scalar avgU = -flowRate_/gSum(patch().magSf()); + scalarField U = -phi/patch().magSf(); + + vectorField n = patch().nf(); + +// const surfaceScalarField& phi = +// db().lookupObject<surfaceScalarField>(phiName_); + + if (phiName.dimensions() == dimVelocity*dimArea) + { + // volumetric flow-rate + operator==(n*U); + } + else if (phiName.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + // mass flow-rate + operator==(n*U/rhop); + + if (debug) + { + scalar phi = gSum(rhop*(*this) & patch().Sf()); + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " <- " + << nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " mass flux[Kg/s]:" << -phi + << endl; + } + } + else + { + FatalErrorIn + ( + "flowRateInletVelocityCoupledFvPatchVectorField::updateCoeffs()" + ) << "dimensions of " << phiName_ << " are incorrect" << nl + << " on patch " << this->patch().name() + << " of field " << this->dimensionedInternalField().name() + << " in file " << this->dimensionedInternalField().objectPath() + << nl << exit(FatalError); + } + + fixedValueFvPatchField<vector>::updateCoeffs(); +} + + +void Foam::flowRateInletVelocityCoupledFvPatchVectorField::write(Ostream& os) const +{ + fvPatchField<vector>::write(os); + writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeKeyword("nbrPhi") << nbrPhiName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + flowRateInletVelocityCoupledFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.H b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.H new file mode 100644 index 00000000000..e44a26bf1f5 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.H @@ -0,0 +1,180 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2006-2011 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 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::flowRateInletVelocityCoupledFvPatchVectorField + +Description + Describes a volumetric/mass flow normal vector boundary condition by its + magnitude as an integral over its area. + + The inlet mass flux is taken from the neighbor region. + + phi is used to determine if the flow is compressible or incompressible. + + The basis of the patch (volumetric or mass) is determined by the + dimensions of the flux, phi. + The current density is used to correct the velocity when applying the + mass basis. + + Example of the boundary condition specification: + @verbatim + inlet + { + type flowRateInletVelocityCoupled; + phi phi; + rho rho; + neigPhi neigPhiName_; // Volumetric/mass flow rate [m3/s or kg/s] + value uniform (0 0 0); // placeholder + } + @endverbatim + +Note + - The value is positive inwards + - May not work correctly for transonic inlets + - Strange behaviour with potentialFoam since the U equation is not solved + +SourceFiles + flowRateInletVelocityCoupledFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef flowRateInletVelocityCoupledFvPatchVectorField_H +#define flowRateInletVelocityCoupledFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class flowRateInletVelocityFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class flowRateInletVelocityCoupledFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Name of the neighbor flux setting the inlet mass flux + word nbrPhiName_; + + //- Name of the local mass flux + word phiName_; + + //- Name of the density field used to normalize the mass flux + word rhoName_; + + +public: + + //- Runtime type information + TypeName("flowRateInletVelocityCoupled"); + + + // Constructors + + //- Construct from patch and internal field + flowRateInletVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + flowRateInletVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // flowRateInletVelocityCoupledFvPatchVectorField + // onto a new patch + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField&, + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchVectorField> clone() const + { + return tmp<fvPatchVectorField> + ( + new flowRateInletVelocityCoupledFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchVectorField> clone + ( + const DimensionedField<vector, volMesh>& iF + ) const + { + return tmp<fvPatchVectorField> + ( + new flowRateInletVelocityCoupledFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C b/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C new file mode 100644 index 00000000000..23e11fe5c0c --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C @@ -0,0 +1,211 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "IOobjectList.H" +#include "LESModel.H" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(p, iF), + phiName_("phi"), + rhoName_("none") +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchField<scalar>(p, iF), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + rhoName_(dict.lookupOrDefault<word>("rho", "none")) +{ + + refValue() = 1.0; + refGrad() = 0.0; + valueFraction() = 0.0; + + if (dict.found("value")) + { + fvPatchField<scalar>::operator= + ( + Field<scalar>("value", dict, p.size()) + ); + } + else + { + fvPatchField<scalar>::operator=(refValue()); + } +} + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField<scalar>(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf +) +: + mixedFvPatchField<scalar>(tppsf), + phiName_(tppsf.phiName_), + rhoName_(tppsf.rhoName_) +{} + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchField<scalar>(tppsf, iF), + phiName_(tppsf.phiName_), + rhoName_(tppsf.rhoName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); +} + + +void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchField<scalar>::rmap(ptf, addr); +} + +void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::updateCoeffs() +{ + + if (this->updated()) + { + return; + } + + const label patchI = patch().index(); + + const compressible::LESModel& turbulence = + db().lookupObject<compressible::LESModel> + ( + "LESProperties" + ); + + const fvsPatchField<scalar>& phip = + patch().lookupPatchField<surfaceScalarField, scalar>(phiName_); + + const scalarField alphap = turbulence.alphaEff()().boundaryField()[patchI]; + + refValue() = 1.0; + refGrad() = 0.0; + + valueFraction() = + 1.0 + / + ( + 1.0 + + alphap*patch().deltaCoeffs()*patch().magSf()/max(mag(phip), SMALL) + ); + + mixedFvPatchField<scalar>::updateCoeffs(); + + if (debug) + { + scalar phi = gSum(-phip*(*this));// + alphap*snGrad()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " :" + << " mass flux[Kg/s]:" << phi + << endl; + } +} + + +void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +write(Ostream& os) const +{ + fvPatchField<scalar>::write(os); + os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl; + os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ); + +} + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H b/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H new file mode 100644 index 00000000000..e0120ea8e0c --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/totalFlowRateAdvectiveDiffusiveFvPatchScalarField/totalFlowRateAdvectiveDiffusiveFvPatchScalarField.H @@ -0,0 +1,186 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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::totalFlowRateAdvectiveDiffusiveFvPatchScalarField + +Description + Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField + +SourceFiles + totalFlowRateAdvectiveDiffusiveFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef totalFlowRateAdvectiveDiffusiveFvPatchScalarField_H +#define totalFlowRateAdvectiveDiffusiveFvPatchScalarField_H + +#include "mixedFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class totalFlowRateAdvectiveDiffusiveFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class totalFlowRateAdvectiveDiffusiveFvPatchScalarField +: + public mixedFvPatchField<scalar> +{ + // Private data + + //- Name of the flux transporting the field + word phiName_; + + //- Name of the density field used to normalise the mass flux + // if neccessary + word rhoName_; + + +public: + + //- Runtime type information + TypeName("totalFlowRateAdvectiveDiffusive"); + + + // Constructors + + //- Construct from patch and internal field + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // totalFlowRateAdvectiveDiffusiveFvPatchScalarField + // onto a new patch + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchField<scalar> > clone() const + { + return tmp<fvPatchField<scalar> > + ( + new + totalFlowRateAdvectiveDiffusiveFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchField<scalar> > clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchField<scalar> > + ( + new + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Access + + //- Return reference to the name of the flux field + word& phiName() + { + return phiName_; + } + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +#endif + +// ************************************************************************* // + diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C new file mode 100644 index 00000000000..b1c813fa092 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C @@ -0,0 +1,327 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "directMappedPatchBase.H" +#include "mapDistribute.H" +#include "basicThermo.H" +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + nbrFieldName_("undefined-nbrFieldName"), + KName_("undefined-K") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; +} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + nbrFieldName_(ptf.nbrFieldName_), + KName_(ptf.KName_) +{} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + nbrFieldName_(dict.lookup("nbrFieldName")), + KName_(dict.lookup("K")) +{ + if (!isA<directMappedPatchBase>(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::" + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField<scalar, volMesh>& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << p.type() + << "' not type '" << directMappedPatchBase::typeName << "'" + << "\n for patch " << p.name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + } +} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2& wtcsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + nbrFieldName_(wtcsf.nbrFieldName_), + KName_(wtcsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp<scalarField> +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::K() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + + if (KName_ == "none") + { + const LESModel& model = db().lookupObject<LESModel>("LESProperties"); + + const basicThermo& thermo = + db().lookupObject<basicThermo>("thermophysicalProperties"); + + return + model.alphaEff()().boundaryField()[patch().index()] + *thermo.Cp()().boundaryField()[patch().index()]; + } + else if (mesh.objectRegistry::foundObject<volScalarField>(KName_)) + { + return patch().lookupPatchField<volScalarField, scalar>(KName_); + } + else if (mesh.objectRegistry::foundObject<volSymmTensorField>(KName_)) + { + const symmTensorField& KWall = + patch().lookupPatchField<volSymmTensorField, scalar>(KName_); + + vectorField n = patch().nf(); + + return n & KWall & n; + } + else + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::K()" + " const" + ) << "Did not find field " << KName_ + << " on mesh " << mesh.name() << " patch " << patch().name() + << endl + << "Please set 'K' to 'none', a valid volScalarField" + << " or a valid volSymmTensorField." << exit(FatalError); + + return scalarField(0); + } +} + + +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::updateCoeffs() +{ + if (updated()) + { + return; + } + + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast<const fvMesh> + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + + tmp<scalarField> intFld = patchInternalField(); + + + // Calculate the temperature by harmonic averaging + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2& nbrField = + refCast + < + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + > + ( + nbrPatch.lookupPatchField<volScalarField, scalar> + ( + nbrFieldName_ + ) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField nbrIntFld = nbrField.patchInternalField(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrIntFld + ); + + // Swap to obtain full local values of neighbour K*delta + scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrKDelta + ); + + tmp<scalarField> myKDelta = K()*patch().deltaCoeffs(); + + + // Both sides agree on + // - temperature : (myKDelta*fld + nbrKDelta*nbrFld)/(myKDelta+nbrKDelta) + // - gradient : (temperature-fld)*delta + // We've got a degree of freedom in how to implement this in a mixed bc. + // (what gradient, what fixedValue and mixing coefficient) + // Two reasonable choices: + // 1. specify above temperature on one side (preferentially the high side) + // and above gradient on the other. So this will switch between pure + // fixedvalue and pure fixedgradient + // 2. specify gradient and temperature such that the equations are the + // same on both sides. This leads to the choice of + // - refGradient = zero gradient + // - refValue = neighbour value + // - mixFraction = nbrKDelta / (nbrKDelta + myKDelta()) + + + this->refValue() = nbrIntFld; + + this->refGrad() = 0.0; + + this->valueFraction() = nbrKDelta / (nbrKDelta + myKDelta()); + + mixedFvPatchScalarField::updateCoeffs(); + + + if (debug) + { + scalar Q = gSum(K()*patch().magSf()*snGrad()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " <- " + << nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " heat[W]:" << Q + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } +} + + +void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("nbrFieldName")<< nbrFieldName_ + << token::END_STATEMENT << nl; + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam +} // End namespace LESModels + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H new file mode 100644 index 00000000000..7e2a1634edd --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H @@ -0,0 +1,188 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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::compressible::turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + +Description + Mixed boundary condition for temperature, to be used for heat-transfer + on back-to-back baffles. + + If my temperature is T1, neighbour is T2: + + T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient. + + + Example usage: + myInterfacePatchName + { + type compressible::turbulentTemperatureCoupledBaffleMixed; + nbrFieldName T; + K K; // or none + value uniform 300; + } + + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: if K is "none" looks up RASModel and basicThermo, otherwise expects + the solver to calculate a 'K' field. + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + + Note: lags interface data so both sides use same data. + - problem: schedule to calculate average would interfere + with standard processor swaps. + - so: updateCoeffs sets both to same Twall. Only need to do + this for last outer iteration but don't have access to this. + +SourceFiles + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2_H +#define turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ +namespace LESModels +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of field on the neighbour region + const word nbrFieldName_; + + //- Name of thermal conductivity field + const word KName_; + + +public: + + //- Runtime type information + TypeName("compressible::turbulentTemperatureCoupledBaffleMixed2"); + + + // Constructors + + //- Construct from patch and internal field + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 onto a + // new patch + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + tmp<scalarField> K() const; + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace LESModels +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C new file mode 100644 index 00000000000..3f46e158b54 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C @@ -0,0 +1,539 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "directMappedPatchBase.H" +#include "mapDistribute.H" +#include "regionProperties.H" +#include "basicThermo.H" +#include "LESModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +template<> +const char* +NamedEnum +< + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: + operationMode, + 4 +>::names[] = +{ + "radiative_flux_from_neighbouring_region", + "radiative_flux_from_this_region", + "no_radiation_contribution", + "unknown" +}; + +const NamedEnum +< + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: + operationMode, + 4 +> +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +operationModeNames; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_("undefined-neighbourFieldName"), + neighbourFieldRadiativeName_("undefined-neigbourFieldRadiativeName"), + fieldRadiativeName_("undefined-fieldRadiativeName"), + KName_("undefined-K"), + oldMode_(unknown) +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; +} + + +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +( + const turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + neighbourFieldName_(ptf.neighbourFieldName_), + neighbourFieldRadiativeName_(ptf.neighbourFieldRadiativeName_), + fieldRadiativeName_(ptf.fieldRadiativeName_), + KName_(ptf.KName_), + oldMode_(ptf.oldMode_) +{} + + +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + neighbourFieldName_(dict.lookup("neighbourFieldName")), + neighbourFieldRadiativeName_(dict.lookup("neighbourFieldRadiativeName")), + fieldRadiativeName_(dict.lookup("fieldRadiativeName")), + KName_(dict.lookup("K")), + oldMode_(unknown) +{ + if (!isA<directMappedPatchBase>(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::" + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField<scalar, volMesh>& iF,\n" + " const dictionary& dict\n" + ")\n" + ) << "\n patch type '" << p.type() + << "' not type '" << directMappedPatchBase::typeName << "'" + << "\n for patch " << p.name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + } +} + + +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +( + const turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField& + wtcsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + neighbourFieldName_(wtcsf.neighbourFieldName_), + neighbourFieldRadiativeName_(wtcsf.neighbourFieldRadiativeName_), + fieldRadiativeName_(wtcsf.fieldRadiativeName_), + KName_(wtcsf.KName_), + oldMode_(wtcsf.oldMode_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp<scalarField> +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::K() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + + if (KName_ == "none") + { + const compressible::LESModel& model = + db().lookupObject<compressible::LESModel>("LESProperties"); + + const basicThermo& thermo = + db().lookupObject<basicThermo>("thermophysicalProperties"); + + return + model.alphaEff()().boundaryField()[patch().index()] + *thermo.Cp()().boundaryField()[patch().index()]; + } + else if (mesh.objectRegistry::foundObject<volScalarField>(KName_)) + { + return patch().lookupPatchField<volScalarField, scalar>(KName_); + } + else if (mesh.objectRegistry::foundObject<volSymmTensorField>(KName_)) + { + const symmTensorField& KWall = + patch().lookupPatchField<volSymmTensorField, scalar>(KName_); + + vectorField n = patch().nf(); + + return n & KWall & n; + } + else + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::K()" + " const" + ) << "Did not find field " << KName_ + << " on mesh " << mesh.name() << " patch " << patch().name() + << endl + << "Please set 'K' to 'none', a valid volScalarField" + << " or a valid volSymmTensorField." << exit(FatalError); + + return scalarField(0); + } +} + + +void turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField:: +updateCoeffs() +{ + if (updated()) + { + return; + } + + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = refCast<const directMappedPatchBase> + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast<const fvMesh> + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + + scalarField intFld = patchInternalField(); + + const turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField& + nbrField = + refCast + < + const turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + > + ( + nbrPatch.lookupPatchField<volScalarField, scalar> + ( + neighbourFieldName_ + ) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField nbrIntFld = nbrField.patchInternalField(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrIntFld + ); + + if (debug) + { + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " :" + << " internalT " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + + Info<< nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" + << " internalT " + << " min:" << gMin(nbrIntFld) + << " max:" << gMax(nbrIntFld) + << " avg:" << gAverage(nbrIntFld) + << endl; + } + + + + // Check how to operate + operationMode mode = unknown; + { + if (neighbourFieldRadiativeName_ != "none") + { + if + ( + nbrMesh.foundObject<volScalarField> + ( + neighbourFieldRadiativeName_ + ) + ) + { + mode = radFromNeighbour; + } + else + { + mode = noRad; + } + } + else + { + if + ( + patch().boundaryMesh().mesh().foundObject<volScalarField> + ( + fieldRadiativeName_ + ) + ) + { + mode = radFromMe; + } + else + { + mode = noRad; + } + } + + // Do some warnings if change of mode. + if (mode != oldMode_) + { + WarningIn + ( + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField" + "::updateCoeffs()" + ) << "Switched from mode " << operationModeNames[oldMode_] + << " to mode " << operationModeNames[mode] + << endl; + } + oldMode_ = mode; + } + + + + // Swap to obtain full local values of neighbour K*delta + scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrKDelta + ); + + scalarField myKDelta = K()*patch().deltaCoeffs(); + + scalarField nbrConvFlux = nbrKDelta*(*this - nbrIntFld); + + scalarField nbrTotalFlux = nbrConvFlux; + scalarList nbrRadField(nbrPatch.size(), 0.0); + scalarList myRadField(patch().size(), 0.0); + + // solid + if (mode == radFromNeighbour) + { + nbrRadField = + nbrPatch.lookupPatchField<volScalarField, scalar> + ( + neighbourFieldRadiativeName_ + ); + + // Note: the Qr radiative flux is positive outgoing. + // For a hot solid radiating into a cold fluid Qr will be negative. + + + // Swap to obtain full local values of neighbour radiative heat flux + // field + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrRadField + ); + + nbrTotalFlux -= nbrRadField; + + const scalarField Twall = + (nbrRadField + myKDelta*intFld + nbrKDelta*nbrIntFld) + /(myKDelta + nbrKDelta); + + + if (debug) + { + scalar Qr = gSum(nbrRadField*patch().magSf()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " :" << nl + << " radiative heat [W] : " << Qr << nl + << " predicted wallT [K] : " << gAverage(Twall) << nl + << endl; + } + + label nFixed = 0; + + forAll(*this, i) + { + + this->refValue()[i] = Twall[i]; + this->refGrad()[i] = 0.0; // not used + this->valueFraction()[i] = 1.0; + nFixed++; + } + + if (debug) + { + Pout<< "Using " << nFixed << " fixedValue out of " << this->size() + << endl; + } + } + else if (mode == radFromMe) //fluid + { + const scalarField& myRadField = + patch().lookupPatchField<volScalarField, scalar> + ( + fieldRadiativeName_ + ); + + const scalarField Twall = + (myRadField + myKDelta*intFld + nbrKDelta*nbrIntFld) + /(myKDelta + nbrKDelta); + + if (debug) + { + scalar Qr = gSum(myRadField*patch().magSf()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " :" << nl + << " radiative heat [W] : " << Qr << nl + << " predicted wallT [K] : " << gAverage(Twall) << nl + << endl; + } + + this->refValue() = Twall; + this->refGrad() = 0.0; // not used + this->valueFraction() = 1.0; + } + else if (mode == noRad) + { + this->refValue() = nbrIntFld; + this->refGrad() = 0.0; + this->valueFraction() = nbrKDelta / (nbrKDelta + myKDelta); + } + else + { + FatalErrorIn + ( + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField" + "::updateCoeffs()" + ) << "Illegal mode " << operationModeNames[mode] + << exit(FatalError); + } + + mixedFvPatchScalarField::updateCoeffs(); + + if (debug) + { + scalar Qc = gSum(nbrConvFlux*patch().magSf()); + scalar Qr = gSum(nbrRadField*patch().magSf()); + scalar Qt = gSum(nbrTotalFlux*patch().magSf()); + + Info<< patch().boundaryMesh().mesh().name() << ':' + << patch().name() << ':' + << this->dimensionedInternalField().name() << " <- " + << nbrMesh.name() << ':' + << nbrPatch.name() << ':' + << this->dimensionedInternalField().name() << " :" << nl + << " convective heat[W] : " << Qc << nl + << " radiative heat [W] : " << Qr << nl + << " total heat [W] : " << Qt << nl + << " walltemperature " + << " min:" << gMin(*this) + << " max:" << gMax(*this) + << " avg:" << gAverage(*this) + << endl; + } +} + + +void turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeKeyword("neighbourFieldName")<< neighbourFieldName_ + << token::END_STATEMENT << nl; + os.writeKeyword("neighbourFieldRadiativeName")<< + neighbourFieldRadiativeName_ << token::END_STATEMENT << nl; + os.writeKeyword("fieldRadiativeName")<< fieldRadiativeName_ + << token::END_STATEMENT << nl; + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; +// temperatureCoupledBase::write(os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H new file mode 100644 index 00000000000..b4dad730b7f --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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:: + compressible:: + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + +Description + Mixed boundary condition for temperature, to be used for heat-transfer + on back-to-back baffles. + + If my temperature is T1, neighbour is T2: + + T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient. + + + Example usage: + myInterfacePatchName + { + type compressible::turbulentTemperatureRadiationCoupledMixedST; + neighbourFieldName T; + K lookup; + KName K; + + neighbourFieldRadiativeName Qr; // or none. Use on solid side + fieldRadiativeName Qr; // fluid. Use on fluid side + + value uniform 300; + } + + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: K : heat conduction at patch. Gets supplied how to lookup/calculate K: + - 'lookup' : lookup volScalarField (or volSymmTensorField) with name + - 'basicThermo' : use basicThermo and compressible::RASmodel to calculate K + - 'solidThermo' : use basicSolidThermo K() + - 'directionalSolidThermo' directionalK() + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + + Note: lags interface data so both sides use same data. + - problem: schedule to calculate average would interfere + with standard processor swaps. + - so: updateCoeffs sets both to same Twall. Only need to do + this for last outer iteration but don't have access to this. + +SourceFiles + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField_H +#define turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField_H + +#include "mixedFvPatchFields.H" +//#include "temperatureCoupledBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField +: + public mixedFvPatchScalarField +// public temperatureCoupledBase +{ + // Private data + + //- Name of field on the neighbour region + const word neighbourFieldName_; + + //- Name of the radiative heat flux in the neighbout region + const word neighbourFieldRadiativeName_; + + //- Name of the radiative heat flux in the my region + const word fieldRadiativeName_; + + //- Name of thermal conductivity field + const word KName_; + + //- how to obtain radiative flux + enum operationMode + { + radFromNeighbour, + radFromMe, + noRad, + unknown + }; + static const NamedEnum<operationMode, 4> operationModeNames; + + //- Previous iteration mode + operationMode oldMode_; + + +public: + + //- Runtime type information + TypeName("compressible::turbulentTemperatureRadiationCoupledMixedST"); + + + // Constructors + + //- Construct from patch and internal field + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a + // new patch + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + tmp<scalarField> K() const; + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C new file mode 100644 index 00000000000..7c3499b4e28 --- /dev/null +++ b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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 "noPyrolysis.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(noPyrolysis, 0); +addToRunTimeSelectionTable(pyrolysisModel, noPyrolysis, mesh); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool noPyrolysis::read() +{ + if (pyrolysisModel::read()) + { + // no additional info to read + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +noPyrolysis::noPyrolysis(const word& modelType, const fvMesh& mesh) +: + pyrolysisModel(mesh) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +noPyrolysis::~noPyrolysis() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +const volScalarField& noPyrolysis::rho() const +{ + FatalErrorIn("const volScalarField& noPyrolysis::rho() const") + << "rho field not available for " << type() << abort(FatalError); + return volScalarField::null(); +} + + +const volScalarField& noPyrolysis::T() const +{ + FatalErrorIn("const volScalarField& noPyrolysis::T() const") + << "T field not available for " << type() << abort(FatalError); + return volScalarField::null(); +} + + +const tmp<volScalarField> noPyrolysis::Cp() const +{ + FatalErrorIn("const tmp<volScalarField>& noPyrolysis::Cp() const") + << "Cp field not available for " << type() << abort(FatalError); + + return tmp<volScalarField> + ( + new volScalarField + ( + IOobject + ( + "noPyrolysis::Cp", + time().timeName(), + primaryMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + primaryMesh(), + dimensionedScalar("zero", dimEnergy/dimVolume/dimTime, 0.0) + ) + ); +} + + +const volScalarField& noPyrolysis::kappa() const +{ + FatalErrorIn("const volScalarField& noPyrolysis::kappa() const") + << "kappa field not available for " << type() << abort(FatalError); + return volScalarField::null(); +} + + +const volScalarField& noPyrolysis::K() const +{ + FatalErrorIn("const volScalarField& noPyrolysis::K() const") + << "K field not available for " << type() << abort(FatalError); + return volScalarField::null(); +} + + +const surfaceScalarField& noPyrolysis::phiGas() const +{ + FatalErrorIn("const volScalarField& noPyrolysis::phiGas() const") + << "phiGas field not available for " << type() << abort(FatalError); + return surfaceScalarField::null(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFilmModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H new file mode 100644 index 00000000000..4be55df5d15 --- /dev/null +++ b/src/regionModels/pyrolysisModels/noPyrolysis/noPyrolysis.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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::noPyrolysis + +Description + Dummy surface pyrolysis model for 'none' + +SourceFiles + noPyrolysis.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noPyrolysis_H +#define noPyrolysis_H + +#include "pyrolysisModel.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +/*---------------------------------------------------------------------------*\ + Class noPyrolysis Declaration +\*---------------------------------------------------------------------------*/ + +class noPyrolysis +: + public pyrolysisModel +{ +private: + + // Private member functions + + //- Disallow default bitwise copy construct + noPyrolysis(const noPyrolysis&); + + //- Disallow default bitwise assignment + void operator=(const noPyrolysis&); + + +protected: + + // Protected member functions + + //- Read control parameters from dictionary + virtual bool read(); + + +public: + + //- Runtime type information + TypeName("none"); + + + // Constructors + + //- Construct from type name and mesh + noPyrolysis(const word& modelType, const fvMesh& mesh); + + + //- Destructor + virtual ~noPyrolysis(); + + + // Member Functions + + // Fields + + //- Return density [kg/m3] + virtual const volScalarField& rho() const; + + //- Return const temperature [K] + virtual const volScalarField& T() const; + + //- Return specific heat capacity [J/kg/K] + virtual const tmp<volScalarField> Cp() const; + + //- Return the region absorptivity [1/m] + virtual const volScalarField& kappa() const; + + //- Return the region thermal conductivity [W/m/k] + virtual const volScalarField& K() const; + + //- Return the total gas mass flux to primary region [kg/m2/s] + virtual const surfaceScalarField& phiGas() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace pyrolysisModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C new file mode 100644 index 00000000000..290117e26df --- /dev/null +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.C @@ -0,0 +1,182 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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 "pyrolysisModel.H" +#include "fvMesh.H" +#include "directMappedFieldFvPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(pyrolysisModel, 0); +defineRunTimeSelectionTable(pyrolysisModel, mesh); + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void pyrolysisModel::constructMeshObjects() +{ + // construct filmDelta field if coupled to film model + if (filmCoupled_) + { + filmDeltaPtr_.reset + ( + new volScalarField + ( + IOobject + ( + "filmDelta", + time_.timeName(), + regionMesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ) + ); + + const volScalarField& filmDelta = filmDeltaPtr_(); + + bool foundCoupledPatch = false; + forAll(filmDelta.boundaryField(), patchI) + { + const fvPatchField<scalar>& fvp = filmDelta.boundaryField()[patchI]; + if (isA<directMappedFieldFvPatchField<scalar> >(fvp)) + { + foundCoupledPatch = true; + break; + } + } + + if (!foundCoupledPatch) + { + WarningIn("void pyrolysisModels::constructMeshObjects()") + << "filmCoupled flag set to true, but no " + << directMappedFieldFvPatchField<scalar>::typeName + << " patches found on " << filmDelta.name() << " field" + << endl; + } + } +} + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool pyrolysisModel::read() +{ + if (regionModel1D::read()) + { + filmCoupled_ = readBool(coeffs_.lookup("filmCoupled")); + reactionDeltaMin_ = + coeffs_.lookupOrDefault<scalar>("reactionDeltaMin", 0.0); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +pyrolysisModel::pyrolysisModel(const fvMesh& mesh) +: + regionModel1D(mesh), + filmCoupled_(false), + filmDeltaPtr_(NULL), + reactionDeltaMin_(0.0) +{} + + +pyrolysisModel::pyrolysisModel(const word& modelType, const fvMesh& mesh) +: + regionModel1D(mesh, "pyrolysis", modelType), + filmCoupled_(false), + filmDeltaPtr_(NULL), + reactionDeltaMin_(0.0) +{ + if (active_) + { + read(); + constructMeshObjects(); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +pyrolysisModel::~pyrolysisModel() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +scalar pyrolysisModel::addMassSources +( + const label patchI, + const label faceI +) +{ + return 0.0; +} + + +void pyrolysisModel::preEvolveRegion() +{ + if (filmCoupled_) + { + filmDeltaPtr_->correctBoundaryConditions(); + } +} + + +scalar pyrolysisModel::solidRegionDiffNo() const +{ + return VSMALL; +} + + +scalar pyrolysisModel::maxDiff() const +{ + return GREAT; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFilmModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H new file mode 100644 index 00000000000..756cd2d2576 --- /dev/null +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModel.H @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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::pyrolysisModel + +Description + +SourceFiles + pyrolysisModelI.H + pyrolysisModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pyrolysisModel_H +#define pyrolysisModel_H + +#include "runTimeSelectionTables.H" +#include "volFieldsFwd.H" +#include "solidChemistryModel.H" +#include "basicSolidThermo.H" +#include "regionModel1D.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class fvMesh; +class Time; + +namespace regionModels +{ +namespace pyrolysisModels +{ + +/*---------------------------------------------------------------------------*\ + Class pyrolysisModel Declaration +\*---------------------------------------------------------------------------*/ + +class pyrolysisModel +: + public regionModel1D +{ +private: + + // Private Member Functions + + //- Construct fields + void constructMeshObjects(); + + //- Disallow default bitwise copy construct + pyrolysisModel(const pyrolysisModel&); + + //- Disallow default bitwise assignment + void operator=(const pyrolysisModel&); + + +protected: + + // Protected Data + + //- Flag to indicate whether pyrolysis region coupled to a film region + bool filmCoupled_; + + //- Pointer to film thickness field + autoPtr<volScalarField> filmDeltaPtr_; + + //- Film height below which reactions can occur [m] + scalar reactionDeltaMin_; + + + // Protected Member Functions + + //- Read control parameters from dictionary + virtual bool read(); + + +public: + + //- Runtime type information + TypeName("pyrolysisModel"); + + + // Declare runtime constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + pyrolysisModel, + mesh, + ( + const word& modelType, + const fvMesh& mesh + ), + (modelType, mesh) + ); + + // Constructors + + //- Construct null from mesh + pyrolysisModel(const fvMesh& mesh); + + //- Construct from type name and mesh + pyrolysisModel(const word& modelType, const fvMesh& mesh); + + + // Selectors + + //- Return a reference to the selected surface film model + static autoPtr<pyrolysisModel> New(const fvMesh& mesh); + + + //- Destructor + virtual ~pyrolysisModel(); + + + // Member Functions + + // Access + + // Fields + + //- Return density [kg/m3] + virtual const volScalarField& rho() const = 0; + + //- Return const temperature [K] + virtual const volScalarField& T() const = 0; + + //- Return specific heat capacity [J/kg/K] + virtual const tmp<volScalarField> Cp() const = 0; + + //- Return the region absorptivity [1/m] + virtual const volScalarField& kappa() const = 0; + + //- Return the region thermal conductivity [W/m/k] + virtual const volScalarField& K() const = 0; + + //- Return the total gas mass flux to primary region [kg/m2/s] + virtual const surfaceScalarField& phiGas() const = 0; + + // Sources + + //- External hook to add mass to the primary region + virtual scalar addMassSources + ( + const label patchI, + const label faceI + ); + + + // Evolution + + //- Pre-evolve region + virtual void preEvolveRegion(); + + + // Helper function + + //- Mean diffusion number of the solid region + virtual scalar solidRegionDiffNo() const; + + //- Return max diffusivity allowed in the solid + virtual scalar maxDiff() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace pyrolysisModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelI.H b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelI.H new file mode 100644 index 00000000000..19f7fe165c1 --- /dev/null +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelI.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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 "pyrolysisModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::Switch& +Foam::pyrolysisModels::pyrolysisModel::active() const +{ + return active_; +} + + +inline const Foam::dictionary& +Foam::pyrolysisModels::pyrolysisModel::coeffs() const +{ + return coeffs_; +} + + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C new file mode 100644 index 00000000000..88d31f6cd55 --- /dev/null +++ b/src/regionModels/pyrolysisModels/pyrolysisModel/pyrolysisModelNew.C @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 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 "pyrolysisModel.H" +#include "fvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +autoPtr<pyrolysisModel> pyrolysisModel::New(const fvMesh& mesh) +{ + // get model name, but do not register the dictionary + const word modelType + ( + IOdictionary + ( + IOobject + ( + "pyrolysisProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ).lookup("pyrolysisModel") + ); + + Info<< "Selecting pyrolysisModel " << modelType << endl; + + meshConstructorTable::iterator cstrIter = + meshConstructorTablePtr_->find(modelType); + + if (cstrIter == meshConstructorTablePtr_->end()) + { + FatalErrorIn("pyrolysisModel::New(const fvMesh&)") + << "Unknown pyrolysisModel type " << modelType + << nl << nl << "Valid pyrolisisModel types are:" << nl + << meshConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<pyrolysisModel>(cstrIter()(modelType, mesh)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace surfaceFilmModels +} // End namespace regionModels +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C new file mode 100644 index 00000000000..90e28643dba --- /dev/null +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -0,0 +1,609 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "reactingOneDim.H" +#include "addToRunTimeSelectionTable.H" +#include "directMappedPatchBase.H" +#include "mapDistribute.H" +#include "zeroGradientFvPatchFields.H" +#include "surfaceInterpolate.H" +#include "fvm.H" +#include "fvcDiv.H" +#include "fvcVolumeIntegrate.H" +#include "fvMatrices.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(reactingOneDim, 0); + +addToRunTimeSelectionTable(pyrolysisModel, reactingOneDim, mesh); + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +bool reactingOneDim::read() +{ + if (pyrolysisModel::read()) + { + const dictionary& solution = this->solution().subDict("SIMPLE"); + solution.lookup("nNonOrthCorr") >> nNonOrthCorr_; + time_.controlDict().lookup("maxDi") >> maxDiff_; + + coeffs().lookup("radFluxName") >> primaryRadFluxName_; + coeffs().lookup("minimumDelta") >> minimumDelta_; + return true; + } + else + { + return false; + } +} + + +void reactingOneDim::updateQr() +{ + // Retrieve field from coupled region using mapped boundary conditions + QrCoupled_.correctBoundaryConditions(); + + // Update local Qr from coupled Qr field + Qr_ == dimensionedScalar("zero", Qr_.dimensions(), 0.0); + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + + scalarField& Qrp = Qr_.boundaryField()[patchI]; + + // Qr is negative going out the solid + // If the surface is emitting the radiative flux is set to zero + Qrp = max(Qrp, 0.0); + } + + // Propagate Qr through 1-D regions + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + + const scalarField& Qrp = Qr_.boundaryField()[patchI]; + const vectorField& Cf = regionMesh().Cf().boundaryField()[patchI]; + + forAll(Qrp, faceI) + { + const scalar Qr0 = Qrp[faceI]; + point Cf0 = Cf[faceI]; + const labelList& cells = boundaryFaceCells_[faceI]; + scalar kappaInt = 0.0; + forAll(cells, k) + { + const label cellI = cells[k]; + const point& Cf1 = regionMesh().cellCentres()[cellI]; + const scalar delta = mag(Cf1 - Cf0); + kappaInt += kappa_[cellI]*delta; + Qr_[cellI] = Qr0*exp(-kappaInt); + Cf0 = Cf1; + } + } + } + + Qr_.correctBoundaryConditions(); +} + + +void reactingOneDim::updatePhiGas() +{ + phiHsGas_ == dimensionedScalar("zero", phiHsGas_.dimensions(), 0.0); + phiGas_ == dimensionedScalar("zero", phiGas_.dimensions(), 0.0); + + const speciesTable& gasTable = solidChemistry_->gasTable(); + + forAll(gasTable, gasI) + { + tmp<volScalarField> tHsiGas = solidChemistry_->gasHs(T_, gasI); + tmp<volScalarField> tRRiGas = solidChemistry_->RRg(gasI); + + const volScalarField& HsiGas = tHsiGas(); + const volScalarField& RRiGas = tRRiGas(); + + const surfaceScalarField HsiGasf = fvc::interpolate(HsiGas); + const surfaceScalarField RRiGasf = fvc::interpolate(RRiGas); + + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + const scalarField& phiGasp = phiHsGas_.boundaryField()[patchI]; + + forAll(phiGasp, faceI) + { + const labelList& cells = boundaryFaceCells_[faceI]; + scalar massInt = 0.0; + forAllReverse(cells, k) + { + const label cellI = cells[k]; + massInt += RRiGas[cellI]*regionMesh().V()[cellI]; + phiHsGas_[cellI] += massInt*HsiGas[cellI]; + } + + phiGas_.boundaryField()[patchI][faceI] += massInt; + + if (debug) + { + Info<< " Gas : " << gasTable[gasI] + << " on patch : " << patchI + << " mass produced at face(local) : " + << faceI + << " is : " << massInt + << " [kg/s] " << endl; + } + } + } + tHsiGas().clear(); + } +} + + +void reactingOneDim::updateFields() +{ + updateQr(); + + updatePhiGas(); +} + + +void reactingOneDim::updateMesh(const scalarField& mass0) +{ + if (!moveMesh_) + { + return; + } + + const scalarField newV = mass0/rho_; + + Info<< "Initial/final volumes = " << gSum(regionMesh().V()) << ", " + << gSum(newV) << " [m3]" << endl; + + // move the mesh + const labelList moveMap = moveMesh(regionMesh().V() - newV, minimumDelta_); + + // flag any cells that have not moved as non-reacting + forAll(moveMap, i) + { + if (moveMap[i] == 0) + { + solidChemistry_->setCellReacting(i, false); + } + } +} + + +void reactingOneDim::solveContinuity() +{ + if (debug) + { + Info<< "reactingOneDim::solveContinuity()" << endl; + } + + solve + ( + fvm::ddt(rho_) + == + - solidChemistry_->RRg() + ); +} + + +void reactingOneDim::solveSpeciesMass() +{ + if (debug) + { + Info<< "reactingOneDim::solveSpeciesMass()" << endl; + } + + volScalarField Yt = 0.0*Ys_[0]; + + for (label i=0; i<Ys_.size()-1; i++) + { + volScalarField& Yi = Ys_[i]; + + fvScalarMatrix YiEqn + ( + fvm::ddt(rho_, Yi) + == + solidChemistry_->RRs(i) + ); + + if (moveMesh_) + { + surfaceScalarField phiRhoMesh = + fvc::interpolate(Yi*rho_)*regionMesh().phi(); + + YiEqn -= fvc::div(phiRhoMesh); + } + + YiEqn.solve(regionMesh().solver("Yi")); + Yi.max(0.0); + Yt += Yi; + } + + Ys_[Ys_.size() - 1] = 1.0 - Yt; +} + + +void reactingOneDim::solveEnergy() +{ + if (debug) + { + Info<< "reactingOneDim::solveEnergy()" << endl; + } + + const volScalarField rhoCp = rho_*solidThermo_.Cp(); + + const surfaceScalarField phiQr = fvc::interpolate(Qr_)*nMagSf(); + + const surfaceScalarField phiGas = fvc::interpolate(phiHsGas_); + + fvScalarMatrix TEqn + ( + fvm::ddt(rhoCp, T_) + - fvm::laplacian(K_, T_) + == + chemistrySh_ + + fvc::div(phiQr) + + fvc::div(phiGas) + ); + + if (moveMesh_) + { + surfaceScalarField phiMesh = + fvc::interpolate(rhoCp*T_)*regionMesh().phi(); + + TEqn -= fvc::div(phiMesh); + } + + TEqn.relax(); + TEqn.solve(); + + Info<< "pyrolysis min/max(T) = " << min(T_).value() << ", " + << max(T_).value() << endl; +} + + +void reactingOneDim::calculateMassTransfer() +{ + totalGasMassFlux_ = 0; + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + totalGasMassFlux_ += gSum(phiGas_.boundaryField()[patchI]); + } + + if (infoOutput_) + { + totalHeatRR_ = fvc::domainIntegrate(chemistrySh_); + + addedGasMass_ += + fvc::domainIntegrate(solidChemistry_->RRg())*time_.deltaT(); + lostSolidMass_ += + fvc::domainIntegrate(solidChemistry_->RRs())*time_.deltaT(); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh) +: + pyrolysisModel(modelType, mesh), + solidChemistry_(solidChemistryModel::New(regionMesh())), + solidThermo_(solidChemistry_->solidThermo()), + kappa_(solidThermo_.kappa()), + K_(solidThermo_.K()), + rho_(solidThermo_.rho()), + Ys_(solidThermo_.composition().Y()), + T_(solidThermo_.T()), + primaryRadFluxName_(coeffs().lookupOrDefault<word>("radFluxName", "Qr")), + nNonOrthCorr_(-1), + maxDiff_(10), + minimumDelta_(1e-4), + + phiGas_ + ( + IOobject + ( + "phiGas", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + regionMesh(), + dimensionedScalar("zero", dimMass/dimTime, 0.0) + ), + + phiHsGas_ + ( + IOobject + ( + "phiHsGas", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + regionMesh(), + dimensionedScalar("zero", dimEnergy/dimTime, 0.0) + ), + + chemistrySh_ + ( + IOobject + ( + "chemistrySh", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + regionMesh(), + dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0) + ), + + QrCoupled_ + ( + IOobject + ( + primaryRadFluxName_, + time().timeName(), + regionMesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + regionMesh() + ), + + Qr_ + ( + IOobject + ( + "QrPyr", + time().timeName(), + regionMesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + regionMesh(), + dimensionedScalar("zero", dimEnergy/dimArea/dimTime, 0.0), + zeroGradientFvPatchVectorField::typeName + ), + + lostSolidMass_(dimensionedScalar("zero", dimMass, 0.0)), + addedGasMass_(dimensionedScalar("zero", dimMass, 0.0)), + totalGasMassFlux_(0.0), + totalHeatRR_(dimensionedScalar("zero", dimEnergy/dimTime, 0.0)) +{ + if (active_) + { + read(); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +reactingOneDim::~reactingOneDim() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +scalar reactingOneDim::addMassSources(const label patchI, const label faceI) +{ + label index = 0; + forAll(primaryPatchIDs_, i) + { + if (primaryPatchIDs_[i] == patchI) + { + index = i; + break; + } + } + + const label localPatchId = intCoupledPatchIDs_[index]; + + const scalar massAdded = phiGas_.boundaryField()[localPatchId][faceI]; + + if (debug) + { + Info<< "\nPyrolysis region: " << type() << "added mass : " + << massAdded << endl; + } + + return massAdded; +} + + +scalar reactingOneDim::solidRegionDiffNo() const +{ + scalar DiNum = 0.0; + scalar meanDiNum = 0.0; + if (regionMesh().nInternalFaces() > 0) + { + surfaceScalarField KrhoCpbyDelta = + regionMesh().surfaceInterpolation::deltaCoeffs() + * fvc::interpolate(K_) + / fvc::interpolate(Cp()*rho_); + + DiNum = max(KrhoCpbyDelta.internalField())*time_.deltaTValue(); + + meanDiNum = average(KrhoCpbyDelta.internalField())*time().deltaTValue(); + } + + return DiNum; +} + + +scalar reactingOneDim::maxDiff() const +{ + return maxDiff_; +} + + +const volScalarField& reactingOneDim::rho() const +{ + return rho_; +} + + +const volScalarField& reactingOneDim::T() const +{ + return T_; +} + + +const tmp<volScalarField> reactingOneDim::Cp() const +{ + return solidThermo_.Cp(); +} + + +const volScalarField& reactingOneDim::kappa() const +{ + return kappa_; +} + + +const volScalarField& reactingOneDim::K() const +{ + return K_; +} + + +const surfaceScalarField& reactingOneDim::phiGas() const +{ + return phiGas_; +} + + +void reactingOneDim::preEvolveRegion() +{ + pyrolysisModel::preEvolveRegion(); + + // Initialise all cells as able to react + forAll(T_, cellI) + { + solidChemistry_->setCellReacting(cellI, true); + } + + // De-activate reactions if pyrolysis region coupled to (valid) film + if (filmCoupled_) + { + const volScalarField& filmDelta = filmDeltaPtr_(); + + forAll(intCoupledPatchIDs_, i) + { + const label patchI = intCoupledPatchIDs_[i]; + const scalarField& filmDeltap = filmDelta.boundaryField()[patchI]; + + forAll(filmDeltap, faceI) + { + const scalar filmDelta0 = filmDeltap[faceI]; + if (filmDelta0 > reactionDeltaMin_) + { + const labelList& cells = boundaryFaceCells_[faceI]; + + // TODO: only limit cell adjacent to film? + //solidChemistry_->setCellNoReacting(cells[0]) + + // Propagate flag through 1-D region + forAll(cells, k) + { + solidChemistry_->setCellReacting(cells[k], false); + } + } + } + } + } +} + + +void reactingOneDim::evolveRegion() +{ + const scalarField mass0 = rho_*regionMesh().V(); + + solidChemistry_->solve + ( + time().value() - time().deltaTValue(), + time().deltaTValue() + ); + + solveContinuity(); + + updateMesh(mass0); + + chemistrySh_ = solidChemistry_->Sh()(); + + updateFields(); + + solveSpeciesMass(); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr_; nonOrth++) + { + solveEnergy(); + } + + calculateMassTransfer(); + + solidThermo_.correct(); +} + + +void reactingOneDim::info() const +{ + Info<< "\nPyrolysis: " << type() << endl; + + Info<< indent << "Total gas mass produced [kg] = " + << addedGasMass_.value() << nl + << indent << "Total solid mass lost [kg] = " + << lostSolidMass_.value() << nl + << indent << "Total pyrolysis gases [kg/s] = " + << totalGasMassFlux_ << nl + << indent << "Total heat release rate [J/s] = " + << totalHeatRR_.value() << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam +} // End namespace regionModels +} // End namespace pyrolysisModels + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H new file mode 100644 index 00000000000..aadc429160a --- /dev/null +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H @@ -0,0 +1,284 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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::reactingOneDim + +Description + Reacting, 1-D pyrolysis model + +SourceFiles + reactingOneDim.C + +\*---------------------------------------------------------------------------*/ + +#ifndef reactingOneDim_H +#define reactingOneDim_H + +#include "pyrolysisModel.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + + +/*---------------------------------------------------------------------------*\ + Class reactingOneDim Declaration +\*---------------------------------------------------------------------------*/ + +class reactingOneDim +: + public pyrolysisModel +{ +private: + + // Private member functions + + //- Disallow default bitwise copy construct + reactingOneDim(const reactingOneDim&); + + //- Disallow default bitwise assignment + void operator=(const reactingOneDim&); + + +protected: + + // Protected data + + //- Reference to the solid chemistry model + autoPtr<solidChemistryModel> solidChemistry_; + + //- Reference to solid thermo + basicSolidThermo& solidThermo_; + + + // Reference to solid thermo properties + + //- Absorption coefficient [1/m] + const volScalarField& kappa_; + + //- Thermal conductivity [W/m/K] + const volScalarField& K_; + + //- Density [kg/m3] + volScalarField& rho_; + + //- List of solid components + PtrList<volScalarField>& Ys_; + + // Non-const access to temperature + volScalarField& T_; + + + //- Name of the radiative flux in the primary region + word primaryRadFluxName_; + + + // Solution parameters + + //- Number of non-orthogonal correctors + label nNonOrthCorr_; + + //- Maximum diffussivity + scalar maxDiff_; + + //- Minimum delta for combustion + scalar minimumDelta_; + + + // Fields + + //- Total gas mass flux to the primary region [kg/m2/s] + surfaceScalarField phiGas_; + + //- Sensible enthalpy gas flux [J/m2/s] + volScalarField phiHsGas_; + + //- Heat release [J/s/m3] + volScalarField chemistrySh_; + + + // Source term fields + + //- Coupled region radiative heat flux [W/m2] + // Requires user to input mapping info for coupled patches + volScalarField QrCoupled_; + + //- In depth radiative heat flux [W/m2] + volScalarField Qr_; + + + // Checks + + //- Cumulative lost mass of the condensed phase [kg] + dimensionedScalar lostSolidMass_; + + //- Cumulative mass generation of the gas phase [kg] + dimensionedScalar addedGasMass_; + + //- Total mass gas flux at the pyrolysing walls [kg/s] + scalar totalGasMassFlux_; + + //- Total heat release rate [J/s] + dimensionedScalar totalHeatRR_; + + + // Protected member functions + + //- Read control parameters from dictionary + bool read(); + + //- Update submodels + void updateFields(); + + //- Update/move mesh based on change in mass + void updateMesh(const scalarField& mass0); + + //- Update radiative flux in pyrolysis region + void updateQr(); + + //- Update enthalpy flux for pyrolysis gases + void updatePhiGas(); + + //- Mass check + void calculateMassTransfer(); + + + // Equations + + //- Solve continuity equation + void solveContinuity(); + + //- Solve energy + void solveEnergy(); + + //- Solve solid species mass conservation + void solveSpeciesMass(); + + +public: + + //- Runtime type information + TypeName("reactingOneDim"); + + + // Constructors + + //- Construct from type name and mesh + reactingOneDim(const word& modelType, const fvMesh& mesh); + + + //- Destructor + virtual ~reactingOneDim(); + + + // Member Functions + + // Access + + //- Fields + + //- Return density [kg/m3] + virtual const volScalarField& rho() const; + + //- Return const temperature [K] + virtual const volScalarField& T() const; + + //- Return specific heat capacity [J/kg/K] + virtual const tmp<volScalarField> Cp() const; + + //- Return the region absorptivity [1/m] + virtual const volScalarField& kappa() const; + + //- Return the region thermal conductivity [W/m/k] + virtual const volScalarField& K() const; + + //- Return the total gas mass flux to primary region [kg/m2/s] + virtual const surfaceScalarField& phiGas() const; + + + // Solution parameters + + //- Return the number of non-orthogonal correctors + inline label nNonOrthCorr() const; + + //- Return max diffusivity allowed in the solid + virtual scalar maxDiff() const; + + + // Helper functions + + //- External hook to add mass to the primary region + virtual scalar addMassSources + ( + const label patchI, // patchI on primary region + const label faceI // faceI of patchI + ); + + //- Mean diffusion number of the solid region + virtual scalar solidRegionDiffNo() const; + + + // Source fields (read/write access) + + //- In depth radiative heat flux + inline const volScalarField& Qr() const; + + + // Evolution + + //- Pre-evolve region + virtual void preEvolveRegion(); + + //- Evolve the pyrolysis equations + virtual void evolveRegion(); + + + // I-O + + //- Provide some feedback + virtual void info() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace pyrolysisModels +} // End namespace regionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "reactingOneDimI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDimI.H b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDimI.H new file mode 100644 index 00000000000..352ddad9ea7 --- /dev/null +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDimI.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "reactingOneDim.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline Foam::label +Foam::regionModels::pyrolysisModels::reactingOneDim::nNonOrthCorr() const +{ + return nNonOrthCorr_; +} + + +inline const Foam::volScalarField& +Foam::regionModels::pyrolysisModels::reactingOneDim::Qr() const +{ + return Qr_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/Allwmake b/src/thermophysicalModels/Allwmake index 07d4cbf0333..c27c4b6648b 100755 --- a/src/thermophysicalModels/Allwmake +++ b/src/thermophysicalModels/Allwmake @@ -18,6 +18,9 @@ wmake $makeType SLGThermo # Should be combined with solids&solidMixture wmake $makeType basicSolidThermo +wmake $makeType solidChemistryModel + +wmake $makeType combustionModels wmake $makeType radiationModels diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C index 6b06924cb36..4ebc3929ebc 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -33,7 +33,7 @@ template<class CompType, class ThermoType> Foam::ODEChemistryModel<CompType, ThermoType>::ODEChemistryModel ( const fvMesh& mesh, - const word& compTypeName, + const word& ODEModelName, const word& thermoTypeName ) : @@ -56,16 +56,6 @@ Foam::ODEChemistryModel<CompType, ThermoType>::ODEChemistryModel nSpecie_(Y_.size()), nReaction_(reactions_.size()), - solver_ - ( - chemistrySolver<CompType, ThermoType>::New - ( - *this, - compTypeName, - thermoTypeName - ) - ), - RR_(nSpecie_) { // create the fields for the chemistry sources @@ -135,6 +125,88 @@ Foam::ODEChemistryModel<CompType, ThermoType>::omega } +template<class CompType, class ThermoType> +Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omegaI +( + const label index, + const scalarField& c, + const scalar T, + const scalar p, + scalar& pf, + scalar& cf, + label& lRef, + scalar& pr, + scalar& cr, + label& rRef +) const +{ + + const Reaction<ThermoType>& R = reactions_[index]; + scalar w = omega(R, c, T, p, pf, cf, lRef, pr, cr, rRef); + return(w); +} + + +template<class CompType, class ThermoType> +void Foam::ODEChemistryModel<CompType, ThermoType>::updateConcsInReactionI +( + const label index, + const scalar dt, + const scalar omeg, + scalarField& c +) const +{ + // update species + const Reaction<ThermoType>& R = reactions_[index]; + forAll(R.lhs(), s) + { + label si = R.lhs()[s].index; + scalar sl = R.lhs()[s].stoichCoeff; + c[si] -= dt*sl*omeg; + c[si] = max(0.0, c[si]); + } + + forAll(R.rhs(), s) + { + label si = R.rhs()[s].index; + scalar sr = R.rhs()[s].stoichCoeff; + c[si] += dt*sr*omeg; + c[si] = max(0.0, c[si]); + } +} + + +template<class CompType, class ThermoType> +void Foam::ODEChemistryModel<CompType, ThermoType>::updateRRInReactionI +( + const label index, + const scalar pr, + const scalar pf, + const scalar corr, + const label lRef, + const label rRef, + simpleMatrix<scalar>& RR +) const +{ + const Reaction<ThermoType>& R = reactions_[index]; + forAll(R.lhs(), s) + { + label si = R.lhs()[s].index; + scalar sl = R.lhs()[s].stoichCoeff; + RR[si][rRef] -= sl*pr*corr; + RR[si][lRef] += sl*pf*corr; + } + + forAll(R.rhs(), s) + { + label si = R.rhs()[s].index; + scalar sr = R.rhs()[s].stoichCoeff; + RR[si][lRef] -= sr*pf*corr; + RR[si][rRef] += sr*pr*corr; + } +} + + template<class CompType, class ThermoType> Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::omega ( @@ -731,7 +803,7 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve // calculate the chemical source terms while (timeLeft > SMALL) { - tauC = solver().solve(c, Ti, pi, t, dt); + tauC = this->solve(c, Ti, pi, t, dt); t += dt; // update the temperature @@ -763,4 +835,28 @@ Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve } +template<class CompType, class ThermoType> +Foam::scalar Foam::ODEChemistryModel<CompType, ThermoType>::solve +( + scalarField &c, + const scalar T, + const scalar p, + const scalar t0, + const scalar dt +) const +{ + notImplemented + ( + "ODEChemistryModel::solve" + "scalarField&, " + "const scalar, " + "const scalar, " + "const scalar, " + "const scalar" + ); + + return (0); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H index d9cc946458d..33391fab9d0 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,7 @@ SourceFiles #include "Reaction.H" #include "ODE.H" #include "volFieldsFwd.H" +#include "simpleMatrix.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -50,9 +51,6 @@ namespace Foam // Forward declaration of classes class fvMesh; -template<class CompType, class ThermoType> -class chemistrySolver; - /*---------------------------------------------------------------------------*\ Class ODEChemistryModel Declaration \*---------------------------------------------------------------------------*/ @@ -65,6 +63,9 @@ class ODEChemistryModel { // Private Member Functions + //- Disallow copy constructor + ODEChemistryModel(const ODEChemistryModel&); + //- Disallow default bitwise assignment void operator=(const ODEChemistryModel&); @@ -88,9 +89,6 @@ protected: //- Number of reactions label nReaction_; - //- Chemistry solver - autoPtr<chemistrySolver<CompType, ThermoType> > solver_; - //- List of reaction rate per specie [kg/m3/s] PtrList<scalarField> RR_; @@ -114,7 +112,7 @@ public: ODEChemistryModel ( const fvMesh& mesh, - const word& compTypeName, + const word& ODEModelName, const word& thermoTypeName ); @@ -137,9 +135,6 @@ public: //- The number of reactions inline label nReaction() const; - //- Return the chemisty solver - inline const chemistrySolver<CompType, ThermoType>& solver() const; - //- dc/dt = omega, rate of change in concentration, for each species virtual tmp<scalarField> omega ( @@ -164,9 +159,48 @@ public: label& rRef ) const; + + //- Return the reaction rate for iReaction and the reference + // species and charateristic times + virtual scalar omegaI + ( + label iReaction, + const scalarField& c, + const scalar T, + const scalar p, + scalar& pf, + scalar& cf, + label& lRef, + scalar& pr, + scalar& cr, + label& rRef + ) const; + //- Calculates the reaction rates virtual void calculate(); + //- Update concentrations in reaction i given dt and reaction rate omega + // used by sequential solver + void updateConcsInReactionI + ( + const label i, + const scalar dt, + const scalar omega, + scalarField& c + ) const; + + //- Update matrix RR for reaction i. Used by EulerImplicit + void updateRRInReactionI + ( + const label i, + const scalar pr, + const scalar pf, + const scalar corr, + const label lRef, + const label rRef, + simpleMatrix<scalar>& RR + ) const; + // Chemistry model functions (overriding abstract functions in // basicChemistryModel.H) @@ -207,6 +241,15 @@ public: scalarField& dcdt, scalarSquareMatrix& dfdc ) const; + + virtual scalar solve + ( + scalarField &c, + const scalar T, + const scalar p, + const scalar t0, + const scalar dt + ) const; }; diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H index e97593e37b7..fbd408fe3b9 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,14 +68,6 @@ Foam::ODEChemistryModel<CompType, ThermoType>::nReaction() const } -template<class CompType, class ThermoType> -inline const Foam::chemistrySolver<CompType, ThermoType>& -Foam::ODEChemistryModel<CompType, ThermoType>::solver() const -{ - return solver_; -} - - template<class CompType, class ThermoType> inline Foam::tmp<Foam::volScalarField> Foam::ODEChemistryModel<CompType, ThermoType>::RR diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H new file mode 100644 index 00000000000..faf2608a2b5 --- /dev/null +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H @@ -0,0 +1,88 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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/>. + +Description + Macros for instantiating chemistry models based on compressibility and + transport types + +\*---------------------------------------------------------------------------*/ + +#ifndef makeChemistryModel_H +#define makeChemistryModel_H + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeChemistryModel(SS, Comp, Thermo) \ + \ + typedef SS<Comp, Thermo> SS##Comp##Thermo; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##Comp##Thermo, \ + #SS"<"#Comp","#Thermo">", \ + 0 \ + ); \ + \ + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##Comp##Thermo, \ + fvMesh \ + ); + + +#define makeSolidChemistryModel(SS, Comp, SThermo, GThermo) \ + \ + typedef SS<Comp, SThermo, GThermo> SS##Comp##SThermo##GThermo; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##Comp##SThermo##GThermo, \ + #SS"<"#Comp","#SThermo","#GThermo">", \ + 0 \ + ); \ + \ + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##Comp##SThermo##GThermo, \ + fvMesh \ + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C index e090c5d9913..a2fbbe497a1 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C @@ -29,15 +29,16 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::EulerImplicit<CompType, ThermoType>::EulerImplicit +template<class ODEChemistryType> +Foam::EulerImplicit<ODEChemistryType>::EulerImplicit ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver<CompType, ThermoType>(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), + chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict(ODEModelName + "Coeffs")), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter")) {} @@ -45,15 +46,15 @@ Foam::EulerImplicit<CompType, ThermoType>::EulerImplicit // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::EulerImplicit<CompType, ThermoType>::~EulerImplicit() +template<class ODEChemistryType> +Foam::EulerImplicit<ODEChemistryType>::~EulerImplicit() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve +template<class ODEChemistryType> +Foam::scalar Foam::EulerImplicit<ODEChemistryType>::solve ( scalarField &c, const scalar T, @@ -62,7 +63,10 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve const scalar dt ) const { - const label nSpecie = this->model_.nSpecie(); + scalar pf, cf, pr, cr; + label lRef, rRef; + + const label nSpecie = this->nSpecie(); simpleMatrix<scalar> RR(nSpecie, 0, 0); for (label i = 0; i < nSpecie; i++) @@ -75,17 +79,9 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve RR.source()[i] = c[i]/dt; } - forAll(this->model_.reactions(), i) + forAll(this->reactions(), i) { - const Reaction<ThermoType>& R = this->model_.reactions()[i]; - - scalar pf, cf, pr, cr; - label lRef, rRef; - - scalar omegai = this->model_.omega - ( - R, c, T, p, pf, cf, lRef, pr, cr, rRef - ); + scalar omegai = this->omegaI(i, c, T, p, pf, cf, lRef, pr, cr, rRef); scalar corr = 1.0; if (eqRateLimiter_) @@ -100,21 +96,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve } } - forAll(R.lhs(), specieI) - { - const label id = R.lhs()[specieI].index; - const scalar sc = R.lhs()[specieI].stoichCoeff; - RR[id][rRef] -= sc*pr*corr; - RR[id][lRef] += sc*pf*corr; - } - - forAll(R.rhs(), specieI) - { - const label id = R.rhs()[specieI].index; - const scalar sc = R.rhs()[specieI].stoichCoeff; - RR[id][lRef] -= sc*pf*corr; - RR[id][rRef] += sc*pr*corr; - } + this->updateRRInReactionI(i, pr, pf, corr, lRef, rRef, RR); } @@ -131,7 +113,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve // estimate the next time step scalar tMin = GREAT; - const label nEqns = this->model_.nEqns(); + const label nEqns = this->nEqns(); scalarField c1(nEqns, 0.0); for (label i = 0; i < nSpecie; i++) @@ -142,7 +124,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve c1[nSpecie+1] = p; scalarField dcdt(nEqns, 0.0); - this->model_.derivatives(0.0, c1, dcdt); + this->derivatives(0.0, c1, dcdt); const scalar sumC = sum(c); diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.H index fffa5a93d81..1ce3148939d 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,18 +42,14 @@ SourceFiles namespace Foam { -// Forward declaration of classes -template<class CompType, class ThermoType> -class EulerImplicit; - /*---------------------------------------------------------------------------*\ Class EulerImplicit Declaration \*---------------------------------------------------------------------------*/ -template<class CompType, class ThermoType> +template<class ODEChemistryType> class EulerImplicit : - public chemistrySolver<CompType, ThermoType> + public chemistrySolver<ODEChemistryType> { // Private data @@ -81,8 +77,9 @@ public: //- Construct from components EulerImplicit ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEmodelName, + const word& thermoType ); @@ -93,7 +90,7 @@ public: // Member Functions //- Update the concentrations and return the chemical time - scalar solve + virtual scalar solve ( scalarField &c, const scalar T, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.C index ade0485af17..c5b40c1a715 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.C @@ -27,22 +27,23 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::chemistrySolver<CompType, ThermoType>::chemistrySolver +template<class ODEChemistryType> +Foam::chemistrySolver<ODEChemistryType>::chemistrySolver ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - model_(model), - name_(modelName) + ODEChemistryType(mesh, ODEModelName, thermoType), + name_(ODEModelName) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::chemistrySolver<CompType, ThermoType>::~chemistrySolver() +template<class ODEChemistryType> +Foam::chemistrySolver<ODEChemistryType>::~chemistrySolver() {} diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H index a3c2e477c3d..f837a4a154f 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,24 +46,19 @@ SourceFiles namespace Foam { -// Forward declaration of classes -template<class CompType, class ThermoType> -class chemistrySolver; - /*---------------------------------------------------------------------------*\ Class chemistrySolver Declaration \*---------------------------------------------------------------------------*/ -template<class CompType, class ThermoType> +template<class ODEChemistryType> class chemistrySolver +: + public ODEChemistryType { protected: // Protected data - //- Reference to the chemistry model - ODEChemistryModel<CompType, ThermoType>& model_; - //- Name of the chemistry solver const word name_; @@ -81,10 +76,11 @@ public: chemistrySolver, dictionary, ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ), - (model, modelName) + (mesh, ODEModelName, thermoType) ); @@ -93,20 +89,12 @@ public: //- Construct from components chemistrySolver ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ); - //- Selector - static autoPtr<chemistrySolver> New - ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& compTypeName, - const word& thermoTypeName - ); - - //- Destructor virtual ~chemistrySolver(); @@ -131,46 +119,60 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define makeChemistrySolver(Comp, Thermo) \ +#define makeChemistrySolver(ODEChem) \ \ - typedef chemistrySolver<Comp, Thermo> \ - chemistrySolver##Comp##Thermo; \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + chemistrySolver<ODEChem>, \ + "chemistrySolver<"#ODEChem">", \ + 0 \ + ); + + + +#define makeChemistrySolverType(SS, ODEChem, Comp, Thermo) \ + \ + typedef SS<ODEChem<Comp, Thermo> > SS##ODEChem##Comp##Thermo; \ \ defineTemplateTypeNameAndDebugWithName \ ( \ - chemistrySolver##Comp##Thermo, \ - "chemistryModel<"#Comp","#Thermo">", \ + SS##ODEChem##Comp##Thermo, \ + #SS"<"#ODEChem"<"#Comp","#Thermo">>", \ 0 \ ); \ \ - defineTemplateRunTimeSelectionTable \ + addToRunTimeSelectionTable \ ( \ - chemistrySolver##Comp##Thermo, \ - dictionary \ + Comp, \ + SS##ODEChem##Comp##Thermo, \ + fvMesh \ ); -#define makeChemistrySolverType(SS, Comp, Thermo) \ +#define makeSolidChemistrySolverType(SS, ODEChem, Comp, SThermo, GThermo) \ \ - typedef SS<Comp, Thermo> SS##Comp##Thermo; \ + typedef SS<ODEChem<Comp, SThermo, GThermo> > \ + SS##ODEChem##Comp##SThermo##GThermo; \ \ defineTemplateTypeNameAndDebugWithName \ ( \ - SS##Comp##Thermo, \ - #SS"<"#Comp","#Thermo">", \ + SS##ODEChem##Comp##SThermo##GThermo, \ + #SS"<"#ODEChem"<"#Comp","#SThermo","#GThermo">>", \ 0 \ ); \ \ - chemistrySolver<Comp, Thermo>:: \ - adddictionaryConstructorToTable<SS<Comp, Thermo> > \ - add##SS##Comp##Thermo##ConstructorToTable_; + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##ODEChem##Comp##SThermo##GThermo, \ + fvMesh \ + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository # include "chemistrySolver.C" -# include "chemistrySolverNew.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolverNew.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolverNew.C deleted file mode 100644 index f7eab4c2d7a..00000000000 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolverNew.C +++ /dev/null @@ -1,80 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 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 "chemistrySolver.H" - -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // - -template<class CompType, class ThermoType> -Foam::autoPtr<Foam::chemistrySolver<CompType, ThermoType> > -Foam::chemistrySolver<CompType, ThermoType>::New -( - ODEChemistryModel<CompType, ThermoType>& model, - const word& compTypeName, - const word& thermoTypeName -) -{ - const word modelName(model.lookup("chemistrySolver")); - - const word chemistrySolverType = - modelName + '<' + compTypeName + ',' + thermoTypeName + '>'; - - Info<< "Selecting chemistrySolver " << modelName << endl; - - typename dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(chemistrySolverType); - - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - wordList models = dictionaryConstructorTablePtr_->sortedToc(); - forAll(models, i) - { - models[i] = models[i].replace - ( - '<' + compTypeName + ',' + thermoTypeName + '>', - "" - ); - } - - FatalErrorIn - ( - "chemistrySolver::New" - "(" - "const ODEChemistryModel&, " - "const word&, " - "const word&" - ")" - ) << "Unknown chemistrySolver type " - << modelName << nl << nl - << "Valid chemistrySolver types are:" << nl - << models << nl << exit(FatalError); - } - - return autoPtr<chemistrySolver<CompType, ThermoType> > - (cstrIter()(model, modelName)); -} - - -// ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolverTypes.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolverTypes.H new file mode 100644 index 00000000000..ef217617f3b --- /dev/null +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolverTypes.H @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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/>. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeChemistrySolverTypes_H +#define makeChemistrySolverTypes_H + +#include "chemistrySolver.H" + +#include "ODEChemistryModel.H" + +#include "noChemistrySolver.H" +#include "EulerImplicit.H" +#include "ode.H" +#include "sequential.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeChemistrySolverTypes(CompChemModel,Thermo) \ + \ + typedef ODEChemistryModel<CompChemModel, Thermo> CompChemModel##Thermo; \ + \ + makeChemistrySolver(CompChemModel##Thermo); \ + \ + makeChemistrySolverType \ + ( \ + noChemistrySolver, \ + ODEChemistryModel, \ + CompChemModel, \ + Thermo \ + ); \ + \ + makeChemistrySolverType \ + ( \ + EulerImplicit, \ + ODEChemistryModel, \ + CompChemModel, \ + Thermo \ + ); \ + \ + makeChemistrySolverType \ + ( \ + ode, \ + ODEChemistryModel, \ + CompChemModel, \ + Thermo \ + ); \ + \ + makeChemistrySolverType \ + ( \ + sequential, \ + ODEChemistryModel, \ + CompChemModel, \ + Thermo \ + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolvers.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolvers.C index f9ae6bca25b..82b29fb37b7 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolvers.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/makeChemistrySolvers.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,85 +23,20 @@ License \*---------------------------------------------------------------------------*/ -#include "thermoPhysicsTypes.H" -#include "chemistrySolver.H" +#include "makeChemistrySolverTypes.H" +#include "thermoPhysicsTypes.H" #include "psiChemistryModel.H" #include "rhoChemistryModel.H" -#include "noChemistrySolver.H" - -#include "EulerImplicit.H" -#include "ode.H" -#include "sequential.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { - makeChemistrySolver(psiChemistryModel, gasThermoPhysics) - makeChemistrySolverType - ( - noChemistrySolver, - psiChemistryModel, - gasThermoPhysics - ) - makeChemistrySolverType(EulerImplicit, psiChemistryModel, gasThermoPhysics) - makeChemistrySolverType(ode, psiChemistryModel, gasThermoPhysics) - makeChemistrySolverType(sequential, psiChemistryModel, gasThermoPhysics) - - makeChemistrySolver(psiChemistryModel, icoPoly8ThermoPhysics) - makeChemistrySolverType - ( - noChemistrySolver, - psiChemistryModel, - icoPoly8ThermoPhysics - ) - makeChemistrySolverType - ( - EulerImplicit, - psiChemistryModel, - icoPoly8ThermoPhysics - ) - makeChemistrySolverType(ode, psiChemistryModel, icoPoly8ThermoPhysics) - makeChemistrySolverType - ( - sequential, - psiChemistryModel, - icoPoly8ThermoPhysics - ) - - makeChemistrySolver(rhoChemistryModel, gasThermoPhysics) - makeChemistrySolverType - ( - noChemistrySolver, - rhoChemistryModel, - gasThermoPhysics - ) - makeChemistrySolverType(EulerImplicit, rhoChemistryModel, gasThermoPhysics) - makeChemistrySolverType(ode, rhoChemistryModel, gasThermoPhysics) - makeChemistrySolverType(sequential, rhoChemistryModel, gasThermoPhysics) - - makeChemistrySolver(rhoChemistryModel, icoPoly8ThermoPhysics) - makeChemistrySolverType - ( - noChemistrySolver, - rhoChemistryModel, - icoPoly8ThermoPhysics - ) - makeChemistrySolverType - ( - EulerImplicit, - rhoChemistryModel, - icoPoly8ThermoPhysics - ) - makeChemistrySolverType(ode, rhoChemistryModel, icoPoly8ThermoPhysics) - makeChemistrySolverType - ( - sequential, - rhoChemistryModel, - icoPoly8ThermoPhysics - ) + makeChemistrySolverTypes(psiChemistryModel, gasThermoPhysics); + makeChemistrySolverTypes(psiChemistryModel, icoPoly8ThermoPhysics); + makeChemistrySolverTypes(rhoChemistryModel, gasThermoPhysics); + makeChemistrySolverTypes(rhoChemistryModel, icoPoly8ThermoPhysics); } diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.C index 0d64b3fb852..822f8266b1e 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,28 +28,29 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::noChemistrySolver<CompType, ThermoType>::noChemistrySolver +template<class ODEChemistryType> +Foam::noChemistrySolver<ODEChemistryType>::noChemistrySolver ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver<CompType, ThermoType>(model, modelName) + chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::noChemistrySolver<CompType, ThermoType>::~noChemistrySolver() +template<class ODEChemistryType> +Foam::noChemistrySolver<ODEChemistryType>::~noChemistrySolver() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::scalar Foam::noChemistrySolver<CompType, ThermoType>::solve +template<class ODEChemistryType> +Foam::scalar Foam::noChemistrySolver<ODEChemistryType>::solve ( scalarField&, const scalar, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H index 7382beba854..752c8d61776 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,18 +43,14 @@ SourceFiles namespace Foam { -// Forward declaration of classes -template<class CompType, class ThermoType> -class noChemistrySolver; - /*---------------------------------------------------------------------------*\ - Class noChemistrySolver Declaration + Class noChemistrySolver Declaration \*---------------------------------------------------------------------------*/ -template<class CompType, class ThermoType> +template<class ODEChemistryType> class noChemistrySolver : - public chemistrySolver<CompType, ThermoType> + public chemistrySolver<ODEChemistryType> { public: @@ -69,8 +65,9 @@ public: //- Construct from components noChemistrySolver ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ); @@ -81,7 +78,7 @@ public: // Member Functions //- Update the concentrations and return the chemical time - scalar solve + virtual scalar solve ( scalarField &c, const scalar T, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.C index d20f22f91e3..29e7d6c8e7d 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,32 +28,33 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::ode<CompType, ThermoType>::ode +template<class ODEChemistryType> +Foam::ode<ODEChemistryType>::ode ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver<CompType, ThermoType>(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), + chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict(ODEModelName + "Coeffs")), solverName_(coeffsDict_.lookup("ODESolver")), - odeSolver_(ODESolver::New(solverName_, model)), + odeSolver_(ODESolver::New(solverName_, *this)), eps_(readScalar(coeffsDict_.lookup("eps"))) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::ode<CompType, ThermoType>::~ode() +template<class ODEChemistryType> +Foam::ode<ODEChemistryType>::~ode() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::scalar Foam::ode<CompType, ThermoType>::solve +template<class ODEChemistryType> +Foam::scalar Foam::ode<ODEChemistryType>::solve ( scalarField& c, const scalar T, @@ -62,8 +63,8 @@ Foam::scalar Foam::ode<CompType, ThermoType>::solve const scalar dt ) const { - label nSpecie = this->model_.nSpecie(); - scalarField c1(this->model_.nEqns(), 0.0); + label nSpecie = this->nSpecie(); + scalarField c1(this->nEqns(), 0.0); // copy the concentration, T and P to the total solve-vector for (label i = 0; i < nSpecie; i++) @@ -77,7 +78,7 @@ Foam::scalar Foam::ode<CompType, ThermoType>::solve odeSolver_->solve ( - this->model_, + *this, t0, t0 + dt, c1, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.H index e68af7c63cd..d6f7f27a724 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/ode/ode.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,18 +43,14 @@ SourceFiles namespace Foam { -// Forward declaration of classes -template<class CompType, class ThermoType> -class ode; - /*---------------------------------------------------------------------------*\ Class ode Declaration \*---------------------------------------------------------------------------*/ -template<class CompType, class ThermoType> +template<class ODEChemistryType> class ode : - public chemistrySolver<CompType, ThermoType> + public chemistrySolver<ODEChemistryType> { // Private data @@ -78,8 +74,9 @@ public: //- Construct from components ode ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModeNewlName, + const word& thermoType ); @@ -89,7 +86,7 @@ public: // Member Functions - scalar solve + virtual scalar solve ( scalarField& c, const scalar T, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C index 8046aaf2f0a..28a80563cc9 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,15 +28,16 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::sequential<CompType, ThermoType>::sequential +template<class ODEChemistryType> +Foam::sequential<ODEChemistryType>::sequential ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver<CompType, ThermoType>(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), + chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict(ODEModelName + "Coeffs")), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter")) {} @@ -44,15 +45,15 @@ Foam::sequential<CompType, ThermoType>::sequential // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::sequential<CompType, ThermoType>::~sequential() +template<class ODEChemistryType> +Foam::sequential<ODEChemistryType>::~sequential() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class CompType, class ThermoType> -Foam::scalar Foam::sequential<CompType, ThermoType>::solve +template<class ODEChemistryType> +Foam::scalar Foam::sequential<ODEChemistryType>::solve ( scalarField &c, const scalar T, @@ -66,14 +67,9 @@ Foam::scalar Foam::sequential<CompType, ThermoType>::solve scalar pf, cf, pb, cb; label lRef, rRef; - forAll(this->model_.reactions(), i) + forAll(this->reactions(), i) { - const Reaction<ThermoType>& R = this->model_.reactions()[i]; - - scalar omega = this->model_.omega - ( - R, c, T, p, pf, cf, lRef, pb, cb, rRef - ); + scalar omega = this->omegaI(i, c, T, p, pf, cf, lRef, pb, cb, rRef); if (eqRateLimiter_) { @@ -89,23 +85,7 @@ Foam::scalar Foam::sequential<CompType, ThermoType>::solve tChemInv = max(tChemInv, mag(omega)); - - // update species - forAll(R.lhs(), specieI) - { - const label id = R.lhs()[specieI].index; - const scalar sc = R.lhs()[specieI].stoichCoeff; - c[id] -= dt*sc*omega; - c[id] = max(0.0, c[id]); - } - - forAll(R.rhs(), specieI) - { - const label id = R.rhs()[specieI].index; - const scalar sc = R.rhs()[specieI].stoichCoeff; - c[id] += dt*sc*omega; - c[id] = max(0.0, c[id]); - } + this->updateConcsInReactionI(i, dt, omega, c); } return cTauChem_/tChemInv; diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.H index 795c9f9c828..81635c6d7ff 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.H +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,18 +44,14 @@ SourceFiles namespace Foam { -// Forward declaration of classes -template<class CompType, class ThermoType> -class sequential; - /*---------------------------------------------------------------------------*\ Class sequential Declaration \*---------------------------------------------------------------------------*/ -template<class CompType, class ThermoType> +template<class ODEChemistryType> class sequential : - public chemistrySolver<CompType, ThermoType> + public chemistrySolver<ODEChemistryType> { // Private data @@ -83,8 +79,9 @@ public: //- Construct from components sequential ( - ODEChemistryModel<CompType, ThermoType>& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ); @@ -95,7 +92,7 @@ public: // Member Functions //- Update the concentrations and return the chemical time - scalar solve + virtual scalar solve ( scalarField &c, const scalar T, diff --git a/src/thermophysicalModels/combustionModels/Make/files b/src/thermophysicalModels/combustionModels/Make/files new file mode 100644 index 00000000000..86696b07093 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/Make/files @@ -0,0 +1,9 @@ +combustionModel/combustionModel.C +combustionModel/combustionModelNew.C + +infinitelyFastChemistry/infinitelyFastChemistry.C + +noCombustion/noCombustion.C + +LIB = $(FOAM_LIBBIN)/libcombustionModels + diff --git a/src/thermophysicalModels/combustionModels/Make/options b/src/thermophysicalModels/combustionModels/Make/options new file mode 100644 index 00000000000..314c820f246 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +LIB_LIBS = \ + -lfiniteVolume diff --git a/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.C b/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.C new file mode 100644 index 00000000000..bfccadf733d --- /dev/null +++ b/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.C @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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 "combustionModel.H" +#include "surfaceFields.H" +#include "fvScalarMatrix.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(combustionModel, 0); + defineRunTimeSelectionTable(combustionModel, dictionary); +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModel::combustionModel +( + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + coeffs_(dictionary::null), + thermo_(thermo), + turbulence_(turbulence), + mesh_(phi.mesh()), + phi_(phi), + rho_(rho) +{} + + +Foam::combustionModel::combustionModel +( + const word& modelType, + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + coeffs_(combustionProps.subDict(modelType + "Coeffs")), + thermo_(thermo), + turbulence_(turbulence), + mesh_(phi.mesh()), + phi_(phi), + rho_(rho) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModel::~combustionModel() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::combustionModel::correct() +{ + // do nothing +} + + +Foam::tmp<Foam::fvScalarMatrix> Foam::combustionModel::R +( + volScalarField& Y +) const +{ + return tmp<fvScalarMatrix> + ( + new fvScalarMatrix(Y, dimMass/dimTime*Y.dimensions()) + ); +} + + +Foam::tmp<Foam::volScalarField> Foam::combustionModel::dQ() const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "dQ", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimEnergy/dimVolume/dimTime, 0.0) + ) + ); +} + + +Foam::tmp<Foam::volScalarField> Foam::combustionModel::wFuelNorm() const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "wFuelNorm", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimMass/dimTime/pow3(dimLength), 0.0) + ) + ); +} + + +bool Foam::combustionModel::read(const dictionary& combustionProps) +{ + coeffs_ = combustionProps.subDict(type() + "Coeffs"); + + return true; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.H b/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.H new file mode 100644 index 00000000000..28ccb85b1b8 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/combustionModel/combustionModel.H @@ -0,0 +1,201 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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::combustionModel + +Description + Base class for all non-premixed combustion models based on single step + chemistry + +SourceFiles + combustionModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef combustionModel_H +#define combustionModel_H + +#include "IOdictionary.H" +#include "hsCombustionThermo.H" +#include "turbulenceModel.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class combustionModel Declaration +\*---------------------------------------------------------------------------*/ + +class combustionModel +{ + +protected: + + // Protected data + + //- Dictionary of coefficients for the particular model + dictionary coeffs_; + + //- Reference to the thermodynamics + hsCombustionThermo& thermo_; + + //- Reference to the turbulence model + const compressible::turbulenceModel& turbulence_; + + //- Reference to the mesh database + const fvMesh& mesh_; + + //- Reference to mass-flux field + const surfaceScalarField& phi_; + + //- Reference to the density field + const volScalarField& rho_; + + +private: + + // Private Member Functions + + //- Disallow copy construct + combustionModel(const combustionModel&); + + //- Disallow default bitwise assignment + void operator=(const combustionModel&); + + +public: + + //- Runtime type information + TypeName("combustionModel"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + combustionModel, + dictionary, + ( + const dictionary& combustionProperties, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ), + ( + combustionProperties, + thermo, + turbulence, + phi, + rho + ) + ); + + + // Selectors + + //- Return a reference to the selected combustion model + static autoPtr<combustionModel> New + ( + const dictionary& combustionProperties, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + // Constructors + + //- Construct null from components + combustionModel + ( + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + //- Construct from components + combustionModel + ( + const word& modelType, + const dictionary& combustionProperties, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + //- Destructor + virtual ~combustionModel(); + + + // Member Functions + + // Access functions + + //- Access combustion dictionary + const dictionary coeffs() const + { + return coeffs_; + } + + + // Evolution + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix, i.e. source term for fuel equation + virtual tmp<fvScalarMatrix> R(volScalarField& Y) const; + + //- Heat release rate calculated from fuel consumption rate matrix + virtual tmp<volScalarField> dQ() const; + + //- Return normalised consumption rate of (fu - fres) + virtual tmp<Foam::volScalarField> wFuelNorm() const; + + + // I-O + + //- Update properties from given dictionary + virtual bool read(const dictionary& combustionProps); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/combustionModel/combustionModelNew.C b/src/thermophysicalModels/combustionModels/combustionModel/combustionModelNew.C new file mode 100644 index 00000000000..23e07f76e13 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/combustionModel/combustionModelNew.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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 "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::combustionModel> Foam::combustionModel::New +( + const dictionary& combustionProperties, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +{ + word combustionModelTypeName = combustionProperties.lookup + ( + "combustionModel" + ); + + Info<< "Selecting combustion model " << combustionModelTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(combustionModelTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "combustionModel::New" + ) << "Unknown combustionModel type " + << combustionModelTypeName << endl << endl + << "Valid combustionModels are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr<combustionModel> + (cstrIter()(combustionProperties, thermo, turbulence, phi, rho)); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C b/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C new file mode 100644 index 00000000000..c66099a88c9 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.C @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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 "infinitelyFastChemistry.H" +#include "addToRunTimeSelectionTable.H" +#include "fvmSup.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + defineTypeNameAndDebug(infinitelyFastChemistry, 0); + addToRunTimeSelectionTable + ( + combustionModel, + infinitelyFastChemistry, + dictionary + ); +}; +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModels::infinitelyFastChemistry::infinitelyFastChemistry +( + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + combustionModel(typeName, combustionProps, thermo, turbulence, phi, rho), + C_(readScalar(coeffs_.lookup("C"))), + singleMixture_ + ( + dynamic_cast<singleStepReactingMixture<gasThermoPhysics>&>(thermo) + ), + wFuelNorm_ + ( + IOobject + ( + "wFuelNorm", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_, + dimensionedScalar("zero", dimMass/pow3(dimLength)/dimTime, 0.0) + ) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModels::infinitelyFastChemistry::~infinitelyFastChemistry() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::combustionModels::infinitelyFastChemistry::correct() +{ + singleMixture_.fresCorrect(); + + const label fuelI = singleMixture_.fuelIndex(); + + const volScalarField& YFuel = thermo_.composition().Y()[fuelI]; + + const dimensionedScalar s = singleMixture_.s(); + + if (thermo_.composition().contains("O2")) + { + const volScalarField& YO2 = thermo_.composition().Y("O2"); + wFuelNorm_ == rho_/(mesh_.time().deltaT()*C_)*min(YFuel, YO2/s.value()); + } +} + + +Foam::tmp<Foam::fvScalarMatrix> +Foam::combustionModels::infinitelyFastChemistry::R(volScalarField& Y) const +{ + const label specieI = thermo_.composition().species()[Y.name()]; + + const label fNorm = singleMixture_.specieProd()[specieI]; + + const volScalarField fres = singleMixture_.fres(specieI); + + const volScalarField wSpecie = + wFuelNorm_*singleMixture_.specieStoichCoeffs()[specieI] + / max(fNorm*(Y - fres), 0.001); + + return -fNorm*wSpecie*fres + fNorm*fvm::Sp(wSpecie, Y); +} + + +Foam::tmp<Foam::volScalarField> +Foam::combustionModels::infinitelyFastChemistry::dQ() const +{ + const label fuelI = singleMixture_.fuelIndex(); + volScalarField& YFuel = thermo_.composition().Y(fuelI); + + return -singleMixture_.qFuel()*(R(YFuel) & YFuel); +} + + +Foam::tmp<Foam::volScalarField> +Foam::combustionModels::infinitelyFastChemistry::wFuelNorm() const +{ + return wFuelNorm_; +} + + +bool Foam::combustionModels::infinitelyFastChemistry::read +( + const dictionary& combustionProps +) +{ + combustionModel::read(combustionProps); + coeffs_.lookup("C") >> C_ ; + + return true; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H b/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H new file mode 100644 index 00000000000..304dba46a3b --- /dev/null +++ b/src/thermophysicalModels/combustionModels/infinitelyFastChemistry/infinitelyFastChemistry.H @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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::combustionModels::infinitelyFastChemistry + +Description + Simple infinitely fast chemistry combustion model based on the principle + mixed is burnt. Additional parameter C is used to distribute the heat + release rate.in time + +SourceFiles + infinitelyFastChemistry.C + +\*---------------------------------------------------------------------------*/ + +#ifndef infinitelyFastChemistry_H +#define infinitelyFastChemistry_H + +#include "combustionModel.H" +#include "singleStepReactingMixture.H" +#include "thermoPhysicsTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class infinitelyFastChemistry Declaration +\*---------------------------------------------------------------------------*/ + +class infinitelyFastChemistry +: + public combustionModel +{ + // Private data + + //- Model constant + scalar C_; + + //- Reference to singleStepReactingMixture mixture + singleStepReactingMixture<gasThermoPhysics>& singleMixture_; + + //- Normalised consumption rate of (fu - fres) + volScalarField wFuelNorm_; + + + // Private Member Functions + + //- Disallow copy construct + infinitelyFastChemistry(const infinitelyFastChemistry&); + + //- Disallow default bitwise assignment + void operator=(const infinitelyFastChemistry&); + + +public: + + //- Runtime type information + TypeName("infinitelyFastChemistry"); + + + // Constructors + + //- Construct from components + infinitelyFastChemistry + ( + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + //- Destructor + virtual ~infinitelyFastChemistry(); + + + // Member Functions + + // Evolution + + //- Correct combustion rate + virtual void correct(); + + //- Fuel consumption rate matrix, i.e. source term for fuel equation + virtual tmp<fvScalarMatrix> R(volScalarField& Y) const; + + //- Heat release rate calculated from fuel consumption rate matrix + virtual tmp<volScalarField> dQ() const; + + //- Return normalised consumption rate of (fu - fres) + virtual tmp<volScalarField> wFuelNorm() const; + + + // I-O + + //- Update properties from given dictionary + virtual bool read(const dictionary& combustionProperties); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.C b/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.C new file mode 100644 index 00000000000..4fc8c7d0c90 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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 "noCombustion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + defineTypeNameAndDebug(noCombustion, 0); + addToRunTimeSelectionTable + ( + combustionModel, + noCombustion, + dictionary + ); +}; +}; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::combustionModels::noCombustion::noCombustion +( + const dictionary& combustionProps, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho +) +: + combustionModel(combustionProps, thermo, turbulence, phi, rho) +{} + + +// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * // + +Foam::combustionModels::noCombustion::~noCombustion() +{} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.H b/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.H new file mode 100644 index 00000000000..d36f4c11e34 --- /dev/null +++ b/src/thermophysicalModels/combustionModels/noCombustion/noCombustion.H @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + + 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::combustionModel::noCombustion + +Description + Dummy combustion model for 'none' option + +SourceFiles + noCombustion.C + +\*---------------------------------------------------------------------------*/ + +#ifndef noCombustion_H +#define noCombustion_H + +#include "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace combustionModels +{ + +/*---------------------------------------------------------------------------*\ + Class noCombustion Declaration +\*---------------------------------------------------------------------------*/ + +class noCombustion +: + public combustionModel +{ + // Private Member Functions + + //- Disallow copy construct + noCombustion(const noCombustion&); + + //- Disallow default bitwise assignment + void operator=(const noCombustion&); + + +public: + + //- Runtime type information + TypeName("none"); + + + // Constructors + + //- Construct from components + noCombustion + ( + const dictionary& combustionProperties, + hsCombustionThermo& thermo, + const compressible::turbulenceModel& turbulence, + const surfaceScalarField& phi, + const volScalarField& rho + ); + + + //- Destructor + virtual ~noCombustion(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace combustionModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.C b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.C index 9bb945952cc..2751ac0bf2f 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.C @@ -43,6 +43,7 @@ License #include "dieselMixture.H" #include "multiComponentMixture.H" #include "reactingMixture.H" +#include "singleStepReactingMixture.H" #include "thermoPhysicsTypes.H" @@ -164,6 +165,14 @@ makeCombustionThermo // Multi-component thermo +makeCombustionMixtureThermo +( + hCombustionThermo, + hPsiMixtureThermo, + multiComponentMixture, + constGasThermoPhysics +); + makeCombustionMixtureThermo ( hCombustionThermo, @@ -175,6 +184,14 @@ makeCombustionMixtureThermo // Multi-component reaction thermo +makeCombustionMixtureThermo +( + hCombustionThermo, + hPsiMixtureThermo, + reactingMixture, + constGasThermoPhysics +); + makeCombustionMixtureThermo ( hCombustionThermo, @@ -183,6 +200,13 @@ makeCombustionMixtureThermo gasThermoPhysics ); +makeCombustionMixtureThermo +( + hCombustionThermo, + hPsiMixtureThermo, + singleStepReactingMixture, + gasThermoPhysics +); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C b/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C index b8b6c9668cc..f3edd7158fa 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hsCombustionThermo/hsCombustionThermos.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,7 @@ License #include "homogeneousMixture.H" #include "inhomogeneousMixture.H" #include "veryInhomogeneousMixture.H" +#include "singleStepReactingMixture.H" #include "reactingMixture.H" #include "multiComponentMixture.H" @@ -126,6 +127,14 @@ makeHsCombustionThermo // Multi-component thermo +makeHsCombustionMixtureThermo +( + hsCombustionThermo, + hsPsiMixtureThermo, + multiComponentMixture, + constGasThermoPhysics +); + makeHsCombustionMixtureThermo ( hsCombustionThermo, @@ -137,6 +146,14 @@ makeHsCombustionMixtureThermo // Multi-component reaction thermo +makeHsCombustionMixtureThermo +( + hsCombustionThermo, + hsPsiMixtureThermo, + reactingMixture, + constGasThermoPhysics +); + makeHsCombustionMixtureThermo ( hsCombustionThermo, @@ -145,6 +162,16 @@ makeHsCombustionMixtureThermo gasThermoPhysics ); + +makeHsCombustionMixtureThermo +( + hsCombustionThermo, + hsPsiMixtureThermo, + singleStepReactingMixture, + gasThermoPhysics +); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C new file mode 100644 index 00000000000..57471ce57ba --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.C @@ -0,0 +1,259 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "singleStepReactingMixture.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template<class ThermoType> +void Foam::singleStepReactingMixture<ThermoType>::calculateqFuel() +{ + const Reaction<ThermoType>& reaction = this->operator[](0); + const scalar Wu = this->speciesData()[fuelIndex_].W(); + + forAll(reaction.lhs(), i) + { + const label specieI = reaction.lhs()[i].index; + const scalar stoichCoeff = reaction.lhs()[i].stoichCoeff; + specieStoichCoeffs_[specieI] = -stoichCoeff; + qFuel_.value() += this->speciesData()[specieI].hc()*stoichCoeff/Wu; + } + + forAll(reaction.rhs(), i) + { + const label specieI = reaction.rhs()[i].index; + const scalar stoichCoeff = reaction.rhs()[i].stoichCoeff; + specieStoichCoeffs_[specieI] = stoichCoeff; + qFuel_.value() -= this->speciesData()[specieI].hc()*stoichCoeff/Wu; + specieProd_[specieI] = -1; + } + + Info << "Fuel heat of combustion :" << qFuel_.value() << endl; +} + + +template<class ThermoType> +void Foam::singleStepReactingMixture<ThermoType>::massAndAirStoichRatios() +{ + const label O2Index = this->species()["O2"]; + const scalar Wu = this->speciesData()[fuelIndex_].W(); + + stoicRatio_ = + (this->speciesData()[inertIndex_].W() + * specieStoichCoeffs_[inertIndex_] + + this->speciesData()[O2Index].W() + * mag(specieStoichCoeffs_[O2Index])) + / (Wu*mag(specieStoichCoeffs_[fuelIndex_])); + + s_ = + (this->speciesData()[O2Index].W() + * mag(specieStoichCoeffs_[O2Index])) + / (Wu*mag(specieStoichCoeffs_[fuelIndex_])); + + Info << "stoichiometric air-fuel ratio :" << stoicRatio_.value() << endl; + + Info << "stoichiometric oxygen-fuel ratio :" << s_.value() << endl; +} + + +template<class ThermoType> +void Foam::singleStepReactingMixture<ThermoType>::calculateMaxProducts() +{ + const Reaction<ThermoType>& reaction = this->operator[](0); + + scalar Wm = 0.0; + scalar totalMol = 0.0; + forAll(reaction.rhs(), i) + { + label specieI = reaction.rhs()[i].index; + totalMol += mag(specieStoichCoeffs_[specieI]); + } + + scalarList Xi(reaction.rhs().size()); + + forAll(reaction.rhs(), i) + { + const label specieI = reaction.rhs()[i].index; + Xi[i] = mag(specieStoichCoeffs_[specieI])/totalMol; + + Wm += Xi[i]*this->speciesData()[specieI].W(); + } + + forAll(reaction.rhs(), i) + { + const label specieI = reaction.rhs()[i].index; + Yprod0_[specieI] = this->speciesData()[specieI].W()/Wm*Xi[i]; + } + + Info << "Max products: " << Yprod0_ << endl; + + // Normalize the stoichiometric coeff to mass + forAll(specieStoichCoeffs_, i) + { + specieStoichCoeffs_[i] = + specieStoichCoeffs_[i] + * this->speciesData()[i].W() + / (this->speciesData()[fuelIndex_].W() + * mag(specieStoichCoeffs_[fuelIndex_])); + } +} + + +template<class ThermoType> +void Foam::singleStepReactingMixture<ThermoType>::fresCorrect() +{ + const Reaction<ThermoType>& reaction = this->operator[](0); + + label O2Index = this->species()["O2"]; + const volScalarField& YFuel = this->Y()[fuelIndex_]; + const volScalarField& YO2 = this->Y()[O2Index]; + + // reactants + forAll(reaction.lhs(), i) + { + const label specieI = reaction.lhs()[i].index; + if (specieI == fuelIndex_) + { + fres_[specieI] = max(YFuel - YO2/s_, 0.0); + } + else if (specieI == O2Index) + { + fres_[specieI] = max(YO2 - YFuel*s_, 0.0); + } + } + + + // products + forAll(reaction.rhs(), i) + { + const label specieI = reaction.rhs()[i].index; + if (specieI != inertIndex_) + { + forAll(fres_[specieI], cellI) + { + if (fres_[fuelIndex_][cellI] > 0.0) + { + // rich mixture + fres_[specieI][cellI] = + Yprod0_[specieI] + * (1.0 + YO2[cellI]/s_.value() - YFuel[cellI]); + } + else + { + // lean mixture + fres_[specieI][cellI] = + Yprod0_[specieI] + * ( + 1.0 + - YO2[cellI]/s_.value()*stoicRatio_.value() + + YFuel[cellI]*stoicRatio_.value() + ); + } + } + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class ThermoType> +Foam::singleStepReactingMixture<ThermoType>::singleStepReactingMixture +( + const dictionary& thermoDict, + const fvMesh& mesh +) +: + reactingMixture<ThermoType>(thermoDict, mesh), + stoicRatio_(dimensionedScalar("stoicRatio", dimless, 0.0)), + s_(dimensionedScalar("s", dimless, 0.0)), + qFuel_(dimensionedScalar("qFuel", sqr(dimVelocity), 0.0)), + specieStoichCoeffs_(this->species_.size(), 0.0), + Yprod0_(this->species_.size(), 0.0), + fres_(Yprod0_.size()), + inertIndex_(this->species()[thermoDict.lookup("inertSpecie")]), + fuelIndex_(this->species()[thermoDict.lookup("fuel")]), + specieProd_(Yprod0_.size(), 1) +{ + if (this->size() == 1) + { + forAll(fres_, fresI) + { + IOobject header + ( + "fres_" + this->species()[fresI], + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ); + + fres_.set + ( + fresI, + new volScalarField + ( + header, + mesh, + dimensionedScalar("fres" + name(fresI), dimless, 0.0) + ) + ); + } + + calculateqFuel(); + + massAndAirStoichRatios(); + + calculateMaxProducts(); + + autoPtr<chemistryReader<ThermoType> >::clear(); + } + else + { + FatalErrorIn + ( + "singleStepReactingMixture::<ThermoType>::singleStepReactingMixture" + "(" + "const dictionary&, " + "const fvMesh&" + ")" + ) << "Only one reaction required for single step reaction" + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class ThermoType> +void Foam::singleStepReactingMixture<ThermoType>::read +( + const dictionary& thermoDict +) +{} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H new file mode 100644 index 00000000000..5f31f225eab --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixture.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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::singleStepReactingMixture + +Description + Single step reacting mixture + +SourceFiles + singleStepReactingMixture.C + +\*---------------------------------------------------------------------------*/ + +#ifndef singleStepReactingMixture_H +#define singleStepReactingMixture_H + +#include "chemistryReader.H" +#include "reactingMixture.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class singleStepReactingMixture Declaration +\*---------------------------------------------------------------------------*/ + +template<class ThermoType> +class singleStepReactingMixture +: + public reactingMixture<ThermoType> +{ + +protected: + + // Protected data + + //- Stoichiometric air-fuel mass ratio + dimensionedScalar stoicRatio_; + + //- Stoichiometric oxygen-fuel mass ratio + dimensionedScalar s_; + + //- Heat of combustion [J/Kg] + dimensionedScalar qFuel_; + + //- Stoichiometric coefficient for the reaction. + scalarList specieStoichCoeffs_; + + //- Mass concentrations at stoichiometric mixture for fres. + scalarList Yprod0_; + + //- List of components residual + PtrList<volScalarField> fres_; + + //- Inert specie index + label inertIndex_; + + //- Fuel specie index + label fuelIndex_; + + //- List to indicate if specie is produced/consumed + List<int> specieProd_; + + + // Protected member functions + + //- Disallow default bitwise copy construct + singleStepReactingMixture(const singleStepReactingMixture&); + + //- Disallow default bitwise assignment + void operator=(const singleStepReactingMixture&); + + //- Calculate qFuel + void calculateqFuel(); + + //- Calculate air/fuel and oxygen/fuel ratio + void massAndAirStoichRatios(); + + //- Calculate maximum products at stoichiometric mixture + void calculateMaxProducts(); + + +public: + + //- The type of thermo package this mixture is instantiated for + typedef ThermoType thermoType; + + + // Constructors + + //- Construct from dictionary and mesh + singleStepReactingMixture(const dictionary&, const fvMesh&); + + + //- Destructor + virtual ~singleStepReactingMixture() + {} + + + // Member functions + + //- Calculates the residual for all components + void fresCorrect(); + + + // Access functions + + //- Return the stoichiometric air-fuel mass ratio + inline const dimensionedScalar stoicRatio() const; + + //- Return the Stoichiometric oxygen-fuel mass ratio + inline const dimensionedScalar s() const; + + //- Return the heat of combustion [J/Kg] + inline const dimensionedScalar qFuel() const; + + //- Return the stoichiometric coefficient for the reaction + inline const List<scalar>& specieStoichCoeffs() const; + + //- Return the list of components residual + inline tmp<volScalarField> fres(const label index) const; + + //- Return the inert specie index + inline label inertIndex() const; + + //- Return the fuel specie index + inline label fuelIndex() const; + + //- Return the list to indicate if specie is produced/consumed + inline const List<int>& specieProd() const; + + + // I-O + + //- Read dictionary + void read(const dictionary&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "singleStepReactingMixtureI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "singleStepReactingMixture.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixtureI.H b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixtureI.H new file mode 100644 index 00000000000..f8cfe1d9f14 --- /dev/null +++ b/src/thermophysicalModels/reactionThermo/mixtures/singleStepReactingMixture/singleStepReactingMixtureI.H @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "singleStepReactingMixture.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class ThermoType> +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture<ThermoType>::stoicRatio() const +{ + return stoicRatio_; +} + + +template<class ThermoType> +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture<ThermoType>::s() const +{ + return s_; +} + + +template<class ThermoType> +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture<ThermoType>::qFuel() const +{ + return qFuel_; +} + + +template<class ThermoType> +inline const Foam::List<Foam::scalar>& +Foam::singleStepReactingMixture<ThermoType>::specieStoichCoeffs() const +{ + return specieStoichCoeffs_; +} + + +template<class ThermoType> +inline Foam::tmp<Foam::volScalarField> +Foam::singleStepReactingMixture<ThermoType>::fres +( + const label index +) const +{ + return fres_[index]; +} + + +template<class ThermoType> +inline Foam::label +Foam::singleStepReactingMixture<ThermoType>::inertIndex() const +{ + return inertIndex_; +} + + +template<class ThermoType> +inline Foam::label +Foam::singleStepReactingMixture<ThermoType>::fuelIndex() const +{ + return fuelIndex_; +} + + +template<class ThermoType> +inline const Foam::List<int>& +Foam::singleStepReactingMixture<ThermoType>::specieProd() const +{ + return specieProd_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C index f5e392578bc..235b1f796d0 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C @@ -43,6 +43,7 @@ License #include "dieselMixture.H" #include "multiComponentMixture.H" #include "reactingMixture.H" +#include "singleStepReactingMixture.H" #include "thermoPhysicsTypes.H" @@ -127,6 +128,14 @@ makeReactionThermo // Multi-component thermo +makeReactionMixtureThermo +( + hReactionThermo, + hRhoMixtureThermo, + multiComponentMixture, + constGasThermoPhysics +); + makeReactionMixtureThermo ( hReactionThermo, @@ -146,6 +155,14 @@ makeReactionMixtureThermo // Multi-component reaction thermo +makeReactionMixtureThermo +( + hReactionThermo, + hRhoMixtureThermo, + reactingMixture, + constGasThermoPhysics +); + makeReactionMixtureThermo ( hReactionThermo, @@ -162,6 +179,14 @@ makeReactionMixtureThermo gasThermoPhysics ); +makeReactionMixtureThermo +( + hReactionThermo, + hRhoMixtureThermo, + singleStepReactingMixture, + gasThermoPhysics +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C index 09ea4011607..23547705ae9 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C @@ -43,6 +43,7 @@ License #include "dieselMixture.H" #include "multiComponentMixture.H" #include "reactingMixture.H" +#include "singleStepReactingMixture.H" #include "thermoPhysicsTypes.H" @@ -127,6 +128,14 @@ makeHsReactionThermo // Multi-component thermo +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + multiComponentMixture, + constGasThermoPhysics +); + makeHsReactionMixtureThermo ( hsReactionThermo, @@ -146,6 +155,14 @@ makeHsReactionMixtureThermo // Multi-component reaction thermo +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + reactingMixture, + constGasThermoPhysics +); + makeHsReactionMixtureThermo ( hsReactionThermo, @@ -162,6 +179,14 @@ makeHsReactionMixtureThermo gasThermoPhysics ); +makeHsReactionMixtureThermo +( + hsReactionThermo, + hsRhoMixtureThermo, + singleStepReactingMixture, + gasThermoPhysics +); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/solidChemistryModel/Make/files b/src/thermophysicalModels/solidChemistryModel/Make/files new file mode 100644 index 00000000000..9f2b681e801 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/Make/files @@ -0,0 +1,8 @@ + +solidChemistryModel/solidChemistryModel.C +solidChemistryModel/solidChemistryModelNew.C +solidChemistryModel/solidChemistryModels.C + +solidChemistrySolver/makeSolidChemistrySolvers.C + +LIB = $(FOAM_LIBBIN)/libsolidChemistryModel diff --git a/src/thermophysicalModels/solidChemistryModel/Make/options b/src/thermophysicalModels/solidChemistryModel/Make/options new file mode 100644 index 00000000000..d989adfd5b0 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/Make/options @@ -0,0 +1,15 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solid/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude + + +LIB_LIBS = \ + -chemistryModel \ + -lfiniteVolume \ + -lODE diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C new file mode 100644 index 00000000000..f11b5bbc2fe --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.C @@ -0,0 +1,812 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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 "ODESolidChemistryModel.H" +#include "reactingSolidMixture.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class CompType, class SolidThermo, class GasThermo> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +ODESolidChemistryModel +( + const fvMesh& mesh, + const word& compTypeName, + const word& solidThermoName +) +: + CompType(mesh, solidThermoName), + ODE(), + Ys_(this->solidThermo().composition().Y()), + pyrolisisGases_ + ( + mesh.lookupObject<dictionary> + ("chemistryProperties").lookup("species") + ), + reactions_ + ( + static_cast<const reactingSolidMixture<SolidThermo>& > + (this->solidThermo().composition()) + ), + solidThermo_ + ( + static_cast<const reactingSolidMixture<SolidThermo>& > + (this->solidThermo().composition()).solidData() + ), + gasThermo_(pyrolisisGases_.size()), + nGases_(pyrolisisGases_.size()), + nSpecie_(Ys_.size() + nGases_), + nSolids_(Ys_.size()), + nReaction_(reactions_.size()), + RRs_(nSolids_), + RRg_(nGases_), + Ys0_(nSolids_), + cellCounter_(0), + reactingCells_(mesh.nCells(), true) +{ + // create the fields for the chemistry sources + forAll(RRs_, fieldI) + { + RRs_.set + ( + fieldI, + new scalarField(mesh.nCells(), 0.0) + ); + + + IOobject header + ( + Ys_[fieldI].name() + "_0", + mesh.time().timeName(), + mesh, + IOobject::NO_READ + ); + + // check if field exists and can be read + if (header.headerOk()) + { + Ys0_.set + ( + fieldI, + new volScalarField + ( + IOobject + ( + Ys_[fieldI].name() + "_0", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ) + ); + } + else + { + volScalarField Y0Default + ( + IOobject + ( + "Y0Default", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + mesh + ); + + Ys0_.set + ( + fieldI, + new volScalarField + ( + IOobject + ( + Ys_[fieldI].name() + "_0", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + Y0Default + ) + ); + } + + // Calculate inital values of Ysi0 = rho*delta*Yi + Ys0_[fieldI].internalField() = + //this->solidThermo().rho()*Ys_[fieldI]*mesh.V(); + this->solidThermo().rho()*max(Ys_[fieldI],0.001)*mesh.V(); + } + + forAll(RRg_, fieldI) + { + RRg_.set(fieldI, new scalarField(mesh.nCells(), 0.0)); + } + + dictionary thermoDict = + mesh.lookupObject<dictionary>("chemistryProperties"); + + forAll(gasThermo_, gasI) + { + gasThermo_.set + ( + gasI, + new GasThermo(thermoDict.lookup(pyrolisisGases_[gasI])) + ); + } + + Info<< "ODESolidChemistryModel: Number of solids = " << nSolids_ + << " and reactions = " << nReaction_ << endl; + + Info<< "Number of gases from pyrolysis = " << nGases_ << endl; + + forAll(reactions_, i) + { + Info<< indent << "Reaction " << i << nl << reactions_[i] << nl; + } + +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class CompType, class SolidThermo, class GasThermo> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +~ODESolidChemistryModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CompType, class SolidThermo, class GasThermo> +Foam::scalarField Foam:: +ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega +( + const scalarField& c, + const scalar T, + const scalar p, + const bool updateC0 +) const +{ + scalar pf, cf, pr, cr; + label lRef, rRef; + + const label cellI = cellCounter_; + + scalarField om(nEqns(), 0.0); + + forAll(reactions_, i) + { + const solidReaction& R = reactions_[i]; + + scalar omegai = omega + ( + R, c, T, 0.0, pf, cf, lRef, pr, cr, rRef + ); + scalar rhoL = 0.0; + forAll(R.slhs(), s) + { + label si = R.slhs()[s]; + om[si] -= omegai; + rhoL = solidThermo_[si].rho(T); + } + scalar sr = 0.0; + forAll(R.srhs(), s) + { + label si = R.srhs()[s]; + scalar rhoR = solidThermo_[si].rho(T); + sr = rhoR/rhoL; + om[si] += sr*omegai; + + if (updateC0) + { + Ys0_[si][cellI] += sr*omegai; + } + } + forAll(R.grhs(), g) + { + label gi = R.grhs()[g]; + om[gi + nSolids_] += (1.0 - sr)*omegai; + } + } + + return om; +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::scalar +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::omega +( + const solidReaction& R, + const scalarField& c, + const scalar T, + const scalar p, + scalar& pf, + scalar& cf, + label& lRef, + scalar& pr, + scalar& cr, + label& rRef +) const +{ + scalarField c1(nSpecie_, 0.0); + + label cellI = cellCounter_; + + for (label i=0; i<nSpecie_; i++) + { + c1[i] = max(0.0, c[i]); + } + + scalar kf = R.kf(T, 0.0, c1); + + scalar exponent = R.nReact(); + + const label Nl = R.slhs().size(); + + for (label s=0; s<Nl; s++) + { + label si = R.slhs()[s]; + + kf *= +// pow(c1[si]/max(Ys0_[si][cellI], 0.001), exponent) + pow(c1[si]/Ys0_[si][cellI], exponent) + *(Ys0_[si][cellI]); + } + + return kf; +} + + +template<class CompType, class SolidThermo, class GasThermo> +void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::derivatives +( + const scalar time, + const scalarField &c, + scalarField& dcdt +) const +{ + scalar T = c[nSpecie_]; + + dcdt = 0.0; + + dcdt = omega(c, T, 0); + + //Total mass concentration + scalar cTot = 0.0; + for (label i=0; i<nSolids_; i++) + { + cTot += c[i]; + } + + scalar newCp = 0.0; + scalar newhi = 0.0; + for (label i=0; i<nSolids_; i++) + { + scalar dYidt = dcdt[i]/cTot; + scalar Yi = c[i]/cTot; + newCp += Yi*solidThermo_[i].Cp(T); + //newhi += dYidt*solidThermo_[i].hf(); + newhi -= dYidt*solidThermo_[i].hf(); + } + + scalar dTdt = newhi/newCp; + scalar dtMag = min(500.0, mag(dTdt)); + dcdt[nSpecie_] = dTdt*dtMag/(mag(dTdt) + 1.0e-10); + + // dp/dt = ... + dcdt[nSpecie_ + 1] = 0.0; +} + + +template<class CompType, class SolidThermo, class GasThermo> +void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::jacobian +( + const scalar t, + const scalarField& c, + scalarField& dcdt, + scalarSquareMatrix& dfdc +) const +{ + scalar T = c[nSpecie_]; + + scalarField c2(nSpecie_, 0.0); + + for (label i=0; i<nSolids_; i++) + { + c2[i] = max(c[i], 0.0); + } + + for (label i=0; i<nEqns(); i++) + { + for (label j=0; j<nEqns(); j++) + { + dfdc[i][j] = 0.0; + } + } + + // length of the first argument must be nSolids + dcdt = omega(c2, T, 0.0); + + for (label ri=0; ri<reactions_.size(); ri++) + { + const solidReaction& R = reactions_[ri]; + + scalar kf0 = R.kf(T, 0.0, c2); + + forAll(R.slhs(), j) + { + label sj = R.slhs()[j]; + scalar kf = kf0; + forAll(R.slhs(), i) + { + label si = R.slhs()[i]; + scalar exp = R.nReact(); + if (i == j) + { + if (exp < 1.0) + { + if (c2[si]>SMALL) + { + kf *= exp*pow(c2[si] + VSMALL, exp - 1.0); + } + else + { + kf = 0.0; + } + } + else + { + kf *= exp*pow(c2[si], exp - 1.0); + } + } + else + { + Info<< "Solid reactions have only elements on slhs" + << endl; + kf = 0.0; + } + } + + forAll(R.slhs(), i) + { + label si = R.slhs()[i]; + dfdc[si][sj] -= kf; + } + forAll(R.srhs(), i) + { + label si = R.srhs()[i]; + dfdc[si][sj] += kf; + } + } + } + + // calculate the dcdT elements numerically + scalar delta = 1.0e-8; + scalarField dcdT0 = omega(c2, T - delta, 0); + scalarField dcdT1 = omega(c2, T + delta, 0); + + for (label i=0; i<nEqns(); i++) + { + dfdc[i][nSpecie_] = 0.5*(dcdT1[i] - dcdT0[i])/delta; + } + +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::tc() const +{ + notImplemented + ( + "ODESolidChemistryModel::tc()" + ); + + return volScalarField::null(); +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::Sh() const +{ + tmp<volScalarField> tSh + ( + new volScalarField + ( + IOobject + ( + "Sh", + this->mesh_.time().timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + this->mesh_, + dimensionedScalar("zero", dimEnergy/dimTime/dimVolume, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + scalarField& Sh = tSh(); + + forAll(Ys_, i) + { + forAll(Sh, cellI) + { + scalar hf = solidThermo_[i].hf(); + //Sh[cellI] += hf*RRs_[i][cellI]; + Sh[cellI] -= hf*RRs_[i][cellI]; + } + } + } + + return tSh; +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::dQ() const +{ + tmp<volScalarField> tdQ + ( + new volScalarField + ( + IOobject + ( + "dQ", + this->mesh_.time().timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->mesh_, + dimensionedScalar("dQ", dimEnergy/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + volScalarField& dQ = tdQ(); + dQ.dimensionedInternalField() = this->mesh_.V()*Sh()(); + } + + return tdQ; +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::label Foam:: +ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nEqns() const +{ + // nEqns = number of solids + gases + temperature + pressure + return (nSpecie_ + 2); +} + + +template<class CompType, class SolidThermo, class GasThermo> +void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +calculate() +{ + + const volScalarField rho + ( + IOobject + ( + "rho", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->solidThermo().rho() + ); + + if (this->mesh().changing()) + { + forAll(RRs_, i) + { + RRs_[i].setSize(rho.size()); + } + forAll(RRg_, i) + { + RRg_[i].setSize(rho.size()); + } + } + + forAll(RRs_, i) + { + RRs_[i] = 0.0; + } + forAll(RRg_, i) + { + RRg_[i] = 0.0; + } + + if (this->chemistry_) + { + forAll(rho, celli) + { + cellCounter_ = celli; + + const scalar delta = this->mesh().V()[celli]; + + if (reactingCells_[celli]) + { + scalar rhoi = rho[celli]; + scalar Ti = this->solidThermo().T()[celli]; + + scalarField c(nSpecie_, 0.0); + for (label i=0; i<nSolids_; i++) + { + c[i] = rhoi*Ys_[i][celli]*delta; + } + + const scalarField dcdt = omega(c, Ti, 0.0, true); + + forAll(RRs_, i) + { + RRs_[i][celli] = dcdt[i]/delta; + } + + forAll(RRg_, i) + { + RRg_[i][celli] = dcdt[nSolids_ + i]/delta; + } + } + } + } +} + + +template<class CompType, class SolidThermo, class GasThermo> +Foam::scalar +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve +( + const scalar t0, + const scalar deltaT +) +{ + const volScalarField rho + ( + IOobject + ( + "rho", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + this->solidThermo().rho() + ); + + if (this->mesh().changing()) + { + forAll(RRs_, i) + { + RRs_[i].setSize(rho.size()); + } + forAll(RRg_, i) + { + RRg_[i].setSize(rho.size()); + } + } + + forAll(RRs_, i) + { + RRs_[i] = 0.0; + } + forAll(RRg_, i) + { + RRg_[i] = 0.0; + } + + if (!this->chemistry_) + { + return GREAT; + } + + scalar deltaTMin = GREAT; + + forAll(rho, celli) + { + if (reactingCells_[celli]) + { + cellCounter_ = celli; + + scalar rhoi = rho[celli]; + scalar Ti = this->solidThermo().T()[celli]; + + scalarField c(nSpecie_, 0.0); + scalarField c0(nSpecie_, 0.0); + scalarField dc(nSpecie_, 0.0); + + scalar delta = this->mesh().V()[celli]; + + for (label i=0; i<nSolids_; i++) + { + c[i] = rhoi*Ys_[i][celli]*delta; + } + + c0 = c; + + scalar t = t0; + scalar tauC = this->deltaTChem_[celli]; + scalar dt = min(deltaT, tauC); + scalar timeLeft = deltaT; + + // calculate the chemical source terms + while (timeLeft > SMALL) + { + tauC = this->solve(c, Ti, 0.0, t, dt); + t += dt; + + // update the temperature + scalar cTot = 0.0; + + //Total mass concentration + for (label i=0; i<nSolids_; i++) + { + cTot += c[i]; + } + + scalar newCp = 0.0; + scalar newhi = 0.0; + scalar invRho = 0.0; + scalarList dcdt = (c - c0)/dt; + + for (label i=0; i<nSolids_; i++) + { + scalar dYi = dcdt[i]/cTot; + scalar Yi = c[i]/cTot; + newCp += Yi*solidThermo_[i].Cp(Ti); + //newhi += dYi*solidThermo_[i].hf(); + newhi -= dYi*solidThermo_[i].hf(); + invRho += Yi/solidThermo_[i].rho(Ti); + } + + scalar dTi = (newhi/newCp)*dt; + + Ti += dTi; + + timeLeft -= dt; + this->deltaTChem_[celli] = tauC; + dt = min(timeLeft, tauC); + dt = max(dt, SMALL); + } + + deltaTMin = min(tauC, deltaTMin); + dc = c - c0; + + forAll(RRs_, i) + { + RRs_[i][celli] = dc[i]/(deltaT*delta); + } + + forAll(RRg_, i) + { + RRg_[i][celli] = dc[nSolids_ + i]/(deltaT*delta); + } + + // Update Ys0_ + dc = omega(c0, Ti, 0.0, true); + } + } + + // Don't allow the time-step to change more than a factor of 2 + deltaTMin = min(deltaTMin, 2*deltaT); + + return deltaTMin; +} + + +template<class CompType, class SolidThermo,class GasThermo> +Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasHs +( + const volScalarField& T, + const label index +) const +{ + + tmp<volScalarField> tHs + ( + new volScalarField + ( + IOobject + ( + "Hs_" + pyrolisisGases_[index], + this->mesh_.time().timeName(), + this->mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh_, + dimensionedScalar("zero", dimEnergy/dimMass, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + volScalarField& gasHs = tHs(); + + const GasThermo& mixture = gasThermo_[index]; + + forAll(gasHs.internalField(), cellI) + { + gasHs[cellI] = mixture.Hs(T[cellI]); + } + + return tHs; +} + + +template<class CompType, class SolidThermo,class GasThermo> +Foam::scalar +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::solve +( + scalarField &c, + const scalar T, + const scalar p, + const scalar t0, + const scalar dt +) const +{ + notImplemented + ( + "ODESolidChemistryModel::solve" + "(" + "scalarField&, " + "const scalar, " + "const scalar, " + "const scalar, " + "const scalar" + ")" + ); + return (0); +} + + +template<class CompType, class SolidThermo,class GasThermo> +void Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +setCellReacting(const label cellI, const bool active) +{ + reactingCells_[cellI] = active; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H new file mode 100644 index 00000000000..a8363c0ecec --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModel.H @@ -0,0 +1,290 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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::ODESolidChemistryModel + +Description + Extends base chemistry model by adding a thermo package, and ODE functions. + Introduces chemistry equation system and evaluation of chemical source + terms. + +SourceFiles + ODESolidChemistryModelI.H + ODESolidChemistryModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ODESolidChemistryModel_H +#define ODESolidChemistryModel_H + +#include "solidReaction.H" +#include "ODE.H" +#include "volFieldsFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class ODESolidChemistryModel Declaration +\*---------------------------------------------------------------------------*/ + +template<class CompType, class SolidThermo, class GasThermo> +class ODESolidChemistryModel +: + public CompType, + public ODE +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const ODESolidChemistryModel&); + + +protected: + + //- Reference to solid mass fractions + PtrList<volScalarField>& Ys_; + + //- List of gas species present in reaction system + speciesTable pyrolisisGases_; + + //- Reactions + const PtrList<solidReaction>& reactions_; + + //- Thermodynamic data of solids + const PtrList<SolidThermo>& solidThermo_; + + //- Thermodynamic data of gases + PtrList<GasThermo> gasThermo_; + + //- Number of gas species + label nGases_; + + //- Number of components being solved by ODE + label nSpecie_; + + //- Number of solid components + label nSolids_; + + //- Number of solid reactions + label nReaction_; + + //- List of reaction rate per solid [kg/m3/s] + PtrList<scalarField> RRs_; + + //- List of reaction rate per gas [kg/m3/s] + PtrList<scalarField> RRg_; + + + // Protected Member Functions + + //- Write access to source terms for solids + inline PtrList<scalarField>& RRs(); + + //- Write access to source terms for gases + inline PtrList<scalarField>& RRg(); + + +private: + + //- List of accumulative solid concentrations + mutable PtrList<volScalarField> Ys0_; + + //- Cell counter + label cellCounter_; + + //- List of active reacting cells + List<bool> reactingCells_; + + + // Private members + + //- Set reacting status of cell, cellI + void setCellReacting(const label cellI, const bool active); + + +public: + + //- Runtime type information + TypeName("ODESolidChemistryModel"); + + + // Constructors + + //- Construct from components + ODESolidChemistryModel + ( + const fvMesh& mesh, + const word& compTypeName, + const word& SolidThermoName + ); + + + //- Destructor + virtual ~ODESolidChemistryModel(); + + + // Member Functions + + //- The reactions + inline const PtrList<solidReaction>& reactions() const; + + //- Thermodynamic data of gases + inline const PtrList<GasThermo>& gasThermo() const; + + //- Gases table + inline const speciesTable& gasTable() const; + + //- The number of solids + inline label nSpecie() const; + + //- The number of solids + inline label nGases() const; + + //- The number of reactions + inline label nReaction() const; + + + //- dc/dt = omega, rate of change in concentration, for each species + virtual scalarField omega + ( + const scalarField& c, + const scalar T, + const scalar p, + const bool updateC0 = false + ) const; + + //- Return the reaction rate for reaction r and the reference + // species and charateristic times + virtual scalar omega + ( + const solidReaction& r, + const scalarField& c, + const scalar T, + const scalar p, + scalar& pf, + scalar& cf, + label& lRef, + scalar& pr, + scalar& cr, + label& rRef + ) const; + + //- Calculates the reaction rates + virtual void calculate(); + + + // Chemistry model functions + + //- Return const access to the chemical source terms for solids + inline tmp<volScalarField> RRs(const label i) const; + + //- Return const access to the chemical source terms for gases + inline tmp<volScalarField> RRg(const label i) const; + + //- Return total gas source term + inline tmp<volScalarField> RRg() const; + + //- Return total solid source term + inline tmp<volScalarField> RRs() const; + + //- Return const access to the total source terms + inline tmp<volScalarField> RR(const label i) const; + + //- Return sensible enthalpy for gas i [J/Kg] + virtual tmp<volScalarField> gasHs + ( + const volScalarField& T, + const label i + ) const; + + //- Solve the reaction system for the given start time and time + // step and return the characteristic time + virtual scalar solve(const scalar t0, const scalar deltaT); + + //- Return the chemical time scale + virtual tmp<volScalarField> tc() const; + + //- Return source for enthalpy equation [kg/m/s3] + virtual tmp<volScalarField> Sh() const; + + //- Return the heat release, i.e. enthalpy/sec [m2/s3] + virtual tmp<volScalarField> dQ() const; + + + // ODE functions (overriding abstract functions in ODE.H) + + //- Number of ODE's to solve + virtual label nEqns() const; + + virtual void derivatives + ( + const scalar t, + const scalarField& c, + scalarField& dcdt + ) const; + + virtual void jacobian + ( + const scalar t, + const scalarField& c, + scalarField& dcdt, + scalarSquareMatrix& dfdc + ) const; + + virtual scalar solve + ( + scalarField &c, + const scalar T, + const scalar p, + const scalar t0, + const scalar dt + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +# include "ODESolidChemistryModelI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "ODESolidChemistryModel.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H new file mode 100644 index 00000000000..f71d38bb482 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/ODESolidChemistryModel/ODESolidChemistryModelI.H @@ -0,0 +1,237 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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 "volFields.H" +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::PtrList<Foam::scalarField>& +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs() +{ + return RRs_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::PtrList<Foam::scalarField>& +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg() +{ + return RRg_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline const Foam::PtrList<Foam::solidReaction>& +Foam::ODESolidChemistryModel<CompType, SolidThermo,GasThermo>::reactions() const +{ + return reactions_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline const Foam::PtrList<GasThermo>& +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +gasThermo() const +{ + return gasThermo_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline const Foam::speciesTable& +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::gasTable() const +{ + return pyrolisisGases_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::label +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::nSpecie() const +{ + return nSpecie_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::label +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>:: +nReaction() const +{ + return nReaction_; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs +( + const label i +) const +{ + tmp<volScalarField> tRRs + ( + new volScalarField + ( + IOobject + ( + "RRs(" + Ys_[i].name() + ')', + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + tRRs().internalField() = RRs_[i]; + tRRs().correctBoundaryConditions(); + } + return tRRs; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg +( + const label i +) const +{ + tmp<volScalarField> tRRg + ( + new volScalarField + ( + IOobject + ( + "RRg(" + this->pyrolisisGases_[i] + ')', + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + tRRg().internalField() = RRg_[i]; + tRRg().correctBoundaryConditions(); + } + return tRRg; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRg() const +{ + tmp<volScalarField> tRRg + ( + new volScalarField + ( + IOobject + ( + "RRg", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + for (label i=0; i < nGases_; i++) + { + tRRg().internalField() += RRg_[i]; + } + tRRg().correctBoundaryConditions(); + } + return tRRg; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RRs() const +{ + tmp<volScalarField> tRRs + ( + new volScalarField + ( + IOobject + ( + "RRs", + this->time().timeName(), + this->mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + this->mesh(), + dimensionedScalar("zero", dimMass/dimVolume/dimTime, 0.0), + zeroGradientFvPatchScalarField::typeName + ) + ); + + if (this->chemistry_) + { + for (label i=0; i < nSolids_; i++) + { + tRRs().internalField() += RRs_[i]; + } + tRRs().correctBoundaryConditions(); + } + return tRRs; +} + + +template<class CompType, class SolidThermo, class GasThermo> +inline Foam::tmp<Foam::volScalarField> +Foam::ODESolidChemistryModel<CompType, SolidThermo, GasThermo>::RR +( + const label i +) const +{ + notImplemented("ODESolidChemistryModel::RR(const label)"); + return (Foam::volScalarField::null()); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C new file mode 100644 index 00000000000..8bd02b5a44d --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.C @@ -0,0 +1,57 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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 "solidChemistryModel.H" +#include "fvMesh.H" +#include "Time.H" + +/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */ + +namespace Foam +{ + defineTypeNameAndDebug(solidChemistryModel, 0); + defineRunTimeSelectionTable(solidChemistryModel, fvMesh); +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidChemistryModel::solidChemistryModel +( + const fvMesh& mesh, + const word& solidThermoTypeName +) +: + basicChemistryModel(mesh), + solidThermo_(basicSolidThermo::New(mesh)) //, thermoTypeName)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::solidChemistryModel::~solidChemistryModel() +{} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H new file mode 100644 index 00000000000..b03a1ad7f29 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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::solidChemistryModel + +Description + Chemistry model for solid thermodynamics + +SourceFiles + solidChemistryModelI.H + solidChemistryModel.C + newChemistrySolidModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidChemistryModel_H +#define solidChemistryModel_H + +#include "basicChemistryModel.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" +#include "basicSolidThermo.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class fvMesh; + +/*---------------------------------------------------------------------------*\ + class solidChemistryModel Declaration +\*---------------------------------------------------------------------------*/ + +class solidChemistryModel +: + public basicChemistryModel +{ + // Private Member Functions + + //- Construct as copy (not implemented) + solidChemistryModel(const solidChemistryModel&); + + //- Disallow default bitwise assignment + void operator=(const solidChemistryModel&); + + +protected: + + // Protected data + + //- Solid thermo package + autoPtr<basicSolidThermo> solidThermo_; + + +public: + + //- Runtime type information + TypeName("solidChemistryModel"); + + + //- Declare run-time constructor selection tables + declareRunTimeSelectionTable + ( + autoPtr, + solidChemistryModel, + fvMesh, + ( + const fvMesh& mesh, + const word& compTypeName, + const word& solidThermoTypeName + ), + (mesh, compTypeName, solidThermoTypeName) + ); + + + // Constructors + + //- Construct from mesh and thermo type name + solidChemistryModel + ( + const fvMesh& mesh, + const word& solidThermoTypeName + ); + + + //- Selector + static autoPtr<solidChemistryModel> New(const fvMesh& mesh); + + + //- Destructor + virtual ~solidChemistryModel(); + + + // Member Functions + + //- Return access to the solid thermo package + inline basicSolidThermo& solidThermo(); + + //- Return const access to the solid thermo package + inline const basicSolidThermo& solidThermo() const; + + //- Return total gases mass source term [kg/m3/s] + virtual tmp<volScalarField> RRg() const = 0; + + //- Return total solids mass source term [kg/m3/s] + virtual tmp<volScalarField> RRs() const = 0; + + //- Return chemical source terms for solids [kg/m3/s] + virtual tmp<volScalarField> RRs(const label i) const = 0; + + //- Return chemical source terms for gases [kg/m3/s] + virtual tmp<volScalarField> RRg(const label i) const = 0; + + //- Return sensible enthalpy for gas i [J/Kg] + virtual tmp<volScalarField> gasHs + ( + const volScalarField& T, + const label i + ) const = 0; + + //- Return specie Table for gases + virtual const speciesTable& gasTable() const = 0; + + //- Set reacting status of cell, cellI + virtual void setCellReacting(const label cellI, const bool active) = 0; + + //- Calculates the reaction rates + virtual void calculate() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "solidChemistryModelI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H new file mode 100644 index 00000000000..c159d7329e5 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::basicSolidThermo& Foam::solidChemistryModel::solidThermo() +{ + return solidThermo_(); +} + + +inline const Foam::basicSolidThermo& Foam::solidChemistryModel::solidThermo() const +{ + return solidThermo_(); +} + + +// inline Foam::hsReactionThermo& Foam::solidChemistryModel::gasThermo() +// { +// return gasThermo_(); +// } +// +// +// inline const Foam::hsReactionThermo& Foam::solidChemistryModel::gasThermo() const +// { +// return gasThermo_(); +// } + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C new file mode 100644 index 00000000000..a1a996d982e --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2010 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 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 "solidChemistryModel.H" + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::solidChemistryModel> Foam::solidChemistryModel::New +( + const fvMesh& mesh +) +{ + IOdictionary chemistryPropertiesDict + ( + IOobject + ( + "chemistryProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + const word userModel(chemistryPropertiesDict.lookup("solidChemistryModel")); + + const word ODEModelName(chemistryPropertiesDict.lookup("chemistrySolver")); + const word gasThermoName(chemistryPropertiesDict.lookup("gasThermoModel")); + + // construct chemistry model type name by inserting first template argument + const label tempOpen = userModel.find('<'); + const label tempClose = userModel.find('>'); + + const word className = userModel(0, tempOpen); + const word thermoTypeName = + userModel(tempOpen + 1, tempClose - tempOpen - 1); + + const word modelType = + ODEModelName + '<' + className + + '<' + typeName + ',' + thermoTypeName + ',' + gasThermoName + ">>"; + + + if (debug) + { + Info<< "Selecting solidChemistryModel " << modelType << endl; + } + else + { + Info<< "Selecting solidChemistryModel " << userModel + gasThermoName + << endl; + } + + fvMeshConstructorTable::iterator cstrIter = + fvMeshConstructorTablePtr_->find(modelType); + + if (cstrIter == fvMeshConstructorTablePtr_->end()) + { + if (debug) + { + FatalErrorIn("solidChemistryModel::New(const mesh&)") + << "Unknown solidChemistryModel type " + << modelType << nl << nl + << "Valid solidChemistryModel types are:" << nl + << fvMeshConstructorTablePtr_->sortedToc() << nl + << exit(FatalError); + } + else + { + wordList models = fvMeshConstructorTablePtr_->sortedToc(); + forAll(models, i) + { + models[i] = models[i].replace(typeName + ',', ""); + } + + FatalErrorIn("solidChemistryModel::New(const mesh&)") + << "Unknown solidChemistryModel type " + << userModel << nl << nl + << "Valid solidChemistryModel types are:" << nl + << models << nl + << exit(FatalError); + } + } + + return autoPtr<solidChemistryModel> + (cstrIter()(mesh, ODEModelName, thermoTypeName)); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModels.C b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModels.C new file mode 100644 index 00000000000..fdffe7050d9 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModels.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 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 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/>. + +InClass + Foam::solidChemistryModel + +Description + Creates solid chemistry model instances templated on the type of + solid thermodynamics + +\*---------------------------------------------------------------------------*/ + +#include "makeChemistryModel.H" + +#include "ODESolidChemistryModel.H" +#include "solidChemistryModel.H" +#include "solidThermoPhysicsTypes.H" +#include "thermoPhysicsTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makeSolidChemistryModel + ( + ODESolidChemistryModel, + solidChemistryModel, + constSolidThermoPhysics, + gasThermoPhysics + ); + + makeSolidChemistryModel + ( + ODESolidChemistryModel, + solidChemistryModel, + expoSolidThermoPhysics, + gasThermoPhysics + ); +} + +// ************************************************************************* // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H similarity index 63% rename from src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H rename to src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H index 29b021e4c20..2e9768c7b21 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,17 +21,14 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -InClass - Foam::psiChemistryModel - Description - Macros for instantiating chemistry models based on compressibility and - transport types + Macros for instantiating solid chemistry models based on compressibility + and transport types \*---------------------------------------------------------------------------*/ -#ifndef makeChemistryModel_H -#define makeChemistryModel_H +#ifndef makeSolidChemistrySolverType_H +#define makeSolidChemistrySolverType_H #include "addToRunTimeSelectionTable.H" @@ -42,23 +39,25 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define makeChemistryModel(SS, Comp, Thermo) \ +#define makeSolidChemistrySolverType(SS, ODEChem, Comp, SThermo, GThermo) \ \ -typedef SS<Comp, Thermo> SS##Comp##Thermo; \ + typedef SS<ODEChem<Comp, SThermo, GThermo> > \ + SS##ODEChem##Comp##SThermo##GThermo; \ \ -defineTemplateTypeNameAndDebugWithName \ -( \ - SS##Comp##Thermo, \ - #SS"<"#Comp","#Thermo">", \ - 0 \ -); \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##ODEChem##Comp##SThermo##GThermo, \ + #SS"<"#ODEChem"<"#Comp","#SThermo","#GThermo">>", \ + 0 \ + ); \ \ -addToRunTimeSelectionTable \ -( \ - Comp, \ - SS##Comp##Thermo, \ - fvMesh \ -); + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##ODEChem##Comp##SThermo##GThermo, \ + fvMesh \ + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C new file mode 100644 index 00000000000..3efdf505c51 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C @@ -0,0 +1,73 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2011 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 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 "makeSolidChemistrySolverType.H" +#include "solidThermoPhysicsTypes.H" +#include "thermoPhysicsTypes.H" + +#include "chemistrySolver.H" + +#include "ODESolidChemistryModel.H" +#include "solidChemistryModel.H" + +#include "ode.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef ODESolidChemistryModel + <solidChemistryModel, constSolidThermoPhysics, gasThermoPhysics> + solidODEChemistryConstThermo; + + makeChemistrySolver(solidODEChemistryConstThermo) + + makeSolidChemistrySolverType + ( + ode, + ODESolidChemistryModel, + solidChemistryModel, + constSolidThermoPhysics, + gasThermoPhysics + ) + + typedef ODESolidChemistryModel + <solidChemistryModel, expoSolidThermoPhysics, gasThermoPhysics> + solidODEChemistryExpThermo; + + makeChemistrySolver(solidODEChemistryExpThermo) + + makeSolidChemistrySolverType + ( + ode, + ODESolidChemistryModel, + solidChemistryModel, + expoSolidThermoPhysics, + gasThermoPhysics + ) +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -- GitLab