Hidden bugs in OpenFLUID 2.1.11

 November 14, 2024  |   A. Thöni


While testing the incoming 2.2.0 release, we discovered two old bugs that could impact simulations made with OpenFLUID 2.1.11 (and previous) in very narrow contexts. Both bugs are patched in upcoming OpenFLUID 2.2.0 but we give here sufficient workarounds for users needing to work with OpenFLUID 2.1.x.


OPENFLUID_GetUnit(ClassName, ID, aUnit)

The OPENFLUID_GetUnit(ClassName, ID, aUnit) function where the unit is changed in arguments fails to set correctly the unit.

The function aUnit = OPENFLUID_GetUnit(ClassName, ID) (where unit is affected by return) works fine so it is highly advised to use it instead.


DateTimeB.diffInSeconds(DateTimeA)

This function is supposed to return a “time difference” but will return an unsigned value, meaning that it works correctly only when DateTimeB > DateTimeA.

To avoid erronous values, it is advised to check the order of dates when unknown:

openfluid::core::RawTime_t Seconds
if (DateTimeB > DateTimeA)
{
    Seconds = DateTimeB.diffInSeconds(DateTimeA)
}
else
{
    Seconds = DateTimeA.diffInSeconds(DateTime)
}

If a signed difference DateTimeB - DateTimeA is required instead of distance, you can adjust the code as follows:

int Substract;
if (DateTimeB > DateTimeA)
{
    Substract = DateTimeB.diffInSeconds(DateTimeA)
}
else
{
    Substract = -DateTimeA.diffInSeconds(DateTimeB)
}

Don’t hesitate to contact us if you need further information!