functionObject: Fixed bugs in function object time-step adjustment
The logic governing function objects' ability to change the time-step has been modified so that it is compatible with the time-step adjustment done in the Time class. The behaviour has been split into a method which sets the step directly, and another which moidifies the time until the next write operation (i.e., the time that the solver "aims" for). This fixes an issue where the adjustments in Time and the function objects interfere and cause the time step to decrease exponentially down to machine precision. It also means that the set-time-step function object now does not break the adjustable run-time setting. This resolves bug report https://bugs.openfoam.org/view.php?id=2820
This commit is contained in:
@ -565,9 +565,46 @@ bool Foam::functionObjectList::end()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::adjustTimeStep()
|
||||
bool Foam::functionObjectList::setTimeStep()
|
||||
{
|
||||
bool ok = true;
|
||||
bool set = true;
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (!updated_)
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
wordList names;
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
if (operator[](objectI).setTimeStep())
|
||||
{
|
||||
names.append(operator[](objectI).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;
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
@ -578,11 +615,11 @@ bool Foam::functionObjectList::adjustTimeStep()
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
ok = operator[](objectI).adjustTimeStep() && ok;
|
||||
result = min(result, operator[](objectI).timeToNextWrite());
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user