functionObjects/setTimeStep: Compatibility with 'adjustableRunTime'

setTimeStep is now compatible with a 'writeControl adjustableRunTime;'
setting in the systemControlDict. If 'adjustableRunTime' is selected
then the time-step values set by this function object will not be
exactly as specified, but write intervals will be matched exactly.

All function object time adjustment is now done during the execute
methods, so the specific setTimeStep hooks have been removed.
This commit is contained in:
Will Bainbridge
2021-01-22 19:18:51 +00:00
parent ac56655601
commit 2caad45a9b
7 changed files with 17 additions and 65 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -970,8 +970,6 @@ void Foam::Time::setDeltaT(const scalar deltaT)
{
setDeltaTNoAdjust(deltaT);
functionObjects_.setTimeStep();
if (writeControl_ == writeControl::adjustableRunTime)
{
adjustDeltaT();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -150,12 +150,6 @@ bool Foam::functionObject::end()
}
bool Foam::functionObject::setTimeStep()
{
return false;
}
Foam::scalar Foam::functionObject::timeToNextWrite()
{
return vGreat;

View File

@ -230,11 +230,6 @@ public:
//- Called when Time::run() determines that the time-loop exits.
virtual bool end();
//- Called by Time::setDeltaT(). Allows the functionObject to override
// the time-step value.
// Returns whether or not the value was overridden.
virtual bool setTimeStep();
//- Called by Time::adjustTimeStep(). Allows the functionObject to
// insert a write time earlier than that already in use by the run
// time. Returns the write time, or vGreat.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -628,43 +628,6 @@ bool Foam::functionObjectList::end()
}
bool Foam::functionObjectList::setTimeStep()
{
bool set = true;
if (execution_)
{
if (!updated_)
{
read();
}
wordList names;
forAll(*this, oi)
{
if (operator[](oi).setTimeStep())
{
names.append(operator[](oi).name());
set = true;
}
}
if (names.size() > 1)
{
WarningInFunction << "Multiple function objects (" << names[0];
for (label i = 1; i < names.size(); ++ i)
{
WarningInFunction << ", " << names[i];
}
WarningInFunction << ") are setting the time step." << endl;
}
}
return set;
}
Foam::scalar Foam::functionObjectList::timeToNextWrite()
{
scalar result = vGreat;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -272,9 +272,6 @@ public:
//- Called when Time::run() determines that the time-loop exits
bool end();
//- Override the time-step value
bool setTimeStep();
//- Return the time to the next write
scalar timeToNextWrite();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -86,7 +86,7 @@ bool Foam::functionObjects::setTimeStepFunctionObject::execute()
if (!adjustTimeStep)
{
const_cast<Time&>(time_).setDeltaTNoAdjust
const_cast<Time&>(time_).setDeltaT
(
timeStepPtr_().value(time_.timeOutputValue())
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2013-2020 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2021 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,12 +25,17 @@ Class
Foam::functionObjects::setTimeStepFunctionObject
Description
Updates the writeInterval as a Function1 of time.
Updates the time step as a Function1 of time.
Can only be used with solvers with adjustTimeStep control
(e.g. pimpleFoam). Makes no attempt to cooperate with other timeStep
'controllers' (maxCo, other functionObjects). Supports 'enabled' flag but
none of the other ones 'startTime', 'endTime', 'writeControl' etc.
Makes no attempt to cooperate with other timeStep controllers (i.e., solver
courant number control or other functionObjects). In general any value set
here will be overwritten by solver time-step adjustment if enabled, so for
this to work 'adjustTime' should be switched off. This is compatible with
'adjustableWriteTime', in which case the time-step values set will not be
exactly as specified, but write intervals will be matched exactly.
This function supports the 'enabled' flag but none of the other run
controls; 'startTime', 'endTime', 'writeControl', etc...
SourceFiles
setTimeStepFunctionObject.C