From edd7a671d9dea0ac2643010c2db4c5fa99b4c555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 28 Aug 2014 11:24:41 +0200 Subject: [PATCH] riMULTXYZ: Added tolerances for CellEdge and Calculations --- .../RivCellEdgeGeometryUtils.cpp | 8 ++++++-- .../ModelVisualization/RivCellEdgeGeometryUtils.h | 2 ++ .../RimReservoirCellResultsStorage.cpp | 15 ++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index 14b3d9f3a7..a9c8e58444 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -150,7 +150,7 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast(cubeFaceIdx)); - if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue) + if (!hideScalarValue(scalarValue, ignoredScalarValue, 1e-2)) { edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0]; } @@ -178,6 +178,10 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( geo->setVertexAttribute(new cvf::FloatVertexAttribute("a_colorNegK", cellEdgeColorTextureCoordsArrays.at(5))); } +bool RivCellEdgeGeometryUtils::hideScalarValue(double scalarValue, double scalarValueToHide, double tolerance) +{ + return (scalarValue == HUGE_VAL || abs(scalarValue - scalarValueToHide) <= scalarValueToHide*tolerance); +} //-------------------------------------------------------------------------------------------------- /// @@ -247,7 +251,7 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim double scalarValue = cellEdgeResultAccessor->cellFaceScalar(cellIndex, static_cast(cubeFaceIdx)); - if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue) + if (!hideScalarValue(scalarValue, ignoredScalarValue, 1e-2)) { edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0]; } diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h index fdc96745a6..80465bd6ab 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.h @@ -67,4 +67,6 @@ private: size_t timeStepIndex, RigCaseData* eclipseCase, const RigGridBase* grid); + + static bool hideScalarValue(double scalarValue, double scalarValueToHide, double tolerance); }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index ae96319e30..2a349a63cb 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -1104,15 +1104,16 @@ void RimReservoirCellResultsStorage::computeNncCombRiTrans() double riMult(double transResults, double riTransResults) { // To make 0.0 values give 1.0 in mult value - // We might want a tolerance here. - if (transResults == riTransResults) + + if (riTransResults == 0.0) { - return 1.0; - } - else - { - return transResults / riTransResults; + if (abs (transResults) < 1e-12) + { + return 1.0; + } } + + return transResults / riTransResults; } //--------------------------------------------------------------------------------------------------