-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re arrange read time according to adjustable dt #298
Conversation
Here is the respective OpenFOAM code: void Foam::Time::adjustDeltaT()
{
bool adjustTime = false;
scalar timeToNextWrite = VGREAT;
if (writeControl_ == wcAdjustableRunTime)
{
adjustTime = true;
timeToNextWrite = max
(
0.0,
(writeTimeIndex_ + 1)*writeInterval_ - (value() - startTime_)
);
}
if (adjustTime)
{
scalar nSteps = timeToNextWrite/deltaT_;
// For tiny deltaT the label can overflow!
if (nSteps < scalar(labelMax))
{
// nSteps can be < 1 so make sure at least 1
label nStepsToNextWrite = max(1, round(nSteps));
scalar newDeltaT = timeToNextWrite/nStepsToNextWrite;
// Control the increase of the time step to within a factor of 2
// and the decrease within a factor of 5.
if (newDeltaT >= deltaT_)
{
deltaT_ = min(newDeltaT, 2.0*deltaT_);
}
else
{
deltaT_ = max(newDeltaT, 0.2*deltaT_);
}
}
}
functionObjects_.adjustTimeStep();
}
if (adjustTime)
{
scalar nSteps = timeToNextWrite/deltaT_; I think that you could test the behavior by specifying a fixed preCICE does something similar, so the two mechanisms compete. I don't find any particular documentation (code/thesis) regarding I am struggling a bit to evaluate all paths, but I think the changes make sense, especially since now the Questions: Are you sure that the How can we test that the changes still give the same (or more correct) results? What have you checked and what is still open? Other than these questions, I think that your contribution is on the right rails. |
Main reason why the |
So, status: Looks good, but waiting for #285 and #297 to be merged (and then rebase this branch) and for precice/precice#1751 to be resolved in the library. We will potentially need to document any restrictions regarding |
Merged all dependencies into Next step: waiting for precice/precice#1751 to be resolved in the library. We will potentially need to document any restrictions regarding |
Update: I triggered precice/precice#1890 while testing the adapter from develop. However, even when using this branch, I run into the same issue when subcycling. We should wait for that to be fixed. See also precice/tutorials#406, which uses subcycling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All known related issues seem to be fixed, and we now have a case with subcycling that works: precice/tutorials#406
This looks good to go! 🚀 👌
Only the last commit is relevant
Since read data is now affiliated to a time stamp, we need to ensure that the time stamp we read data is consistent with our solver time-step size. However, the solver time-step size changes in different places, depending on the configuration in the
controlDict
.execute
routine of the functionObject. We have the orderadjustTimeStep
routine of the functionObject, which is triggered in the beginning of each time-step. This results in the order:The described data reading is consistent with a backward Euler scheme (or just
ddt Euler
in OpenFOAM terminology) and not with all the time-integration schemes OpenFOAM offers.This PR ensures the readData logic according to the described scenarios.
The only thing (feature-wise), which still does not work with the current workflow is the
writeControl adjustable;
option and only the optionwriteControl runTime;
works as expected. This option only affects the generation of result files, though. However, I think this was already the case before we introduced the changes here, correct @MakisH ? I'm still a bit confused, where and how the first option modifies the time-step size (triggered actually precice/precice#1751 ), but I guess we cannot do a whole lot about it.DB driven development
TODO list:
docs/
changelog-entries/
(create directory if missing)