diff --git a/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/files b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/Make/files new file mode 100644 index 0000000000..cd3553a302 --- /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 0000000000..08bd50dbe8 --- /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 0000000000..ca28910aaf --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/UEqn.H @@ -0,0 +1,25 @@ + // Solve the Momentum equation + + tmp 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 0000000000..6a31904e78 --- /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 . + +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 0000000000..7adb8e41e7 --- /dev/null +++ b/applications/solvers/heatTransfer/buoyantBaffleSimpleFoam/createFields.H @@ -0,0 +1,94 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr 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 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 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 0000000000..23313b56cf --- /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 0000000000..17bf590f29 --- /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 0000000000..7910a02965 --- /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 0000000000..7782cc45cc --- /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 0000000000..a64e50a2d2 --- /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 0000000000..ae70f37d8c --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/YhsEqn.H @@ -0,0 +1,69 @@ +tmp > mvConvection +( + fv::convectionScheme::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 0000000000..c568be12a1 --- /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 0000000000..96a3457b83 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createFields.H @@ -0,0 +1,154 @@ + Info<< "Reading thermophysical properties\n" << endl; + + autoPtr pThermo + ( + hsCombustionThermo::New(mesh) + ); + hsCombustionThermo& thermo = pThermo(); + + SLGThermo slgThermo(mesh, thermo); + + basicMultiComponentMixture& composition = thermo.composition(); + PtrList& 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 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 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::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 0000000000..e5b8d4e457 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFilmPyrolysisFoam/createPyrolysisModel.H @@ -0,0 +1,6 @@ +Info<< "Creating pyrolysis model" << endl; + +autoPtr 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 0000000000..1db870f0aa --- /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 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 0000000000..bbfb5be051 --- /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 0000000000..6a46b2fbfb --- /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 . + +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 0000000000..f0bcf7597f --- /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 0000000000..1fd0ce382c --- /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 . + +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 0000000000..c37162df42 --- /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 . + +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 0000000000..6c5a6a7215 --- /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 . + +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 0000000000..a6ab0eb14a --- /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 86638a3ff3..5c97cae02b 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 0000000000..cc875c46ca --- /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 0000000000..4b69dbaac2 --- /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 0000000000..cdfb8d7739 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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& iF +) +: + fixedValueFvPatchField(p, iF), + nbrPhiName_("none"), + phiName_("phi"), + rhoName_("rho") +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchField(ptf, p, iF, mapper), + nbrPhiName_(ptf.nbrPhiName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchField(p, iF, dict), + nbrPhiName_(dict.lookupOrDefault("nbrPhi", "phi")), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf +) +: + fixedValueFvPatchField(ptf), + nbrPhiName_(ptf.nbrPhiName_), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::flowRateInletVelocityCoupledFvPatchVectorField:: +flowRateInletVelocityCoupledFvPatchVectorField +( + const flowRateInletVelocityCoupledFvPatchVectorField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchField(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 + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + + scalarList phi = + nbrPatch.lookupPatchField(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(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(phiName_); + + if (phiName.dimensions() == dimVelocity*dimArea) + { + // volumetric flow-rate + operator==(n*U); + } + else if (phiName.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField& rhop = + patch().lookupPatchField(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::updateCoeffs(); +} + + +void Foam::flowRateInletVelocityCoupledFvPatchVectorField::write +( + Ostream& os +) const +{ + fvPatchField::write(os); + writeEntryIfDifferent(os, "phi", "phi", phiName_); + writeEntryIfDifferent(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 0000000000..fcc252da1c --- /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 . + +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& + ); + + //- Construct from patch, internal field and dictionary + flowRateInletVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // flowRateInletVelocityCoupledFvPatchVectorField + // onto a new patch + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new flowRateInletVelocityCoupledFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + flowRateInletVelocityCoupledFvPatchVectorField + ( + const flowRateInletVelocityCoupledFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + 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 0000000000..23e11fe5c0 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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& iF +) +: + mixedFvPatchField(p, iF), + phiName_("phi"), + rhoName_("none") +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "none")) +{ + + refValue() = 1.0; + refGrad() = 0.0; + valueFraction() = 0.0; + + if (dict.found("value")) + { + fvPatchField::operator= + ( + Field("value", dict, p.size()) + ); + } + else + { + fvPatchField::operator=(refValue()); + } +} + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchField(ptf, p, iF, mapper), + phiName_(ptf.phiName_), + rhoName_(ptf.rhoName_) +{} + + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf +) +: + mixedFvPatchField(tppsf), + phiName_(tppsf.phiName_), + rhoName_(tppsf.rhoName_) +{} + +Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField:: +totalFlowRateAdvectiveDiffusiveFvPatchScalarField +( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + mixedFvPatchField(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::rmap(ptf, addr); +} + +void Foam::totalFlowRateAdvectiveDiffusiveFvPatchScalarField::updateCoeffs() +{ + + if (this->updated()) + { + return; + } + + const label patchI = patch().index(); + + const compressible::LESModel& turbulence = + db().lookupObject + ( + "LESProperties" + ); + + const fvsPatchField& phip = + patch().lookupPatchField(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::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::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 0000000000..e0120ea8e0 --- /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 . + +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 +{ + // 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& + ); + + //- Construct from patch, internal field and dictionary + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // totalFlowRateAdvectiveDiffusiveFvPatchScalarField + // onto a new patch + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new + totalFlowRateAdvectiveDiffusiveFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + totalFlowRateAdvectiveDiffusiveFvPatchScalarField + ( + const totalFlowRateAdvectiveDiffusiveFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + 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 0000000000..b1c813fa09 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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& 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& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + nbrFieldName_(ptf.nbrFieldName_), + KName_(ptf.KName_) +{} + + +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2:: +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + nbrFieldName_(dict.lookup("nbrFieldName")), + KName_(dict.lookup("K")) +{ + if (!isA(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::" + "turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField& 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& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + nbrFieldName_(wtcsf.nbrFieldName_), + KName_(wtcsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp +turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2::K() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + + if (KName_ == "none") + { + const LESModel& model = db().lookupObject("LESProperties"); + + const basicThermo& thermo = + db().lookupObject("thermophysicalProperties"); + + return + model.alphaEff()().boundaryField()[patch().index()] + *thermo.Cp()().boundaryField()[patch().index()]; + } + else if (mesh.objectRegistry::foundObject(KName_)) + { + return patch().lookupPatchField(KName_); + } + else if (mesh.objectRegistry::foundObject(KName_)) + { + const symmTensorField& KWall = + patch().lookupPatchField(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 + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + // Force recalculation of mapping and schedule + const mapDistribute& distMap = mpp.map(); + + tmp intFld = patchInternalField(); + + + // Calculate the temperature by harmonic averaging + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2& nbrField = + refCast + < + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + > + ( + nbrPatch.lookupPatchField + ( + 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 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 0000000000..0545d5ab91 --- /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 . + +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& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 onto a + // new patch + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + const turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentTemperatureCoupledBaffleMixedFvPatchScalarField2 + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + tmp 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 0000000000..3f46e158b5 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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& 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& 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& 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(this->patch().patch())) + { + FatalErrorIn + ( + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::" + "turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField& 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& iF +) +: + mixedFvPatchScalarField(wtcsf, iF), + neighbourFieldName_(wtcsf.neighbourFieldName_), + neighbourFieldRadiativeName_(wtcsf.neighbourFieldRadiativeName_), + fieldRadiativeName_(wtcsf.fieldRadiativeName_), + KName_(wtcsf.KName_), + oldMode_(wtcsf.oldMode_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp +turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField::K() const +{ + const fvMesh& mesh = patch().boundaryMesh().mesh(); + + if (KName_ == "none") + { + const compressible::LESModel& model = + db().lookupObject("LESProperties"); + + const basicThermo& thermo = + db().lookupObject("thermophysicalProperties"); + + return + model.alphaEff()().boundaryField()[patch().index()] + *thermo.Cp()().boundaryField()[patch().index()]; + } + else if (mesh.objectRegistry::foundObject(KName_)) + { + return patch().lookupPatchField(KName_); + } + else if (mesh.objectRegistry::foundObject(KName_)) + { + const symmTensorField& KWall = + patch().lookupPatchField(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 + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const fvPatch& nbrPatch = refCast + ( + 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 + ( + 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 + ( + neighbourFieldRadiativeName_ + ) + ) + { + mode = radFromNeighbour; + } + else + { + mode = noRad; + } + } + else + { + if + ( + patch().boundaryMesh().mesh().foundObject + ( + 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 + ( + 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 + ( + 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 0000000000..2d101bbf00 --- /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 . + +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 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& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a + // new patch + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + const + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new + turbulentTemperatureRadiationCoupledMixedSTFvPatchScalarField + ( + *this, + iF + ) + ); + } + + + // Member functions + + //- Get corresponding K field + tmp 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 0000000000..7c3499b4e2 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 noPyrolysis::Cp() const +{ + FatalErrorIn("const tmp& noPyrolysis::Cp() const") + << "Cp field not available for " << type() << abort(FatalError); + + return tmp + ( + 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 0000000000..4be55df5d1 --- /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 . + +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 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 0000000000..290117e26d --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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& fvp = filmDelta.boundaryField()[patchI]; + if (isA >(fvp)) + { + foundCoupledPatch = true; + break; + } + } + + if (!foundCoupledPatch) + { + WarningIn("void pyrolysisModels::constructMeshObjects()") + << "filmCoupled flag set to true, but no " + << directMappedFieldFvPatchField::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("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 0000000000..756cd2d257 --- /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 . + +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 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 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 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 0000000000..19f7fe165c --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 0000000000..88d31f6cd5 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "pyrolysisModel.H" +#include "fvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace regionModels +{ +namespace pyrolysisModels +{ + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +autoPtr 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(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 0000000000..90e28643db --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 tHsiGas = solidChemistry_->gasHs(T_, gasI); + tmp 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; iRRs(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("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 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 0000000000..aadc429160 --- /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 . + +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 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& 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 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 0000000000..352ddad9ea --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 0000000000..d9d961e3a5 --- /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 0000000000..40d7a67126 --- /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 0000000000..fa63e8980b --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "filmPyrolysisTemperatureCoupledFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "pyrolysisModel.H" +#include "surfaceFilmModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + phiName_("phi"), + rhoName_("rho"), + deltaWet_(1e-6) +{} + + +Foam::filmPyrolysisTemperatureCoupledFvPatchScalarField:: +filmPyrolysisTemperatureCoupledFvPatchScalarField +( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& 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& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), + deltaWet_(dict.lookupOrDefault("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& 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 + ( + "surfaceFilmProperties" + ); + + + bool pyrOk = + db().objectRegistry::foundObject + ( + "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("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("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(os, "phi", "phi", phiName_); + writeEntryIfDifferent(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 0000000000..35864435fa --- /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 . + +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& + ); + + //- Construct from patch, internal field and dictionary + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // filmPyrolysisTemperatureCoupledFvPatchScalarField onto a new patch + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new filmPyrolysisTemperatureCoupledFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + filmPyrolysisTemperatureCoupledFvPatchScalarField + ( + const filmPyrolysisTemperatureCoupledFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + 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 0000000000..57955d166c --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "filmPyrolysisVelocityCoupledFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "pyrolysisModel.H" +#include "surfaceFilmModel.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(p, iF), + phiName_("phi"), + rhoName_("rho"), + deltaWet_(1e-6) +{} + + +Foam::filmPyrolysisVelocityCoupledFvPatchVectorField:: +filmPyrolysisVelocityCoupledFvPatchVectorField +( + const filmPyrolysisVelocityCoupledFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& 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& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF), + phiName_(dict.lookupOrDefault("phi", "phi")), + rhoName_(dict.lookupOrDefault("rho", "rho")), + deltaWet_(dict.lookupOrDefault("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& 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 + ( + "surfaceFilmProperties" + ); + + + bool pyrOk = + db().objectRegistry::foundObject + ( + "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 + ( + "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 + ( + "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(phiName_); + + if (phi.dimensions() == dimVelocity*dimArea) + { + // do nothing + } + else if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField& rhop = + patch().lookupPatchField(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(os, "phi", "phi", phiName_); + writeEntryIfDifferent(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 0000000000..c06dbda902 --- /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 . + +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& + ); + + //- Construct from patch, internal field and dictionary + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // filmPyrolysisVelocityCoupledFvPatchVectorField onto a new patch + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new filmPyrolysisVelocityCoupledFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + filmPyrolysisVelocityCoupledFvPatchVectorField + ( + const filmPyrolysisVelocityCoupledFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + 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 07d4cbf033..c27c4b6648 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 6b06924cb3..008f5ad42c 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 Foam::ODEChemistryModel::ODEChemistryModel ( const fvMesh& mesh, - const word& compTypeName, + const word& ODEModelName, const word& thermoTypeName ) : @@ -56,16 +56,6 @@ Foam::ODEChemistryModel::ODEChemistryModel nSpecie_(Y_.size()), nReaction_(reactions_.size()), - solver_ - ( - chemistrySolver::New - ( - *this, - compTypeName, - thermoTypeName - ) - ), - RR_(nSpecie_) { // create the fields for the chemistry sources @@ -135,6 +125,88 @@ Foam::ODEChemistryModel::omega } +template +Foam::scalar Foam::ODEChemistryModel::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& R = reactions_[index]; + scalar w = omega(R, c, T, p, pf, cf, lRef, pr, cr, rRef); + return(w); +} + + +template +void Foam::ODEChemistryModel::updateConcsInReactionI +( + const label index, + const scalar dt, + const scalar omeg, + scalarField& c +) const +{ + // update species + const Reaction& 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 +void Foam::ODEChemistryModel::updateRRInReactionI +( + const label index, + const scalar pr, + const scalar pf, + const scalar corr, + const label lRef, + const label rRef, + simpleMatrix& RR +) const +{ + const Reaction& 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 Foam::scalar Foam::ODEChemistryModel::omega ( @@ -731,7 +803,7 @@ Foam::scalar Foam::ODEChemistryModel::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::solve } +template +Foam::scalar Foam::ODEChemistryModel::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 d9cc946458..33391fab9d 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 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 > solver_; - //- List of reaction rate per specie [kg/m3/s] PtrList 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& solver() const; - //- dc/dt = omega, rate of change in concentration, for each species virtual tmp 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& 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 e97593e37b..fbd408fe3b 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::nReaction() const } -template -inline const Foam::chemistrySolver& -Foam::ODEChemistryModel::solver() const -{ - return solver_; -} - - template inline Foam::tmp Foam::ODEChemistryModel::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 29b021e4c2..29b65f385e 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 . -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 SS##Comp##Thermo; \ + typedef SS 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 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 7c1d6b596a..8b22ae7ce5 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::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::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::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::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 f4dbc3a671..ec9b968c50 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::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::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::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::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 e090c5d991..dd094b7820 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 -Foam::EulerImplicit::EulerImplicit +template +Foam::EulerImplicit::EulerImplicit ( - ODEChemistryModel& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), + chemistrySolver(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict("EulerImplicitCoeffs")), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter")) {} @@ -45,15 +46,15 @@ Foam::EulerImplicit::EulerImplicit // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::EulerImplicit::~EulerImplicit() +template +Foam::EulerImplicit::~EulerImplicit() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar Foam::EulerImplicit::solve +template +Foam::scalar Foam::EulerImplicit::solve ( scalarField &c, const scalar T, @@ -62,7 +63,10 @@ Foam::scalar Foam::EulerImplicit::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 RR(nSpecie, 0, 0); for (label i = 0; i < nSpecie; i++) @@ -75,17 +79,9 @@ Foam::scalar Foam::EulerImplicit::solve RR.source()[i] = c[i]/dt; } - forAll(this->model_.reactions(), i) + forAll(this->reactions(), i) { - const Reaction& 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::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::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::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 fffa5a93d8..1ce3148939 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 EulerImplicit; - /*---------------------------------------------------------------------------*\ Class EulerImplicit Declaration \*---------------------------------------------------------------------------*/ -template +template class EulerImplicit : - public chemistrySolver + public chemistrySolver { // Private data @@ -81,8 +77,9 @@ public: //- Construct from components EulerImplicit ( - ODEChemistryModel& 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 ade0485af1..3cceb2466d 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 -Foam::chemistrySolver::chemistrySolver +template +Foam::chemistrySolver::chemistrySolver ( - ODEChemistryModel& 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 -Foam::chemistrySolver::~chemistrySolver() +template +Foam::chemistrySolver::~chemistrySolver() {} diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/chemistrySolver/chemistrySolver.H index a3c2e477c3..f837a4a154 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 chemistrySolver; - /*---------------------------------------------------------------------------*\ Class chemistrySolver Declaration \*---------------------------------------------------------------------------*/ -template +template class chemistrySolver +: + public ODEChemistryType { protected: // Protected data - //- Reference to the chemistry model - ODEChemistryModel& model_; - //- Name of the chemistry solver const word name_; @@ -81,10 +76,11 @@ public: chemistrySolver, dictionary, ( - ODEChemistryModel& 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& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ); - //- Selector - static autoPtr New - ( - ODEChemistryModel& model, - const word& compTypeName, - const word& thermoTypeName - ); - - //- Destructor virtual ~chemistrySolver(); @@ -131,46 +119,60 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#define makeChemistrySolver(Comp, Thermo) \ - \ - typedef chemistrySolver \ - chemistrySolver##Comp##Thermo; \ +#define makeChemistrySolver(ODEChem) \ \ defineTemplateTypeNameAndDebugWithName \ ( \ - chemistrySolver##Comp##Thermo, \ - "chemistryModel<"#Comp","#Thermo">", \ + chemistrySolver, \ + "chemistrySolver<"#ODEChem">", \ 0 \ - ); \ - \ - defineTemplateRunTimeSelectionTable \ - ( \ - chemistrySolver##Comp##Thermo, \ - dictionary \ ); -#define makeChemistrySolverType(SS, Comp, Thermo) \ + +#define makeChemistrySolverType(SS, ODEChem, Comp, Thermo) \ \ - typedef SS SS##Comp##Thermo; \ + typedef SS > SS##ODEChem##Comp##Thermo; \ \ defineTemplateTypeNameAndDebugWithName \ ( \ - SS##Comp##Thermo, \ - #SS"<"#Comp","#Thermo">", \ + SS##ODEChem##Comp##Thermo, \ + #SS"<"#ODEChem"<"#Comp","#Thermo">>", \ 0 \ ); \ \ - chemistrySolver:: \ - adddictionaryConstructorToTable > \ - add##SS##Comp##Thermo##ConstructorToTable_; + addToRunTimeSelectionTable \ + ( \ + Comp, \ + SS##ODEChem##Comp##Thermo, \ + fvMesh \ + ); + + +#define makeSolidChemistrySolverType(SS, ODEChem, Comp, SThermo, GThermo) \ + \ + typedef SS > \ + 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 \ + ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #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 f7eab4c2d7..0000000000 --- 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 . - -\*---------------------------------------------------------------------------*/ - -#include "chemistrySolver.H" - -// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // - -template -Foam::autoPtr > -Foam::chemistrySolver::New -( - ODEChemistryModel& 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 > - (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 0000000000..ef217617f3 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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; \ + \ + 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 f9ae6bca25..82b29fb37b 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 0d64b3fb85..822f8266b1 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 -Foam::noChemistrySolver::noChemistrySolver +template +Foam::noChemistrySolver::noChemistrySolver ( - ODEChemistryModel& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver(model, modelName) + chemistrySolver(mesh, ODEModelName, thermoType) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::noChemistrySolver::~noChemistrySolver() +template +Foam::noChemistrySolver::~noChemistrySolver() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar Foam::noChemistrySolver::solve +template +Foam::scalar Foam::noChemistrySolver::solve ( scalarField&, const scalar, diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H b/src/thermophysicalModels/chemistryModel/chemistrySolver/noChemistrySolver/noChemistrySolver.H index 7382beba85..752c8d6177 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 noChemistrySolver; - /*---------------------------------------------------------------------------*\ - Class noChemistrySolver Declaration + Class noChemistrySolver Declaration \*---------------------------------------------------------------------------*/ -template +template class noChemistrySolver : - public chemistrySolver + public chemistrySolver { public: @@ -69,8 +65,9 @@ public: //- Construct from components noChemistrySolver ( - ODEChemistryModel& 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 d20f22f91e..d14299e235 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 -Foam::ode::ode +template +Foam::ode::ode ( - ODEChemistryModel& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), - solverName_(coeffsDict_.lookup("ODESolver")), - odeSolver_(ODESolver::New(solverName_, model)), + chemistrySolver(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict("odeCoeffs")), + solverName_(coeffsDict_.lookup("solver")), + odeSolver_(ODESolver::New(solverName_, *this)), eps_(readScalar(coeffsDict_.lookup("eps"))) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::ode::~ode() +template +Foam::ode::~ode() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar Foam::ode::solve +template +Foam::scalar Foam::ode::solve ( scalarField& c, const scalar T, @@ -62,8 +63,8 @@ Foam::scalar Foam::ode::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::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 e68af7c63c..d6f7f27a72 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 ode; - /*---------------------------------------------------------------------------*\ Class ode Declaration \*---------------------------------------------------------------------------*/ -template +template class ode : - public chemistrySolver + public chemistrySolver { // Private data @@ -78,8 +74,9 @@ public: //- Construct from components ode ( - ODEChemistryModel& 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 8046aaf2f0..c0005f6420 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 -Foam::sequential::sequential +template +Foam::sequential::sequential ( - ODEChemistryModel& model, - const word& modelName + const fvMesh& mesh, + const word& ODEModelName, + const word& thermoType ) : - chemistrySolver(model, modelName), - coeffsDict_(model.subDict(modelName + "Coeffs")), + chemistrySolver(mesh, ODEModelName, thermoType), + coeffsDict_(this->subDict("sequentialCoeffs")), cTauChem_(readScalar(coeffsDict_.lookup("cTauChem"))), eqRateLimiter_(coeffsDict_.lookup("equilibriumRateLimiter")) {} @@ -44,15 +45,15 @@ Foam::sequential::sequential // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::sequential::~sequential() +template +Foam::sequential::~sequential() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::scalar Foam::sequential::solve +template +Foam::scalar Foam::sequential::solve ( scalarField &c, const scalar T, @@ -66,14 +67,9 @@ Foam::scalar Foam::sequential::solve scalar pf, cf, pb, cb; label lRef, rRef; - forAll(this->model_.reactions(), i) + forAll(this->reactions(), i) { - const Reaction& 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::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 795c9f9c82..81635c6d7f 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 sequential; - /*---------------------------------------------------------------------------*\ Class sequential Declaration \*---------------------------------------------------------------------------*/ -template +template class sequential : - public chemistrySolver + public chemistrySolver { // Private data @@ -83,8 +79,9 @@ public: //- Construct from components sequential ( - ODEChemistryModel& 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 0000000000..86696b0709 --- /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 0000000000..314c820f24 --- /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 0000000000..bfccadf733 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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::combustionModel::R +( + volScalarField& Y +) const +{ + return tmp + ( + new fvScalarMatrix(Y, dimMass/dimTime*Y.dimensions()) + ); +} + + +Foam::tmp Foam::combustionModel::dQ() const +{ + return tmp + ( + 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::combustionModel::wFuelNorm() const +{ + return tmp + ( + 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 0000000000..28ccb85b1b --- /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 . + +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 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 R(volScalarField& Y) const; + + //- Heat release rate calculated from fuel consumption rate matrix + virtual tmp dQ() const; + + //- Return normalised consumption rate of (fu - fres) + virtual tmp 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 0000000000..23e07f76e1 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "combustionModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr 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 + (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 0000000000..c66099a88c --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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&>(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::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::combustionModels::infinitelyFastChemistry::dQ() const +{ + const label fuelI = singleMixture_.fuelIndex(); + volScalarField& YFuel = thermo_.composition().Y(fuelI); + + return -singleMixture_.qFuel()*(R(YFuel) & YFuel); +} + + +Foam::tmp +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 0000000000..304dba46a3 --- /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 . + +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& 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 R(volScalarField& Y) const; + + //- Heat release rate calculated from fuel consumption rate matrix + virtual tmp dQ() const; + + //- Return normalised consumption rate of (fu - fres) + virtual tmp 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 0000000000..4fc8c7d0c9 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 0000000000..d36f4c11e3 --- /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 . + +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 9bb945952c..80514bfd5e 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 b8b6c9668c..f3edd7158f 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 0000000000..57471ce57b --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "singleStepReactingMixture.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +void Foam::singleStepReactingMixture::calculateqFuel() +{ + const Reaction& 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 +void Foam::singleStepReactingMixture::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 +void Foam::singleStepReactingMixture::calculateMaxProducts() +{ + const Reaction& 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 +void Foam::singleStepReactingMixture::fresCorrect() +{ + const Reaction& 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 +Foam::singleStepReactingMixture::singleStepReactingMixture +( + const dictionary& thermoDict, + const fvMesh& mesh +) +: + reactingMixture(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 >::clear(); + } + else + { + FatalErrorIn + ( + "singleStepReactingMixture::::singleStepReactingMixture" + "(" + "const dictionary&, " + "const fvMesh&" + ")" + ) << "Only one reaction required for single step reaction" + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::singleStepReactingMixture::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 0000000000..5f31f225ea --- /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 . + +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 singleStepReactingMixture +: + public reactingMixture +{ + +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 fres_; + + //- Inert specie index + label inertIndex_; + + //- Fuel specie index + label fuelIndex_; + + //- List to indicate if specie is produced/consumed + List 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& specieStoichCoeffs() const; + + //- Return the list of components residual + inline tmp 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& 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 0000000000..f8cfe1d9f1 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "singleStepReactingMixture.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture::stoicRatio() const +{ + return stoicRatio_; +} + + +template +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture::s() const +{ + return s_; +} + + +template +inline const Foam::dimensionedScalar +Foam::singleStepReactingMixture::qFuel() const +{ + return qFuel_; +} + + +template +inline const Foam::List& +Foam::singleStepReactingMixture::specieStoichCoeffs() const +{ + return specieStoichCoeffs_; +} + + +template +inline Foam::tmp +Foam::singleStepReactingMixture::fres +( + const label index +) const +{ + return fres_[index]; +} + + +template +inline Foam::label +Foam::singleStepReactingMixture::inertIndex() const +{ + return inertIndex_; +} + + +template +inline Foam::label +Foam::singleStepReactingMixture::fuelIndex() const +{ + return fuelIndex_; +} + + +template +inline const Foam::List& +Foam::singleStepReactingMixture::specieProd() const +{ + return specieProd_; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C b/src/thermophysicalModels/reactionThermo/reactionThermo/hReactionThermo/hReactionThermos.C index f5e392578b..e0bded71e5 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 09ea401160..e232028807 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 0000000000..9f2b681e80 --- /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 0000000000..d989adfd5b --- /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 0000000000..f06c2ef001 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "ODESolidChemistryModel.H" +#include "reactingSolidMixture.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::ODESolidChemistryModel:: +ODESolidChemistryModel +( + const fvMesh& mesh, + const word& compTypeName, + const word& solidThermoName +) +: + CompType(mesh, solidThermoName), + ODE(), + Ys_(this->solidThermo().composition().Y()), + pyrolisisGases_ + ( + mesh.lookupObject + ("chemistryProperties").lookup("species") + ), + reactions_ + ( + static_cast& > + (this->solidThermo().composition()) + ), + solidThermo_ + ( + static_cast& > + (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("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 +Foam::ODESolidChemistryModel:: +~ODESolidChemistryModel() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +Foam::scalarField Foam:: +ODESolidChemistryModel::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 +Foam::scalar +Foam::ODESolidChemistryModel::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 +void Foam::ODESolidChemistryModel::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 +void Foam::ODESolidChemistryModel::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; iSMALL) + { + 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 +Foam::tmp +Foam::ODESolidChemistryModel::tc() const +{ + notImplemented + ( + "ODESolidChemistryModel::tc()" + ); + + return volScalarField::null(); +} + + +template +Foam::tmp +Foam::ODESolidChemistryModel::Sh() const +{ + tmp 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 +Foam::tmp +Foam::ODESolidChemistryModel::dQ() const +{ + tmp 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 +Foam::label Foam:: +ODESolidChemistryModel::nEqns() const +{ + // nEqns = number of solids + gases + temperature + pressure + return (nSpecie_ + 2); +} + + +template +void Foam::ODESolidChemistryModel:: +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 +Foam::scalar +Foam::ODESolidChemistryModel::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; ideltaTChem_[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; ideltaTChem_[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 +Foam::tmp +Foam::ODESolidChemistryModel::gasHs +( + const volScalarField& T, + const label index +) const +{ + + tmp 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 +Foam::scalar +Foam::ODESolidChemistryModel::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 +void Foam::ODESolidChemistryModel:: +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 0000000000..107029eed6 --- /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 . + +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 ODESolidChemistryModel +: + public CompType, + public ODE +{ + // Private Member Functions + + //- Disallow default bitwise assignment + void operator=(const ODESolidChemistryModel&); + + +protected: + + //- Reference to solid mass fractions + PtrList& Ys_; + + //- List of gas species present in reaction system + speciesTable pyrolisisGases_; + + //- Reactions + const PtrList& reactions_; + + //- Thermodynamic data of solids + const PtrList& solidThermo_; + + //- Thermodynamic data of gases + PtrList 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 RRs_; + + //- List of reaction rate per gas [kg/m3/s] + PtrList RRg_; + + + // Protected Member Functions + + //- Write access to source terms for solids + inline PtrList& RRs(); + + //- Write access to source terms for gases + inline PtrList& RRg(); + + +private: + + //- List of accumulative solid concentrations + mutable PtrList Ys0_; + + //- Cell counter + label cellCounter_; + + //- List of active reacting cells + List 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& reactions() const; + + //- Thermodynamic data of gases + inline const PtrList& 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 RRs(const label i) const; + + //- Return const access to the chemical source terms for gases + inline tmp RRg(const label i) const; + + //- Return total gas source term + inline tmp RRg() const; + + //- Return total solid source term + inline tmp RRs() const; + + //- Return const access to the total source terms + inline tmp RR(const label i) const; + + //- Return sensible enthalpy for gas i [J/Kg] + virtual tmp 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 tc() const; + + //- Return source for enthalpy equation [kg/m/s3] + virtual tmp Sh() const; + + //- Return the heat release, i.e. enthalpy/sec [m2/s3] + virtual tmp 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 0000000000..f3e4655dec --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "volFields.H" +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Foam::PtrList& +Foam::ODESolidChemistryModel::RRs() +{ + return RRs_; +} + + +template +inline Foam::PtrList& +Foam::ODESolidChemistryModel::RRg() +{ + return RRg_; +} + + +template +inline const Foam::PtrList& +Foam::ODESolidChemistryModel::reactions() const +{ + return reactions_; +} + + +template +inline const Foam::PtrList& +Foam::ODESolidChemistryModel:: +gasThermo() const +{ + return gasThermo_; +} + + +template +inline const Foam::speciesTable& +Foam::ODESolidChemistryModel::gasTable() const +{ + return pyrolisisGases_; +} + + +template +inline Foam::label +Foam::ODESolidChemistryModel::nSpecie() const +{ + return nSpecie_; +} + + +template +inline Foam::label +Foam::ODESolidChemistryModel:: +nReaction() const +{ + return nReaction_; +} + + +template +inline Foam::tmp +Foam::ODESolidChemistryModel::RRs +( + const label i +) const +{ + tmp 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 +inline Foam::tmp +Foam::ODESolidChemistryModel::RRg +( + const label i +) const +{ + tmp 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 +inline Foam::tmp +Foam::ODESolidChemistryModel::RRg() const +{ + tmp 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 +inline Foam::tmp +Foam::ODESolidChemistryModel::RRs() const +{ + tmp 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 +inline Foam::tmp +Foam::ODESolidChemistryModel::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 0000000000..64a92d520a --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 0000000000..f390bd4088 --- /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 . + +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 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 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 RRg() const = 0; + + //- Return total solids mass source term [kg/m3/s] + virtual tmp RRs() const = 0; + + //- Return chemical source terms for solids [kg/m3/s] + virtual tmp RRs(const label i) const = 0; + + //- Return chemical source terms for gases [kg/m3/s] + virtual tmp RRg(const label i) const = 0; + + //- Return sensible enthalpy for gas i [J/Kg] + virtual tmp 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 0000000000..bdc173948f --- /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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * 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 0000000000..05c0b939b8 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#include "solidChemistryModel.H" + +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + +Foam::autoPtr 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 + (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 0000000000..cf738fae45 --- /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 . + +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 0000000000..2e9768c7b2 --- /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 . + +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 > \ + 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 0000000000..3efdf505c5 --- /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 . + +\*---------------------------------------------------------------------------*/ + +#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 + + solidODEChemistryConstThermo; + + makeChemistrySolver(solidODEChemistryConstThermo) + + makeSolidChemistrySolverType + ( + ode, + ODESolidChemistryModel, + solidChemistryModel, + constSolidThermoPhysics, + gasThermoPhysics + ) + + typedef ODESolidChemistryModel + + 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 5e36f2dada..6714a333e7 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 8a413c489e..bc7593e792 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 f9c5480d40..0ccb565916 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 99b0689c34..6e8da91823 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 49f4d3ee44..b50ba98bff 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 644b893310..14d3f4ab0a 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 0000000000..2e95cadde5 --- /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 0000000000..f570788abe --- /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 0000000000..0f9fd90151 --- /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 0000000000..1062586afe --- /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 0000000000..a4a67f3356 --- /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 0000000000..d67e74eec4 --- /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 0000000000..729596084b --- /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 0000000000..b98d4ba3d6 --- /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 0000000000..bbb2246df0 --- /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 0000000000..ef3b660348 --- /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 0000000000..89be31e65e --- /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 0000000000..70cbcdec44 --- /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 0000000000..4fea433a00 --- /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 0000000000..2e040b855b --- /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 0000000000..d848038c6e --- /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 0000000000..d734e603cd --- /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 0000000000..83df353395 --- /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>>>>; + +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 0000000000..4f2dbc3f76 --- /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; + 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 0000000000..43d2a5ea72 --- /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 0000000000..3e67c328bd --- /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 0000000000..271f262f8e --- /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 506c086b68..fd54b84768 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 02d3bb5a71..d332d6144c 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 02d3bb5a71..d332d6144c 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 02d3bb5a71..d332d6144c 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 9c4b54407c..462583d3e2 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 3a7d1a555b..5612988231 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; }