2018-06-29 04:48:10 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-09-05 05:24:45 -05:00
|
|
|
//
|
2018-06-29 04:48:10 -05:00
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-05 05:24:45 -05:00
|
|
|
//
|
2018-06-29 04:48:10 -05:00
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
2019-09-05 05:24:45 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-06-29 04:48:10 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicNewWellBoreStabilityPlotFeature.h"
|
|
|
|
|
|
|
|
#include "RicNewWellLogCurveExtractionFeature.h"
|
2019-09-05 05:24:45 -05:00
|
|
|
#include "RicNewWellLogFileCurveFeature.h"
|
|
|
|
#include "RicNewWellLogPlotFeatureImpl.h"
|
2018-06-29 04:48:10 -05:00
|
|
|
#include "RicWellLogTools.h"
|
|
|
|
|
|
|
|
#include "RigFemPartResultsCollection.h"
|
2019-09-05 05:24:45 -05:00
|
|
|
#include "RigFemResultAddress.h"
|
2018-06-29 04:48:10 -05:00
|
|
|
#include "RigGeoMechCaseData.h"
|
|
|
|
#include "RigWellPath.h"
|
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
#include "RimGeoMechView.h"
|
|
|
|
#include "RimProject.h"
|
2019-09-05 05:24:45 -05:00
|
|
|
#include "RimWellBoreStabilityPlot.h"
|
2018-06-29 04:48:10 -05:00
|
|
|
#include "RimWellLogExtractionCurve.h"
|
|
|
|
#include "RimWellLogFile.h"
|
|
|
|
#include "RimWellLogFileChannel.h"
|
2019-09-05 05:24:45 -05:00
|
|
|
#include "RimWellLogFileCurve.h"
|
|
|
|
#include "RimWellLogPlotCollection.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
2018-06-29 04:48:10 -05:00
|
|
|
#include "RimWellPath.h"
|
|
|
|
|
|
|
|
#include "RicWellLogTools.h"
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2018-08-22 03:35:30 -05:00
|
|
|
#include "cafProgressInfo.h"
|
|
|
|
#include "cafSelectionManager.h"
|
2019-09-05 05:24:45 -05:00
|
|
|
#include "cvfAssert.h"
|
|
|
|
#include "cvfMath.h"
|
2018-06-29 04:48:10 -05:00
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QString>
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilityPlotFeature" );
|
2018-06-29 04:48:10 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
///
|
2018-06-29 04:48:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicNewWellBoreStabilityPlotFeature::isCommandEnabled()
|
2019-09-05 05:24:45 -05:00
|
|
|
{
|
2018-06-29 04:48:10 -05:00
|
|
|
Rim3dView* view = RiaApplication::instance()->activeReservoirView();
|
2019-09-05 05:24:45 -05:00
|
|
|
if ( !view ) return false;
|
|
|
|
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view );
|
|
|
|
return geoMechView != nullptr;
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
///
|
2018-06-29 04:48:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::onActionTriggered( bool isChecked )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
|
|
|
|
RimWellLogPlotCollection* plotCollection = caf::SelectionManager::instance()
|
|
|
|
->selectedItemOfType<RimWellLogPlotCollection>();
|
|
|
|
if ( !wellPath )
|
2018-08-22 03:35:30 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
if ( plotCollection )
|
2018-08-22 03:35:30 -05:00
|
|
|
{
|
|
|
|
RimProject* project = nullptr;
|
2019-09-05 05:24:45 -05:00
|
|
|
plotCollection->firstAncestorOrThisOfTypeAsserted( project );
|
2018-08-22 03:35:30 -05:00
|
|
|
std::vector<RimWellPath*> allWellPaths;
|
2019-09-05 05:24:45 -05:00
|
|
|
project->descendantsIncludingThisOfType( allWellPaths );
|
|
|
|
if ( !allWellPaths.empty() )
|
2018-08-22 03:35:30 -05:00
|
|
|
{
|
|
|
|
wellPath = allWellPaths.front();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
if ( !wellPath )
|
2018-08-22 03:35:30 -05:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2018-06-29 04:48:10 -05:00
|
|
|
|
|
|
|
Rim3dView* view = RiaApplication::instance()->activeReservoirView();
|
2019-09-05 05:24:45 -05:00
|
|
|
if ( !view ) return;
|
2018-08-07 07:12:35 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
RimGeoMechView* geoMechView = dynamic_cast<RimGeoMechView*>( view );
|
|
|
|
if ( !geoMechView ) return;
|
2018-06-29 04:48:10 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
caf::ProgressInfo progInfo( 100, "Creating Well Bore Stability Plot" );
|
2019-03-12 05:01:49 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
RimGeoMechCase* geoMechCase = geoMechView->geoMechCase();
|
|
|
|
RimWellBoreStabilityPlot* plot = RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( false,
|
|
|
|
"Well Bore Stability" );
|
2019-03-12 05:01:49 -05:00
|
|
|
|
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
auto task = progInfo.task( "Creating formation track", 2 );
|
|
|
|
createFormationTrack( plot, wellPath, geoMechCase );
|
2019-03-12 05:01:49 -05:00
|
|
|
}
|
2019-09-05 05:24:45 -05:00
|
|
|
|
2019-03-12 05:01:49 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
auto task = progInfo.task( "Creating well design track", 3 );
|
|
|
|
createCasingShoeTrack( plot, wellPath, geoMechCase );
|
2019-03-12 05:01:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
auto task = progInfo.task( "Creating stability curves track", 75 );
|
|
|
|
createStabilityCurvesTrack( plot, wellPath, geoMechView );
|
2019-03-12 05:01:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
auto task = progInfo.task( "Creating angles track", 15 );
|
|
|
|
createAnglesTrack( plot, wellPath, geoMechView );
|
2019-03-12 05:01:49 -05:00
|
|
|
}
|
2018-08-07 07:12:35 -05:00
|
|
|
|
2019-03-12 05:01:49 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
auto task = progInfo.task( "Updating all tracks", 5 );
|
2019-03-12 05:01:49 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
plot->enableAllAutoNameTags( true );
|
|
|
|
plot->setPlotTitleVisible( true );
|
|
|
|
plot->setTrackLegendsVisible( true );
|
|
|
|
plot->setTrackLegendsHorizontal( true );
|
|
|
|
plot->setDepthType( RimWellLogPlot::TRUE_VERTICAL_DEPTH );
|
|
|
|
plot->setDepthAutoZoom( true );
|
2019-03-12 05:01:49 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
RicNewWellLogPlotFeatureImpl::updateAfterCreation( plot );
|
2019-03-12 05:01:49 -05:00
|
|
|
}
|
2018-06-29 04:48:10 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
2018-06-29 04:48:10 -05:00
|
|
|
|
2018-08-07 07:12:35 -05:00
|
|
|
// Make sure the summary plot window is visible
|
2018-06-29 04:48:10 -05:00
|
|
|
RiuPlotMainWindowTools::showPlotMainWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
///
|
2018-06-29 04:48:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::setupActionLook( QAction* actionToSetup )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
actionToSetup->setText( "New Well Bore Stability Plot" );
|
|
|
|
actionToSetup->setIcon( QIcon( ":/WellLogPlot16x16.png" ) );
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::createFormationTrack( RimWellBoreStabilityPlot* plot,
|
|
|
|
RimWellPath* wellPath,
|
|
|
|
RimGeoMechCase* geoMechCase )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
RimWellLogTrack* formationTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "Formations", plot );
|
|
|
|
formationTrack->setFormationWellPath( wellPath );
|
|
|
|
formationTrack->setFormationCase( geoMechCase );
|
2019-09-25 04:59:31 -05:00
|
|
|
formationTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
|
2019-09-05 05:24:45 -05:00
|
|
|
formationTrack->setVisibleXRange( 0.0, 0.0 );
|
|
|
|
formationTrack->setWidthScaleFactor( RimWellLogTrack::NARROW_TRACK );
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::createCasingShoeTrack( RimWellBoreStabilityPlot* plot,
|
|
|
|
RimWellPath* wellPath,
|
|
|
|
RimGeoMechCase* geoMechCase )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
RimWellLogTrack* casingShoeTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false, "Well Design", plot );
|
|
|
|
casingShoeTrack->setWidthScaleFactor( RimWellLogTrack::NARROW_TRACK );
|
|
|
|
casingShoeTrack->setFormationWellPath( wellPath );
|
|
|
|
casingShoeTrack->setFormationCase( geoMechCase );
|
2019-09-25 04:59:31 -05:00
|
|
|
casingShoeTrack->setAnnotationType( RiuPlotAnnotationTool::FORMATION_ANNOTATIONS );
|
|
|
|
casingShoeTrack->setAnnotationDisplay( RiuPlotAnnotationTool::DARK_LINES );
|
|
|
|
casingShoeTrack->setShowRegionLabels( false );
|
2019-09-05 05:24:45 -05:00
|
|
|
casingShoeTrack->setShowWellPathAttributes( true );
|
|
|
|
casingShoeTrack->setWellPathAttributesSource( wellPath );
|
|
|
|
casingShoeTrack->setVisibleXRange( 0.0, 0.0 );
|
|
|
|
casingShoeTrack->setAutoScaleXEnabled( true );
|
|
|
|
casingShoeTrack->loadDataAndUpdate();
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBoreStabilityPlot* plot,
|
|
|
|
RimWellPath* wellPath,
|
|
|
|
RimGeoMechView* geoMechView )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
RimWellLogTrack* stabilityCurvesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false,
|
|
|
|
"Stability Curves",
|
|
|
|
plot );
|
|
|
|
stabilityCurvesTrack->setWidthScaleFactor( RimWellLogTrack::EXTRA_WIDE_TRACK );
|
|
|
|
stabilityCurvesTrack->setAutoScaleXEnabled( true );
|
|
|
|
stabilityCurvesTrack->setTickIntervals( 0.5, 0.05 );
|
|
|
|
stabilityCurvesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR );
|
|
|
|
stabilityCurvesTrack->setFormationWellPath( wellPath );
|
|
|
|
stabilityCurvesTrack->setFormationCase( geoMechView->geoMechCase() );
|
2019-09-30 04:53:54 -05:00
|
|
|
stabilityCurvesTrack->setAnnotationType( RiuPlotAnnotationTool::NO_ANNOTATIONS );
|
2019-09-25 04:59:31 -05:00
|
|
|
stabilityCurvesTrack->setShowRegionLabels( true );
|
2018-07-06 02:16:03 -05:00
|
|
|
|
2018-07-02 02:47:34 -05:00
|
|
|
std::vector<QString> resultNames = RiaDefines::wellPathStabilityResultNames();
|
2018-06-29 04:48:10 -05:00
|
|
|
|
2019-09-30 04:53:54 -05:00
|
|
|
std::vector<cvf::Color3f> colors = {cvf::Color3f::BLUE,
|
|
|
|
cvf::Color3f::BROWN,
|
|
|
|
cvf::Color3f::RED,
|
2019-09-05 05:24:45 -05:00
|
|
|
cvf::Color3f::PURPLE,
|
2019-09-30 04:53:54 -05:00
|
|
|
cvf::Color3f::DARK_GREEN};
|
2019-09-05 05:24:45 -05:00
|
|
|
|
|
|
|
for ( size_t i = 0; i < resultNames.size(); ++i )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
const QString& resultName = resultNames[i];
|
|
|
|
RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" );
|
2019-09-11 05:51:25 -05:00
|
|
|
RimWellLogExtractionCurve* curve = RicWellLogTools::addExtractionCurve( stabilityCurvesTrack,
|
|
|
|
geoMechView,
|
|
|
|
wellPath,
|
|
|
|
nullptr,
|
|
|
|
-1,
|
|
|
|
false,
|
|
|
|
false );
|
2019-09-05 05:24:45 -05:00
|
|
|
curve->setGeoMechResultAddress( resAddr );
|
|
|
|
curve->setCurrentTimeStep( geoMechView->currentTimeStep() );
|
|
|
|
curve->setCustomName( resultName );
|
|
|
|
curve->setColor( colors[i % colors.size()] );
|
|
|
|
curve->setLineThickness( 2 );
|
|
|
|
curve->loadDataAndUpdate( false );
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
|
|
|
stabilityCurvesTrack->calculateXZoomRangeAndUpdateQwt();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-05 05:24:45 -05:00
|
|
|
void RicNewWellBoreStabilityPlotFeature::createAnglesTrack( RimWellBoreStabilityPlot* plot,
|
|
|
|
RimWellPath* wellPath,
|
|
|
|
RimGeoMechView* geoMechView )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
RimWellLogTrack* wellPathAnglesTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack( false,
|
|
|
|
"Well Path Angles",
|
|
|
|
plot );
|
|
|
|
double minValue = 360.0, maxValue = 0.0;
|
|
|
|
const double angleIncrement = 90.0;
|
|
|
|
std::vector<QString> resultNames = RiaDefines::wellPathAngleResultNames();
|
|
|
|
|
2019-09-30 04:53:54 -05:00
|
|
|
std::vector<cvf::Color3f> colors = {cvf::Color3f::GREEN, cvf::Color3f::ORANGE};
|
2018-07-02 07:49:40 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
std::vector<RiuQwtPlotCurve::LineStyleEnum> lineStyles = {RiuQwtPlotCurve::STYLE_SOLID, RiuQwtPlotCurve::STYLE_DASH};
|
2018-07-02 07:49:40 -05:00
|
|
|
|
2019-09-05 05:24:45 -05:00
|
|
|
for ( size_t i = 0; i < resultNames.size(); ++i )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
2019-09-05 05:24:45 -05:00
|
|
|
const QString& resultName = resultNames[i];
|
|
|
|
RigFemResultAddress resAddr( RIG_WELLPATH_DERIVED, resultName.toStdString(), "" );
|
|
|
|
RimWellLogExtractionCurve* curve =
|
2019-09-11 05:51:25 -05:00
|
|
|
RicWellLogTools::addExtractionCurve( wellPathAnglesTrack, geoMechView, wellPath, nullptr, -1, false, false );
|
2019-09-05 05:24:45 -05:00
|
|
|
curve->setGeoMechResultAddress( resAddr );
|
|
|
|
curve->setCurrentTimeStep( geoMechView->currentTimeStep() );
|
|
|
|
curve->setCustomName( resultName );
|
|
|
|
|
|
|
|
curve->setColor( colors[i % colors.size()] );
|
|
|
|
curve->setLineStyle( lineStyles[i % lineStyles.size()] );
|
|
|
|
curve->setLineThickness( 2 );
|
|
|
|
|
|
|
|
curve->loadDataAndUpdate( false );
|
|
|
|
|
2018-06-29 04:48:10 -05:00
|
|
|
double actualMinValue = minValue, actualMaxValue = maxValue;
|
2019-09-11 08:54:59 -05:00
|
|
|
curve->xValueRangeInQwt( &actualMinValue, &actualMaxValue );
|
2019-09-05 05:24:45 -05:00
|
|
|
while ( maxValue < actualMaxValue )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
|
|
|
maxValue += angleIncrement;
|
|
|
|
}
|
2019-09-05 05:24:45 -05:00
|
|
|
while ( minValue > actualMinValue )
|
2018-06-29 04:48:10 -05:00
|
|
|
{
|
|
|
|
minValue -= angleIncrement;
|
|
|
|
}
|
2019-09-05 05:24:45 -05:00
|
|
|
maxValue = cvf::Math::clamp( maxValue, angleIncrement, 360.0 );
|
|
|
|
minValue = cvf::Math::clamp( minValue, 0.0, maxValue - 90.0 );
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|
2019-09-05 05:24:45 -05:00
|
|
|
wellPathAnglesTrack->setWidthScaleFactor( RimWellLogTrack::NORMAL_TRACK );
|
|
|
|
wellPathAnglesTrack->setVisibleXRange( minValue, maxValue );
|
|
|
|
wellPathAnglesTrack->setTickIntervals( 90.0, 30.0 );
|
|
|
|
wellPathAnglesTrack->setXAxisGridVisibility( RimWellLogPlot::AXIS_GRID_MAJOR_AND_MINOR );
|
|
|
|
wellPathAnglesTrack->setFormationWellPath( wellPath );
|
|
|
|
wellPathAnglesTrack->setFormationCase( geoMechView->geoMechCase() );
|
2019-09-25 04:59:31 -05:00
|
|
|
wellPathAnglesTrack->setAnnotationType( RiuPlotAnnotationTool::NO_ANNOTATIONS );
|
|
|
|
wellPathAnglesTrack->setShowRegionLabels( false );
|
2018-06-29 04:48:10 -05:00
|
|
|
}
|