2022-08-17 03:04:10 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2022 Equinor ASA
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2022-08-18 00:12:23 -05:00
|
|
|
#include "RicNewRftSegmentWellLogPlotFeature.h"
|
2022-08-17 03:04:10 -05:00
|
|
|
|
|
|
|
#include "RicNewWellLogPlotFeatureImpl.h"
|
|
|
|
#include "RicWellLogPlotCurveFeatureImpl.h"
|
|
|
|
#include "RicWellLogTools.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2022-10-27 04:17:41 -05:00
|
|
|
#include "RiaColorTools.h"
|
2022-12-09 01:47:40 -06:00
|
|
|
#include "RiaLogging.h"
|
2022-10-27 04:17:41 -05:00
|
|
|
#include "RiaPlotWindowRedrawScheduler.h"
|
2022-08-17 03:04:10 -05:00
|
|
|
#include "RiaRftDefines.h"
|
2023-03-08 00:35:27 -06:00
|
|
|
#include "RiaSummaryTools.h"
|
2022-08-17 03:04:10 -05:00
|
|
|
|
2022-10-07 05:37:23 -05:00
|
|
|
#include "RifReaderOpmRft.h"
|
|
|
|
|
2022-08-17 03:04:10 -05:00
|
|
|
#include "RimRftCase.h"
|
2022-10-07 05:37:23 -05:00
|
|
|
#include "RimRftTopologyCurve.h"
|
2022-08-17 03:04:10 -05:00
|
|
|
#include "RimSummaryCase.h"
|
2022-10-27 04:17:41 -05:00
|
|
|
#include "RimWellLogRftCurve.h"
|
2022-08-17 03:04:10 -05:00
|
|
|
#include "RimWellLogTrack.h"
|
|
|
|
|
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
#include "RiuPlotMainWindowTools.h"
|
|
|
|
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
|
|
|
#include <QAction>
|
|
|
|
|
2022-08-18 01:09:05 -05:00
|
|
|
CAF_CMD_SOURCE_INIT( RicNewRftSegmentWellLogPlotFeature, "RicNewRftSegmentWellLogPlotFeature" );
|
2022-08-17 03:04:10 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-08-18 00:12:23 -05:00
|
|
|
bool RicNewRftSegmentWellLogPlotFeature::isCommandEnabled()
|
2022-08-17 03:04:10 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-08-18 00:12:23 -05:00
|
|
|
void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked )
|
2022-08-17 03:04:10 -05:00
|
|
|
{
|
2023-03-08 00:35:27 -06:00
|
|
|
RimSummaryCase* summaryCase = RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase();
|
2022-10-07 05:37:23 -05:00
|
|
|
if ( !summaryCase ) return;
|
2022-08-17 03:04:10 -05:00
|
|
|
|
2022-10-07 05:37:23 -05:00
|
|
|
auto rftReader = summaryCase->rftReader();
|
2022-12-09 01:47:40 -06:00
|
|
|
if ( !rftReader )
|
2022-08-17 03:04:10 -05:00
|
|
|
{
|
2022-12-09 01:47:40 -06:00
|
|
|
RiaLogging::error( "Could not open RFT file or no RFT file present. " );
|
|
|
|
return;
|
2022-08-17 03:04:10 -05:00
|
|
|
}
|
|
|
|
|
2023-03-08 00:35:27 -06:00
|
|
|
auto plot = RicNewWellLogPlotFeatureImpl::createRftSegmentPlot();
|
2022-12-09 01:47:40 -06:00
|
|
|
|
|
|
|
QString wellName = "Unknown";
|
|
|
|
auto wellNames = rftReader->wellNames();
|
|
|
|
if ( !wellNames.empty() ) wellName = *wellNames.begin();
|
|
|
|
|
2023-03-13 02:10:33 -05:00
|
|
|
// Reservoir rates can be available on both annulus and device
|
|
|
|
for ( auto branchType : { RiaDefines::RftBranchType::RFT_ANNULUS, RiaDefines::RftBranchType::RFT_DEVICE } )
|
2022-10-27 04:17:41 -05:00
|
|
|
{
|
2023-03-13 02:10:33 -05:00
|
|
|
QString trackName = "Reservoir Rates - " + caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
|
|
|
|
|
2023-03-06 07:34:22 -06:00
|
|
|
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
2022-10-27 04:17:41 -05:00
|
|
|
plot->addPlot( plotTrack );
|
2023-03-13 02:10:33 -05:00
|
|
|
plotTrack->setDescription( trackName );
|
2022-10-27 04:17:41 -05:00
|
|
|
|
2023-03-13 02:10:33 -05:00
|
|
|
auto curve = createAndAddCurve( plotTrack, "CONGRAT", wellName, branchType, summaryCase );
|
2022-10-27 04:17:41 -05:00
|
|
|
curve->setScaleFactor( 1e-3 );
|
|
|
|
curve->setFillStyle( Qt::SolidPattern );
|
|
|
|
}
|
2022-10-07 05:37:23 -05:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
for ( auto branchType :
|
|
|
|
{ RiaDefines::RftBranchType::RFT_ANNULUS, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_TUBING } )
|
2022-10-07 05:37:23 -05:00
|
|
|
{
|
2022-10-27 04:17:41 -05:00
|
|
|
QString resultName = "SEGGRAT";
|
2023-03-06 07:34:22 -06:00
|
|
|
QString trackName = caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
|
|
|
|
trackName += " Rates";
|
|
|
|
auto curve = appendTrackAndCurveForBranchType( plot, trackName, resultName, wellName, branchType, summaryCase );
|
2022-10-27 04:17:41 -05:00
|
|
|
curve->setScaleFactor( 1e-3 );
|
|
|
|
curve->setFillStyle( Qt::SolidPattern );
|
2022-08-17 03:04:10 -05:00
|
|
|
}
|
|
|
|
|
2022-10-27 04:17:41 -05:00
|
|
|
appendPressureTrack( plot, wellName, summaryCase );
|
|
|
|
appendConnectionFactorTrack( plot, wellName, summaryCase );
|
2022-10-07 05:37:23 -05:00
|
|
|
appendTopologyTrack( plot, wellName, summaryCase );
|
2022-10-27 04:17:41 -05:00
|
|
|
|
2022-10-07 05:37:23 -05:00
|
|
|
plot->loadDataAndUpdate();
|
2023-03-06 07:34:22 -06:00
|
|
|
plot->updateTrackVisibility();
|
2022-10-07 05:37:23 -05:00
|
|
|
|
2022-10-27 04:17:41 -05:00
|
|
|
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
|
|
|
plot->updateLayout();
|
|
|
|
|
2022-08-18 05:37:51 -05:00
|
|
|
RiuPlotMainWindowTools::onObjectAppended( plot );
|
2022-08-17 03:04:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
RimWellLogRftCurve* RicNewRftSegmentWellLogPlotFeature::appendTrackAndCurveForBranchType( RimWellLogPlot* plot,
|
|
|
|
const QString& trackName,
|
|
|
|
const QString& resultName,
|
|
|
|
const QString& wellName,
|
2022-10-27 04:17:41 -05:00
|
|
|
RiaDefines::RftBranchType branchType,
|
2023-02-26 03:48:40 -06:00
|
|
|
RimSummaryCase* summaryCase )
|
2022-08-17 03:04:10 -05:00
|
|
|
{
|
2023-03-06 07:34:22 -06:00
|
|
|
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
2022-08-17 03:04:10 -05:00
|
|
|
plot->addPlot( plotTrack );
|
2022-10-27 04:17:41 -05:00
|
|
|
plotTrack->setDescription( trackName );
|
2022-08-17 03:04:10 -05:00
|
|
|
|
2022-10-27 04:17:41 -05:00
|
|
|
auto curve = createAndAddCurve( plotTrack, resultName, wellName, branchType, summaryCase );
|
|
|
|
|
|
|
|
curve->updateAllRequiredEditors();
|
|
|
|
|
|
|
|
return curve;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogRftCurve* RicNewRftSegmentWellLogPlotFeature::createAndAddCurve( RimWellLogTrack* track,
|
|
|
|
const QString& resultName,
|
|
|
|
const QString& wellName,
|
|
|
|
RiaDefines::RftBranchType branchType,
|
|
|
|
RimSummaryCase* summaryCase )
|
|
|
|
{
|
|
|
|
auto curve = RicWellLogTools::addSummaryRftSegmentCurve( track, resultName, wellName, branchType, summaryCase );
|
2022-10-12 05:41:08 -05:00
|
|
|
curve->setNamingMethod( RiaDefines::ObjectNamingMethod::TEMPLATE );
|
|
|
|
|
|
|
|
QString templateText = RiaDefines::namingVariableResultName() + ", " + RiaDefines::namingVariableResultType();
|
|
|
|
curve->setCurveNameTemplateText( templateText );
|
|
|
|
|
2022-10-27 04:17:41 -05:00
|
|
|
return curve;
|
2022-08-17 03:04:10 -05:00
|
|
|
}
|
|
|
|
|
2022-10-17 12:48:24 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
std::vector<RimPlotCurve*> RicNewRftSegmentWellLogPlotFeature::appendAdditionalDataSourceTrack( RimWellLogPlot* plot,
|
2023-02-26 03:48:40 -06:00
|
|
|
const QString& wellName,
|
2022-10-17 12:48:24 -05:00
|
|
|
RimSummaryCase* summaryCase )
|
|
|
|
{
|
|
|
|
auto additionalDataSourceTrack = new RimWellLogTrack();
|
|
|
|
additionalDataSourceTrack->setDescription( "Additional Data Source Curves" );
|
|
|
|
|
|
|
|
plot->addPlot( additionalDataSourceTrack );
|
|
|
|
additionalDataSourceTrack->setShowWindow( false );
|
|
|
|
|
|
|
|
QString resultName = RiaDefines::segmentNumberResultName();
|
|
|
|
QString templateText = RiaDefines::namingVariableResultName() + ", " + RiaDefines::namingVariableResultType();
|
|
|
|
|
|
|
|
std::vector<RimPlotCurve*> curves;
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
for ( auto branchType :
|
|
|
|
{ RiaDefines::RftBranchType::RFT_TUBING, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_ANNULUS } )
|
2022-10-17 12:48:24 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
auto curve = RicWellLogTools::addSummaryRftSegmentCurve( additionalDataSourceTrack, resultName, wellName, branchType, summaryCase );
|
2022-10-17 12:48:24 -05:00
|
|
|
curve->setFillStyle( Qt::NoBrush );
|
|
|
|
curve->setNamingMethod( RiaDefines::ObjectNamingMethod::TEMPLATE );
|
|
|
|
curve->setCurveNameTemplateText( templateText );
|
|
|
|
|
|
|
|
curves.push_back( curve );
|
|
|
|
}
|
|
|
|
|
|
|
|
additionalDataSourceTrack->updateAllRequiredEditors();
|
|
|
|
|
|
|
|
return curves;
|
|
|
|
}
|
|
|
|
|
2022-10-07 05:37:23 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicNewRftSegmentWellLogPlotFeature::appendTopologyTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase )
|
2022-10-07 05:37:23 -05:00
|
|
|
{
|
2022-12-09 01:47:40 -06:00
|
|
|
auto rftReader = dynamic_cast<RifReaderOpmRft*>( summaryCase->rftReader() );
|
|
|
|
if ( !rftReader ) return;
|
|
|
|
|
2022-10-07 05:37:23 -05:00
|
|
|
QDateTime dateTime;
|
|
|
|
int branchIndex = 1;
|
|
|
|
|
2022-12-09 01:47:40 -06:00
|
|
|
auto timeSteps = rftReader->availableTimeSteps( wellName );
|
|
|
|
if ( !timeSteps.empty() ) dateTime = *timeSteps.rbegin();
|
2022-10-07 05:37:23 -05:00
|
|
|
|
|
|
|
auto track = new RimWellLogTrack();
|
|
|
|
track->setDescription( "Topology" );
|
2022-10-13 06:03:55 -05:00
|
|
|
track->enablePropertyAxis( false );
|
2022-12-14 02:29:17 -06:00
|
|
|
track->setRowSpan( RimPlot::TWO );
|
2022-10-07 05:37:23 -05:00
|
|
|
|
|
|
|
plot->addPlot( track );
|
|
|
|
|
2022-10-17 12:48:24 -05:00
|
|
|
std::vector<RimPlotCurve*> additionalDataSourceCurves = appendAdditionalDataSourceTrack( plot, wellName, summaryCase );
|
2022-10-07 05:37:23 -05:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
for ( auto branchType :
|
|
|
|
{ RiaDefines::RftBranchType::RFT_TUBING, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_ANNULUS } )
|
2022-10-07 05:37:23 -05:00
|
|
|
{
|
2022-10-13 06:03:55 -05:00
|
|
|
auto curve = RimRftTopologyCurve::createTopologyCurve( summaryCase, dateTime, wellName, branchIndex, branchType );
|
2022-10-17 12:48:24 -05:00
|
|
|
curve->setAdditionalDataSources( additionalDataSourceCurves );
|
2022-10-13 06:03:55 -05:00
|
|
|
curve->applyDefaultAppearance();
|
|
|
|
track->addCurve( curve );
|
|
|
|
}
|
|
|
|
|
2022-10-17 12:48:24 -05:00
|
|
|
auto packerCurve = RimRftTopologyCurve::createPackerCurve( summaryCase, dateTime, wellName, branchIndex );
|
|
|
|
packerCurve->setAdditionalDataSources( additionalDataSourceCurves );
|
|
|
|
packerCurve->applyDefaultAppearance();
|
|
|
|
track->addCurve( packerCurve );
|
2022-10-07 05:37:23 -05:00
|
|
|
|
|
|
|
track->updateAllRequiredEditors();
|
|
|
|
}
|
|
|
|
|
2022-10-27 04:17:41 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicNewRftSegmentWellLogPlotFeature::appendPressureTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase )
|
2022-10-27 04:17:41 -05:00
|
|
|
{
|
2023-03-06 07:34:22 -06:00
|
|
|
auto track = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
|
|
|
track->setAutoCheckStateBasedOnCurveData( true );
|
2022-10-27 04:17:41 -05:00
|
|
|
track->setDescription( "Pressure" );
|
|
|
|
|
|
|
|
plot->addPlot( track );
|
|
|
|
|
|
|
|
QString resultName = "SEGPRES";
|
2023-02-26 03:48:40 -06:00
|
|
|
for ( auto branchType :
|
|
|
|
{ RiaDefines::RftBranchType::RFT_TUBING, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_ANNULUS } )
|
2022-10-27 04:17:41 -05:00
|
|
|
{
|
|
|
|
auto curve = createAndAddCurve( track, resultName, wellName, branchType, summaryCase );
|
|
|
|
auto color = RimRftTopologyCurve::colorForRftBranchType( branchType );
|
|
|
|
curve->setColor( color );
|
|
|
|
curve->setLineThickness( 3 );
|
2023-03-06 07:34:22 -06:00
|
|
|
curve->setAutoCheckStateBasedOnCurveData( true );
|
2022-10-27 04:17:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
auto curve = createAndAddCurve( track, "PRESSURE", wellName, RiaDefines::RftBranchType::RFT_ANNULUS, summaryCase );
|
|
|
|
curve->setLineThickness( 3 );
|
2023-03-06 07:34:22 -06:00
|
|
|
curve->setAutoCheckStateBasedOnCurveData( true );
|
2022-10-27 04:17:41 -05:00
|
|
|
|
|
|
|
track->updateAllRequiredEditors();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicNewRftSegmentWellLogPlotFeature::appendConnectionFactorTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase )
|
2022-10-27 04:17:41 -05:00
|
|
|
{
|
|
|
|
QString resultName = "CONFAC";
|
2022-11-14 03:55:08 -06:00
|
|
|
|
|
|
|
// Connection factor data can be found in the tubing, device and annulus branches.
|
|
|
|
// Search for data ordered by annulus, device and tubing.
|
|
|
|
RiaDefines::RftBranchType branchType = RiaDefines::RftBranchType::RFT_ANNULUS;
|
|
|
|
bool foundData = false;
|
|
|
|
if ( RicWellLogTools::hasData( resultName, wellName, branchType, summaryCase ) )
|
|
|
|
{
|
|
|
|
foundData = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !foundData && RicWellLogTools::hasData( resultName, wellName, RiaDefines::RftBranchType::RFT_DEVICE, summaryCase ) )
|
|
|
|
{
|
|
|
|
branchType = RiaDefines::RftBranchType::RFT_DEVICE;
|
|
|
|
foundData = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !foundData && RicWellLogTools::hasData( resultName, wellName, RiaDefines::RftBranchType::RFT_TUBING, summaryCase ) )
|
|
|
|
{
|
|
|
|
branchType = RiaDefines::RftBranchType::RFT_TUBING;
|
|
|
|
foundData = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString trackName = "Connection Factors";
|
2023-02-26 03:48:40 -06:00
|
|
|
auto curve = appendTrackAndCurveForBranchType( plot, trackName, resultName, wellName, branchType, summaryCase );
|
2022-10-27 04:17:41 -05:00
|
|
|
|
|
|
|
auto curveColor = cvf::Color3f( cvf::Color3f::ColorIdent::ORANGE );
|
|
|
|
curve->setColor( curveColor );
|
|
|
|
|
|
|
|
auto fillColor = RiaColorTools::makeLighter( curveColor, 0.3f );
|
|
|
|
curve->setFillColor( fillColor );
|
|
|
|
curve->setFillStyle( Qt::SolidPattern );
|
|
|
|
}
|
|
|
|
|
2023-03-08 00:35:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimSummaryCase* RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase()
|
|
|
|
{
|
|
|
|
auto rftCase = caf::SelectionManager::instance()->selectedItemOfType<RimRftCase>();
|
|
|
|
if ( rftCase )
|
|
|
|
{
|
|
|
|
RimSummaryCase* summaryCase = nullptr;
|
|
|
|
rftCase->firstAncestorOfType( summaryCase );
|
|
|
|
if ( summaryCase ) return summaryCase;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto summaryCases = RiaSummaryTools::singleTopLevelSummaryCases();
|
|
|
|
for ( const auto& candidateCase : summaryCases )
|
|
|
|
{
|
|
|
|
if ( candidateCase && candidateCase->rftReader() )
|
|
|
|
{
|
|
|
|
return candidateCase;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2022-08-17 03:04:10 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2022-08-18 00:12:23 -05:00
|
|
|
void RicNewRftSegmentWellLogPlotFeature::setupActionLook( QAction* actionToSetup )
|
2022-08-17 03:04:10 -05:00
|
|
|
{
|
2023-03-13 02:10:33 -05:00
|
|
|
actionToSetup->setText( "Create Segment Plot" );
|
2022-08-17 03:04:10 -05:00
|
|
|
actionToSetup->setIcon( QIcon( ":/WellLogCurve16x16.png" ) );
|
|
|
|
}
|