diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..0b34210865f87a91c78d489ea0a9dd71d83b448f --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +Application + LTSReactingFoam + +Description + Local time stepping (LTS) solver for steady, compressible, laminar or + turbulent reacting and non-reacting flow. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "turbulenceModel.H" +#include "psiCombustionModel.H" +#include "multivariateScheme.H" +#include "pimpleControl.H" +#include "fvIOoptionList.H" +#include "fvcSmooth.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + pimpleControl pimple(mesh); + + #include "readGravitationalAcceleration.H" + #include "createFields.H" + #include "createFvOptions.H" + #include "initContinuityErrs.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setInitialrDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "setrDeltaT.H" + + #include "rhoEqn.H" + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + #include "UEqn.H" + #include "YEqn.H" + #include "EEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + 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/combustion/reactingFoam/LTSReactingFoam/Make/files b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..0b81e7a03247e0f362b71cc12cee85fd0c9f134e --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/Make/files @@ -0,0 +1,3 @@ +LTSReactingFoam.C + +EXE = $(FOAM_APPBIN)/LTSReactingFoam diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/Make/options b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..abac9d96a4c1da64039dd6e1c09b4b6e7ad4fbcc --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/Make/options @@ -0,0 +1,28 @@ +EXE_INC = -ggdb3 \ + -I.. \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/fvOptions/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude \ + -I$(LIB_SRC)/combustionModels/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lfvOptions \ + -lmeshTools \ + -lsampling \ + -lcompressibleTurbulenceModel \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -lreactionThermophysicalModels \ + -lspecie \ + -lfluidThermophysicalModels \ + -lchemistryModel \ + -lODE \ + -lcombustionModels diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H new file mode 100644 index 0000000000000000000000000000000000000000..2a6dd6f3456c2d7659e05ba931e63cf18b9e790b --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// Maximum flow Courant number +scalar maxCo(readScalar(pimple.dict().lookup("maxCo"))); + +// Maximum time scale +scalar maxDeltaT(pimple.dict().lookupOrDefault<scalar>("maxDeltaT", GREAT)); + +// Smoothing parameter (0-1) when smoothing iterations > 0 +scalar rDeltaTSmoothingCoeff +( + pimple.dict().lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1) +); + +// Damping coefficient (1-0) +scalar rDeltaTDampingCoeff +( + pimple.dict().lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1.0) +); + +// Maximum change in cell temperature per iteration (relative to previous value) +scalar alphaTemp(pimple.dict().lookupOrDefault("alphaTemp", 0.5)); + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setInitialrDeltaT.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setInitialrDeltaT.H new file mode 100644 index 0000000000000000000000000000000000000000..c445eaee71e69d203e425df155dfa058ea71a170 --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setInitialrDeltaT.H @@ -0,0 +1,14 @@ + volScalarField rDeltaT + ( + IOobject + ( + "rDeltaT", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("one", dimless/dimTime, 1), + zeroGradientFvPatchScalarField::typeName + ); diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H new file mode 100644 index 0000000000000000000000000000000000000000..ce1caf1de5eec3efdde8b9365ad0e96a4b866dbe --- /dev/null +++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +{ + Info<< "Time scales min/max:" << endl; + + // Cache old reciprocal time scale field + volScalarField rDeltaT0("rDeltaT0", rDeltaT); + + // Flow time scale + { + rDeltaT.dimensionedInternalField() = + ( + fvc::surfaceSum(mag(phi))().dimensionedInternalField() + /((2*maxCo)*mesh.V()*rho.dimensionedInternalField()) + ); + + // Limit the largest time scale + rDeltaT.max(1/maxDeltaT); + + Info<< " Flow = " + << gMin(1/rDeltaT.internalField()) << ", " + << gMax(1/rDeltaT.internalField()) << endl; + } + + // Reaction source time scale + if (alphaTemp < 1.0) + { + volScalarField::DimensionedInternalField rDeltaTT + ( + mag(reaction->Sh())/(alphaTemp*rho*thermo.Cp()*T) + ); + + Info<< " Temperature = " + << gMin(1/(rDeltaTT.field() + VSMALL)) << ", " + << gMax(1/(rDeltaTT.field() + VSMALL)) << endl; + + rDeltaT.dimensionedInternalField() = max + ( + rDeltaT.dimensionedInternalField(), + rDeltaTT + ); + } + + // Update tho boundary values of the reciprocal time-step + rDeltaT.correctBoundaryConditions(); + + // Spatially smooth the time scale field + if (rDeltaTSmoothingCoeff < 1.0) + { + fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff); + } + + // Limit rate of change of time scale + // - reduce as much as required + // - only increase at a fraction of old time scale + if + ( + rDeltaTDampingCoeff < 1.0 + && runTime.timeIndex() > runTime.startTimeIndex() + 1 + ) + { + rDeltaT = max + ( + rDeltaT, + (scalar(1.0) - rDeltaTDampingCoeff)*rDeltaT0 + ); + } + + Info<< " Overall = " + << gMin(1/rDeltaT.internalField()) + << ", " << gMax(1/rDeltaT.internalField()) << endl; +} + +// ************************************************************************* //