View Issue Details

IDProjectCategoryView StatusLast Update
0004157OpenFOAMContributionpublic2024-09-30 22:03
Reportercgoessni Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0004157: functionObject startTime with adjustableRunTime causes deltaT=1e-16 for long-running simulations
DescriptionFor long-running simulations with adjustableRunTime and adjustTimeStep true, but constant time step due to maxCo not being used, using startTime in a functionObject timeControl causes very small time steps due to round-off errors in floating point treatment (and potentially crashes).

This bug is related to https://bugs.openfoam.org/view.php?id=4134, and the proposed and implemented fix there seems to not be enough to cover all cases.
Steps To ReproduceRun the attached test case. Observations:

1.) 10800/uniform/time shows

...
value 10799.9999999999982;
...

as time value

2.) This seems to be causing timeToNextAction() returned from the timeControlFunctionObject to be very small, causing adjustDeltaT() in Time.C to set the time step to 1e-16 due to nSteps being zero.
Additional InformationA diff for Time.C which solves the problem for our cases is attached. It introduces a check if nSteps (converted to a label) is not zero before adjusting deltaT.
TagsNo tags attached.

Activities

cgoessni

2024-09-30 09:51

reporter  

adjustDeltaT.diff.txt (599 bytes)   
diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C
index b7038b6..8d1e799 100644
--- a/src/OpenFOAM/db/Time/Time.C
+++ b/src/OpenFOAM/db/Time/Time.C
@@ -95,8 +95,8 @@ void Foam::Time::adjustDeltaT()
 
     const scalar nSteps = timeToNextAction/deltaT_;
 
-    // Ensure nStepsToNextWrite does not overflow
-    if (nSteps < labelMax)
+    // Ensure nStepsToNextWrite does not overflow and is not zero
+    if (nSteps < labelMax && label(nSteps) != 0)
     {
         // Allow the time-step to increase by up to 1%
         // to accommodate the next write time before splitting
adjustDeltaT.diff.txt (599 bytes)   

henry

2024-09-30 22:03

manager   ~0013419

Resolved by commit f69a419a400adb667ef5639966a0058f7075d136

Issue History

Date Modified Username Field Change
2024-09-30 09:51 cgoessni New Issue
2024-09-30 09:51 cgoessni File Added: testCaseTimeControl.tgz
2024-09-30 09:51 cgoessni File Added: adjustDeltaT.diff.txt
2024-09-30 22:03 henry Assigned To => henry
2024-09-30 22:03 henry Status new => resolved
2024-09-30 22:03 henry Resolution open => fixed
2024-09-30 22:03 henry Fixed in Version => dev
2024-09-30 22:03 henry Note Added: 0013419