From 8293227964a918436f3a0875fd5847b069209113 Mon Sep 17 00:00:00 2001
From: Henry Weller <http://cfd.direct>
Date: Tue, 16 Jun 2015 12:42:37 +0100
Subject: [PATCH] Rationalized the LTS solvers

---
 .../LTSReactingFoam/LTSReactingFoam.C         |  16 +--
 .../{setInitialrDeltaT.H => createRDeltaT.H}  |   0
 .../LTSReactingFoam/readTimeControls.H        |  48 -------
 .../reactingFoam/LTSReactingFoam/setrDeltaT.H |  28 +++-
 .../{setInitialrDeltaT.H => createRDeltaT.H}  |   0
 .../rhoLTSPimpleFoam/rhoLTSPimpleFoam.C       |   2 +-
 .../LTSCoalChemistryFoam.C                    |   9 +-
 .../LTSCoalChemistryFoam/setrDeltaT.H         | 134 ++++++++++++++++++
 .../LTSCoalChemistryFoam/timeScales.H         | 114 ---------------
 .../LTSReactingParcelFoam.C                   |  15 +-
 .../LTSReactingParcelFoam/readTimeControls.H  |  42 ------
 .../LTSReactingParcelFoam/setrDeltaT.H        | 133 +++++++++++++++++
 .../LTSReactingParcelFoam/timeScales.H        | 115 ---------------
 .../interFoam/LTSInterFoam/LTSInterFoam.C     |   2 +-
 .../{setInitialrDeltaT.H => createRDeltaT.H}  |   0
 .../verticalChannel/system/controlDict        |   2 +-
 .../verticalChannel/system/fvSolution         |   2 +-
 .../parcelInBox/system/controlDict            |   2 +-
 .../verticalChannel/system/controlDict        |   2 +-
 .../verticalChannel/system/controlDict        |   2 +-
 20 files changed, 316 insertions(+), 352 deletions(-)
 rename applications/solvers/combustion/reactingFoam/LTSReactingFoam/{setInitialrDeltaT.H => createRDeltaT.H} (100%)
 delete mode 100644 applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H
 rename applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/{setInitialrDeltaT.H => createRDeltaT.H} (100%)
 create mode 100644 applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/setrDeltaT.H
 delete mode 100644 applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/timeScales.H
 delete mode 100644 applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/readTimeControls.H
 create mode 100644 applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/setrDeltaT.H
 delete mode 100644 applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/timeScales.H
 rename applications/solvers/multiphase/interFoam/LTSInterFoam/{setInitialrDeltaT.H => createRDeltaT.H} (100%)

diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C
index 55e33d91deb..aa7be196d6c 100644
--- a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C
+++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/LTSReactingFoam.C
@@ -53,9 +53,7 @@ int main(int argc, char *argv[])
     #include "createMRF.H"
     #include "createFvOptions.H"
     #include "initContinuityErrs.H"
-    #include "readTimeControls.H"
-    #include "compressibleCourantNo.H"
-    #include "setInitialrDeltaT.H"
+    #include "createRDeltaT.H"
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -63,8 +61,6 @@ int main(int argc, char *argv[])
 
     while (runTime.run())
     {
-        #include "readTimeControls.H"
-
         runTime++;
 
         Info<< "Time = " << runTime.timeName() << nl << endl;
@@ -76,6 +72,11 @@ int main(int argc, char *argv[])
         // --- Pressure-velocity PIMPLE corrector loop
         while (pimple.loop())
         {
+            if (pimple.turbCorr())
+            {
+                turbulence->correct();
+            }
+
             #include "UEqn.H"
             #include "YEqn.H"
             #include "EEqn.H"
@@ -85,11 +86,6 @@ int main(int argc, char *argv[])
             {
                 #include "pEqn.H"
             }
-
-            if (pimple.turbCorr())
-            {
-                turbulence->correct();
-            }
         }
 
         runTime.write();
diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setInitialrDeltaT.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/createRDeltaT.H
similarity index 100%
rename from applications/solvers/combustion/reactingFoam/LTSReactingFoam/setInitialrDeltaT.H
rename to applications/solvers/combustion/reactingFoam/LTSReactingFoam/createRDeltaT.H
diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H
deleted file mode 100644
index 133f5b8165a..00000000000
--- a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/readTimeControls.H
+++ /dev/null
@@ -1,48 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  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", 1)
-);
-
-// Damping coefficient (1-0)
-scalar rDeltaTDampingCoeff
-(
-    pimple.dict().lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1)
-);
-
-// Maximum change in cell temperature per iteration (relative to previous value)
-scalar alphaTemp(pimple.dict().lookupOrDefault("alphaTemp", 0.05));
-
-
-// ************************************************************************* //
diff --git a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H
index ce1caf1de5e..6e771864a06 100644
--- a/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H
+++ b/applications/solvers/combustion/reactingFoam/LTSReactingFoam/setrDeltaT.H
@@ -2,7 +2,7 @@
   =========                 |
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2013 OpenFOAM Foundation
+    \\  /    A nd           | Copyright (C) 2013-2015 OpenFOAM Foundation
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
 License
@@ -24,6 +24,31 @@ License
 \*---------------------------------------------------------------------------*/
 
 {
+    const dictionary& pimpleDict = pimple.dict();
+
+    // Maximum flow Courant number
+    scalar maxCo(readScalar(pimpleDict.lookup("maxCo")));
+
+    // Maximum time scale
+    scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
+
+    // Smoothing parameter (0-1) when smoothing iterations > 0
+    scalar rDeltaTSmoothingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
+    );
+
+    // Damping coefficient (1-0)
+    scalar rDeltaTDampingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 1)
+    );
+
+    // Maximum change in cell temperature per iteration
+    // (relative to previous value)
+    scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
+
+
     Info<< "Time scales min/max:" << endl;
 
     // Cache old reciprocal time scale field
@@ -94,4 +119,5 @@ License
         << ", " << gMax(1/rDeltaT.internalField()) << endl;
 }
 
+
 // ************************************************************************* //
diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/setInitialrDeltaT.H b/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/createRDeltaT.H
similarity index 100%
rename from applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/setInitialrDeltaT.H
rename to applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/createRDeltaT.H
diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/rhoLTSPimpleFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/rhoLTSPimpleFoam.C
index c6368171a00..ce3be57cac6 100644
--- a/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/rhoLTSPimpleFoam.C
+++ b/applications/solvers/compressible/rhoPimpleFoam/rhoLTSPimpleFoam/rhoLTSPimpleFoam.C
@@ -53,7 +53,7 @@ int main(int argc, char *argv[])
 
     pimpleControl pimple(mesh);
 
-    #include "setInitialrDeltaT.H"
+    #include "createRDeltaT.H"
     #include "createFields.H"
     #include "createMRF.H"
     #include "createFvOptions.H"
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/LTSCoalChemistryFoam.C b/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/LTSCoalChemistryFoam.C
index 5ee21e9c49a..d84a9c08d98 100644
--- a/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/LTSCoalChemistryFoam.C
+++ b/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/LTSCoalChemistryFoam.C
@@ -51,7 +51,6 @@ Description
 int main(int argc, char *argv[])
 {
     #include "setRootCase.H"
-
     #include "createTime.H"
     #include "createMesh.H"
 
@@ -59,13 +58,12 @@ int main(int argc, char *argv[])
 
     #include "readGravitationalAcceleration.H"
     #include "createFields.H"
-    #include "readTimeControls.H"
-    #include "createRDeltaT.H"
     #include "createMRF.H"
     #include "createFvOptions.H"
     #include "createClouds.H"
     #include "createRadiationModel.H"
     #include "initContinuityErrs.H"
+    #include "createRDeltaT.H"
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -73,8 +71,6 @@ int main(int argc, char *argv[])
 
     while (runTime.run())
     {
-        #include "readTimeControls.H"
-
         runTime++;
 
         Info<< "Time = " << runTime.timeName() << nl << endl;
@@ -83,10 +79,9 @@ int main(int argc, char *argv[])
         pDyn = 0.5*rho*magSqr(U);
 
         coalParcels.evolve();
-
         limestoneParcels.evolve();
 
-        #include "timeScales.H"
+        #include "setrDeltaT.H"
 
         #include "rhoEqn.H"
 
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/setrDeltaT.H b/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/setrDeltaT.H
new file mode 100644
index 00000000000..e9697c7903b
--- /dev/null
+++ b/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/setrDeltaT.H
@@ -0,0 +1,134 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+{
+    const dictionary& pimpleDict = pimple.dict();
+
+    // Maximum flow Courant number
+    scalar maxCo(readScalar(pimpleDict.lookup("maxCo")));
+
+    // Maximum time scale
+    scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
+
+    // Smoothing parameter (0-1) when smoothing iterations > 0
+    scalar rDeltaTSmoothingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
+    );
+
+    // Damping coefficient (1-0)
+    scalar rDeltaTDampingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
+    );
+
+    // Maximum change in cell temperature per iteration
+    // (relative to previous value)
+    scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
+
+
+    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
+            (
+               (coalParcels.hsTrans() + limestoneParcels.hsTrans())
+              /(mesh.V()*runTime.deltaT())
+             + combustion->Sh()()
+            )
+           /(
+               alphaTemp
+              *rho.dimensionedInternalField()
+              *thermo.Cp()().dimensionedInternalField()
+              *T.dimensionedInternalField()
+           )
+        );
+
+        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;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/timeScales.H b/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/timeScales.H
deleted file mode 100644
index a32048fc04f..00000000000
--- a/applications/solvers/lagrangian/coalChemistryFoam/LTSCoalChemistryFoam/timeScales.H
+++ /dev/null
@@ -1,114 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
-
-\*---------------------------------------------------------------------------*/
-
-Info<< "Time scales min/max:" << endl;
-
-{
-    // Cache old time scale field
-    tmp<volScalarField> trDeltaT
-    (
-        new volScalarField
-        (
-            IOobject
-            (
-                "rDeltaT0",
-                runTime.timeName(),
-                mesh,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE,
-                false
-            ),
-            rDeltaT
-        )
-    );
-    const volScalarField& rDeltaT0 = trDeltaT();
-
-
-    // Flow time scale
-    // ~~~~~~~~~~~~~~~
-    {
-        rDeltaT =
-            fvc::surfaceSum
-            (
-                mag(phi)*mesh.deltaCoeffs()/(maxCo*mesh.magSf())
-            )
-           /rho;
-
-        rDeltaT.max(1.0/maxDeltaT);
-
-        Info<< "    Flow        = "
-            << gMin(1/rDeltaT.internalField()) << ", "
-            << gMax(1/rDeltaT.internalField()) << endl;
-    }
-
-
-    // Temperature source time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    {
-        scalarField tau
-        (
-            runTime.deltaTValue()
-           *mag
-            (
-                (coalParcels.hsTrans() + limestoneParcels.hsTrans())
-                    /(mesh.V()*runTime.deltaT())
-              + combustion->Sh()()
-              - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")()
-            )
-           /rho
-        );
-
-        tau = alphaTemp*thermo.Cp()*T/(tau + ROOTVSMALL);
-
-        Info<< "    Temperature = " << min(maxDeltaT, gMin(tau)) << ", "
-            << min(maxDeltaT, gMax(tau)) << endl;
-
-        rDeltaT.internalField() = max(rDeltaT.internalField(), 1/tau);
-    }
-
-
-    // Limit rate of change of time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    // - reduce as much as required for flow, but limit source contributions
-    const dimensionedScalar deltaTRamp("deltaTRamp", dimless, 1/(1 + 0.2));
-    rDeltaT = max(rDeltaT, rDeltaT0*deltaTRamp);
-
-
-    // Limit the largest time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    rDeltaT.max(1/maxDeltaT);
-
-
-    // Spatially smooth the time scale field
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
-
-    Info<< "    Overall     = " << min(1/rDeltaT).value()
-        << ", " << max(1/rDeltaT).value() << nl << endl;
-}
-
-
-// ************************************************************************* //
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C
index 875d07d8bb9..3a178e0eaf6 100644
--- a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C
+++ b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/LTSReactingParcelFoam.C
@@ -48,21 +48,19 @@ Description
 int main(int argc, char *argv[])
 {
     #include "setRootCase.H"
-
     #include "createTime.H"
     #include "createMesh.H"
-    #include "readGravitationalAcceleration.H"
 
     pimpleControl pimple(mesh);
 
-    #include "readTimeControls.H"
+    #include "readGravitationalAcceleration.H"
     #include "createFields.H"
     #include "createMRF.H"
     #include "createFvOptions.H"
-    #include "createRDeltaT.H"
     #include "createRadiationModel.H"
     #include "createClouds.H"
     #include "initContinuityErrs.H"
+    #include "createRDeltaT.H"
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
@@ -70,22 +68,23 @@ int main(int argc, char *argv[])
 
     while (runTime.run())
     {
-        #include "readTimeControls.H"
-
         runTime++;
 
         Info<< "Time = " << runTime.timeName() << nl << endl;
 
         parcels.evolve();
 
-        #include "timeScales.H"
+        #include "setrDeltaT.H"
 
         #include "rhoEqn.H"
 
         // --- Pressure-velocity PIMPLE corrector loop
         while (pimple.loop())
         {
-            turbulence->correct();
+            if (pimple.turbCorr())
+            {
+                turbulence->correct();
+            }
 
             #include "UEqn.H"
             #include "YEqn.H"
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/readTimeControls.H b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/readTimeControls.H
deleted file mode 100644
index 73083f5fddf..00000000000
--- a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/readTimeControls.H
+++ /dev/null
@@ -1,42 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-2012 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)
-);
-
-// Maximum change in cell temperature per iteration (relative to previous value)
-scalar alphaTemp(pimple.dict().lookupOrDefault("alphaTemp", 0.05));
-
-
-// ************************************************************************* //
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/setrDeltaT.H b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/setrDeltaT.H
new file mode 100644
index 00000000000..2a3935fd912
--- /dev/null
+++ b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/setrDeltaT.H
@@ -0,0 +1,133 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
+
+\*---------------------------------------------------------------------------*/
+
+{
+    const dictionary& pimpleDict = pimple.dict();
+
+    // Maximum flow Courant number
+    scalar maxCo(readScalar(pimpleDict.lookup("maxCo")));
+
+    // Maximum time scale
+    scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
+
+    // Smoothing parameter (0-1) when smoothing iterations > 0
+    scalar rDeltaTSmoothingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
+    );
+
+    // Damping coefficient (1-0)
+    scalar rDeltaTDampingCoeff
+    (
+        pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
+    );
+
+    // Maximum change in cell temperature per iteration
+    // (relative to previous value)
+    scalar alphaTemp(pimpleDict.lookupOrDefault("alphaTemp", 0.05));
+
+
+    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
+            (
+               parcels.hsTrans()/(mesh.V()*runTime.deltaT())
+             + combustion->Sh()()
+            )
+           /(
+               alphaTemp
+              *rho.dimensionedInternalField()
+              *thermo.Cp()().dimensionedInternalField()
+              *T.dimensionedInternalField()
+           )
+        );
+
+        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;
+}
+
+
+// ************************************************************************* //
diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/timeScales.H b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/timeScales.H
deleted file mode 100644
index 50ceb3b433f..00000000000
--- a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/timeScales.H
+++ /dev/null
@@ -1,115 +0,0 @@
-/*---------------------------------------------------------------------------*\
-  =========                 |
-  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
-   \\    /   O peration     |
-    \\  /    A nd           | Copyright (C) 2011-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 time scale field
-    tmp<volScalarField> trDeltaT
-    (
-        new volScalarField
-        (
-            IOobject
-            (
-                "rDeltaT0",
-                runTime.timeName(),
-                mesh,
-                IOobject::NO_READ,
-                IOobject::NO_WRITE,
-                false
-            ),
-            rDeltaT
-        )
-    );
-    const volScalarField& rDeltaT0 = trDeltaT();
-
-
-    // Flow time scale
-    // ~~~~~~~~~~~~~~~
-    {
-        rDeltaT =
-            fvc::surfaceSum
-            (
-                mag(phi)*mesh.deltaCoeffs()/(maxCo*mesh.magSf())
-            )
-           /rho;
-
-        rDeltaT.max(1.0/maxDeltaT);
-
-        Info<< "    Flow        = "
-            << gMin(1/rDeltaT.internalField()) << ", "
-            << gMax(1/rDeltaT.internalField()) << endl;
-    }
-
-
-    // Temperature source time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-    {
-        scalarField tau
-        (
-            runTime.deltaTValue()
-           *mag
-            (
-                parcels.hsTrans()/(mesh.V()*runTime.deltaT())
-           // + fvOptions(rho, hs)
-              + combustion->Sh()()
-              - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")()
-            )
-           /rho
-        );
-
-        tau = alphaTemp*thermo.Cp()*T/(tau + ROOTVSMALL);
-
-        Info<< "    Temperature = " << min(maxDeltaT, gMin(tau)) << ", "
-            << min(maxDeltaT, gMax(tau)) << endl;
-
-        rDeltaT.internalField() = max(rDeltaT.internalField(), 1/tau);
-    }
-
-
-    // Limit rate of change of time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    // - reduce as much as required for flow, but limit source contributions
-    const dimensionedScalar deltaTRamp("deltaTRamp", dimless, 1/(1 + 0.2));
-    rDeltaT = max(rDeltaT, rDeltaT0*deltaTRamp);
-
-
-    // Limit the largest time scale
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    rDeltaT.max(1/maxDeltaT);
-
-
-    // Spatially smooth the time scale field
-    // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-    fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
-
-    Info<< "    Overall     = " << min(1/rDeltaT).value()
-        << ", " << max(1/rDeltaT).value() << nl << endl;
-}
-
-
-// ************************************************************************* //
diff --git a/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C b/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C
index 37183abdcc6..69867e43167 100644
--- a/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C
+++ b/applications/solvers/multiphase/interFoam/LTSInterFoam/LTSInterFoam.C
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
     #include "createFvOptions.H"
     #include "correctPhi.H"
     #include "CourantNo.H"
-    #include "setInitialrDeltaT.H"
+    #include "createRDeltaT.H"
 
     // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
 
diff --git a/applications/solvers/multiphase/interFoam/LTSInterFoam/setInitialrDeltaT.H b/applications/solvers/multiphase/interFoam/LTSInterFoam/createRDeltaT.H
similarity index 100%
rename from applications/solvers/multiphase/interFoam/LTSInterFoam/setInitialrDeltaT.H
rename to applications/solvers/multiphase/interFoam/LTSInterFoam/createRDeltaT.H
diff --git a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/controlDict b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/controlDict
index 42ba5153d47..350b043ca5c 100644
--- a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/controlDict
+++ b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/controlDict
@@ -17,7 +17,7 @@ FoamFile
 
 application     LTSReactingParcelFoam;
 
-startFoam       latestTime;
+startFrom       latestTime;
 
 startTime       0;
 
diff --git a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/fvSolution b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/fvSolution
index b9b9e87728c..e3b19c8abe8 100644
--- a/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/fvSolution
+++ b/tutorials/lagrangian/LTSReactingParcelFoam/verticalChannel/system/fvSolution
@@ -70,7 +70,7 @@ PIMPLE
     rhoMin          0.1;
     rhoMax          1.5;
 
-    maxCo           5;
+    maxCo           2.5;
     rDeltaTSmoothingCoeff 1;
     alphaTemp       1;
     maxDeltaT       1;
diff --git a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/system/controlDict b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/system/controlDict
index 353d99f42f4..e3cab720a50 100644
--- a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/system/controlDict
+++ b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/system/controlDict
@@ -17,7 +17,7 @@ FoamFile
 
 application     reactingParcelFoam;
 
-startFoam       startTime;
+startFrom       startTime;
 
 startTime       0;
 
diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict
index 52d917a65f2..0db2ed9c0c9 100644
--- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict
+++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/system/controlDict
@@ -17,7 +17,7 @@ FoamFile
 
 application     reactingParcelFoam;
 
-startFoam       latestTime;
+startFrom       latestTime;
 
 startTime       0;
 
diff --git a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict
index 273cb3b23dc..899d68f0a91 100644
--- a/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict
+++ b/tutorials/lagrangian/simpleReactingParcelFoam/verticalChannel/system/controlDict
@@ -17,7 +17,7 @@ FoamFile
 
 application     simpleReactingParcelFoam;
 
-startFoam       latestTime;
+startFrom       latestTime;
 
 startTime       0;
 
-- 
GitLab