Commit 82932279 authored by Henry Weller's avatar Henry Weller
Browse files

Rationalized the LTS solvers

parent 03adb37a
......@@ -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();
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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));
// ************************************************************************* //
......@@ -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;
}
// ************************************************************************* //
......@@ -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"
......
......@@ -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"
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -23,92 +23,111 @@ License
\*---------------------------------------------------------------------------*/
Info<< "Time scales min/max:" << endl;
{
const dictionary& pimpleDict = pimple.dict();
// Maximum flow Courant number
scalar maxCo(readScalar(pimpleDict.lookup("maxCo")));
{
// Cache old time scale field
tmp<volScalarField> trDeltaT
// Maximum time scale
scalar maxDeltaT(pimpleDict.lookupOrDefault<scalar>("maxDeltaT", GREAT));
// Smoothing parameter (0-1) when smoothing iterations > 0
scalar rDeltaTSmoothingCoeff
(
new volScalarField
(
IOobject
(
"rDeltaT0",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
rDeltaT
)
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
const volScalarField& rDeltaT0 = trDeltaT();
// 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 =
fvc::surfaceSum
(
mag(phi)*mesh.deltaCoeffs()/(maxCo*mesh.magSf())
)
/rho;
rDeltaT.dimensionedInternalField() =
(
fvc::surfaceSum(mag(phi))().dimensionedInternalField()
/((2*maxCo)*mesh.V()*rho.dimensionedInternalField())
);
rDeltaT.max(1.0/maxDeltaT);
// Limit the largest time scale
rDeltaT.max(1/maxDeltaT);
Info<< " Flow = "
<< gMin(1/rDeltaT.internalField()) << ", "
<< gMax(1/rDeltaT.internalField()) << endl;
}
// Temperature source time scale
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Reaction source time scale
if (alphaTemp < 1.0)
{
scalarField tau
volScalarField::DimensionedInternalField rDeltaTT
(
runTime.deltaTValue()
*mag
mag
(
parcels.hsTrans()/(mesh.V()*runTime.deltaT())
// + fvOptions(rho, hs)
+ combustion->Sh()()
- fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")()
(coalParcels.hsTrans() + limestoneParcels.hsTrans())
/(mesh.V()*runTime.deltaT())
+ combustion->Sh()()
)
/rho
/(
alphaTemp
*rho.dimensionedInternalField()
*thermo.Cp()().dimensionedInternalField()
*T.dimensionedInternalField()
)
);
tau = alphaTemp*thermo.Cp()*T/(tau + ROOTVSMALL);
Info<< " Temperature = "
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
Info<< " Temperature = " << min(maxDeltaT, gMin(tau)) << ", "
<< min(maxDeltaT, gMax(tau)) << endl;
rDeltaT.internalField() = max(rDeltaT.internalField(), 1/tau);
rDeltaT.dimensionedInternalField() = max
(
rDeltaT.dimensionedInternalField(),
rDeltaTT
);
}
// 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);
// Update tho boundary values of the reciprocal time-step
rDeltaT.correctBoundaryConditions();
// Spatially smooth the time scale field
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fvc::smooth(rDeltaT, rDeltaTSmoothingCoeff);
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 = " << min(1/rDeltaT).value()
<< ", " << max(1/rDeltaT).value() << nl << endl;
Info<< " Overall = "
<< gMin(1/rDeltaT.internalField())
<< ", " << gMax(1/rDeltaT.internalField()) << endl;
}
......
......@@ -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"
......
/*---------------------------------------------------------------------------*\
========= |
\\ / 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));
// ************************************************************************* //
......@@ -23,91 +23,110 @@ License
\*---------------------------------------------------------------------------*/
Info<< "Time scales min/max:" << endl;
{
// Cache old time scale field
tmp<volScalarField> trDeltaT
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
(
new volScalarField
(
IOobject
(
"rDeltaT0",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
rDeltaT
)
pimpleDict.lookupOrDefault<scalar>("rDeltaTSmoothingCoeff", 0.1)
);
// Damping coefficient (1-0)
scalar rDeltaTDampingCoeff
(
pimpleDict.lookupOrDefault<scalar>("rDeltaTDampingCoeff", 0.2)
);
const volScalarField& rDeltaT0 = trDeltaT();
// 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 =
fvc::surfaceSum
(
mag(phi)*mesh.deltaCoeffs()/(maxCo*mesh.magSf())
)
/rho;
rDeltaT.dimensionedInternalField() =
(
fvc::surfaceSum(mag(phi))().dimensionedInternalField()
/((2*maxCo)*mesh.V()*rho.dimensionedInternalField())
);
rDeltaT.max(1.0/maxDeltaT);
// Limit the largest time scale
rDeltaT.max(1/maxDeltaT);
Info<< " Flow = "
<< gMin(1/rDeltaT.internalField()) << ", "
<< gMax(1/rDeltaT.internalField()) << endl;
}
// Temperature source time scale
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Reaction source time scale
if (alphaTemp < 1.0)
{
scalarField tau
volScalarField::DimensionedInternalField rDeltaTT
(
runTime.deltaTValue()
*mag
mag
(
(coalParcels.hsTrans() + limestoneParcels.hsTrans())
/(mesh.V()*runTime.deltaT())
+ combustion->Sh()()
- fvc::div(phi, 0.5*magSqr(U), "div(phi,K)")()
parcels.hsTrans()/(mesh.V()*runTime.deltaT())
+ combustion->Sh()()
)
/rho
/(
alphaTemp
*rho.dimensionedInternalField()
*thermo.Cp()().dimensionedInternalField()
*T.dimensionedInternalField()
)
);
tau = alphaTemp*thermo.Cp()*T/(tau + ROOTVSMALL);
Info<< " Temperature = "
<< gMin(1/(rDeltaTT.field() + VSMALL)) << ", "
<< gMax(1/(rDeltaTT.field() + VSMALL)) << endl;
Info<< " Temperature = " << min(maxDeltaT, gMin(tau)) << ", "
<< min(maxDeltaT, gMax(tau)) << endl;
rDeltaT.internalField() = max(rDeltaT.internalField(), 1/tau