View Issue Details

IDProjectCategoryView StatusLast Update
0003669OpenFOAMBugpublic2021-04-30 12:23
Reportertniemi Assigned Tohenry  
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0003669: Regression in Time.C, first write time is wrong if not starting from 0 and not a restart

We stumbled to odd behavior of sometimes not getting time directories as output if the starting folder was not 0 and it was not a normal restart, ie. no uniform/time file present which would contain the original beginTime.

Managed to bisect it to this commit:

I think the problem is that beginTime_ is first initialized to 0 and setWriteInterval is called in readDict using this beginTime. Later on beginTime is set properly as
beginTime_ = timeDict.lookupOrDefault("beginTime", startTime_); to be equal to non-zero startTime. But after this restart() is not true, so the writeTimeIndex_ is not updated and the invalid value set in readDict remains. Thus the first write will be "value()-0", which can be quite a big value if value is large.

Steps To ReproduceTake cavity tutorial, change:
startTime 0->2 (and rename the 0-folder to 2)
endTime 0.5->5
writeControl timeStep->runTime-
writeInterval 20->0.1

First write will be 4.1, not 2.1 as it should
TagsNo tags attached.



2021-04-29 15:48

manager   ~0012009

Shall I revert the commit?


2021-04-29 16:58

reporter   ~0012010

No, I think the commit is mostly fine. It is just that the logic regarding the very first writeTimeIndex_ calculation is slightly changed which breaks this one type of startup. I can perhaps provide a patch, but it is too late for today.

It should be enough to just always update writeTimeIndex_ with beginTime=startTime if no other beginTime was found. I wonder is for instance the check for restart() in line 272 necessary? If the check would be removed, I think it would fix this issue. But not sure if it would break something else.


2021-04-30 12:23

manager   ~0012011

Resolved by commit 6d7703bfa3467767faa3202a2d7b07cfd6bffde4

Issue History

Date Modified Username Field Change
2021-04-29 15:33 tniemi New Issue
2021-04-29 15:48 henry Note Added: 0012009
2021-04-29 16:58 tniemi Note Added: 0012010
2021-04-30 12:23 henry Assigned To => henry
2021-04-30 12:23 henry Status new => resolved
2021-04-30 12:23 henry Resolution open => fixed
2021-04-30 12:23 henry Fixed in Version => dev
2021-04-30 12:23 henry Note Added: 0012011