View Issue Details

IDProjectCategoryView StatusLast Update
0002510OpenFOAMBugpublic2017-05-03 18:46
Reportertniemi Assigned Tohenry  
Status resolvedResolutionfixed 
Product Versiondev 
Summary0002510: Subtle bug in fieldAverage function object
DescriptionThe recent changes to fieldAverage ( introduce a subtle bug, where totalTime_[fieldi] is not properly initialized for fields that are not present in the Properties-dict during restart.

Possible fixes:
1. In line 245 give a default value obr_.time().deltaTValue() to totalTime_[fieldi]. This corresponds to earlier behavior, but may not be accurate for variable time step cases.
2. Give an invalid value for totalTime_[fieldi], eg. negative, and detect these in initialize(). So in addition to checking for size, loop over totalTimes and initialize if necessary.
3. Disallow adding new fields to the same fieldAverage-function. Throw a warning or crash if props are not found for all fields.
Steps To ReproduceSteps to reproduce

1. Start averaging, run until write and kill solver
2. Add new fields to the same fieldAverage-object
3. Restart averaging, totalTime for new fields is now arbitrary leading to incorrect results or crash
TagsNo tags attached.



2017-03-21 12:53

manager   ~0007956

Option 1 is not good because it recreates the previous error is a slightly different form.

Option 2 is a bit clunky but workable.

Option 3 is the cleanest but least flexible.

Which option do you prefer?


2017-03-21 12:59

reporter   ~0007957

I think option 2 would be best, because the properties-dict supports having different averaging times for different fields and I see no reason to prevent user from adding new fields. Also this has worked before and the changed behavior may confuse users.


2017-03-21 13:03

manager   ~0007958

Can you provide a patch for option 2?


2017-03-21 13:30

reporter   ~0007959

Ok, I have attached a very straightforward patch which uses -1.0 as a dummy value.
fieldAverage.C (8,948 bytes)


2017-03-22 18:39

manager   ~0007968

Thanks Timo

Resolved by commit c95bf5e31d627456713266e29f5ca32e1bad9216


2017-04-20 07:59

reporter   ~0008033

I just noticed that this bug also affects 4.x. The fix should probably be also added to 4.x?


2017-05-03 18:46

manager   ~0008076

Resolved in OpenFOAM-4.x by commit f10cfe3fb0ab9360a9b47bd0cfba4c7dfc0c56d3

Issue History

Date Modified Username Field Change
2017-03-21 12:39 tniemi New Issue
2017-03-21 12:53 henry Note Added: 0007956
2017-03-21 12:59 tniemi Note Added: 0007957
2017-03-21 13:03 henry Note Added: 0007958
2017-03-21 13:30 tniemi File Added: fieldAverage.C
2017-03-21 13:30 tniemi Note Added: 0007959
2017-03-22 18:39 henry Assigned To => henry
2017-03-22 18:39 henry Status new => resolved
2017-03-22 18:39 henry Resolution open => fixed
2017-03-22 18:39 henry Fixed in Version => dev
2017-03-22 18:39 henry Note Added: 0007968
2017-04-20 07:59 tniemi Status resolved => feedback
2017-04-20 07:59 tniemi Resolution fixed => reopened
2017-04-20 07:59 tniemi Note Added: 0008033
2017-05-03 18:46 henry Status feedback => resolved
2017-05-03 18:46 henry Resolution reopened => fixed
2017-05-03 18:46 henry Fixed in Version dev => 4.x
2017-05-03 18:46 henry Note Added: 0008076