From 74f927e13f91d74f2917e9f3ff81b44bb5f2a99c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 9 Sep 2014 15:21:09 +0200 Subject: [PATCH] riTRAN/MULT :Improved handling of invalid operations 0/0 etc. --- .../RimReservoirCellResultsStorage.cpp | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 30874e7b6f..24820f5aee 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -734,7 +734,14 @@ namespace RigTransmissibilityCalcTools //-------------------------------------------------------------------------------------------------- double newtran(double cdarchy, double mult, double halfCellTrans, double neighborHalfCellTrans) { - return cdarchy * mult / ((1 / halfCellTrans) + (1 / neighborHalfCellTrans)); + if (cvf::Math::abs(halfCellTrans) < 1e-15 || cvf::Math::abs(neighborHalfCellTrans) < 1e-15) + { + return 0.0; + } + + double result = cdarchy * mult / ((1 / halfCellTrans) + (1 / neighborHalfCellTrans)); + CVF_TIGHT_ASSERT(result == result); + return result; } //-------------------------------------------------------------------------------------------------- @@ -923,7 +930,7 @@ void RimReservoirCellResultsStorage::computeRiTransComponent(const QString& riTr neighborHalfCellTrans = halfCellTransmissibility(perm, ntg, centerToFace, -faceAreaVec); } - riTransResults[tranResIdx] = newtran(cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans);; + riTransResults[tranResIdx] = newtran(cdarchy, 1.0, halfCellTrans, neighborHalfCellTrans); } } @@ -1094,17 +1101,23 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double riMult(double transResults, double riTransResults) { - // To make 0.0 values give 1.0 in mult value + if (transResults == HUGE_VAL || riTransResults == HUGE_VAL) return HUGE_VAL; - if (riTransResults == 0.0) + // To make 0.0 values give 1.0 in mult value + if (cvf::Math::abs (riTransResults) < 1e-12) { if (cvf::Math::abs (transResults) < 1e-12) { return 1.0; } + + return HUGE_VAL; } - return transResults / riTransResults; + + double result = transResults / riTransResults; + + return result; } //--------------------------------------------------------------------------------------------------