fluidSolvers: Stabilise rDeltaT calculation

When the flow is stationary (e.g., at the beginning of a run) the
rDeltaT calculation now requires a maxDeltaT setting in the PIMPLE
sub-section of the fvSolution dictionary. This prevents floating point
errors associated with rDeltaT approaching zero.
This commit is contained in:
Will Bainbridge
2023-07-27 11:42:51 +01:00
parent 9cba18a073
commit 2f579ca041
6 changed files with 91 additions and 48 deletions

View File

@ -42,20 +42,25 @@ void Foam::solvers::VoFSolver::setRDeltaT()
const volScalarField rDeltaT0("rDeltaT0", rDeltaT);
// Set the reciprocal time-step from the local Courant number
// and maximum and minimum time-steps
rDeltaT.ref() = fvc::surfaceSum(mag(phi))()()/((2*maxCo)*mesh.V());
if (pimpleDict.found("maxDeltaT"))
// Clip to user-defined maximum and minimum time-steps
scalar minRDeltaT = gMin(rDeltaT.primitiveField());
if (pimpleDict.found("maxDeltaT") || minRDeltaT < rootVSmall)
{
rDeltaT.max(1/pimpleDict.lookup<scalar>("maxDeltaT"));
const scalar clipRDeltaT = 1/pimpleDict.lookup<scalar>("maxDeltaT");
rDeltaT.max(clipRDeltaT);
minRDeltaT = max(minRDeltaT, clipRDeltaT);
}
if (pimpleDict.found("minDeltaT"))
{
rDeltaT.min(1/pimpleDict.lookup<scalar>("minDeltaT"));
const scalar clipRDeltaT = 1/pimpleDict.lookup<scalar>("minDeltaT");
rDeltaT.min(clipRDeltaT);
minRDeltaT = min(minRDeltaT, clipRDeltaT);
}
Info<< "Flow time scale min/max = "
<< gMin(1/rDeltaT.primitiveField())
<< ", " << gMax(1/rDeltaT.primitiveField()) << endl;
<< gMin(1/rDeltaT.primitiveField()) << ", " << 1/minRDeltaT << endl;
setInterfaceRDeltaT(rDeltaT);