diff --git a/ApplicationCode/ProjectDataModel/RimFractureModelPlot.cpp b/ApplicationCode/ProjectDataModel/RimFractureModelPlot.cpp index 0982824e05..7382a12626 100644 --- a/ApplicationCode/ProjectDataModel/RimFractureModelPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimFractureModelPlot.cpp @@ -152,20 +152,23 @@ void RimFractureModelPlot::calculateLayers( std::vector& values, - std::vector>& layerBoundaryDepths, - double depth ) +double RimFractureModelPlot::findValueAtTopOfLayer( const std::vector& values, + const std::vector>& layerBoundaryIndexes, + size_t layerNo ) { - for ( size_t i = 0; i < layerBoundaryDepths.size(); i++ ) - { - if ( layerBoundaryDepths[i].first <= depth && layerBoundaryDepths[i].second >= depth ) - { - return values[i]; - } - } + int index = layerBoundaryIndexes[layerNo].first; + return values.at( index ); +} - RiaLogging::error( QString( "Failed to compute value at depth: %1" ).arg( depth ) ); - return std::numeric_limits::infinity(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureModelPlot::findValueAtBottomOfLayer( const std::vector& values, + const std::vector>& layerBoundaryIndexes, + size_t layerNo ) +{ + int index = layerBoundaryIndexes[layerNo].second; + return values.at( index ); } //-------------------------------------------------------------------------------------------------- @@ -357,11 +360,11 @@ bool RimFractureModelPlot::calculateStressWithGradients( std::vector& st double depthBottomOfZone = layerBoundaryDepths[i].second; // Data from curves at the top zone depth - double k0 = computeValueAtDepth( k0Data, layerBoundaryDepths, depthTopOfZone ); - double biot = computeValueAtDepth( biotData, layerBoundaryDepths, depthTopOfZone ); - double poissonsRatio = computeValueAtDepth( poissonsRatioData, layerBoundaryDepths, depthTopOfZone ); - double initialPressure = computeValueAtDepth( initialPressureData, layerBoundaryDepths, depthTopOfZone ); - double timeStepPressure = computeValueAtDepth( timeStepPressureData, layerBoundaryDepths, depthTopOfZone ); + double k0 = findValueAtTopOfLayer( k0Data, layerBoundaryIndexes, i ); + double biot = findValueAtTopOfLayer( biotData, layerBoundaryIndexes, i ); + double poissonsRatio = findValueAtTopOfLayer( poissonsRatioData, layerBoundaryIndexes, i ); + double initialPressure = findValueAtTopOfLayer( initialPressureData, layerBoundaryIndexes, i ); + double timeStepPressure = findValueAtTopOfLayer( timeStepPressureData, layerBoundaryIndexes, i ); // Vertical stress // Use difference between reference depth and depth of top of zone @@ -387,8 +390,8 @@ bool RimFractureModelPlot::calculateStressWithGradients( std::vector& st if ( i == layerBoundaryDepths.size() - 1 ) { // Use the bottom of the last layer to compute gradient for last layer - double bottomInitialPressure = - computeValueAtDepth( initialPressureData, layerBoundaryDepths, depthBottomOfZone ); + double bottomInitialPressure = findValueAtBottomOfLayer( initialPressureData, layerBoundaryIndexes, i ); + double bottomDepthDiff = depthBottomOfZone - stressDepthRef; double bottomSv = verticalStressRef + verticalStressGradientRef * bottomDepthDiff; stressForGradients.push_back( bottomSv ); @@ -407,7 +410,7 @@ bool RimFractureModelPlot::calculateStressWithGradients( std::vector& st double diffStress = stressForGradients[i + 1] - stressForGradients[i]; double diffPressure = pressureForGradients[i + 1] - pressureForGradients[i]; double diffDepth = depthForGradients[i + 1] - depthForGradients[i]; - double k0 = computeValueAtDepth( k0Data, layerBoundaryDepths, depthForGradients[i] ); + double k0 = findValueAtTopOfLayer( k0Data, layerBoundaryIndexes, i ); double gradient = ( diffStress * k0 + diffPressure * ( 1.0 - k0 ) ) / diffDepth; stressGradients.push_back( RiaEclipseUnitTools::barPerMeterToPsiPerFeet( gradient ) ); } diff --git a/ApplicationCode/ProjectDataModel/RimFractureModelPlot.h b/ApplicationCode/ProjectDataModel/RimFractureModelPlot.h index 89b11ffa46..42a7127511 100644 --- a/ApplicationCode/ProjectDataModel/RimFractureModelPlot.h +++ b/ApplicationCode/ProjectDataModel/RimFractureModelPlot.h @@ -84,9 +84,12 @@ protected: RimWellLogExtractionCurve* findCurveByProperty( RiaDefines::CurveProperty curveProperty ) const; bool calculateStressWithGradients( std::vector& stress, std::vector& stressGradients ) const; - static double computeValueAtDepth( const std::vector& values, - std::vector>& layerBoundaryDepths, - double depth ); + static double findValueAtTopOfLayer( const std::vector& values, + const std::vector>& layerBoundaryIndexes, + size_t layerNo ); + static double findValueAtBottomOfLayer( const std::vector& values, + const std::vector>& layerBoundaryIndexes, + size_t layerNo ); static void computeAverageByLayer( const std::vector>& layerBoundaryIndexes, const std::vector& inputVector, std::vector& result );