View Issue Details

IDProjectCategoryView StatusLast Update
0004225OpenFOAMBugpublic2025-03-13 05:19
Reportercgoessni Assigned To 
PrioritylowSeverityminorReproducibilityalways
Status newResolutionopen 
Product Versiondev 
Summary0004225: Simulation stops before endTime even when writeControl is adjustableRunTime and adjustTimeStep is true
DescriptionUnder certain conditions, simulation stops before endTime is reached even when writeControl is adjustableRunTime and adjustTimeStep is true.
Steps To ReproduceIn kivaTest, run:

foamDictionary -entry endTime -set "-170.03" system/controlDict
foamDictionary -entry deltaT -set 0.01 system/controlDict
foamDictionary -entry writeControl -set adjustableRunTime system/controlDict
foamDictionary -entry adjustTimeStep -set yes system/controlDict
foamDictionary -entry maxCo -set 1 system/controlDict
foamDictionary -entry maxDeltaT -set 0.05 system/controlDict
./Allrun

Expected behaviour: simulation runs until -170.03 (inclusive)
Observed behaviour: simulation runs until -170.05 (see log file, or files in postProcessing folder)
Additional InformationIn Time.C, we have the following condition:

bool Foam::Time::running() const
{
    return value() < (endTime_ - 0.5*deltaT_);
}

which - in userTime - is, for the above case:

value() = -170.05
endTime_ = -170.03
deltaT_ = 0.05

which leads to
return -170.05 < (-170.03 - 0.05/2 = -170.075)

which yields false although there would still be one time step required with deltaT = 0.02. This leads to pimple.run(runTime) being false in the foamRun main time loop.
TagsNo tags attached.

Activities

peksa

2025-03-12 21:32

reporter   ~0013545

In general I'd recommend avoiding negative values even though it is possible in userTime. You can get burned by some edge cases in function objects and third party libraries (if ever used). I'd prefer to execute mapping to negative CA values as a post-processing step if required.

cgoessni

2025-03-13 05:12

reporter   ~0013546

This is independent from the negative times, this happens with all of our engine cases which start and end with a positive CA / time.

cgoessni

2025-03-13 05:19

reporter   ~0013547

This is now a kivaTest with positive start and end time. It should stop at 550.02 CAD, but stops pre-maturely at 550 CAD.

In my initial calculation, I have a small typo, this should read as:
 return -170.05 < (-170.03 - 0.05/2 = -170.055)

which would still be false, though.
kivaTestPositive.tgz (5,863 bytes)

Issue History

Date Modified Username Field Change
2025-03-11 13:55 cgoessni New Issue
2025-03-12 21:32 peksa Note Added: 0013545
2025-03-13 05:12 cgoessni Note Added: 0013546
2025-03-13 05:19 cgoessni Note Added: 0013547
2025-03-13 05:19 cgoessni File Added: kivaTestPositive.tgz