diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/files b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..cd3553a3027dc21ead56f619b6615465267c60aa --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/files @@ -0,0 +1,3 @@ +buoyantBaffleSimpleFoam.C + +EXE = $(FOAM_APPBIN)/buoyantBaffleSimpleFoam diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/options b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..08bd50dbe804c1d80242e1a6fed5c199c100035b --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/options @@ -0,0 +1,19 @@ +EXE_INC = \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ + -I$(LIB_SRC)/regionModels/thermoBaffleModels/lnInclude + +EXE_LIBS = \ + -lmeshTools \ + -lbasicThermophysicalModels \ + -lspecie \ + -lcompressibleTurbulenceModel \ + -lcompressibleRASModels \ + -lfiniteVolume \ + -lmeshTools \ + -lthermoBaffleModels diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..ca28910aaf3c51186663b2fb5919104d4fd07398 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/UEqn.H @@ -0,0 +1,25 @@ + // Solve the Momentum equation + + tmp<fvVectorMatrix> UEqn + ( + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) + ); + + UEqn().relax(); + + if (simple.momentumPredictor()) + { + solve + ( + UEqn() + == + fvc::reconstruct + ( + ( + - ghf*fvc::snGrad(rho) + - fvc::snGrad(p_rgh) + )*mesh.magSf() + ) + ); + } diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/buoyantBaffleSimpleFoam.C b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/buoyantBaffleSimpleFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..6a31904e78dc3f8151f60a39ee63862c71a215b6 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/buoyantBaffleSimpleFoam.C @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-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/>. + +Application + buoyantBaffleSimpleFoam + +Description + Steady-state solver for buoyant, turbulent flow of compressible fluids + using thermal baffles + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "basicPsiThermo.H" +#include "RASModel.H" +#include "fixedGradientFvPatchFields.H" +#include "simpleControl.H" +#include "thermoBaffleModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readGravitationalAcceleration.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + simpleControl simple(mesh); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (simple.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + p_rgh.storePrevIter(); + rho.storePrevIter(); + + // Pressure-velocity SIMPLE corrector + { + #include "UEqn.H" + #include "hEqn.H" + #include "pEqn.H" + } + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..7adb8e41e712d34bfde5fae5152a1567cc26bb42 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/createFields.H @@ -0,0 +1,94 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr<basicPsiThermo> pThermo + ( + basicPsiThermo::New(mesh) + ); + basicPsiThermo& thermo = pThermo(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermo.rho() + ); + + volScalarField& p = thermo.p(); + volScalarField& h = thermo.h(); + const volScalarField& psi = thermo.psi(); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "compressibleCreatePhi.H" + + Info<< "Creating turbulence model\n" << endl; + autoPtr<compressible::RASModel> turbulence + ( + compressible::RASModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + surfaceScalarField ghf("ghf", g & mesh.Cf()); + + Info<< "Reading field p_rgh\n" << endl; + volScalarField p_rgh + ( + IOobject + ( + "p_rgh", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + // Force p_rgh to be consistent with p + p_rgh = p - rho*gh; + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell + ( + p, + p_rgh, + mesh.solutionDict().subDict("SIMPLE"), + pRefCell, + pRefValue + ); + + autoPtr<regionModels::thermoBaffleModels::thermoBaffleModel> baffles + ( + regionModels::thermoBaffleModels::thermoBaffleModel::New(mesh) + ); + + dimensionedScalar initialMass = fvc::domainIntegrate(rho); + dimensionedScalar totalVolume = sum(mesh.V()); diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/hEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..23313b56cf10d7819fe0cd0f69cae76341941cc9 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/hEqn.H @@ -0,0 +1,17 @@ +{ + fvScalarMatrix hEqn + ( + fvm::div(phi, h) + - fvm::Sp(fvc::div(phi), h) + - fvm::laplacian(turbulence->alphaEff(), h) + == + fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p)) + - p*fvc::div(phi/fvc::interpolate(rho)) + ); + + hEqn.relax(); + hEqn.solve(); + + baffles->evolve(); + thermo.correct(); +} diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..17bf590f2958c9df5fb4aac55953e441a830d497 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/pEqn.H @@ -0,0 +1,59 @@ +{ + rho = thermo.rho(); + rho.relax(); + + volScalarField rAU(1.0/UEqn().A()); + surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU)); + + U = rAU*UEqn().H(); + UEqn.clear(); + + phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); + bool closedVolume = adjustPhi(phi, U, p_rgh); + + surfaceScalarField buoyancyPhi(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); + phi -= buoyancyPhi; + + for (int nonOrth=0; nonOrth<=simple.nNonOrthCorr(); nonOrth++) + { + fvScalarMatrix p_rghEqn + ( + fvm::laplacian(rhorAUf, p_rgh) == fvc::div(phi) + ); + + p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); + p_rghEqn.solve(); + + if (nonOrth == simple.nNonOrthCorr()) + { + // Calculate the conservative fluxes + phi -= p_rghEqn.flux(); + + // Explicitly relax pressure for momentum corrector + p_rgh.relax(); + + // Correct the momentum source with the pressure gradient flux + // calculated from the relaxed pressure + U -= rAU*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorAUf); + U.correctBoundaryConditions(); + } + } + + #include "continuityErrs.H" + + p = p_rgh + rho*gh; + + // For closed-volume cases adjust the pressure level + // to obey overall mass continuity + if (closedVolume) + { + p += (initialMass - fvc::domainIntegrate(psi*p)) + /fvc::domainIntegrate(psi); + p_rgh = p - rho*gh; + } + + rho = thermo.rho(); + rho.relax(); + Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() + << endl; +} diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/files b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..7910a0296578f689ba0cb09fe8212f09a2eae6ae --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/files @@ -0,0 +1,3 @@ +reactingParcelFilmPyrolysisFoam.C + +EXE = $(FOAM_APPBIN)/reactingParcelFilmPyrolysisFoam diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..7782cc45ccb80be0afa7df6874b97d62551a200a --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/Make/options @@ -0,0 +1,51 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I${LIB_SRC}/meshTools/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/lagrangian/distributionModels/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/chemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidChemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/combustionModels/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ + -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ + -I$(LIB_SRC)/regionModels/pyrolysisModels/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -lspecie \ + -lbasicThermophysicalModels \ + -lsolidProperties \ + -lsolidMixtureProperties \ + -lthermophysicalFunctions \ + -lreactionThermophysicalModels \ + -lSLGThermo \ + -lchemistryModel \ + -lsolidChemistryModel \ + -lcombustionModels \ + -lregionModels \ + -lradiationModels \ + -lsurfaceFilmModels \ + -lpyrolysisModels \ + -llagrangianIntermediate \ + -lODE \ + -lsampling diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/UEqn.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..a64e50a2d24d19b3f1dd25e4bc73acbcfc27a356 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/UEqn.H @@ -0,0 +1,26 @@ + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) + == + parcels.SU(U) + ); + + UEqn.relax(); + + if (pimple.momentumPredictor()) + { + solve + ( + UEqn + == + fvc::reconstruct + ( + ( + - ghf*fvc::snGrad(rho) + - fvc::snGrad(p_rgh) + )*mesh.magSf() + ) + ); + } diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/YhsEqn.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/YhsEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..ae70f37d8cd3293765fd439594e0c3bee7697f09 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/YhsEqn.H @@ -0,0 +1,69 @@ +tmp<fv::convectionScheme<scalar> > mvConvection +( + fv::convectionScheme<scalar>::New + ( + mesh, + fields, + phi, + mesh.divScheme("div(phi,Yi_hs)") + ) +); +{ + combustion->correct(); + dQ = combustion->dQ(); + label inertIndex = -1; + volScalarField Yt = 0.0*Y[0]; + + forAll(Y, i) + { + if (Y[i].name() != inertSpecie) + { + volScalarField& Yi = Y[i]; + fvScalarMatrix R = combustion->R(Yi); + + solve + ( + fvm::ddt(rho, Yi) + + mvConvection->fvmDiv(phi, Yi) + - fvm::laplacian(turbulence->alphaEff(), Yi) + == + parcels.SYi(i, Yi) + + surfaceFilm.Srho(i) + + R, + mesh.solver("Yi") + ); + + Yi.max(0.0); + Yt += Yi; + } + else + { + inertIndex = i; + } + } + + Y[inertIndex] = scalar(1) - Yt; + Y[inertIndex].max(0.0); + + fvScalarMatrix hsEqn + ( + fvm::ddt(rho, hs) + + mvConvection->fvmDiv(phi, hs) + - fvm::laplacian(turbulence->alphaEff(), hs) + == + DpDt + + dQ + + radiation->Shs(thermo) + + parcels.Sh(hs) + + surfaceFilm.Sh() + ); + + hsEqn.relax(); + hsEqn.solve(); + + thermo.correct(); + + radiation->correct(); + + Info<< "min/max(T) = " << min(T).value() << ", " << max(T).value() << endl; +} diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createClouds.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createClouds.H new file mode 100644 index 0000000000000000000000000000000000000000..c568be12a16faa253b69d064499038de506a36b5 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createClouds.H @@ -0,0 +1,9 @@ +Info<< "\nConstructing reacting cloud" << endl; +basicReactingCloud parcels +( + "reactingCloud1", + rho, + U, + g, + slgThermo +); diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..96a3457b8378d863a4d44024cd9fc4d5e3730d09 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createFields.H @@ -0,0 +1,154 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr<hsCombustionThermo> pThermo + ( + hsCombustionThermo::New(mesh) + ); + hsCombustionThermo& thermo = pThermo(); + + SLGThermo slgThermo(mesh, thermo); + + basicMultiComponentMixture& composition = thermo.composition(); + PtrList<volScalarField>& Y = composition.Y(); + + const word inertSpecie(thermo.lookup("inertSpecie")); + + Info<< "Creating field rho\n" << endl; + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermo.rho() + ); + + volScalarField& p = thermo.p(); + volScalarField& hs = thermo.hs(); + const volScalarField& T = thermo.T(); + const volScalarField& psi = thermo.psi(); + + Info<< "\nReading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + #include "compressibleCreatePhi.H" + + Info<< "Creating turbulence model\n" << endl; + autoPtr<compressible::turbulenceModel> turbulence + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + IOdictionary combustionProperties + ( + IOobject + ( + "combustionProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + Info<< "Creating combustion model\n" << endl; + autoPtr<combustionModel> combustion + ( + combustionModel::combustionModel::New + ( + combustionProperties, + thermo, + turbulence(), + phi, + rho + ) + ); + + volScalarField dQ + ( + IOobject + ( + "dQ", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("dQ", dimMass/pow3(dimTime)/dimLength, 0.0) + ); + + Info<< "Creating field DpDt\n" << endl; + volScalarField DpDt + ( + "DpDt", + fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) + ); + + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + + surfaceScalarField ghf("gh", g & mesh.Cf()); + + volScalarField p_rgh + ( + IOobject + ( + "p_rgh", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + // Force p_rgh to be consistent with p + p_rgh = p - rho*gh; + + multivariateSurfaceInterpolationScheme<scalar>::fieldTable fields; + + forAll(Y, i) + { + fields.add(Y[i]); + } + fields.add(hs); + + IOdictionary additionalControlsDict + ( + IOobject + ( + "additionalControls", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + Switch solvePrimaryRegion + ( + additionalControlsDict.lookup("solvePrimaryRegion") + ); diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createPyrolysisModel.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createPyrolysisModel.H new file mode 100644 index 0000000000000000000000000000000000000000..e5b8d4e45793215a334c71b2c42d5939272e7f64 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createPyrolysisModel.H @@ -0,0 +1,6 @@ +Info<< "Creating pyrolysis model" << endl; + +autoPtr<regionModels::pyrolysisModels::pyrolysisModel> pyrolysis +( + regionModels::pyrolysisModels::pyrolysisModel::New(mesh) +); diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createSurfaceFilmModel.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createSurfaceFilmModel.H new file mode 100644 index 0000000000000000000000000000000000000000..1db870f0aa76f02a89cc98748782f97fd0f1242b --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createSurfaceFilmModel.H @@ -0,0 +1,7 @@ +Info<< "\nConstructing surface film model" << endl; + +typedef regionModels::surfaceFilmModels::surfaceFilmModel filmModelType; + +autoPtr<filmModelType> tsurfaceFilm(filmModelType::New(mesh, g)); +filmModelType& surfaceFilm = tsurfaceFilm(); + diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..bbfb5be051c06d5378b0e15d7f33cff76a19f1a3 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/pEqn.H @@ -0,0 +1,50 @@ +rho = thermo.rho(); + +volScalarField rAU(1.0/UEqn.A()); +surfaceScalarField rhorAUf(rAU.name(), fvc::interpolate(rho*rAU)); +U = rAU*UEqn.H(); + +surfaceScalarField phiU +( + fvc::interpolate(rho) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phi) + ) +); + +phi = phiU - rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf(); + +for (int nonOrth=0; nonOrth<=pimple.nNonOrthCorr(); nonOrth++) +{ + fvScalarMatrix p_rghEqn + ( + fvc::ddt(psi, rho)*gh + + fvc::div(phi) + + fvm::ddt(psi, p_rgh) + - fvm::laplacian(rhorAUf, p_rgh) + == + parcels.Srho() + + surfaceFilm.Srho() + ); + + p_rghEqn.solve + ( + mesh.solver(p_rgh.select(pimple.finalInnerIter(corr, nonOrth))) + ); + + if (nonOrth == pimple.nNonOrthCorr()) + { + phi += p_rghEqn.flux(); + } +} + +p = p_rgh + rho*gh; + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +U += rAU*fvc::reconstruct((phi - phiU)/rhorAUf); +U.correctBoundaryConditions(); + +DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/reactingParcelFilmPyrolysisFoam.C b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/reactingParcelFilmPyrolysisFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..6a46b2fbfb157574c01fabda9f7a8c406c0c8304 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/reactingParcelFilmPyrolysisFoam.C @@ -0,0 +1,130 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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/>. + +Application + reactingParcelFilmPyrolysisFoam + +Description + Transient PISO solver for compressible, laminar or turbulent flow with + reacting Lagrangian parcels, surface film and pyrolysis modelling. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "turbulenceModel.H" +#include "basicReactingCloud.H" +#include "surfaceFilmModel.H" +#include "pyrolysisModel.H" +#include "radiationModel.H" +#include "SLGThermo.H" +#include "hsCombustionThermo.H" +#include "solidChemistryModel.H" +#include "combustionModel.H" +#include "pimpleControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + #include "readChemistryProperties.H" + #include "readGravitationalAcceleration.H" + #include "createFields.H" + #include "createClouds.H" + #include "createRadiationModel.H" + #include "createSurfaceFilmModel.H" + #include "createPyrolysisModel.H" + #include "initContinuityErrs.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + #include "readPyrolysisTimeControls.H" + + pimpleControl pimple(mesh); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "solidRegionDiffusionNo.H" + #include "setMultiRegionDeltaT.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + parcels.evolve(); + + surfaceFilm.evolve(); + + pyrolysis->evolve(); + + if (solvePrimaryRegion) + { + #include "rhoEqn.H" + + // --- PIMPLE loop + for (pimple.start(); pimple.loop(); pimple++) + { + #include "UEqn.H" + #include "YhsEqn.H" + + // --- PISO loop + for (int corr=1; corr<=pimple.nCorr(); corr++) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + turbulence->correct(); + } + } + + rho = thermo.rho(); + } + else + { + runTime.write(); + } + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readChemistryProperties.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readChemistryProperties.H new file mode 100644 index 0000000000000000000000000000000000000000..f0bcf7597fcf71f1e9b8ee2dbc879200a85fa2cc --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readChemistryProperties.H @@ -0,0 +1,23 @@ +Info<< "Reading chemistry properties\n" << endl; + +IOdictionary chemistryProperties +( + IOobject + ( + "chemistryProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) +); + +Switch turbulentReaction(chemistryProperties.lookup("turbulentReaction")); + +dimensionedScalar Cmix("Cmix", dimless, 1.0); + +if (turbulentReaction) +{ + chemistryProperties.lookup("Cmix") >> Cmix; +} diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readPyrolysisTimeControls.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readPyrolysisTimeControls.H new file mode 100644 index 0000000000000000000000000000000000000000..1fd0ce382cfe2bf96d9ca5aa2f8bdf08d74cf7f1 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/readPyrolysisTimeControls.H @@ -0,0 +1,34 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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/>. + +Global + readPyrolysisTimeControls + +Description + + +\*---------------------------------------------------------------------------*/ + +scalar maxDi = pyrolysis->maxDiff(); + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/rhoEqn.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/rhoEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..c37162df4277d3082cfbae5d682cea1bbf0de6cc --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/rhoEqn.H @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-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/>. + +Global + rhoEqn + +Description + Solve the continuity for density. + +\*---------------------------------------------------------------------------*/ + +{ + solve + ( + fvm::ddt(rho) + + fvc::div(phi) + == + parcels.Srho(rho) + + surfaceFilm.Srho() + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/setMultiRegionDeltaT.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/setMultiRegionDeltaT.H new file mode 100644 index 0000000000000000000000000000000000000000..6c5a6a7215c09a4b77ea90abec664099f7c39e35 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/setMultiRegionDeltaT.H @@ -0,0 +1,64 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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/>. + +Global + setMultiRegionDeltaT + +Description + Reset the timestep to maintain a constant maximum Courant numbers. + Reduction of time-step is immediate, but increase is damped to avoid + unstable oscillations. + +\*---------------------------------------------------------------------------*/ + +if (adjustTimeStep) +{ + if (CoNum == -GREAT) + { + CoNum = SMALL; + } + + if (DiNum == -GREAT) + { + DiNum = SMALL; + } + + + const scalar TFactorFluid = maxCo/(CoNum + SMALL); + const scalar TFactorSolid = maxDi/(DiNum + SMALL); + const scalar TFactorFilm = maxCo/(surfaceFilm.CourantNumber() + SMALL); + + const scalar dt0 = runTime.deltaTValue(); + + runTime.setDeltaT + ( + min + ( + dt0*min(min(TFactorFluid, min(TFactorFilm, TFactorSolid)), 1.2), + maxDeltaT + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/solidRegionDiffusionNo.H b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/solidRegionDiffusionNo.H new file mode 100644 index 0000000000000000000000000000000000000000..a6ab0eb14a6741700fa0379190cbc7b52b21426d --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/solidRegionDiffusionNo.H @@ -0,0 +1,2 @@ +scalar DiNum = pyrolysis->solidRegionDiffNo(); + diff --git a/src/regionModels/Allwmake b/src/regionModels/Allwmake index 86638a3ff3716d802eb262d9b149738e804fe043..5c97cae02b1c15bd910e3547f6c7ae639b82d25e 100755 --- a/src/regionModels/Allwmake +++ b/src/regionModels/Allwmake @@ -4,10 +4,10 @@ makeType=${1:-libso} set -x wmake $makeType regionModel -#wmake $makeType pyrolysisModels +wmake $makeType pyrolysisModels wmake $makeType surfaceFilmModels wmake $makeType thermoBaffleModels -#wmake $makeType regionCoupling +wmake $makeType regionCoupling # ----------------------------------------------------------------- end-of-file diff --git a/src/regionModels/pyrolysisModels/Make/files b/src/regionModels/pyrolysisModels/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..cc875c46ca7a15763cbdeeb44b98685ac83290be --- /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 0000000000000000000000000000000000000000..4b69dbaac21ec57d5230226d5d9a42f1e9692756 --- /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 0000000000000000000000000000000000000000..cdfb8d7739afdffd89e45d0ece2b80c226d4fa36 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.C @@ -0,0 +1,226 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 0000000000000000000000000000000000000000..fcc252da1cb73599f098f63995b9d9604af60571 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/flowRateInletVelocityCoupled/flowRateInletVelocityCoupledFvPatchVectorField.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 0000000000000000000000000000000000000000..23e11fe5c0c43588b309936dca31c2627c931ad2 --- /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 0000000000000000000000000000000000000000..e0120ea8e0cafdffded7647d1417c718cae27803 --- /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 0000000000000000000000000000000000000000..b1c813fa09288cd5bc76c76992c84e87a5996dad --- /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 0000000000000000000000000000000000000000..0545d5ab91bf53e476ba572e1af871a713c03c00 --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::LESModels + + 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 0000000000000000000000000000000000000000..3f46e158b5436ec209c4c1a903e0837bd7b0b7ec --- /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 0000000000000000000000000000000000000000..2d101bbf00c49ca9d1cfcb2df27c072187625bac --- /dev/null +++ b/src/regionModels/pyrolysisModels/derivedFvPatchFields/turbulentTemperatureRadiativeCoupledMixed/turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField.H @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 0000000000000000000000000000000000000000..7c3499b4e28c736744886ecf9cff62de0dedeb48 --- /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 0000000000000000000000000000000000000000..4be55df5d15f0ca2b9cceb3a0d7179e63854e4cd --- /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 0000000000000000000000000000000000000000..290117e26df12b3d43e24b67fdf5c78c380c9c53 --- /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 0000000000000000000000000000000000000000..756cd2d257626d07dabdf702fc099139fce5de79 --- /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 0000000000000000000000000000000000000000..19f7fe165c11ca726b4b0cd02a2ab3f0c8699e9d --- /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 0000000000000000000000000000000000000000..88d31f6cd550c6d7f8e8a91bd0acc556b6dde4f8 --- /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 0000000000000000000000000000000000000000..90e28643dbaa1cf0b581008d6df9305dc0f288eb --- /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 0000000000000000000000000000000000000000..aadc429160a386aa02aac16752fa4deca0a4cbf5 --- /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 0000000000000000000000000000000000000000..352ddad9ea782e2ecca04242e87d7e01ef6d9a54 --- /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/regionModels/regionCoupling/Make/files b/src/regionModels/regionCoupling/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..d9d961e3a563a541a26d538921d94d07cc8b963c --- /dev/null +++ b/src/regionModels/regionCoupling/Make/files @@ -0,0 +1,5 @@ +derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C +derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C + + +LIB = $(FOAM_LIBBIN)/libregionCoupling diff --git a/src/regionModels/regionCoupling/Make/options b/src/regionModels/regionCoupling/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..40d7a67126608416c50f95a6d6db81a104981349 --- /dev/null +++ b/src/regionModels/regionCoupling/Make/options @@ -0,0 +1,29 @@ + +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/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solid/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 \ + -I$(LIB_SRC)/regionModels/pyrolysisModels/lnInclude \ + -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ + + +EXE_LIBS = \ + -lregionModels \ + -lpyrolysisModels \ + -lsurfaceFilmModels \ + -lsolidChemistryModel \ + -lfiniteVolume \ + -lmeshTools \ + -lcompressibleRASModels \ + -lcompressibleLESModels diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..fa63e8980b39da8767d128d5db90130f64dca249 --- /dev/null +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.C @@ -0,0 +1,213 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "filmPyrolysisTemperatureCoupledFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "pyrolysisModel.H" +#include "surfaceFilmModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(p, iF), + phiName_("phi"), + rhoName_("rho"), + deltaWet_(1e-6) +{} + + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), + deltaWet_(ptf.deltaWet_) +{} + + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + rhoName_(dict.lookupOrDefault<word>("rho", "rho")), + deltaWet_(dict.lookupOrDefault<scalar>("deltaWet", 1e-6)) +{ + fvPatchScalarField::operator=(scalarField("value", dict, p.size())); +} + + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& fptpsf +) +: + fixedValueFvPatchScalarField(fptpsf), + phiName_(fptpsf.phiName_), + rhoName_(fptpsf.rhoName_), + deltaWet_(fptpsf.deltaWet_) +{} + + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& fptpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + fixedValueFvPatchScalarField(fptpsf, iF), + phiName_(fptpsf.phiName_), + rhoName_(fptpsf.rhoName_), + deltaWet_(fptpsf.deltaWet_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + typedef regionModels::surfaceFilmModels::surfaceFilmModel filmModelType; + typedef regionModels::pyrolysisModels::pyrolysisModel pyrModelType; + + bool filmOk = + db().objectRegistry::foundObject<filmModelType> + ( + "surfaceFilmProperties" + ); + + + bool pyrOk = + db().objectRegistry::foundObject<pyrModelType> + ( + "pyrolysisProperties" + ); + + if (!filmOk || !pyrOk) + { + // do nothing on construction - film model doesn't exist yet + return; + } + + scalarField& Tp = *this; + + const label patchI = patch().index(); + + // Retrieve film model + const filmModelType& filmModel = + db().lookupObject<filmModelType>("surfaceFilmProperties"); + + const label filmPatchI = filmModel.regionPatchID(patchI); + + const mapDistribute& filmMap = filmModel.mappedPatches()[filmPatchI].map(); + + scalarField deltaFilm = filmModel.delta().boundaryField()[filmPatchI]; + filmMap.distribute(deltaFilm); + + scalarField TFilm = filmModel.Ts().boundaryField()[filmPatchI]; + filmMap.distribute(TFilm); + + + // Retrieve pyrolysis model + const pyrModelType& pyrModel = + db().lookupObject<pyrModelType>("pyrolysisProperties"); + + const label pyrPatchI = pyrModel.regionPatchID(patchI); + + const mapDistribute& pyrMap = pyrModel.mappedPatches()[pyrPatchI].map(); + + scalarField TPyr = pyrModel.T().boundaryField()[pyrPatchI]; + pyrMap.distribute(TPyr); + + + forAll(deltaFilm, i) + { + if (deltaFilm[i] > deltaWet_) + { + // temperature set by film + Tp[i] = TFilm[i]; + } + else + { + // temperature set by pyrolysis model + Tp[i] = TPyr[i]; + } + } + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeKeyword("deltaWet") << deltaWet_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + filmPyrolysisTemperatureCoupledFvPatchScalarField + ); +} + + +// ************************************************************************* // diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..35864435fa506793275c13d3f86db2c34aad0c36 --- /dev/null +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisTemperatureCoupled/filmPyrolysisTemperatureCoupledFvPatchScalarField.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::filmPyrolysisTemperatureCoupledFvPatchScalarField + +Description + Temperature boundary condition for patches on the primary region: + + - where the film height > height threshold value: + apply film surface temperature values + - else + apply pyrolysis surface temperature values + +SourceFiles + filmPyrolysisTemperatureCoupledFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef filmPyrolysisTemperatureCoupledFvPatchScalarField_H +#define filmPyrolysisTemperatureCoupledFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class filmPyrolysisTemperatureCoupledFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class filmPyrolysisTemperatureCoupledFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Name of flux field + word phiName_; + + //- Name of density field + word rhoName_; + + //- Film height threshold beyond which it is considered 'wet' + scalar deltaWet_; + + +public: + + //- Runtime type information + TypeName("filmPyrolysisTemperatureCoupled"); + + + // Constructors + + //- Construct from patch and internal field + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // filmPyrolysisTemperatureCoupledFvPatchScalarField onto a new patch + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new filmPyrolysisTemperatureCoupledFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField&, + 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 filmPyrolysisTemperatureCoupledFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + + //- 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/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..57955d166cc794aa65d914930d6c6629b52cbb31 --- /dev/null +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.C @@ -0,0 +1,248 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "filmPyrolysisVelocityCoupledFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "pyrolysisModel.H" +#include "surfaceFilmModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), + deltaWet_(1e-6) +{} + + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const filmPyrolysisVelocityCoupledFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_), + deltaWet_(ptf.deltaWet_) +{} + + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField<vector, volMesh>& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault<word>("phi", "phi")), + rhoName_(dict.lookupOrDefault<word>("rho", "rho")), + deltaWet_(dict.lookupOrDefault<scalar>("deltaWet", 1e-6)) +{ + fvPatchVectorField::operator=(vectorField("value", dict, p.size())); +} + + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const filmPyrolysisVelocityCoupledFvPatchVectorField& fpvpvf +) +: + fixedValueFvPatchVectorField(fpvpvf), + phiName_(fpvpvf.phiName_), + rhoName_(fpvpvf.rhoName_), + deltaWet_(fpvpvf.deltaWet_) +{} + + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const filmPyrolysisVelocityCoupledFvPatchVectorField& fpvpvf, + const DimensionedField<vector, volMesh>& iF +) +: + fixedValueFvPatchVectorField(fpvpvf, iF), + phiName_(fpvpvf.phiName_), + rhoName_(fpvpvf.rhoName_), + deltaWet_(fpvpvf.deltaWet_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + typedef regionModels::surfaceFilmModels::surfaceFilmModel filmModelType; + typedef regionModels::pyrolysisModels::pyrolysisModel pyrModelType; + + bool filmOk = + db().objectRegistry::foundObject<filmModelType> + ( + "surfaceFilmProperties" + ); + + + bool pyrOk = + db().objectRegistry::foundObject<pyrModelType> + ( + "pyrolysisProperties" + ); + + if (!filmOk || !pyrOk) + { + // do nothing on construction - film model doesn't exist yet + return; + } + + vectorField& Up = *this; + + const label patchI = patch().index(); + + // Retrieve film model + const filmModelType& filmModel = + db().objectRegistry::lookupObject<filmModelType> + ( + "surfaceFilmProperties" + ); + + const label filmPatchI = filmModel.regionPatchID(patchI); + + const mapDistribute& filmMap = filmModel.mappedPatches()[filmPatchI].map(); + + scalarField deltaFilm = filmModel.delta().boundaryField()[filmPatchI]; + filmMap.distribute(deltaFilm); + + vectorField UFilm = filmModel.Us().boundaryField()[filmPatchI]; + filmMap.distribute(UFilm); + + + // Retrieve pyrolysis model + const pyrModelType& pyrModel = + db().objectRegistry::lookupObject<pyrModelType> + ( + "pyrolysisProperties" + ); + + const label pyrPatchI = pyrModel.regionPatchID(patchI); + + const mapDistribute& pyrMap = pyrModel.mappedPatches()[pyrPatchI].map(); + + scalarField phiPyr = pyrModel.phiGas().boundaryField()[pyrPatchI]; + pyrMap.distribute(phiPyr); + + + const surfaceScalarField& phi = + db().lookupObject<surfaceScalarField>(phiName_); + + if (phi.dimensions() == dimVelocity*dimArea) + { + // do nothing + } + else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + phiPyr /= rhop; + } + else + { + FatalErrorIn + ( + "filmPyrolysisVelocityCoupledFvPatchVectorField::updateCoeffs()" + ) << "Unable to process flux field phi with dimensions " + << phi.dimensions() << nl + << " on patch " << patch().name() + << " of field " << dimensionedInternalField().name() + << " in file " << dimensionedInternalField().objectPath() + << exit(FatalError); + } + + const scalarField UAvePyr = -phiPyr/patch().magSf(); + const vectorField& nf = patch().nf(); + + forAll(deltaFilm, i) + { + if (deltaFilm[i] > deltaWet_) + { + // velocity set by film + Up[i] = UFilm[i]; + } + else + { + // velocity set by pyrolysis model + Up[i] = UAvePyr[i]*nf[i]; + } + } + + fixedValueFvPatchVectorField::updateCoeffs(); +} + + +void Foam::filmPyrolysisVelocityCoupledFvPatchVectorField::write +( + Ostream& os +) const +{ + fvPatchVectorField::write(os); + writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); + writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + os.writeKeyword("deltaWet") << deltaWet_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchVectorField, + filmPyrolysisVelocityCoupledFvPatchVectorField + ); +} + + +// ************************************************************************* // diff --git a/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..c06dbda902760c511671aed3b25e4e54241450a4 --- /dev/null +++ b/src/regionModels/regionCoupling/derivedFvPatchFields/filmPyrolysisVelocityCoupled/filmPyrolysisVelocityCoupledFvPatchVectorField.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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::filmPyrolysisVelocityCoupledFvPatchVectorField + +Description + Velocity boundary condition for patches on the primary region: + + - where the film height > height threshold value: + apply film surface velocity values + - else + apply pyrolysis out-gassing velocity values + +SourceFiles + filmPyrolysisVelocityCoupledFvPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef filmPyrolysisVelocityCoupledFvPatchVectorField_H +#define filmPyrolysisVelocityCoupledFvPatchVectorField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class filmPyrolysisVelocityCoupledFvPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class filmPyrolysisVelocityCoupledFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Name of flux field + word phiName_; + + //- Name of density field + word rhoName_; + + //- Film height threshold beyond which it is considered 'wet' + scalar deltaWet_; + + +public: + + //- Runtime type information + TypeName("filmPyrolysisVelocityCoupled"); + + + // Constructors + + //- Construct from patch and internal field + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // filmPyrolysisVelocityCoupledFvPatchVectorField onto a new patch + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField&, + const fvPatch&, + const DimensionedField<vector, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchVectorField> clone() const + { + return tmp<fvPatchVectorField> + ( + new filmPyrolysisVelocityCoupledFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField&, + 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 filmPyrolysisVelocityCoupledFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return the name of phi + const word& phiName() const + { + return phiName_; + } + + //- Return reference to the name of phi to allow adjustment + word& phiName() + { + return phiName_; + } + + //- Return the name of rho + const word& rhoName() const + { + return rhoName_; + } + + //- Return reference to the name of rho to allow adjustment + word& rhoName() + { + return rhoName_; + } + + + //- 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/thermophysicalModels/Allwmake b/src/thermophysicalModels/Allwmake index 07d4cbf0333f9764453ae1268844cb78048ec9b3..c27c4b6648b571862abc07df50be1f20bb7318b4 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 6b06924cb36c94f891cd75ba4aa1bc22591336a7..008f5ad42c9b2db60d070a50c6c40b96f8252810 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,30 @@ 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 d9cc946458d200998116571b047b821b23d9abd5..33391fab9d059cf67f27c329d26488223f4cfa46 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 e97593e37b767643b307f976f762a718ee2c6c77..fbd408fe3b9ec3f2aa073ad6cbc876f17dee74ef 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/basicChemistryModel/makeChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H similarity index 69% rename from src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H rename to src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.H index 29b021e4c20c42a6ea679b58d28480441e24dcfe..29b65f385e0b3d38a7ff269e91f1fcd37eb3f1a5 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/makeChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/makeChemistryModel.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 @@ -21,9 +21,6 @@ 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 @@ -44,21 +41,27 @@ namespace Foam #define makeChemistryModel(SS, Comp, Thermo) \ \ -typedef SS<Comp, Thermo> SS##Comp##Thermo; \ + typedef SS<Comp, Thermo> SS##Comp##Thermo; \ \ -defineTemplateTypeNameAndDebugWithName \ -( \ - SS##Comp##Thermo, \ - #SS"<"#Comp","#Thermo">", \ - 0 \ -); \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##Comp##Thermo, \ + #SS"<"#Comp","#Thermo">", \ + 0 \ + ); + + +#define makeSolidChemistryModel(SS, Comp, SThermo, GThermo) \ \ -addToRunTimeSelectionTable \ -( \ - Comp, \ - SS##Comp##Thermo, \ - fvMesh \ -); + typedef SS<Comp, SThermo, GThermo> SS##Comp##SThermo##GThermo; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##Comp##SThermo##GThermo, \ + #SS"<"#Comp","#SThermo","#GThermo">", \ + 0 \ + ); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/psiChemistryModel/psiChemistryModelNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/psiChemistryModel/psiChemistryModelNew.C index 7c1d6b596a1dbc04365f0a389ac4aa1653dbe5a9..8b22ae7ce55e70f54aab9f248dc3800265d41384 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/psiChemistryModel/psiChemistryModelNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/psiChemistryModel/psiChemistryModelNew.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 @@ -32,24 +32,40 @@ Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New const fvMesh& mesh ) { - // get model name, but do not register the dictionary - // otherwise it is registered in the database twice - const word userModel + IOdictionary chemistryPropertiesDict ( - IOdictionary + IOobject ( - IOobject - ( - "chemistryProperties", - mesh.time().constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("psiChemistryModel") + "chemistryProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) ); + const word solver(chemistryPropertiesDict.lookup("chemistrySolver")); + + wordList models = fvMeshConstructorTablePtr_->sortedToc(); + wordHashSet validModels; + forAll(models, i) + { + label delim = models[i].find('<'); + validModels.insert(models[i](0, delim)); + } + + wordHashSet::iterator solverIter = validModels.find(solver); + if (solverIter == validModels.end()) + { + FatalErrorIn("psiChemistryModel::New(const fvMesh&)") + << "Valid chemistrySolver types are:" << validModels + << exit(FatalError); + } + + + const word userModel(chemistryPropertiesDict.lookup("psiChemistryModel")); + // construct chemistry model type name by inserting first template argument const label tempOpen = userModel.find('<'); const label tempClose = userModel.find('>'); @@ -59,7 +75,7 @@ Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New userModel(tempOpen + 1, tempClose - tempOpen - 1); const word modelType = - className + '<' + typeName + ',' + thermoTypeName + '>'; + solver + '<' + className + '<' + typeName + ',' + thermoTypeName + ">>"; if (debug) { @@ -77,7 +93,7 @@ Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New { if (debug) { - FatalErrorIn("psiChemistryModelBase::New(const mesh&)") + FatalErrorIn("psiChemistryModel::New(const mesh&)") << "Unknown psiChemistryModel type " << modelType << nl << nl << "Valid psiChemistryModel types are:" << nl @@ -86,16 +102,22 @@ Foam::autoPtr<Foam::psiChemistryModel> Foam::psiChemistryModel::New } else { - wordList models = fvMeshConstructorTablePtr_->sortedToc(); - forAll(models, i) + wordList allModels(fvMeshConstructorTablePtr_->sortedToc()); + wordHashSet models; + forAll(allModels, i) { - models[i] = models[i].replace(typeName + ',', ""); + const label tempOpen = allModels[i].find('<'); + const label tempClose = allModels[i].rfind('>'); + word modelName = + allModels[i](tempOpen + 1, tempClose - tempOpen - 1); + modelName = modelName.replace(typeName + ',', ""); + models.insert(modelName); } - FatalErrorIn("psiChemistryModelBase::New(const mesh&)") + FatalErrorIn("psiChemistryModel::New(const mesh&)") << "Unknown psiChemistryModel type " << userModel - << nl << nl << "Valid psiChemistryModel types are:" << nl - << models << nl << exit(FatalError); + << nl << nl << "Valid psiChemistryModel types are:" + << models << exit(FatalError); } } diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/rhoChemistryModel/rhoChemistryModelNew.C b/src/thermophysicalModels/chemistryModel/chemistryModel/rhoChemistryModel/rhoChemistryModelNew.C index f4dbc3a671502a6c36a3f32d2072bf81c7eecd6f..ec9b968c50c69b058f91c37bcc95706c75334c25 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/rhoChemistryModel/rhoChemistryModelNew.C +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/rhoChemistryModel/rhoChemistryModelNew.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 @@ -32,24 +32,40 @@ Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New const fvMesh& mesh ) { - // get model name, but do not register the dictionary - // otherwise it is registered in the database twice - const word userModel + IOdictionary chemistryPropertiesDict ( - IOdictionary + IOobject ( - IOobject - ( - "chemistryProperties", - mesh.time().constant(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ).lookup("rhoChemistryModel") + "chemistryProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) ); + const word solver(chemistryPropertiesDict.lookup("chemistrySolver")); + + wordList models = fvMeshConstructorTablePtr_->sortedToc(); + wordHashSet validModels; + forAll(models, i) + { + label delim = models[i].find('<'); + validModels.insert(models[i](0, delim)); + } + + wordHashSet::iterator solverIter = validModels.find(solver); + if (solverIter == validModels.end()) + { + FatalErrorIn("rhoChemistryModel::New(const fvMesh&)") + << "Valid chemistrySolver types are:" << validModels + << exit(FatalError); + } + + + const word userModel(chemistryPropertiesDict.lookup("rhoChemistryModel")); + // construct chemistry model type name by inserting first template argument const label tempOpen = userModel.find('<'); const label tempClose = userModel.find('>'); @@ -59,7 +75,7 @@ Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New userModel(tempOpen + 1, tempClose - tempOpen - 1); const word modelType = - className + '<' + typeName + ',' + thermoTypeName + '>'; + solver + '<' + className + '<' + typeName + ',' + thermoTypeName + ">>"; if (debug) { @@ -77,7 +93,7 @@ Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New { if (debug) { - FatalErrorIn("rhoChemistryModelBase::New(const mesh&)") + FatalErrorIn("rhoChemistryModel::New(const mesh&)") << "Unknown rhoChemistryModel type " << modelType << nl << nl << "Valid rhoChemistryModel types are:" << nl @@ -86,18 +102,22 @@ Foam::autoPtr<Foam::rhoChemistryModel> Foam::rhoChemistryModel::New } else { - wordList models = fvMeshConstructorTablePtr_->sortedToc(); - forAll(models, i) + wordList allModels(fvMeshConstructorTablePtr_->sortedToc()); + wordHashSet models; + forAll(allModels, i) { - models[i] = models[i].replace(typeName + ',', ""); + const label tempOpen = allModels[i].find('<'); + const label tempClose = allModels[i].rfind('>'); + word modelName = + allModels[i](tempOpen + 1, tempClose - tempOpen - 1); + modelName = modelName.replace(typeName + ',', ""); + models.insert(modelName); } - FatalErrorIn("rhoChemistryModelBase::New(const mesh&)") - << "Unknown rhoChemistryModel type " - << userModel << nl << nl - << "Valid rhoChemistryModel types are:" << nl - << models << nl - << exit(FatalError); + FatalErrorIn("rhoChemistryModel::New(const mesh&)") + << "Unknown rhoChemistryModel type " << userModel + << nl << nl << "Valid rhoChemistryModel types are:" + << models << exit(FatalError); } } diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C index e090c5d9913ef3d271d4505ee5a459a5323dc97d..dd094b78200564439295d7e70ded91ed053bdd17 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.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 @@ -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("EulerImplicitCoeffs")), 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 fffa5a93d8180aef2c3510e8feeafe3af50c2ece..1ce3148939d37d6320ebe805b3c149a9f79b4f69 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 ade0485af17cb4b10729f0dd79ac09ede8b24621..3cceb2466d9de717329fc7c30e99642639bdccd1 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.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 @@ -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 a3c2e477c3d802cb035096762af19ba5bef0cbef..f837a4a154f75f94c1e0ac48af1103f8f13a4b9a 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 f7eab4c2d7a53252bf9ba6a89e08ab7768bd7b1f..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..ef217617f3b7b36a06f1ee963b1f6bf5023c4488 --- /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 f9ae6bca25bb4586b66128919be5f11f62b922af..82b29fb37b77bd5f25e80746fd66efe9e39744ce 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 0d64b3fb8522dc4f1cc0f8b85c04233969b623f9..822f8266b1e883579ce9ac89e064aa63e9ec135c 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 7382beba85436a9e05fbb0114a090e9f10e4d3e5..752c8d61776d36ecbb715780b8bdcb5d328ac62d 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 d20f22f91e3a22542034363d9d20209175128435..d14299e235d27886b9c8752df222419add5d1b73 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")), - solverName_(coeffsDict_.lookup("ODESolver")), - odeSolver_(ODESolver::New(solverName_, model)), + chemistrySolver<ODEChemistryType>(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict("odeCoeffs")), + solverName_(coeffsDict_.lookup("solver")), + 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 e68af7c63cdc947cf1c5a9ce7187c3b1ab3d3184..d6f7f27a7240e4674c96f4de113e225165b2e147 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 8046aaf2f0a2002c02b12c1d00bec9db9f6a566c..c0005f642039bd31bf6c68c6d153854bb64e4b05 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("sequentialCoeffs")), 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 795c9f9c8281d8499f6199b3bab4ce567e1c1e61..81635c6d7ff28ea8763a5ff3068adcc1da5c18e6 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 0000000000000000000000000000000000000000..86696b0709373fbb8bb6c63f090564f55b85d740 --- /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 0000000000000000000000000000000000000000..314c820f246e9647033b316e36cbdec038a85a08 --- /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 0000000000000000000000000000000000000000..bfccadf733d45683dcc470ebb53779bc3458452d --- /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 0000000000000000000000000000000000000000..28ccb85b1b82027eeb2299512b72eac101447336 --- /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 0000000000000000000000000000000000000000..23e07f76e13014350cc80c0edea2b53091f5cd44 --- /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 0000000000000000000000000000000000000000..c66099a88c978cecc72ab886bf8fba1b1d55a42e --- /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 0000000000000000000000000000000000000000..304dba46a3bbae9c610588fd9890cb648cee7bf2 --- /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 0000000000000000000000000000000000000000..4fc8c7d0c905c11d21c05b7b396c6a3d6439864c --- /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 0000000000000000000000000000000000000000..d36f4c11e342657f43019015c7c42a30fa104121 --- /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 9bb945952cc8e2b0a543c78805c675dbe27d9b35..80514bfd5e34e1c1423792f6850f5a5d1ef69971 100644 --- a/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.C +++ b/src/thermophysicalModels/reactionThermo/combustionThermo/hCombustionThermo/hCombustionThermos.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 @@ -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 b8b6c9668cce36a31b247a09405d2a2cba8e6dc3..f3edd7158fa71366fa184b82abf6483e090b17d2 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 0000000000000000000000000000000000000000..57471ce57ba9a132c447fecea69b359abad757ab --- /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 0000000000000000000000000000000000000000..5f31f225eab6f374287c5c7d87ac7666e506af2f --- /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 0000000000000000000000000000000000000000..f8cfe1d9f14d290fa3d2d7a5212a34bd782142a9 --- /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 f5e392578bc11a938834cc75365fb48ff430f076..e0bded71e56397a3395a03076cc4aa1884ee69d0 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.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 @@ -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 09ea4011607a043aa8ae7f3682bfddf4e2bac5d4..e232028807b4ad94374ddd50db2b6c1d7e06d0a6 100644 --- a/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.C +++ b/src/thermophysicalModels/reactionThermo/reactionThermo/hsReactionThermo/hsReactionThermos.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 @@ -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 0000000000000000000000000000000000000000..9f2b681e80195e75b51bd32c28a7a3997c039c88 --- /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 0000000000000000000000000000000000000000..d989adfd5b0b9e850169536fa5c1f17317bbc717 --- /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 0000000000000000000000000000000000000000..f06c2ef0015ecc9af25a847e9c7b842b788fe5fc --- /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-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 "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 0000000000000000000000000000000000000000..107029eed636e2b1539005f3ec591090bb29f537 --- /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-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::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 0000000000000000000000000000000000000000..f3e4655decf023f175497534231a0b54402e2d09 --- /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-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 "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 0000000000000000000000000000000000000000..64a92d520ad0d949e9406d219250269e6be79522 --- /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-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 "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 0000000000000000000000000000000000000000..f390bd4088493771422d959dea08b4503347197a --- /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-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::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 0000000000000000000000000000000000000000..bdc173948ff90fdddd507f58efe7d9214f87f576 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::basicSolidThermo& Foam::solidChemistryModel::solidThermo() +{ + return solidThermo_(); +} + + +inline const Foam::basicSolidThermo& +Foam::solidChemistryModel::solidThermo() const +{ + return solidThermo_(); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelNew.C new file mode 100644 index 0000000000000000000000000000000000000000..05c0b939b8823aa29973c02246ccfe2837ee7ea0 --- /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-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 "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 0000000000000000000000000000000000000000..cf738fae4509173e1790394f72ed22bcc6265ebb --- /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-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/>. + +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/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H new file mode 100644 index 0000000000000000000000000000000000000000..2e9768c7b213b317b21c17e8499fa46abab5f5d4 --- /dev/null +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H @@ -0,0 +1,70 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-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/>. + +Description + Macros for instantiating solid chemistry models based on compressibility + and transport types + +\*---------------------------------------------------------------------------*/ + +#ifndef makeSolidChemistrySolverType_H +#define makeSolidChemistrySolverType_H + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeSolidChemistrySolverType(SS, ODEChem, Comp, SThermo, GThermo) \ + \ + typedef SS<ODEChem<Comp, SThermo, GThermo> > \ + SS##ODEChem##Comp##SThermo##GThermo; \ + \ + defineTemplateTypeNameAndDebugWithName \ + ( \ + SS##ODEChem##Comp##SThermo##GThermo, \ + #SS"<"#ODEChem"<"#Comp","#SThermo","#GThermo">>", \ + 0 \ + ); \ + \ + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##ODEChem##Comp##SThermo##GThermo, \ + fvMesh \ + ); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolvers.C new file mode 100644 index 0000000000000000000000000000000000000000..3efdf505c516282e3efcd15987adae55a47658d1 --- /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 + ) +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/combustion/chemFoam/gri/constant/chemistryProperties b/tutorials/combustion/chemFoam/gri/constant/chemistryProperties index 5e36f2dada155ced1c2e6bb32d0a3d222948337a..6714a333e702906f102ad9c422fb59d82084d4ec 100644 --- a/tutorials/combustion/chemFoam/gri/constant/chemistryProperties +++ b/tutorials/combustion/chemFoam/gri/constant/chemistryProperties @@ -25,7 +25,7 @@ chemistrySolver ode; odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.01; } diff --git a/tutorials/combustion/chemFoam/h2/constant/chemistryProperties b/tutorials/combustion/chemFoam/h2/constant/chemistryProperties index 8a413c489e86e950ddd4ce04579449afe3e39365..bc7593e79269a1c6e7ab7a30a3ac3462a0e60081 100644 --- a/tutorials/combustion/chemFoam/h2/constant/chemistryProperties +++ b/tutorials/combustion/chemFoam/h2/constant/chemistryProperties @@ -25,7 +25,7 @@ chemistrySolver ode; odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.001; } diff --git a/tutorials/combustion/chemFoam/ic8h18/constant/chemistryProperties b/tutorials/combustion/chemFoam/ic8h18/constant/chemistryProperties index f9c5480d40460efc7db501a15e4b8801c38e916e..0ccb565916b5e232a8ca5560ee3bd5789c05f40d 100644 --- a/tutorials/combustion/chemFoam/ic8h18/constant/chemistryProperties +++ b/tutorials/combustion/chemFoam/ic8h18/constant/chemistryProperties @@ -25,7 +25,7 @@ chemistrySolver ode; odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 1e-03; } diff --git a/tutorials/combustion/chemFoam/nc7h16/constant/chemistryProperties b/tutorials/combustion/chemFoam/nc7h16/constant/chemistryProperties index 99b0689c340458dd97bb8c47a73fd8f2cd62223f..6e8da91823dce3dfaef19ccb93b01cc817fb839c 100644 --- a/tutorials/combustion/chemFoam/nc7h16/constant/chemistryProperties +++ b/tutorials/combustion/chemFoam/nc7h16/constant/chemistryProperties @@ -25,7 +25,7 @@ chemistrySolver ode; odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 1e-04; } diff --git a/tutorials/combustion/dieselFoam/aachenBomb/constant/chemistryProperties b/tutorials/combustion/dieselFoam/aachenBomb/constant/chemistryProperties index 49f4d3ee44b098b620c1071989a6850b77de2ae6..b50ba98bff9faaa0df9ae6705f371253aeedf3c3 100644 --- a/tutorials/combustion/dieselFoam/aachenBomb/constant/chemistryProperties +++ b/tutorials/combustion/dieselFoam/aachenBomb/constant/chemistryProperties @@ -36,7 +36,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.05; scale 1; } diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties index 644b8933107b4a3f12b0f16a426d04e221ed65ac..14d3f4ab0aed2d7816a2e3baaad052eb4c175361 100644 --- a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2D/constant/chemistryProperties @@ -38,7 +38,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.05; scale 1; } diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/T b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/T new file mode 100644 index 0000000000000000000000000000000000000000..2e95cadde53bf34216f66d1efd813ae628a04bf8 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/T @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 0 0 1 0 0 0 ]; + +internalField uniform 300; + +boundaryField +{ + floor + { + type zeroGradient; + } + ceiling + { + type zeroGradient; + } + inlet + { + type fixedValue; + value uniform 300; + } + outlet + { + type inletOutlet; + inletValue uniform 300; + value uniform 300; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/U b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/U new file mode 100644 index 0000000000000000000000000000000000000000..f570788abe86c7415131edbddf22b305b9b09248 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/U @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform ( 0.1 0 0 ); + +boundaryField +{ + floor + { + type fixedValue; + value uniform ( 0 0 0 ); + } + ceiling + { + type fixedValue; + value uniform ( 0 0 0 ); + } + inlet + { + type fixedValue; + value uniform ( 0.1 0 0 ); + } + outlet + { + type inletOutlet; + inletValue uniform ( 0 0 0 ); + value uniform ( 0 0 0 ); + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/alphat b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/alphat new file mode 100644 index 0000000000000000000000000000000000000000..0f9fd90151f0ccf5c77489004530ddd50c8b507d --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/alphat @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -1 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + floor + { + type alphatWallFunction; + value uniform 0; + } + ceiling + { + type alphatWallFunction; + value uniform 0; + } + inlet + { + type calculated; + value uniform 0; + } + outlet + { + type calculated; + value uniform 0; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/epsilon b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..1062586afe1aa0f7f78eee82ea6f60d1cf4956fc --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/epsilon @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -3 0 0 0 0 ]; + +internalField uniform 0.01; + +boundaryField +{ + floor + { + type compressible::epsilonWallFunction; + value uniform 0.01; + } + ceiling + { + type compressible::epsilonWallFunction; + value uniform 0.01; + } + inlet + { + type fixedValue; + value uniform 0.01; + } + outlet + { + type zeroGradient; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/k b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/k new file mode 100644 index 0000000000000000000000000000000000000000..a4a67f33565d051889ddb5a9e3afb744706e6f00 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/k @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -2 0 0 0 0 ]; + +internalField uniform 0.1; + +boundaryField +{ + floor + { + type compressible::kqRWallFunction; + value uniform 0.1; + } + ceiling + { + type compressible::kqRWallFunction; + value uniform 0.1; + } + inlet + { + type fixedValue; + value uniform 0.1; + } + outlet + { + type zeroGradient; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/mut b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/mut new file mode 100644 index 0000000000000000000000000000000000000000..d67e74eec44139d80becedd5c53bf0b6c39ec452 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/mut @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object mut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -1 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + floor + { + type mutkWallFunction; + value uniform 0; + } + ceiling + { + type mutkWallFunction; + value uniform 0; + } + inlet + { + type calculated; + value uniform 0; + } + outlet + { + type calculated; + value uniform 0; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p new file mode 100644 index 0000000000000000000000000000000000000000..729596084bcbc44d38551336f65d3f0af9be7194 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 101325; + +boundaryField +{ + floor + { + type calculated; + value uniform 101325; + } + ceiling + { + type calculated; + value uniform 101325; + } + inlet + { + type calculated; + value uniform 101325; + } + outlet + { + type calculated; + value uniform 101325; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p_rgh b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..b98d4ba3d615feb77b634bcc3fd0b48bfa74f185 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/0.org/p_rgh @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 -1 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + floor + { + type buoyantPressure; + gradient uniform 0; + value uniform 0; + } + ceiling + { + type buoyantPressure; + gradient uniform 0; + value uniform 0; + } + inlet + { + type buoyantPressure; + gradient uniform 0; + value uniform 0; + } + outlet + { + type buoyantPressure; + gradient uniform 0; + value uniform 0; + } + fixedWalls + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allclean b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..bbb2246df08410f7bb8f06844669078600886730 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase +rm -rf sets 0 + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allrun b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..ef3b6603482809bcb0987a0e11c4a37df13b78e2 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/Allrun @@ -0,0 +1,27 @@ +#!/bin/sh +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +# Get application name +application=`getApplication` + +cp -r 0.org 0 +runApplication blockMesh + +runApplication setSet -batch baffle.setSet + +unset FOAM_SETNAN +unset FOAM_SIGFPE + +# Add the patches for the baffles +runApplication changeDictionary -literalRE +rm log.changeDictionary + +# Create first baffle +createBaffles baffleFaces '(baffle1Wall_0 baffle1Wall_1)' -overwrite > log.createBaffles 2>&1 +# Create second baffle +createBaffles baffleFaces2 '(baffle2Wall_0 baffle2Wall_1)' -overwrite > log.createBaffles 2>&1 + +# Reset proper values at the baffles +runApplication changeDictionary + +runApplication $application diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/baffle.setSet b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/baffle.setSet new file mode 100644 index 0000000000000000000000000000000000000000..89be31e65e3839d150cf49aad44b84408862fca3 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/baffle.setSet @@ -0,0 +1,6 @@ +# Create face set +faceSet baffleFaces new boxToFace (0.29 0 0) (0.31 0.18 2) +faceZoneSet baffleFaces new setToFaceZone baffleFaces + +faceSet baffleFaces2 new boxToFace (0.59 0.0 0.0)(0.61 0.18 2.0) +faceZoneSet baffleFaces2 new setToFaceZone baffleFaces2 diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/RASProperties b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..70cbcdec448f1a05590a31bbdc7fd78fb1581fff --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/RASProperties @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel kEpsilon; + +turbulence on; + +printCoeffs on; + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/g b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..4fea433a003518e15418a7270bcf4842db7b2126 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 -9.81 0 ); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/blockMeshDict b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..2e040b855b03020b347c81e11c8f94a8cb639762 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/blockMeshDict @@ -0,0 +1,137 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.1; + +vertices +( + (0 0 0) + (10 0 0) + (10 5 0) + (0 5 0) + (0 0 10) + (10 0 10) + (10 5 10) + (0 5 10) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (40 20 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + floor + { + type wall; + faces + ( + (1 5 4 0) + ); + } + + ceiling + { + type wall; + faces + ( + (2 6 7 3) + ); + } + + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + + fixedWalls + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } + + baffle1Wall_0 + { + type directMappedWall; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle1Wall_1; + offsetMode uniform; + offset (0 0 0); + faces (); + } + + baffle1Wall_1 + { + type directMappedWall; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle1Wall_0; + offsetMode uniform; + offset (0 0 0); + faces (); + } + + baffle2Wall_0 + { + type directMappedWall; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle2Wall_1; + offsetMode uniform; + offset (0 0 0); + faces (); + } + + baffle2Wall_1 + { + type directMappedWall; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle2Wall_0; + offsetMode uniform; + offset (0 0 0); + faces (); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/boundary b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..d848038c6ec78799c3438d87297eff11d1830d8d --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/polyMesh/boundary @@ -0,0 +1,96 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +9 +( + floor + { + type wall; + nFaces 40; + startFace 1526; + } + ceiling + { + type wall; + nFaces 40; + startFace 1566; + } + inlet + { + type patch; + nFaces 20; + startFace 1606; + } + outlet + { + type patch; + nFaces 20; + startFace 1626; + } + fixedWalls + { + type empty; + nFaces 1600; + startFace 1646; + } + baffle1Wall_0 + { + type directMappedWall; + nFaces 7; + startFace 3246; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle1Wall_1; + offsetMode uniform; + offset (0 0 0); + } + baffle1Wall_1 + { + type directMappedWall; + nFaces 7; + startFace 3253; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle1Wall_0; + offsetMode uniform; + offset (0 0 0); + } + baffle2Wall_0 + { + type directMappedWall; + nFaces 7; + startFace 3260; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle2Wall_1; + offsetMode uniform; + offset (0 0 0); + } + baffle2Wall_1 + { + type directMappedWall; + nFaces 7; + startFace 3267; + sampleMode nearestPatchFace; + sampleRegion region0; + samplePatch baffle2Wall_0; + offsetMode uniform; + offset (0 0 0); + } +) + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermoBaffleProperties b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermoBaffleProperties new file mode 100644 index 0000000000000000000000000000000000000000..d734e603cd36bd01be3e48b6359c461d2f9476bf --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermoBaffleProperties @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermoBaffleProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoBaffleModel none; + +active no; + +regionName none; + +thermoBaffle2DCoeffs +{ +} + +noThermoCoeffs +{ +} +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermophysicalProperties b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..83df353395ec7a0b203364f44d9e7a530cd4dac5 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/constant/thermophysicalProperties @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType hPsiThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>; + +mixture +{ + specie + { + nMoles 1; + molWeight 28.96; + } + thermodynamics + { + Cp 1004.4; + Hf 0; + } + transport + { + mu 1.831e-05; + Pr 0.705; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/changeDictionaryDict b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..4f2dbc3f76ade575164461c31ca03a5ae37837bd --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/changeDictionaryDict @@ -0,0 +1,131 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + alphat + { + boundaryField + { + "baffle.*" + { + type alphatWallFunction; + value uniform 0; + } + } + } + epsilon + { + boundaryField + { + "baffle.*" + { + type compressible::epsilonWallFunction; + value uniform 0.01; + } + } + } + k + { + boundaryField + { + "baffle.*" + { + type compressible::kqRWallFunction; + value uniform 0.01; + } + } + } + mut + { + boundaryField + { + "baffle.*" + { + type mutkWallFunction; + value uniform 0.0; + } + } + } + p + { + boundaryField + { + "baffle.*" + { + type calculated; + value uniform 101325; + } + } + } + p_rgh + { + boundaryField + { + "baffle.*" + { + type buoyantPressure; + value uniform 0; + } + } + } + T + { + boundaryField + { + "baffle.*" + { + type compressible::temperatureThermoBaffle1D<constSolidThermoPhysics>; + baffleActivated yes; + thickness uniform 0.005; // thickness [m] + Qs uniform 100; // heat flux [W/m2] + transport + { + K 1.0; + } + radiation + { + sigmaS 0; + kappa 0; + emissivity 0; + } + thermodynamics + { + Hf 0; + Cp 0; + } + density + { + rho 0; + } + value uniform 300; + } + } + } + U + { + boundaryField + { + "baffle.*" + { + type fixedValue; + value uniform (0 0 0); + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/controlDict b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..43d2a5ea7232a0361bb65872ceba49940f1d23fe --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/controlDict @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application buoyantBaffleSimpleFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 2500; + +deltaT 1; + +writeControl timeStep; + +writeInterval 50; + +purgeWrite 3; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSchemes b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..3e67c328bdf7dd05102ce1d75d29da5240696c28 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSchemes @@ -0,0 +1,66 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss limitedLinear 0.2; + div(phi,h) Gauss limitedLinear 0.2; + div(phi,k) Gauss limitedLinear 0.2; + div(phi,epsilon) Gauss limitedLinear 0.2; + div(phi,omega) Gauss limitedLinear 0.2; + div((muEff*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default none; + laplacian(muEff,U) Gauss linear uncorrected; + laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(alphaEff,h) Gauss linear uncorrected; + laplacian(DkEff,k) Gauss linear uncorrected; + laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; + laplacian(DomegaEff,omega) Gauss linear uncorrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +fluxRequired +{ + default no; + p_rgh; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSolution b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..271f262f8e19ed07d7895e81ffdd7defc41b3e16 --- /dev/null +++ b/tutorials/heatTransfer/buoyantBaffleSimpleFoam/circuitBoardCooling/system/fvSolution @@ -0,0 +1,71 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p_rgh + { + solver GAMG; + tolerance 1e-7; + relTol 0.01; + + smoother DICGaussSeidel; + + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + } + + "(U|h|k|epsilon|omega)" + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-8; + relTol 0.1; + } +} + +SIMPLE +{ + momentumPredictor yes; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 0; + + residualControl + { + p_rgh 1e-2; + U 1e-3; + h 1e-3; + + // possibly check turbulence fields + "(k|epsilon|omega)" 1e-3; + } +} + +relaxationFactors +{ + rho 1.0; + p_rgh 0.7; + U 0.3; + h 0.3; + "(k|epsilon|omega)" 0.7; +} + + +// ************************************************************************* // diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/chemistryProperties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/chemistryProperties index 506c086b6819298e90a71910724729d3aa9dd085..fd54b847684388b2766bb421f6dc35976272347b 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/chemistryProperties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/chemistryProperties @@ -39,7 +39,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.05; scale 1; } diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/chemistryProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/chemistryProperties index 02d3bb5a7191d5eef7008737b093a92a2b80608d..d332d6144c4dff6be5f1143fb899738a8dff8c1b 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/chemistryProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/chemistryProperties @@ -39,7 +39,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver RK; + solver RK; eps 0.05; scale 1; } diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/chemistryProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/chemistryProperties index 02d3bb5a7191d5eef7008737b093a92a2b80608d..d332d6144c4dff6be5f1143fb899738a8dff8c1b 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/chemistryProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/constant/chemistryProperties @@ -39,7 +39,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver RK; + solver RK; eps 0.05; scale 1; } diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/chemistryProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/chemistryProperties index 02d3bb5a7191d5eef7008737b093a92a2b80608d..d332d6144c4dff6be5f1143fb899738a8dff8c1b 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/chemistryProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/verticalChannel/constant/chemistryProperties @@ -39,7 +39,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver RK; + solver RK; eps 0.05; scale 1; } diff --git a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/chemistryProperties b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/chemistryProperties index 9c4b54407ca39c536bfa767c7ac7cca671a17627..462583d3e25646bed8bb64009d7ca0ecd4238419 100644 --- a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/chemistryProperties +++ b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/chemistryProperties @@ -38,7 +38,7 @@ EulerImplicitCoeffs odeCoeffs { - ODESolver RK; + solver RK; eps 0.05; scale 1; } diff --git a/tutorials/lagrangian/sprayFoam/aachenBomb/constant/chemistryProperties b/tutorials/lagrangian/sprayFoam/aachenBomb/constant/chemistryProperties index 3a7d1a555bbec1ec28710b42867483c893df9741..5612988231f268a3913dd7d6053b17a8ffbe2d8b 100644 --- a/tutorials/lagrangian/sprayFoam/aachenBomb/constant/chemistryProperties +++ b/tutorials/lagrangian/sprayFoam/aachenBomb/constant/chemistryProperties @@ -29,7 +29,7 @@ Cmix Cmix [0 0 0 0 0] 1; odeCoeffs { - ODESolver SIBS; + solver SIBS; eps 0.05; }