Add reference well to well log extraction curve eclipse case (#9516)

This commit is contained in:
Jørgen Herje 2022-11-30 23:13:39 +01:00 committed by GitHub
parent eb390100bd
commit 278828b08f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 450 additions and 113 deletions

View File

@ -105,6 +105,14 @@ QString RiaDefines::namingVariableWell()
return "$WELL";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaDefines::namingVariableRefWell()
{
return "$REF_WELL";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -84,6 +84,7 @@ enum class WindowTileMode
// Defines relate to curve and plot template names
QString namingVariableCase();
QString namingVariableWell();
QString namingVariableRefWell();
QString namingVariableWellBranch();
QString namingVariableResultName();
QString namingVariableResultType();

View File

@ -614,6 +614,7 @@ QStringList RimDepthTrackPlot::supportedPlotNameVariables() const
{
return { RiaDefines::namingVariableCase(),
RiaDefines::namingVariableWell(),
RiaDefines::namingVariableRefWell(),
RiaDefines::namingVariableWellBranch(),
RiaDefines::namingVariableTime(),
RiaDefines::namingVariableAirGap() };
@ -626,8 +627,9 @@ std::map<QString, QString> RimDepthTrackPlot::createNameKeyValueMap() const
{
std::map<QString, QString> variableValueMap;
RimCase* commonCase = m_commonDataSource->caseToApply();
RimWellPath* commonWellPath = m_commonDataSource->wellPathToApply();
RimCase* commonCase = m_commonDataSource->caseToApply();
RimWellPath* commonWellPath = m_commonDataSource->wellPathToApply();
RimWellPath* commonRefWellPath = m_commonDataSource->referenceWellPathToApply();
if ( commonCase )
{
@ -673,6 +675,11 @@ std::map<QString, QString> RimDepthTrackPlot::createNameKeyValueMap() const
variableValueMap[RiaDefines::namingVariableWell()] = m_commonDataSource->simWellNameToApply();
}
if ( commonRefWellPath && !commonRefWellPath->name().isEmpty() )
{
variableValueMap[RiaDefines::namingVariableRefWell()] = QString( "Ref. Well: %1" ).arg( commonRefWellPath->name() );
}
if ( commonWellPath )
{
RigWellPath* wellPathGeometry = commonWellPath->wellPathGeometry();
@ -1267,6 +1274,7 @@ void RimDepthTrackPlot::defineEditorAttribute( const caf::PdmFieldHandle* field,
//--------------------------------------------------------------------------------------------------
void RimDepthTrackPlot::onLoadDataAndUpdate()
{
updateReferenceWellPathInCurves();
updateMdiWindowVisibility();
performAutoNameUpdate();
updatePlots();
@ -1298,6 +1306,21 @@ caf::PdmFieldHandle* RimDepthTrackPlot::userDescriptionField()
return &m_plotWindowTitle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDepthTrackPlot::updateReferenceWellPathInCurves()
{
for ( auto plot : this->plots() )
{
auto wellLogTrack = dynamic_cast<RimWellLogTrack*>( plot );
for ( auto curve : wellLogTrack->curves() )
{
curve->setReferenceWellPath( m_commonDataSource->referenceWellPathToApply() );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -197,6 +197,8 @@ protected:
void updatePlots();
caf::PdmFieldHandle* userDescriptionField() override;
void updateReferenceWellPathInCurves();
private:
void cleanupBeforeClose();
void updateSubPlotNames();

View File

@ -27,9 +27,11 @@
#include "RimGeoMechCase.h"
#include "RimTools.h"
#include "RimWbsParameters.h"
#include "RimWellLogCurve.h"
#include "RimWellLogCurveCommonDataSource.h"
#include "RimWellLogFile.h"
#include "RimWellLogPlotNameConfig.h"
#include "RimWellLogTrack.h"
#include "cafPdmBase.h"
#include "cafPdmFieldScriptingCapability.h"
@ -213,5 +215,7 @@ void RimWellBoreStabilityPlot::applyDataSource()
m_wbsParameters->setGeoMechCase( dynamic_cast<RimGeoMechCase*>( m_commonDataSource->caseToApply() ) );
m_wbsParameters->setWellPath( m_commonDataSource->wellPathToApply() );
m_wbsParameters->setTimeStep( m_commonDataSource->timeStepToApply() );
this->updateReferenceWellPathInCurves();
this->updateConnectedEditors();
}

View File

@ -19,12 +19,17 @@
#include "RimWellLogCurve.h"
#include "RiaApplication.h"
#include "RiaCurveDataTools.h"
#include "RiaPlotDefines.h"
#include "RigWellLogCurveData.h"
#include "RimDepthTrackPlot.h"
#include "RimMainPlotCollection.h"
#include "RimTools.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RiuQwtPlotCurve.h"
#include "RiuQwtPlotWidget.h"
@ -52,6 +57,12 @@ RimWellLogCurve::RimWellLogCurve()
m_curveDataPropertyValueRange =
std::make_pair( std::numeric_limits<double>::infinity(), -std::numeric_limits<double>::infinity() );
// Ref well path as Ui element for debug purpose. If not needed: Remove use of caf::PdmPtrField,
// and replace with regular non-ui ptr. The remove related code in calculateValueOptions() and
// defineUiOrdering().
CAF_PDM_InitFieldNoDefault( &m_refWellPath, "ReferenceWellPath", "Reference Well Path" );
m_refWellPath.uiCapability()->setUiHidden( !RiaApplication::enableDevelopmentFeatures() );
setDeletable( true );
}
@ -220,6 +231,14 @@ const RigWellLogCurveData* RimWellLogCurve::curveData() const
return m_curveData.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::setReferenceWellPath( RimWellPath* refWellPath )
{
m_refWellPath = refWellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -407,6 +426,36 @@ void RimWellLogCurve::calculateCurveDataPropertyValueRange()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimWellLogCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
auto options = RimStackablePlotCurve::calculateValueOptions( fieldNeedingOptions );
if ( fieldNeedingOptions == &m_refWellPath )
{
options.push_back( caf::PdmOptionItemInfo( QString( "None" ), nullptr ) );
RimTools::wellPathOptionItems( &options );
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
RimStackablePlotCurve::defineUiOrdering( uiConfigName, uiOrdering );
auto group = uiOrdering.findGroup( "DataSource" );
if ( group != nullptr )
{
group->add( &m_refWellPath );
}
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -23,10 +23,12 @@
#include "RiaWellLogUnitTools.h"
#include "RimStackablePlotCurve.h"
#include "cafPdmPtrField.h"
#include "cafSignal.h"
#include "cvfObject.h"
class RigWellLogCurveData;
class RimWellPath;
//==================================================================================================
///
@ -47,6 +49,7 @@ public:
const RigWellLogCurveData* curveData() const;
void setReferenceWellPath( RimWellPath* refWellPath );
void updateCurveAppearance() override;
virtual QString wellName() const = 0;
@ -64,11 +67,13 @@ public:
double closestYValueForX( double xValue ) const override;
protected:
void updateZoomInParentPlot() override;
void updateLegendsInPlot() override;
void setOverrideCurveDataPropertyValueRange( double minimumValue, double maximumValue );
void calculateCurveDataPropertyValueRange();
void updateZoomInParentPlot() override;
void updateLegendsInPlot() override;
void setOverrideCurveDataPropertyValueRange( double minimumValue, double maximumValue );
void calculateCurveDataPropertyValueRange();
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void setPropertyValuesAndDepths( const std::vector<double>& propertyValues,
@ -108,6 +113,9 @@ protected:
RiuPlotAxis depthAxis() const;
RiuPlotAxis valueAxis() const;
protected:
caf::PdmPtrField<RimWellPath*> m_refWellPath;
private:
cvf::ref<RigWellLogCurveData> m_curveData;
std::pair<double, double> m_curveDataPropertyValueRange;

View File

@ -83,6 +83,7 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource()
CAF_PDM_InitFieldNoDefault( &m_trajectoryType, "TrajectoryType", "Trajectory Type" );
CAF_PDM_InitFieldNoDefault( &m_wellPath, "CurveWellPath", "Well Path" );
CAF_PDM_InitFieldNoDefault( &m_refWellPath, "CurveReferenceWellPath", "Reference Well Path" );
CAF_PDM_InitFieldNoDefault( &m_simWellName, "SimulationWellName", "Well Name" );
CAF_PDM_InitFieldNoDefault( &m_branchDetection,
@ -111,8 +112,9 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource()
CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchIndex, "SegmentBranchIndex", "RFT Branch" );
CAF_PDM_InitFieldNoDefault( &m_rftSegmentBranchType, "SegmentBranchType", "RFT Completion" );
m_case = nullptr;
m_wellPath = nullptr;
m_case = nullptr;
m_wellPath = nullptr;
m_refWellPath = nullptr;
}
//--------------------------------------------------------------------------------------------------
@ -187,6 +189,14 @@ void RimWellLogCurveCommonDataSource::setWellPathToApply( RimWellPath* val )
m_wellPath = val;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPath* RimWellLogCurveCommonDataSource::referenceWellPathToApply() const
{
return m_refWellPath;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -286,7 +296,7 @@ void RimWellLogCurveCommonDataSource::setTimeStepToApply( int val )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogCurveCommonDataSource::resetDefaultOptions()
void RimWellLogCurveCommonDataSource::resetSourceStepFields()
{
setCaseToApply( nullptr );
setSummaryCaseToApply( nullptr );
@ -322,8 +332,8 @@ void RimWellLogCurveCommonDataSource::resetDefaultOptions()
void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector<RimWellLogCurve*>& curves,
const std::vector<RimWellLogTrack*>& tracks )
{
// Reset all options in the UI
resetDefaultOptions();
// Reset all source step fields in the UI
resetSourceStepFields();
// Check to see if the parameters are unique
for ( RimWellLogCurve* curve : curves )
@ -838,21 +848,19 @@ void RimWellLogCurveCommonDataSource::fieldChangedByUi( const caf::PdmFieldHandl
RimWellLogPlot* parentPlot = nullptr;
this->firstAncestorOrThisOfType( parentPlot );
if ( changedField == &m_branchDetection )
if ( changedField == &m_wellPath && m_wellPath() == m_refWellPath() )
{
if ( m_branchDetection().isPartiallyTrue() )
{
// The Tristate is cycled from false -> partially true -> true
// Partially true is used for "Mixed state" and is not settable by the user so cycle on to true.
m_branchDetection.v() = caf::Tristate::State::True;
}
m_refWellPath = nullptr;
}
if ( changedField == &m_wbsSmoothing )
if ( changedField == &m_branchDetection && m_branchDetection().isPartiallyTrue() )
{
if ( m_wbsSmoothing().isPartiallyTrue() )
{
m_wbsSmoothing.v() = caf::Tristate::State::True;
}
// The Tristate is cycled from false -> partially true -> true
// Partially true is used for "Mixed state" and is not settable by the user so cycle on to true.
m_branchDetection.v() = caf::Tristate::State::True;
}
if ( changedField == &m_wbsSmoothing && m_wbsSmoothing().isPartiallyTrue() )
{
m_wbsSmoothing.v() = caf::Tristate::State::True;
}
this->applyDataSourceChanges();
@ -929,6 +937,11 @@ QList<caf::PdmOptionItemInfo>
}
}
}
else if ( fieldNeedingOptions == &m_refWellPath )
{
options.push_back( caf::PdmOptionItemInfo( QString( "None" ), nullptr ) );
RimTools::wellPathOptionItemsSubset( { m_wellPath() }, &options );
}
else if ( fieldNeedingOptions == &m_timeStep )
{
if ( m_case() )
@ -1026,13 +1039,14 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca
if ( m_case() ) group->add( &m_case );
if ( m_summaryCase() ) group->add( &m_summaryCase );
auto* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
const auto* eclipseCase = dynamic_cast<RimEclipseCase*>( m_case() );
if ( eclipseCase )
{
group->add( &m_trajectoryType );
if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::WELL_PATH )
{
group->add( &m_wellPath );
group->add( &m_refWellPath );
}
else if ( trajectoryTypeToApply() == RimWellLogExtractionCurve::SIMULATION_WELL )
{
@ -1059,6 +1073,7 @@ void RimWellLogCurveCommonDataSource::defineUiOrdering( QString uiConfigName, ca
else
{
if ( m_wellPath() ) group->add( &m_wellPath );
group->add( &m_refWellPath );
}
if ( uiConfigName == smoothingUiOrderinglabel() )
@ -1086,8 +1101,8 @@ void RimWellLogCurveCommonDataSource::defineEditorAttribute( const caf::PdmField
if ( myAttr )
{
if ( field == &m_case || field == &m_summaryCase || field == &m_simWellName || field == &m_wellPath ||
field == &m_timeStep || field == &m_rftTimeStep || field == &m_rftSegmentBranchIndex ||
field == &m_rftWellName )
field == &m_refWellPath || field == &m_timeStep || field == &m_rftTimeStep ||
field == &m_rftSegmentBranchIndex || field == &m_rftWellName )
{
myAttr->showPreviousAndNextButtons = true;
myAttr->nextIcon = QIcon( ":/ComboBoxDown.svg" );

View File

@ -67,6 +67,7 @@ public:
void setTrajectoryTypeToApply( int val );
RimWellPath* wellPathToApply() const;
void setWellPathToApply( RimWellPath* val );
RimWellPath* referenceWellPathToApply() const;
int branchIndexToApply() const;
void setBranchIndexToApply( int val );
caf::Tristate branchDetectionToApply() const;
@ -87,7 +88,6 @@ public:
QDateTime rftTime() const;
int rftBranchIndex() const;
void resetDefaultOptions();
void analyseCurvesAndTracks( const std::vector<RimWellLogCurve*>& curves, const std::vector<RimWellLogTrack*>& tracks );
void analyseCurvesAndTracks();
void applyDataSourceChanges( const std::vector<RimWellLogCurve*>& curves, const std::vector<RimWellLogTrack*>& tracks );
@ -112,6 +112,7 @@ private:
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute ) override;
void modifyCurrentIndex( caf::PdmValueField* field, int indexOffset );
void resetSourceStepFields();
RifReaderRftInterface* rftReader();
@ -122,6 +123,7 @@ private:
caf::PdmPtrField<RimSummaryCase*> m_summaryCase;
caf::PdmField<int> m_trajectoryType;
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmPtrField<RimWellPath*> m_refWellPath;
caf::PdmField<QString> m_simWellName;
caf::PdmField<bool> m_allow3DSelectionLink;
caf::PdmField<int> m_branchIndex;

View File

@ -36,6 +36,7 @@
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigSimulationWellCoordsAndMD.h"
#include "RigWellLogCurveData.h"
#include "RigWellLogIndexDepthOffset.h"
#include "RigWellPath.h"
#include "RimEclipseCase.h"
@ -67,6 +68,7 @@
#include "cafPdmUiTreeOrdering.h"
#include "cafUtils.h"
#include <algorithm>
#include <cmath>
//==================================================================================================
@ -436,55 +438,94 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength,
clampBranchIndex();
RimWellLogPlotCollection* wellLogCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
cvf::ref<RigEclipseWellLogExtractor> eclExtractor;
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor;
WellLogExtractionCurveData curveData;
if ( eclipseCase )
{
if ( m_trajectoryType == WELL_PATH )
{
eclExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase );
}
else
{
std::vector<const RigWellPath*> simWellBranches =
RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection );
if ( m_branchIndex >= 0 && m_branchIndex < static_cast<int>( simWellBranches.size() ) )
{
auto wellBranch = simWellBranches[m_branchIndex];
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor( m_simWellName,
eclipseCase->caseUserDescription(),
wellBranch,
eclipseCase->eclipseCaseData() );
if ( eclExtractor.notNull() )
{
m_wellPathsWithExtractors.push_back( wellBranch );
}
*isUsingPseudoLength = true;
}
}
curveData = extractEclipseData( eclipseCase, isUsingPseudoLength );
}
else if ( geomCase )
{
geomExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, geomCase );
curveData = extractGeomData( geomCase, isUsingPseudoLength, performDataSmoothing, smoothingThreshold );
}
std::vector<double> values;
std::vector<double> measuredDepthValues;
std::vector<double> tvDepthValues;
double rkbDiff = 0.0;
RiaDefines::DepthUnitType depthUnit = RiaDefines::DepthUnitType::UNIT_METER;
QString xUnits = RiaWellLogUnitTools<double>::noUnitString();
if ( eclExtractor.notNull() )
if ( !curveData.values.empty() && !curveData.measuredDepthValues.empty() )
{
measuredDepthValues = eclExtractor->cellIntersectionMDs();
tvDepthValues = eclExtractor->cellIntersectionTVDs();
rkbDiff = eclExtractor->wellPathGeometry()->rkbDiff();
bool useLogarithmicScale = false;
RimWellLogTrack* track = nullptr;
firstAncestorOfType( track );
if ( track )
{
useLogarithmicScale = track->isLogarithmicScale();
}
if ( curveData.tvDepthValues.empty() )
{
this->setPropertyValuesAndDepths( curveData.values,
curveData.measuredDepthValues,
RiaDefines::DepthTypeEnum::MEASURED_DEPTH,
0.0,
curveData.depthUnit,
!performDataSmoothing,
useLogarithmicScale,
curveData.xUnits );
}
else
{
this->setPropertyValuesWithMdAndTVD( curveData.values,
curveData.measuredDepthValues,
curveData.tvDepthValues,
curveData.rkbDiff,
curveData.depthUnit,
!performDataSmoothing,
useLogarithmicScale,
curveData.xUnits );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve::WellLogExtractionCurveData
RimWellLogExtractionCurve::extractEclipseData( RimEclipseCase* eclipseCase, bool* isUsingPseudoLength )
{
WellLogExtractionCurveData curveData;
RimWellLogPlotCollection* wellLogCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
cvf::ref<RigEclipseWellLogExtractor> wellExtractor;
cvf::ref<RigEclipseWellLogExtractor> refWellExtractor;
if ( m_trajectoryType == WELL_PATH )
{
wellExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, eclipseCase );
refWellExtractor = wellLogCollection->findOrCreateExtractor( m_refWellPath, eclipseCase );
}
else
{
std::vector<const RigWellPath*> simWellBranches =
RiaSimWellBranchTools::simulationWellBranches( m_simWellName, m_branchDetection );
if ( m_branchIndex >= 0 && m_branchIndex < static_cast<int>( simWellBranches.size() ) )
{
auto wellBranch = simWellBranches[m_branchIndex];
wellExtractor = wellLogCollection->findOrCreateSimWellExtractor( m_simWellName,
eclipseCase->caseUserDescription(),
wellBranch,
eclipseCase->eclipseCaseData() );
if ( wellExtractor.notNull() )
{
m_wellPathsWithExtractors.push_back( wellBranch );
}
*isUsingPseudoLength = true;
}
}
if ( wellExtractor.notNull() )
{
curveData.measuredDepthValues = wellExtractor->cellIntersectionMDs();
curveData.tvDepthValues = wellExtractor->cellIntersectionTVDs();
curveData.rkbDiff = wellExtractor->wellPathGeometry()->rkbDiff();
m_eclipseResultDefinition->loadResult();
@ -496,7 +537,7 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength,
if ( resAcc.notNull() )
{
eclExtractor->curveData( resAcc.p(), &values );
wellExtractor->curveData( resAcc.p(), &curveData.values );
}
RiaDefines::EclipseUnitSystem eclipseUnitsType = eclipseCase->eclipseCaseData()->unitsType();
@ -504,72 +545,216 @@ void RimWellLogExtractionCurve::extractData( bool* isUsingPseudoLength,
{
// See https://github.com/OPM/ResInsight/issues/538
depthUnit = RiaDefines::DepthUnitType::UNIT_FEET;
curveData.depthUnit = RiaDefines::DepthUnitType::UNIT_FEET;
}
}
else if ( geomExtractor.notNull() ) // geomExtractor
{
measuredDepthValues = geomExtractor->cellIntersectionMDs();
tvDepthValues = geomExtractor->cellIntersectionTVDs();
rkbDiff = geomExtractor->wellPathGeometry()->rkbDiff();
if ( measuredDepthValues.empty() )
// Reference well adjustment does not support simulated wells
if ( m_trajectoryType == WELL_PATH && wellExtractor.notNull() && refWellExtractor.notNull() )
{
// ************************************************
//
// Adjust measured dept values according to refWell
//
// ************************************************
RigEclipseResultAddress indexKResAdr( RiaResultNames::indexKResultName() );
cvf::ref<RigResultAccessor> indexKResAcc =
RigResultAccessorFactory::createFromResultAddress( eclipseCase->eclipseCaseData(),
0,
RiaDefines::PorosityModelType::MATRIX_MODEL,
m_timeStep,
indexKResAdr );
std::vector<double> refWellMeasuredDepthValues = refWellExtractor->cellIntersectionMDs();
std::vector<double> refWellTvDepthValues = refWellExtractor->cellIntersectionTVDs();
std::vector<double> wellIndexKValues;
std::vector<double> refWellIndexKValues;
if ( indexKResAcc.notNull() )
{
return;
wellExtractor->curveData( indexKResAcc.p(), &wellIndexKValues );
refWellExtractor->curveData( indexKResAcc.p(), &refWellIndexKValues );
}
if ( !wellIndexKValues.empty() && !refWellIndexKValues.empty() )
{
adjustWellDepthValuesToReferenceWell( curveData.measuredDepthValues,
curveData.tvDepthValues,
wellIndexKValues,
refWellMeasuredDepthValues,
refWellTvDepthValues,
refWellIndexKValues );
}
}
return curveData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve::WellLogExtractionCurveData
RimWellLogExtractionCurve::extractGeomData( RimGeoMechCase* geomCase,
bool* isUsingPseudoLength,
bool performDataSmoothing,
double smoothingThreshold )
{
// TODO: Add depth adjustements for reference well
WellLogExtractionCurveData curveData;
RimWellLogPlotCollection* wellLogCollection = RimMainPlotCollection::current()->wellLogPlotCollection();
cvf::ref<RigGeoMechWellLogExtractor> wellExtractor = wellLogCollection->findOrCreateExtractor( m_wellPath, geomCase );
cvf::ref<RigGeoMechWellLogExtractor> refWellExtractor =
wellLogCollection->findOrCreateExtractor( m_refWellPath, geomCase );
if ( wellExtractor.notNull() )
{
curveData.measuredDepthValues = wellExtractor->cellIntersectionMDs();
curveData.tvDepthValues = wellExtractor->cellIntersectionTVDs();
curveData.rkbDiff = wellExtractor->wellPathGeometry()->rkbDiff();
if ( curveData.measuredDepthValues.empty() )
{
return curveData;
}
findAndLoadWbsParametersFromLasFiles( m_wellPath(), geomExtractor.p() );
findAndLoadWbsParametersFromLasFiles( m_wellPath(), wellExtractor.p() );
RimWellBoreStabilityPlot* wbsPlot;
this->firstAncestorOrThisOfType( wbsPlot );
if ( wbsPlot )
{
wbsPlot->applyWbsParametersToExtractor( geomExtractor.p() );
wbsPlot->applyWbsParametersToExtractor( wellExtractor.p() );
}
m_geomResultDefinition->loadResult();
xUnits = geomExtractor->curveData( m_geomResultDefinition->resultAddress(), m_timeStep, &values );
curveData.xUnits =
wellExtractor->curveData( m_geomResultDefinition->resultAddress(), m_timeStep, &curveData.values );
if ( performDataSmoothing )
{
geomExtractor->performCurveDataSmoothing( m_timeStep,
&measuredDepthValues,
&tvDepthValues,
&values,
wellExtractor->performCurveDataSmoothing( m_timeStep,
&curveData.measuredDepthValues,
&curveData.tvDepthValues,
&curveData.values,
smoothingThreshold );
}
}
if ( !values.empty() && !measuredDepthValues.empty() )
if ( wellExtractor.notNull() && refWellExtractor.notNull() )
{
bool useLogarithmicScale = false;
// Add reference well depth adjustments
RimWellLogTrack* track = nullptr;
firstAncestorOfType( track );
if ( track )
{
useLogarithmicScale = track->isLogarithmicScale();
}
// ************************************************
//
// Adjust measured dept values according to refWell
//
// ************************************************
}
if ( tvDepthValues.empty() )
return curveData;
}
//--------------------------------------------------------------------------------------------------
// Utility function to adjust well depth values according to reference well - match k-index
// enter/exit values and linearize between enter/exit of k-index
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::adjustWellDepthValuesToReferenceWell( std::vector<double>& rMeasuredDepthValues,
std::vector<double>& rTvDepthValues,
const std::vector<double>& indexKValues,
const std::vector<double>& refWellMeasuredDepthValues,
const std::vector<double>& refWellTvDepthValues,
const std::vector<double>& refWellIndexKValues )
{
// Description:
// - Adjust values up to largest common k-index value
// Assumptions:
// - Both wells have min k-index equal to 1.
// - k-index values are continously increasing values between top and bottom of well
CAF_ASSERT( rMeasuredDepthValues.size() == rTvDepthValues.size() &&
"Number of depth values must be equal for well!" );
CAF_ASSERT( rMeasuredDepthValues.size() == indexKValues.size() &&
"Number of index K values must be number of depth values for well!" );
CAF_ASSERT( refWellMeasuredDepthValues.size() == refWellTvDepthValues.size() &&
"Number of depth values must be equal for reference well!" );
CAF_ASSERT( refWellMeasuredDepthValues.size() == refWellIndexKValues.size() &&
"Number of index K values must be number of depth values for reference well!" );
CAF_ASSERT( *std::min( indexKValues.cbegin(), indexKValues.cend() ) ==
*std::min( refWellIndexKValues.cbegin(), refWellIndexKValues.cend() ) &&
"Both index-K value vectors must have same start index-K layer" );
// Find common min and max k-index value for range depth values adjustment
const double minLayerK = std::max( *std::min_element( refWellIndexKValues.cbegin(), refWellIndexKValues.cend() ),
*std::min_element( indexKValues.cbegin(), indexKValues.cend() ) );
const double maxLayerK = std::min( *std::max_element( refWellIndexKValues.cbegin(), refWellIndexKValues.cend() ),
*std::max_element( indexKValues.cbegin(), indexKValues.cend() ) );
if ( minLayerK > maxLayerK )
{
RiaLogging::error(
QString( "Invalid K layers found. Minimum: %1 > Maximum : %2" ).arg( minLayerK ).arg( maxLayerK ) );
return;
}
RigWellLogIndexDepthOffset refWellLogIndexDepthOffset;
for ( int kLayer = static_cast<int>( minLayerK ); kLayer <= static_cast<int>( maxLayerK ); kLayer++ )
{
const auto kLayerTopIter =
std::find( refWellIndexKValues.cbegin(), refWellIndexKValues.cend(), static_cast<double>( kLayer ) );
const auto kLayerBottomRIter =
std::find( refWellIndexKValues.crbegin(), refWellIndexKValues.crend(), static_cast<double>( kLayer ) );
const auto indexTop = std::distance( refWellIndexKValues.cbegin(), kLayerTopIter );
const auto indexBottom = refWellIndexKValues.size() - 1 -
std::distance( refWellIndexKValues.crbegin(), kLayerBottomRIter );
const auto topMd = refWellMeasuredDepthValues[indexTop];
const auto bottomMd = refWellMeasuredDepthValues[indexBottom];
const auto topTvd = refWellTvDepthValues[indexTop];
const auto bottomTvd = refWellTvDepthValues[indexBottom];
refWellLogIndexDepthOffset.setIndexOffsetDepth( kLayer, topMd, bottomMd, topTvd, bottomTvd );
}
std::map<int, std::vector<size_t>> wellKLayerAndIndexesMap = {};
for ( size_t i = 0; i < indexKValues.size(); i++ )
{
const int kLayer = static_cast<int>( indexKValues[i] );
wellKLayerAndIndexesMap[kLayer].push_back( i );
}
for ( const auto& [kLayer, indexes] : wellKLayerAndIndexesMap )
{
const auto firstIdx = indexes.front();
const auto lastIdx = indexes.back();
if ( indexes.size() == 2 && refWellLogIndexDepthOffset.hasIndex( kLayer ) )
{
this->setPropertyValuesAndDepths( values,
measuredDepthValues,
RiaDefines::DepthTypeEnum::MEASURED_DEPTH,
0.0,
depthUnit,
!performDataSmoothing,
useLogarithmicScale,
xUnits );
rMeasuredDepthValues[firstIdx] = refWellLogIndexDepthOffset.getTopMd( kLayer );
rMeasuredDepthValues[lastIdx] = refWellLogIndexDepthOffset.getBottomMd( kLayer );
rTvDepthValues[firstIdx] = refWellLogIndexDepthOffset.getTopTvd( kLayer );
rTvDepthValues[lastIdx] = refWellLogIndexDepthOffset.getBottomMd( kLayer );
}
else
else if ( indexes.size() > 2 && refWellLogIndexDepthOffset.hasIndex( kLayer ) )
{
this->setPropertyValuesWithMdAndTVD( values,
measuredDepthValues,
tvDepthValues,
rkbDiff,
depthUnit,
!performDataSmoothing,
useLogarithmicScale,
xUnits );
const auto refWellTopMd = refWellLogIndexDepthOffset.getTopMd( kLayer );
const auto refWellBottomMd = refWellLogIndexDepthOffset.getBottomMd( kLayer );
const auto refWellTopTvd = refWellLogIndexDepthOffset.getTopTvd( kLayer );
const auto refWellBottomTvd = refWellLogIndexDepthOffset.getBottomTvd( kLayer );
// Linearize depth values between top and bottom values in kLayer
const auto topMd = rMeasuredDepthValues[firstIdx];
const auto bottomMd = rMeasuredDepthValues[lastIdx];
const auto topTvd = rTvDepthValues[firstIdx];
const auto bottomTvd = rTvDepthValues[lastIdx];
for ( auto it = indexes.cbegin() + 1; it != indexes.cend() - 1; ++it )
{
const auto idx = *it;
const auto percMd = ( rMeasuredDepthValues[idx] - topMd ) / ( bottomMd - topMd );
const auto percTvd = ( rTvDepthValues[idx] - topTvd ) / ( bottomTvd - topTvd );
rMeasuredDepthValues[idx] = percMd * ( refWellBottomMd - refWellTopMd ) + refWellTopMd;
rTvDepthValues[idx] = percTvd * ( refWellBottomTvd - refWellTopTvd ) + refWellTopTvd;
}
rMeasuredDepthValues[firstIdx] = refWellTopMd;
rMeasuredDepthValues[lastIdx] = refWellBottomMd;
rTvDepthValues[firstIdx] = refWellTopTvd;
rTvDepthValues[lastIdx] = refWellBottomTvd;
}
}
}
@ -701,9 +886,6 @@ void RimWellLogExtractionCurve::clearGeneratedSimWellPaths()
m_wellPathsWithExtractors.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimWellLogExtractionCurve::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
@ -752,7 +934,6 @@ void RimWellLogExtractionCurve::defineUiOrdering( QString uiConfigName, caf::Pdm
RimPlotCurve::updateFieldUiState();
caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword( "Data Source", dataSourceGroupKeyword() );
curveDataGroup->add( &m_case );
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>( m_case.value() );
@ -764,6 +945,7 @@ void RimWellLogExtractionCurve::defineUiOrdering( QString uiConfigName, caf::Pdm
if ( m_trajectoryType() == WELL_PATH )
{
curveDataGroup->add( &m_wellPath );
RimWellLogCurve::defineUiOrdering( uiConfigName, uiOrdering );
}
else
{
@ -779,6 +961,8 @@ void RimWellLogExtractionCurve::defineUiOrdering( QString uiConfigName, caf::Pdm
else if ( geomCase )
{
curveDataGroup->add( &m_wellPath );
RimWellLogCurve::defineUiOrdering( uiConfigName, uiOrdering );
m_geomResultDefinition->uiOrdering( uiConfigName, *curveDataGroup );
}
@ -917,6 +1101,11 @@ QString RimWellLogExtractionCurve::createCurveAutoName()
}
}
if ( m_refWellPath && !m_refWellPath->name().isEmpty() )
{
generatedCurveName.push_back( QString( "Ref. Well: %1" ).arg( m_refWellPath->name() ) );
}
return generatedCurveName.join( ", " );
}

View File

@ -20,6 +20,9 @@
#pragma once
#include "RigWbsParameter.h"
#include "RimEclipseCase.h"
#include "RimGeoMechCase.h"
#include "RimWellLogCurve.h"
#include "cafPdmChildField.h"
@ -137,4 +140,28 @@ protected:
caf::PdmField<bool> m_addDateToCurveName;
std::vector<const RigWellPath*> m_wellPathsWithExtractors;
private:
struct WellLogExtractionCurveData
{
std::vector<double> values = std::vector<double>();
std::vector<double> measuredDepthValues = std::vector<double>();
std::vector<double> tvDepthValues = std::vector<double>();
double rkbDiff = 0.0;
RiaDefines::DepthUnitType depthUnit = RiaDefines::DepthUnitType::UNIT_METER;
QString xUnits = RiaWellLogUnitTools<double>::noUnitString();
};
private:
WellLogExtractionCurveData extractEclipseData( RimEclipseCase* eclipseCase, bool* isUsingPseudoLength );
WellLogExtractionCurveData extractGeomData( RimGeoMechCase* geomCase,
bool* isUsingPseudoLength,
bool performDataSmoothing = false,
double smoothingThreshold = -1.0 );
void adjustWellDepthValuesToReferenceWell( std::vector<double>& rMeasuredDepthValues,
std::vector<double>& rTvDepthValues,
const std::vector<double>& indexKValues,
const std::vector<double>& refWellMeasuredDepthValues,
const std::vector<double>& refWellTvDepthValues,
const std::vector<double>& refWellIndexKValues );
};

View File

@ -99,3 +99,11 @@ std::vector<int> RigWellLogIndexDepthOffset::sortedIndexes() const
std::sort( indexes.begin(), indexes.end() );
return indexes;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigWellLogIndexDepthOffset::hasIndex( int kIndex ) const
{
return m_mdOffsets.count( kIndex ) > 0;
}

View File

@ -34,6 +34,7 @@ public:
double getTopTvd( int kIndex ) const;
double getBottomTvd( int kIndex ) const;
std::vector<int> sortedIndexes() const;
bool hasIndex( int kIndex ) const;
private:
std::map<int, std::pair<double, double>> m_mdOffsets;