timeControl: Moved timeToNextWrite functionality from timeControlFunctionObject
to simplify the interface and make it more extensible
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -178,7 +178,7 @@ bool Foam::timeControl::execute()
|
||||
case timeControls::runTime:
|
||||
case timeControls::adjustableRunTime:
|
||||
{
|
||||
label executionIndex = label
|
||||
const label executionIndex = label
|
||||
(
|
||||
(
|
||||
(time_.value() - time_.beginTime().value())
|
||||
@ -197,7 +197,7 @@ bool Foam::timeControl::execute()
|
||||
|
||||
case timeControls::cpuTime:
|
||||
{
|
||||
label executionIndex = label
|
||||
const label executionIndex = label
|
||||
(
|
||||
returnReduce(time_.elapsedCpuTime(), maxOp<double>())
|
||||
/interval_
|
||||
@ -212,7 +212,7 @@ bool Foam::timeControl::execute()
|
||||
|
||||
case timeControls::clockTime:
|
||||
{
|
||||
label executionIndex = label
|
||||
const label executionIndex = label
|
||||
(
|
||||
returnReduce(label(time_.elapsedClockTime()), maxOp<label>())
|
||||
/interval_
|
||||
@ -244,4 +244,46 @@ bool Foam::timeControl::execute()
|
||||
}
|
||||
|
||||
|
||||
Foam::scalar Foam::timeControl::timeToNextWrite()
|
||||
{
|
||||
switch (timeControl_)
|
||||
{
|
||||
case timeControls::timeStep:
|
||||
case timeControls::writeTime:
|
||||
case timeControls::outputTime:
|
||||
case timeControls::runTime:
|
||||
case timeControls::cpuTime:
|
||||
case timeControls::clockTime:
|
||||
case timeControls::none:
|
||||
{
|
||||
return vGreat;
|
||||
break;
|
||||
}
|
||||
|
||||
case timeControls::adjustableRunTime:
|
||||
{
|
||||
return
|
||||
max
|
||||
(
|
||||
0.0,
|
||||
(executionIndex_ + 1)*interval_
|
||||
- (time_.value() - time_.beginTime().value())
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Undefined output control: "
|
||||
<< timeControlNames_[timeControl_] << nl
|
||||
<< abort(FatalError);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return vGreat;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -123,15 +123,12 @@ public:
|
||||
//- Flag to indicate whether to execute
|
||||
bool execute();
|
||||
|
||||
//- Return the time to the next write
|
||||
scalar timeToNextWrite();
|
||||
|
||||
//- Return control
|
||||
inline timeControls control() const;
|
||||
|
||||
//- Return interval
|
||||
inline scalar interval() const;
|
||||
|
||||
//- Return the index of the previous execution
|
||||
inline label executionIndex() const;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
|
||||
@ -159,26 +159,7 @@ bool Foam::functionObjects::timeControl::end()
|
||||
|
||||
Foam::scalar Foam::functionObjects::timeControl::timeToNextWrite()
|
||||
{
|
||||
if
|
||||
(
|
||||
active()
|
||||
&& writeControl_.control() ==
|
||||
Foam::timeControl::timeControls::adjustableRunTime
|
||||
)
|
||||
{
|
||||
const label writeTimeIndex = writeControl_.executionIndex();
|
||||
const scalar writeInterval = writeControl_.interval();
|
||||
|
||||
return
|
||||
max
|
||||
(
|
||||
0.0,
|
||||
(writeTimeIndex + 1)*writeInterval
|
||||
- (time_.value() - time_.beginTime().value())
|
||||
);
|
||||
}
|
||||
|
||||
return vGreat;
|
||||
return writeControl_.timeToNextWrite();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2016-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2016-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -37,16 +37,4 @@ inline Foam::timeControl::timeControls Foam::timeControl::control() const
|
||||
}
|
||||
|
||||
|
||||
inline Foam::scalar Foam::timeControl::interval() const
|
||||
{
|
||||
return interval_;
|
||||
}
|
||||
|
||||
|
||||
inline Foam::label Foam::timeControl::executionIndex() const
|
||||
{
|
||||
return executionIndex_;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
Reference in New Issue
Block a user