diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C index 0ae37ba0b7d17da4ee99f325c447cc0a637c2dce..261b7ea535e870b267b69c1d43919465d4e33281 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -103,7 +103,16 @@ bool Foam::setTimeStepFunctionObject::adjustTimeStep() // Wanted timestep scalar newDeltaT = timeStepPtr_().value(time_.timeOutputValue()); - const_cast<Time&>(time()).setDeltaT(newDeltaT, false); + static label index = -1; + + if (time().timeIndex() != index) + { + // Store current time so we don't get infinite recursion (since + // setDeltaT calls adjustTimeStep() again) + index = time().timeIndex(); + // Set time, allow deltaT to be adjusted for writeInterval purposes + const_cast<Time&>(time()).setDeltaT(newDeltaT, true); + } return true; } diff --git a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H index f345ea161b7dfe507aceaffb8128b8851f46d552..0d46f98d9e4d08ac8a6a247d80e4c50c38266662 100644 --- a/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/setTimeStep/setTimeStepFunctionObject.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2013-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,10 @@ Description functionObjects. Supports 'enabled' flag but none of the other options 'timeStart', 'timeEnd', 'outputControl' etc. + Note that any 'writeControl adjustableRunTime' will still be in + operation and will limit the wanted time step to account for the + - write interval and - timestep adjustment speed (time step cannot + change too quickly). Example of function object specification to manipulate the time step: \verbatim