From f92d657ab726cd620a19675bba907ba9bc480be1 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Sun, 28 Jun 2015 21:41:40 +0100 Subject: [PATCH] LTS: Formalize the naming of the rDeltaT and rSubDeltaT fields Now the specification of the LTS time scheme is simply: ddtSchemes { default localEuler; } --- .../reactingParcelFoam/reactingParcelFoam.C | 11 +-- .../solvers/multiphase/interFoam/alphaEqn.H | 6 +- .../multiphase/interFoam/alphaEqnSubCycle.H | 6 +- .../interFoam/interMixingFoam/alphaEqns.H | 4 +- .../twoPhaseSystem/twoPhaseSystem.C | 12 +--- src/combustionModels/laminar/laminar.C | 6 +- src/finiteVolume/Make/files | 1 + .../cfdTools/general/include/createRDeltaT.H | 2 +- .../ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H | 3 +- .../localEulerDdtScheme/localEulerDdt.C | 69 +++++++++++++++++++ .../localEulerDdtScheme/localEulerDdtScheme.C | 5 +- .../localEulerDdtScheme/localEulerDdtScheme.H | 67 +++++++++++++----- .../solvers/MULES/CMULESTemplates.C | 6 +- .../fvMatrices/solvers/MULES/MULESTemplates.C | 6 +- .../counterFlowFlame2DLTS/system/fvSchemes | 2 +- .../biconic25-55Run35/system/fvSchemes | 2 +- .../ras/angledDuctLTS/system/fvSchemes | 2 +- .../counterFlowFlame2DLTS/system/fvSchemes | 2 +- .../verticalChannelLTS/system/fvSchemes | 2 +- .../interFoam/ras/DTCHull/system/fvSchemes | 2 +- 20 files changed, 145 insertions(+), 71 deletions(-) create mode 100644 src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdt.C diff --git a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index e122e959fa..2d49b71705 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -77,11 +77,7 @@ int main(int argc, char *argv[]) { #include "readTimeControls.H" - if (LTS) - { - #include "setRDeltaT.H" - } - else + if (!LTS) { #include "compressibleCourantNo.H" #include "setDeltaT.H" @@ -93,6 +89,11 @@ int main(int argc, char *argv[]) parcels.evolve(); + if (LTS) + { + #include "setRDeltaT.H" + } + #include "rhoEqn.H" // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/multiphase/interFoam/alphaEqn.H b/applications/solvers/multiphase/interFoam/alphaEqn.H index 2a90edea65..4405c58015 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interFoam/alphaEqn.H @@ -79,11 +79,7 @@ ( ( LTS - ? fv::localEulerDdtScheme - ( - mesh, - nAlphaSubCycles > 1 ? "rSubDeltaT" : "rDeltaT" - ).fvmDdt(alpha1) + ? fv::localEulerDdtScheme(mesh).fvmDdt(alpha1) : fv::EulerDdtScheme(mesh).fvmDdt(alpha1) ) + fv::gaussConvectionScheme diff --git a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H index 71de077233..772de0b97a 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H @@ -17,10 +17,8 @@ if (nAlphaSubCycles > 1) if (LTS) { - trSubDeltaT = tmp - ( - new volScalarField("rSubDeltaT", trDeltaT()*nAlphaSubCycles) - ); + trSubDeltaT = + fv::localEulerDdt::localRSubDeltaT(mesh, nAlphaSubCycles); } for diff --git a/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqns.H b/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqns.H index 69dda6cd36..9585905c08 100644 --- a/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqns.H +++ b/applications/solvers/multiphase/interFoam/interMixingFoam/alphaEqns.H @@ -75,7 +75,7 @@ if (LTS) { const volScalarField& rDeltaT = - mesh.objectRegistry::lookupObject("rSubDeltaT"); + fv::localEulerDdt::localRDeltaT(mesh); MULES::limiter ( @@ -138,7 +138,7 @@ if (LTS) { const volScalarField& rDeltaT = - mesh.objectRegistry::lookupObject("rSubDeltaT"); + fv::localEulerDdt::localRDeltaT(mesh); MULES::limiter ( diff --git a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/phaseSystems/twoPhaseSystem/twoPhaseSystem.C b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/phaseSystems/twoPhaseSystem/twoPhaseSystem.C index 3ce13f2c43..fa867267a9 100644 --- a/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/phaseSystems/twoPhaseSystem/twoPhaseSystem.C +++ b/applications/solvers/multiphase/reactingTwoPhaseEulerFoam/phaseSystems/twoPhaseSystem/twoPhaseSystem.C @@ -324,16 +324,8 @@ void Foam::twoPhaseSystem::solve() if (LTS) { - const volScalarField& rDeltaT = - mesh.objectRegistry::lookupObject - ( - "rDeltaT" - ); - - trSubDeltaT = tmp - ( - new volScalarField("rSubDeltaT", rDeltaT*nAlphaSubCycles) - ); + trSubDeltaT = + fv::localEulerDdt::localRSubDeltaT(mesh, nAlphaSubCycles); } for diff --git a/src/combustionModels/laminar/laminar.C b/src/combustionModels/laminar/laminar.C index 7203a715e8..07f690caea 100644 --- a/src/combustionModels/laminar/laminar.C +++ b/src/combustionModels/laminar/laminar.C @@ -83,11 +83,7 @@ void Foam::combustionModels::laminar::correct() if (ddtScheme == fv::localEulerDdtScheme::typeName) { const scalarField& rDeltaT = - this->mesh().objectRegistry:: - template lookupObject - ( - "rDeltaT" - ); + fv::localEulerDdt::localRDeltaT(this->mesh()); if (this->coeffs().found("maxIntegrationTime")) { diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 157711b1c1..b049e4a60c 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -335,6 +335,7 @@ $(ddtSchemes)/steadyStateDdtScheme/steadyStateDdtSchemes.C $(ddtSchemes)/EulerDdtScheme/EulerDdtSchemes.C $(ddtSchemes)/CoEulerDdtScheme/CoEulerDdtSchemes.C $(ddtSchemes)/SLTSDdtScheme/SLTSDdtSchemes.C +$(ddtSchemes)/localEulerDdtScheme/localEulerDdt.C $(ddtSchemes)/localEulerDdtScheme/localEulerDdtSchemes.C $(ddtSchemes)/backwardDdtScheme/backwardDdtSchemes.C $(ddtSchemes)/CrankNicolsonDdtScheme/CrankNicolsonDdtSchemes.C diff --git a/src/finiteVolume/cfdTools/general/include/createRDeltaT.H b/src/finiteVolume/cfdTools/general/include/createRDeltaT.H index dae76f4cab..eec4db8583 100644 --- a/src/finiteVolume/cfdTools/general/include/createRDeltaT.H +++ b/src/finiteVolume/cfdTools/general/include/createRDeltaT.H @@ -14,7 +14,7 @@ if (LTS) ( IOobject ( - "rDeltaT", + fv::localEulerDdt::rDeltaTName, runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H index ea6fdd987e..f09ee8a1ce 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H @@ -33,7 +33,8 @@ Description using transient codes where local time-stepping is preferably to under-relaxation for transport consistency reasons. - See also CoEulerDdtScheme. +See Also + Foam::fv::CoEulerDdtScheme SourceFiles SLTSDdtScheme.C diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdt.C b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdt.C new file mode 100644 index 0000000000..8826efba0e --- /dev/null +++ b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdt.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "localEulerDdtScheme.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +Foam::word Foam::fv::localEulerDdt::rDeltaTName("rDeltaT"); +Foam::word Foam::fv::localEulerDdt::rSubDeltaTName("rSubDeltaTName"); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +const Foam::volScalarField& Foam::fv::localEulerDdt::localRDeltaT +( + const fvMesh& mesh +) +{ + return mesh.objectRegistry::template lookupObject + ( + mesh.time().subCycling() ? rSubDeltaTName : rDeltaTName + ); +} + + +Foam::tmp Foam::fv::localEulerDdt::localRSubDeltaT +( + const fvMesh& mesh, + const label nAlphaSubCycles +) +{ + return tmp + ( + new volScalarField + ( + rSubDeltaTName, + nAlphaSubCycles + *mesh.objectRegistry::template lookupObject + ( + rDeltaTName + ) + ) + ); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.C index 50633ac486..4b56cd4c3c 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,8 +42,7 @@ namespace fv template const volScalarField& localEulerDdtScheme::localRDeltaT() const { - return mesh().objectRegistry::template lookupObject - (rDeltaTName_); + return localEulerDdt::localRDeltaT(mesh()); } diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.H index dc7bb0c79b..a0e55d3e47 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/localEulerDdtScheme/localEulerDdtScheme.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,14 +26,15 @@ Class Description Local time-step first-order Euler implicit/explicit ddt. - The reciprocal of the local time-step field is looked-up from the - database with the name provided. - This scheme should only be used for steady-state computations - using transient codes where local time-stepping is preferably to - under-relaxation for transport consistency reasons. + The reciprocal of the local time-step field is looked-up from the database. - See also CoEulerDdtScheme. + This scheme should only be used for steady-state computations using + transient codes where local time-stepping is preferably to under-relaxation + for transport consistency reasons. + +See Also + Foam::fv::CoEulerDdtScheme SourceFiles localEulerDdtScheme.C @@ -56,6 +57,41 @@ namespace Foam namespace fv { +/*---------------------------------------------------------------------------*\ + Class localEulerDdt Declaration +\*---------------------------------------------------------------------------*/ + +class localEulerDdt +{ +public: + + //- Name of the reciprocal local time-step field + static word rDeltaTName; + + //- Name of the reciprocal local sub-cycling time-step field + static word rSubDeltaTName; + + // Constructors + + localEulerDdt() + {} + + // Member Functions + + //- Return the reciprocal of the local time-step + // looked-up from the objectRegistry + static const volScalarField& localRDeltaT(const fvMesh& mesh); + + //- Calculate and return the reciprocal of the local sub-cycling + // time-step + static tmp localRSubDeltaT + ( + const fvMesh& mesh, + const label nAlphaSubCycles + ); +}; + + /*---------------------------------------------------------------------------*\ Class localEulerDdtScheme Declaration \*---------------------------------------------------------------------------*/ @@ -63,14 +99,9 @@ namespace fv template class localEulerDdtScheme : + public localEulerDdt, public fv::ddtScheme { - // Private Data - - //- Name of the reciprocal local time-step field - word rDeltaTName_; - - // Private Member Functions //- Disallow default bitwise copy construct @@ -91,18 +122,16 @@ public: // Constructors - //- Construct from mesh and name of the rDeltaT field - localEulerDdtScheme(const fvMesh& mesh, const word& rDeltaTName) + //- Construct from mesh + localEulerDdtScheme(const fvMesh& mesh) : - ddtScheme(mesh), - rDeltaTName_(rDeltaTName) + ddtScheme(mesh) {} //- Construct from mesh and Istream localEulerDdtScheme(const fvMesh& mesh, Istream& is) : - ddtScheme(mesh, is), - rDeltaTName_(is) + ddtScheme(mesh, is) {} diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C index 75180f09dc..ec1afe2bf3 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/CMULESTemplates.C @@ -95,11 +95,7 @@ void Foam::MULES::correct if (LTS) { - const volScalarField& rDeltaT = - mesh.objectRegistry::lookupObject - ( - mesh.time().subCycling() ? "rSubDeltaT" : "rDeltaT" - ); + const volScalarField& rDeltaT = fv::localEulerDdt::localRDeltaT(mesh); limitCorr ( diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index b0205beccb..6515513d31 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -117,11 +117,7 @@ void Foam::MULES::explicitSolve if (LTS) { - const volScalarField& rDeltaT = - mesh.objectRegistry::lookupObject - ( - mesh.time().subCycling() ? "rSubDeltaT" : "rDeltaT" - ); + const volScalarField& rDeltaT = fv::localEulerDdt::localRDeltaT(mesh); limit ( diff --git a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2DLTS/system/fvSchemes b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2DLTS/system/fvSchemes index 050a277e00..edeed781b1 100644 --- a/tutorials/combustion/reactingFoam/ras/counterFlowFlame2DLTS/system/fvSchemes +++ b/tutorials/combustion/reactingFoam/ras/counterFlowFlame2DLTS/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/fvSchemes b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/fvSchemes index 3060cac40f..1df1a22cb6 100644 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/fvSchemes +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/system/fvSchemes @@ -19,7 +19,7 @@ fluxScheme Kurganov; ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes diff --git a/tutorials/compressible/rhoPimpleFoam/ras/angledDuctLTS/system/fvSchemes b/tutorials/compressible/rhoPimpleFoam/ras/angledDuctLTS/system/fvSchemes index 49aa2c4c83..8d1dad976f 100644 --- a/tutorials/compressible/rhoPimpleFoam/ras/angledDuctLTS/system/fvSchemes +++ b/tutorials/compressible/rhoPimpleFoam/ras/angledDuctLTS/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes diff --git a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/system/fvSchemes b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/system/fvSchemes index a3d785d315..d096520e35 100644 --- a/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/system/fvSchemes +++ b/tutorials/lagrangian/reactingParcelFoam/counterFlowFlame2DLTS/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/fvSchemes b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/fvSchemes index 13bfbc31fe..316f64c021 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/fvSchemes +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannelLTS/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes diff --git a/tutorials/multiphase/interFoam/ras/DTCHull/system/fvSchemes b/tutorials/multiphase/interFoam/ras/DTCHull/system/fvSchemes index 66a883a157..ab0fa54e31 100644 --- a/tutorials/multiphase/interFoam/ras/DTCHull/system/fvSchemes +++ b/tutorials/multiphase/interFoam/ras/DTCHull/system/fvSchemes @@ -17,7 +17,7 @@ FoamFile ddtSchemes { - default localEuler rDeltaT; + default localEuler; } gradSchemes