mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
Time: Added running method to check running state without side effects
chtMultiRegionSimpleFoam needs to check whether or not the simulation is at the end. To facilitate this, a Time::running method has been added. The Time::run method was being used for this purpose, but this lead to function objects being executed multiple times. This resolves bug report https://bugs.openfoam.org/view.php?id=2804
This commit is contained in:
@ -53,12 +53,12 @@ if (resControlUsed)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!runTime.run())
|
if (!runTime.running())
|
||||||
{
|
{
|
||||||
Info<< "\nRegions not converged after " << runTime.timeName()
|
Info<< "\nRegions not converged after " << runTime.timeName()
|
||||||
<< " iterations" << endl;
|
<< " iterations" << endl;
|
||||||
}
|
}
|
||||||
else if (runTime.run() && resControlUsed && allRegionsConverged)
|
else if (runTime.running() && resControlUsed && allRegionsConverged)
|
||||||
{
|
{
|
||||||
Info<< "\nRegions converged after " << runTime.timeName()
|
Info<< "\nRegions converged after " << runTime.timeName()
|
||||||
<< " iterations" << endl;
|
<< " iterations" << endl;
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -778,9 +778,15 @@ Foam::dimensionedScalar Foam::Time::endTime() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::Time::running() const
|
||||||
|
{
|
||||||
|
return value() < (endTime_ - 0.5*deltaT_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::Time::run() const
|
bool Foam::Time::run() const
|
||||||
{
|
{
|
||||||
bool running = value() < (endTime_ - 0.5*deltaT_);
|
const bool running = this->running();
|
||||||
|
|
||||||
if (!subCycling_)
|
if (!subCycling_)
|
||||||
{
|
{
|
||||||
@ -806,21 +812,18 @@ bool Foam::Time::run() const
|
|||||||
functionObjects_.execute();
|
functionObjects_.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the "running" status following the
|
|
||||||
// possible side-effects from functionObjects
|
|
||||||
running = value() < (endTime_ - 0.5*deltaT_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return running;
|
// Re-evaluate if running in case a function object has changed things
|
||||||
|
return this->running();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::Time::loop()
|
bool Foam::Time::loop()
|
||||||
{
|
{
|
||||||
bool running = run();
|
const bool running = this->running();
|
||||||
|
|
||||||
if (running)
|
if (run())
|
||||||
{
|
{
|
||||||
operator++();
|
operator++();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -443,6 +443,9 @@ public:
|
|||||||
|
|
||||||
// Check
|
// Check
|
||||||
|
|
||||||
|
//- Return true if run should continue without any side effects
|
||||||
|
virtual bool running() const;
|
||||||
|
|
||||||
//- Return true if run should continue,
|
//- Return true if run should continue,
|
||||||
// also invokes the functionObjectList::end() method
|
// also invokes the functionObjectList::end() method
|
||||||
// when the time goes out of range
|
// when the time goes out of range
|
||||||
|
|||||||
Reference in New Issue
Block a user