Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/OPM/ResInsight into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Feb 14, 2024
2 parents fc2df17 + 41ed462 commit a4c75ba
Show file tree
Hide file tree
Showing 9 changed files with 167 additions and 44 deletions.
4 changes: 4 additions & 0 deletions ApplicationLibCode/Application/RiaResultNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,5 +595,9 @@ std::vector<QString> RiaResultNames::wbsDerivedResultNames()
wbsSHMkMaxResult(),
wbsFGMkExpResult(),
wbsFGMkMinResult(),
wbsPPMinResult(),
wbsPPMaxResult(),
wbsPPExpResult(),
wbsPPInitialResult(),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@
#include "cafProgressInfo.h"
#include "cafSelectionManager.h"
#include "cvfAssert.h"
#include "cvfColor3.h"
#include "cvfMath.h"

#include <QAction>
#include <QDateTime>
#include <QString>

#include <algorithm>
#include <set>

CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilityPlotFeature" );

Expand Down Expand Up @@ -262,7 +264,7 @@ void RicNewWellBoreStabilityPlotFeature::createParametersTrack( RimWellBoreStabi
paramCurvesTrack->setFormationCase( geoMechCase );
paramCurvesTrack->setShowRegionLabels( true );
paramCurvesTrack->setShowWindow( false );
std::set<RigWbsParameter> parameters = RigWbsParameter::allParameters();
std::set<RigWbsParameter> parameters = parametersForTrack();

caf::ColorTable colors = RiaColorTables::contrastCategoryPaletteColors();
std::vector<RiuQwtPlotCurveDefines::LineStyleEnum> lineStyles = { RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID,
Expand Down Expand Up @@ -321,6 +323,15 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
std::vector<RiuQwtPlotCurveDefines::LineStyleEnum> lineStyles( resultNames.size(), RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID );
lineStyles.back() = RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH;

std::set<QString> defaultOffResults = {
RiaResultNames::wbsSHMkResult(),
RiaResultNames::wbsSHMkExpResult(),
RiaResultNames::wbsSHMkMinResult(),
RiaResultNames::wbsSHMkMaxResult(),
RiaResultNames::wbsFGMkExpResult(),
RiaResultNames::wbsFGMkMinResult(),
};

for ( size_t i = 0; i < resultNames.size(); ++i )
{
const QString& resultName = resultNames[i];
Expand All @@ -330,13 +341,14 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
curve->setGeoMechResultAddress( resAddr );
curve->setCurrentTimeStep( timeStep );
curve->setAutoNameComponents( false, true, false, false, false );
curve->setColor( colors[i % colors.size()] );
curve->setLineStyle( lineStyles[i] );
auto [color, lineStyle] = getColorAndLineStyle( resultName, i, colors );
curve->setColor( color );
curve->setLineStyle( lineStyle );
curve->setLineThickness( 2 );
curve->loadDataAndUpdate( false );
curve->setSmoothCurve( true );
curve->setSmoothingThreshold( 0.002 );
if ( resultNames[i] == RiaResultNames::wbsSHMkResult() )
if ( defaultOffResults.count( resultNames[i] ) )
{
curve->setCheckState( false );
}
Expand All @@ -361,6 +373,34 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
stabilityCurvesTrack->setAutoScalePropertyValuesEnabled( true );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<cvf::Color3f, RiuQwtPlotCurveDefines::LineStyleEnum>
RicNewWellBoreStabilityPlotFeature::getColorAndLineStyle( const QString& resultName, size_t i, const std::vector<cvf::Color3f>& colors )
{
if ( resultName == RiaResultNames::wbsSHMkResult() ) return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
if ( resultName == RiaResultNames::wbsSHMkExpResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsSHMkMinResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
if ( resultName == RiaResultNames::wbsSHMkMaxResult() )
return { cvf::Color3f::GREEN, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };

if ( resultName == RiaResultNames::wbsFGMkExpResult() )
return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsFGMkMinResult() ) return { cvf::Color3f::BLUE, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };

if ( resultName == RiaResultNames::wbsPPInitialResult() )
return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
if ( resultName == RiaResultNames::wbsPPExpResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH };
if ( resultName == RiaResultNames::wbsPPMinResult() ) return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DOT };
if ( resultName == RiaResultNames::wbsPPMaxResult() )
return { cvf::Color3f::RED, RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_DASH_DOT };

return { colors[i % colors.size()], RiuQwtPlotCurveDefines::LineStyleEnum::STYLE_SOLID };
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -408,3 +448,22 @@ void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStability
wellPathAnglesTrack->setAnnotationDisplay( RiaDefines::LIGHT_LINES );
wellPathAnglesTrack->setShowRegionLabels( false );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<RigWbsParameter> RicNewWellBoreStabilityPlotFeature::parametersForTrack()
{
return { RigWbsParameter::PP_Reservoir(),
RigWbsParameter::PP_NonReservoir(),
RigWbsParameter::poissonRatio(),
RigWbsParameter::UCS(),
RigWbsParameter::OBG(),
RigWbsParameter::OBG0(),
RigWbsParameter::SH(),
RigWbsParameter::DF(),
RigWbsParameter::K0_FG(),
RigWbsParameter::K0_SH(),
RigWbsParameter::FG_Shale(),
RigWbsParameter::waterDensity() };
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@

#include "cafCmdFeature.h"

#include "RigWbsParameter.h"

#include "RimPlotCurveAppearance.h"

#include "cvfColor3.h"

#include <set>

class RimGeoMechCase;
class RimGeoMechView;
class RimWbsParameters;
Expand Down Expand Up @@ -48,4 +56,8 @@ class RicNewWellBoreStabilityPlotFeature : public caf::CmdFeature
static void createParametersTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );
static void createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );
static void createAnglesTrack( RimWellBoreStabilityPlot* plot, RimWellPath* wellPath, RimGeoMechCase* geoMechCase, int timeStep );

static std::set<RigWbsParameter> parametersForTrack();
static std::pair<cvf::Color3f, RiuQwtPlotCurveDefines::LineStyleEnum>
getColorAndLineStyle( const QString& resultName, size_t i, const std::vector<cvf::Color3f>& colors );
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////

#include "RimFaultReactivationDataAccessorTemperature.h"
#include "RigFaultReactivationModel.h"
#include "RimFaultReactivationEnums.h"

#include "RiaDefines.h"
Expand Down Expand Up @@ -78,6 +79,48 @@ void RimFaultReactivationDataAccessorTemperature::updateResultAccessor()
RimFaultReactivationDataAccessorWellLogExtraction::createEclipseWellPathExtractors( *m_model, *m_caseData, m_seabedDepth );
m_wellPaths = wellPaths;
m_extractors = extractors;

m_gradient = computeGradient();
}

//--------------------------------------------------------------------------------------------------
/// Find the top encounter with reservoir (of the two well paths), and create gradient from that point
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorTemperature::computeGradient() const
{
double gradient = std::numeric_limits<double>::infinity();
double minDepth = -std::numeric_limits<double>::max();
for ( auto gridPart : m_model->allGridParts() )
{
auto extractor = m_extractors.find( gridPart )->second;
auto wellPath = m_wellPaths.find( gridPart )->second;

auto [values, intersections] =
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );

int lastOverburdenIndex = RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( values );
if ( lastOverburdenIndex != -1 )
{
double depth = intersections[lastOverburdenIndex].z();
double value = values[lastOverburdenIndex];

if ( !std::isinf( value ) )
{
double currentGradient =
RimFaultReactivationDataAccessorWellLogExtraction::computeGradient( intersections[0].z(),
m_seabedTemperature,
intersections[lastOverburdenIndex].z(),
values[lastOverburdenIndex] );
if ( !std::isinf( value ) && !std::isnan( currentGradient ) && depth > minDepth )
{
gradient = currentGradient;
minDepth = depth;
}
}
}
}

return gradient;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -100,6 +143,13 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
{
if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}

CAF_ASSERT( m_extractors.find( gridPart ) != m_extractors.end() );
auto extractor = m_extractors.find( gridPart )->second;

Expand All @@ -110,16 +160,7 @@ double RimFaultReactivationDataAccessorTemperature::valueAtPosition( const cvf::
RimFaultReactivationDataAccessorWellLogExtraction::extractValuesAndIntersections( *m_resultAccessor.p(), *extractor.p(), *wellPath );

auto [value, pos] =
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, values, position, m_seabedTemperature );
if ( pos.isUndefined() )
{
auto cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position );
if ( cellIdx != cvf::UNDEFINED_SIZE_T )
{
double tempFromEclipse = m_resultAccessor->cellScalar( cellIdx );
if ( !std::isinf( tempFromEclipse ) ) return tempFromEclipse;
}
}
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( intersections, position, m_seabedTemperature, m_gradient );

return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ class RimFaultReactivationDataAccessorTemperature : public RimFaultReactivationD
size_t elementIndex = std::numeric_limits<size_t>::max() ) const override;

private:
void updateResultAccessor() override;
void updateResultAccessor() override;
double computeGradient() const;

RimEclipseCase* m_eclipseCase;
RigEclipseCaseData* m_caseData;
const RigMainGrid* m_mainGrid;
double m_seabedTemperature;
double m_seabedDepth;
double m_gradient;

cvf::ref<RigResultAccessor> m_resultAccessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,11 @@ std::pair<double, cvf::Vec3d> RimFaultReactivationDataAccessorWellLogExtraction:
//--------------------------------------------------------------------------------------------------
std::pair<double, cvf::Vec3d>
RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature )
double seabedTemperature,
double gradient )
{
// Fill in missing values
fillInMissingValuesWithTopValue( intersections, values, seabedTemperature );
auto [value, extractionPosition] = findValueAndPosition( intersections, values, position );

double minDistance = computeMinimumDistance( position, intersections );
if ( minDistance < 1.0 )
{
return { value, extractionPosition };
}
else
{
return { value, cvf::Vec3d::UNDEFINED };
}
return { calculateTemperature( seabedTemperature, intersections[0].z(), std::abs( position.z() ), gradient ), position };
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -182,16 +170,6 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findInter
//--------------------------------------------------------------------------------------------------
std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverburdenAndUnderburdenIndex( const std::vector<double>& values )
{
auto findLastOverburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}

return -1;
};

auto findFirstUnderburdenIndex = []( const std::vector<double>& values )
{
for ( size_t i = values.size() - 1; i > 0; i-- )
Expand All @@ -207,6 +185,19 @@ std::pair<int, int> RimFaultReactivationDataAccessorWellLogExtraction::findOverb
return { lastOverburdenIndex, firstUnderburdenIndex };
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimFaultReactivationDataAccessorWellLogExtraction::findLastOverburdenIndex( const std::vector<double>& values )
{
for ( size_t i = 0; i < values.size(); i++ )
{
if ( !std::isinf( values[i] ) ) return static_cast<int>( i );
}

return -1;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -481,3 +472,12 @@ double RimFaultReactivationDataAccessorWellLogExtraction::calculatePorePressure(
{
return RiaEclipseUnitTools::pascalToBar( gradient * 9.81 * depth * 1000.0 );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimFaultReactivationDataAccessorWellLogExtraction::calculateTemperature( double topValue, double topDepth, double depth, double gradient )
{
double tvdDiff = topDepth - depth;
return tvdDiff * gradient + topValue;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ class RimFaultReactivationDataAccessorWellLogExtraction
double gradient );

static std::pair<double, cvf::Vec3d> calculateTemperature( const std::vector<cvf::Vec3d>& intersections,
std::vector<double>& values,
const cvf::Vec3d& position,
double seabedTemperature );
double seabedTemperature,
double gradient );
static std::pair<std::map<RimFaultReactivation::GridPart, cvf::ref<RigWellPath>>,
std::map<RimFaultReactivation::GridPart, cvf::ref<RigEclipseWellLogExtractor>>>
createEclipseWellPathExtractors( const RigFaultReactivationModel& model, RigEclipseCaseData& eclipseCaseData, double seabedDepth );
Expand All @@ -76,6 +76,10 @@ class RimFaultReactivationDataAccessorWellLogExtraction
const cvf::Vec3d& point,
const std::map<RimFaultReactivation::ElementSets, std::vector<unsigned int>>& elementSets );

static int findLastOverburdenIndex( const std::vector<double>& values );

static double computeGradient( double depth1, double value1, double depth2, double value2 );

protected:
static std::pair<int, int> findOverburdenAndUnderburdenIndex( const std::vector<double>& values );
static double computeValueWithGradient( const std::vector<cvf::Vec3d>& intersections,
Expand All @@ -89,7 +93,6 @@ class RimFaultReactivationDataAccessorWellLogExtraction
static std::pair<double, cvf::Vec3d>
findValueAndPosition( const std::vector<cvf::Vec3d>& intersections, const std::vector<double>& values, const cvf::Vec3d& position );

static double computeGradient( double depth1, double value1, double depth2, double value2 );
static std::vector<double> extractDepthValues( const std::vector<cvf::Vec3d>& intersections );

static void insertUnderburdenValues( const std::vector<cvf::Vec3d>& intersections,
Expand All @@ -103,4 +106,5 @@ class RimFaultReactivationDataAccessorWellLogExtraction
static double computeMinimumDistance( const cvf::Vec3d& position, const std::vector<cvf::Vec3d>& positions );

static double calculatePorePressure( double depth, double gradient );
static double calculateTemperature( double topValue, double topDepth, double depth, double gradient );
};
1 change: 1 addition & 0 deletions ApplicationLibCode/ReservoirDataModel/RigWbsParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ RigWbsParameter RigWbsParameter::waterDensity()
{ LAS_FILE, SourceAddress( "RHO_INP", "", RiaWellLogUnitTools<double>::gPerCm3UnitString() ) } } );
return param;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion ResInsightVersion.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(RESINSIGHT_VERSION_TEXT "-dev")
# Must be unique and increasing within one combination of major/minor/patch version
# The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT
# Format of text must be ".xx"
set(RESINSIGHT_DEV_VERSION ".19")
set(RESINSIGHT_DEV_VERSION ".20")

# https://github.com/CRAVA/crava/tree/master/libs/nrlib
set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f")
Expand Down

0 comments on commit a4c75ba

Please sign in to comment.