diff --git a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C index 6699b6349b76e9703a42ffa1b62ca5a37dc1a53a..be8a2b71ba576038eb818a5a05d4d075d25eb9b1 100644 --- a/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C +++ b/src/OpenFOAM/interpolations/interpolationTable/interpolationTable.C @@ -284,10 +284,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue to >= minLimit - while (lookupValue < minLimit) - { - lookupValue += maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -325,10 +323,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue <= maxLimit - while (lookupValue > maxLimit) - { - lookupValue -= maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -540,11 +536,9 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const } case interpolationTable::REPEAT: { - // adjust lookupValue to >= minLimin - while (lookupValue < minLimit) - { - lookupValue += maxLimit; - } + // adjust lookupValue to >= minLimit + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } } @@ -582,10 +576,8 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const case interpolationTable::REPEAT: { // adjust lookupValue <= maxLimit - while (lookupValue > maxLimit) - { - lookupValue -= maxLimit; - } + scalar span = maxLimit-minLimit; + lookupValue = fmod(lookupValue-minLimit, span) + minLimit; break; } }