View Issue Details

IDProjectCategoryView StatusLast Update
0004134OpenFOAMBugpublic2024-08-14 09:38
Reportercgoessni Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Versiondev 
Fixed in Versiondev 
Summary0004134: functionObject startTime or endTime cause crashes when writeControl is adjustableTimeStep and adjustTimeStep is True
DescriptionWhen setting up system/controlDict to allow for an adjusted time step, startTime and endTime of a functionObject with write/executeControl = adjustableRunTime can cause either a hang or a crash due to deltaT set to zero.
Steps To ReproduceRun the following in tutorials/incompressibleFluid/pitzDaily:

foamDictionary -entry startFrom -set startTime system/controlDict # to ensure to start from 0 in sub-seqent calls to foamRun
foamDictionary -entry pAvg -set '{ type volFieldValue; libs ("libfieldFunctionObjects.so"); writeFields no; operation volAverage; fields (p); select all; writeControl adjustableRunTime; writeInterval 0.0001; startTime 0.01; }' system/functions

foamRun would subseqently crash due to deltaT = 0:

Courant Number mean: 0.426143 max: 7.89861
deltaT = 0
Time = 0.0001s

#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in "/lib64/libc.so.6"
#3 Foam::fv::EulerDdtScheme<Foam::Vector<double> >::fvmDdt(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#4 Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::ddt<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5 Foam::solvers::incompressibleFluid::momentumPredictor() at ??:?
#6 ? at ??:?
#7 __libc_start_main in "/lib64/libc.so.6"
#8 ? at ??:?
Floating point exception (core dumped)

The same happens when setting endTime:
foamDictionary -entry pAvg -set '{ type volFieldValue; libs ("libfieldFunctionObjects.so"); writeFields no; operation volAverage; fields (p); select all; writeControl adjustableRunTime; writeInterval 0.0001; endTime 0.01; }' system/functions

  Courant Number mean: 0.233311 max: 1.13311
deltaT = 0
Time = 0.0101s

#0 Foam::error::printStack(Foam::Ostream&) at ??:?
#1 Foam::sigFpe::sigHandler(int) at ??:?
#2 ? in "/lib64/libc.so.6"
#3 Foam::fv::EulerDdtScheme<Foam::Vector<double> >::fvmDdt(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#4 Foam::tmp<Foam::fvMatrix<Foam::Vector<double> > > Foam::fvm::ddt<Foam::Vector<double> >(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&) at ??:?
#5 Foam::solvers::incompressibleFluid::momentumPredictor() at ??:?
#6 ? at ??:?
#7 __libc_start_main in "/lib64/libc.so.6"
#8 ? at ??:?
Floating point exception (core dumped)


Additionally, maxCourant=5 is never reached in the latter case since timeControlFunctionObject would unconditionally return timeToNextAction() according to the user-specified interval, even when the functionObject is inactive.
Additional InformationThe following patch solves the issue for our cases:

diff --git a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C
index 6d86f3c..39ace56 100644
--- a/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C
+++ b/src/OpenFOAM/db/functionObjects/timeControl/timeControlFunctionObject.C
@@ -145,11 +145,22 @@ bool Foam::functionObjects::timeControl::end()

 Foam::scalar Foam::functionObjects::timeControl::timeToNextAction()
 {
- return min
- (
- executeControl_.timeToNextAction(),
- writeControl_.timeToNextAction()
- );
+ if (time_.value() < startTime_)
+ {
+ return startTime_ - time_.value();
+ }
+ else if (active())
+ {
+ return min
+ (
+ executeControl_.timeToNextAction(),
+ writeControl_.timeToNextAction()
+ );
+ }
+ else
+ {
+ return vGreat;
+ }
 }

TagsNo tags attached.

Activities

henry

2024-08-14 09:38

manager   ~0013376

I couldn't apply the patch provided, all the indentation is missing so it doesn't match the code and will not apply. I have made the changes by hand.

henry

2024-08-14 09:38

manager   ~0013377

Resolved by commit 2c83b0e87bf0d2136c8aeea8041282f457596726

Issue History

Date Modified Username Field Change
2024-08-12 11:59 cgoessni New Issue
2024-08-14 09:38 henry Note Added: 0013376
2024-08-14 09:38 henry Assigned To => henry
2024-08-14 09:38 henry Status new => resolved
2024-08-14 09:38 henry Resolution open => fixed
2024-08-14 09:38 henry Fixed in Version => dev
2024-08-14 09:38 henry Note Added: 0013377