Files
ResInsight/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp
T

145 lines
5.9 KiB
C++
Raw Normal View History

2022-10-07 16:08:50 +02: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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicNewMultiPhaseRftSegmentPlotFeature.h"
#include "RicNewRftSegmentWellLogPlotFeature.h"
#include "RicNewWellLogPlotFeatureImpl.h"
#include "RicWellLogPlotCurveFeatureImpl.h"
#include "RicWellLogTools.h"
#include "RiaApplication.h"
2022-12-09 08:47:40 +01:00
#include "RiaLogging.h"
2022-10-27 11:17:41 +02:00
#include "RiaPlotWindowRedrawScheduler.h"
2022-10-07 16:08:50 +02:00
#include "RiaRftDefines.h"
#include "RifReaderOpmRft.h"
2023-03-14 13:14:40 +01:00
#include "RimFileSummaryCase.h"
2022-10-07 16:08:50 +02:00
#include "RimRftCase.h"
#include "RimRftTopologyCurve.h"
#include "RimSummaryCase.h"
#include "RimWellLogPlot.h"
2022-10-27 11:17:41 +02:00
#include "RimWellLogRftCurve.h"
2022-10-07 16:08:50 +02:00
#include "RimWellLogTrack.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicNewMultiPhaseRftSegmentPlotFeature, "RicNewMultiPhaseRftSegmentPlotFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked )
{
2023-03-14 13:14:40 +01:00
auto fileSummaryCase = dynamic_cast<RimFileSummaryCase*>( RicNewRftSegmentWellLogPlotFeature::getSelectedOrFirstRftCase() );
if ( !fileSummaryCase ) return;
2022-10-07 16:08:50 +02:00
2023-03-14 13:14:40 +01:00
fileSummaryCase->searchForWseglinkAndRecreateRftReader();
auto rftReader = fileSummaryCase->rftReader();
2022-12-09 08:47:40 +01:00
if ( !rftReader )
{
RiaLogging::error( "Could not open RFT file or no RFT file present. " );
return;
}
2023-03-08 07:35:27 +01:00
auto plot = RicNewWellLogPlotFeatureImpl::createRftSegmentPlot();
2022-10-07 16:08:50 +02:00
QString wellName = "Unknown";
2022-12-09 08:47:40 +01:00
auto wellNames = rftReader->wellNames();
if ( !wellNames.empty() ) wellName = *wellNames.begin();
2022-10-07 16:08:50 +02:00
2023-03-13 19:01:31 +01:00
const auto allBranchTypes = { RiaDefines::RftBranchType::RFT_ANNULUS,
RiaDefines::RftBranchType::RFT_DEVICE,
RiaDefines::RftBranchType::RFT_TUBING };
for ( auto branchType : allBranchTypes )
2023-03-13 08:10:33 +01:00
{
QString trackName = "Reservoir Rates - " + caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
2023-03-14 13:14:40 +01:00
appendTrackAndCurveForBranchType( plot, trackName, { "CONGRAT", "CONORAT", "CONWRAT" }, wellName, branchType, fileSummaryCase );
2023-03-13 08:10:33 +01:00
}
2022-10-07 16:08:50 +02:00
2023-03-13 19:01:31 +01:00
for ( auto branchType : allBranchTypes )
2022-10-07 16:08:50 +02:00
{
2023-03-13 08:10:33 +01:00
QString trackName = caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
trackName += " Rates";
2023-03-06 14:34:22 +01:00
2023-03-14 13:14:40 +01:00
appendTrackAndCurveForBranchType( plot, trackName, { "SEGGRAT", "SEGORAT", "SEGWRAT" }, wellName, branchType, fileSummaryCase );
2022-10-07 16:08:50 +02:00
}
2023-03-14 13:14:40 +01:00
RicNewRftSegmentWellLogPlotFeature::appendPressureTrack( plot, wellName, fileSummaryCase );
RicNewRftSegmentWellLogPlotFeature::appendConnectionFactorTrack( plot, wellName, fileSummaryCase );
RicNewRftSegmentWellLogPlotFeature::appendTopologyTrack( plot, wellName, fileSummaryCase );
2022-10-07 16:08:50 +02:00
plot->loadDataAndUpdate();
2023-03-06 14:34:22 +01:00
plot->updateTrackVisibility();
2022-10-07 16:08:50 +02:00
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdates();
2022-10-27 11:17:41 +02:00
plot->updateLayout();
2022-10-07 16:08:50 +02:00
RiuPlotMainWindowTools::onObjectAppended( plot );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewMultiPhaseRftSegmentPlotFeature::appendTrackAndCurveForBranchType( RimWellLogPlot* plot,
2022-10-27 11:17:41 +02:00
const QString& trackName,
2022-10-07 16:08:50 +02:00
const std::vector<QString>& resultNames,
const QString& wellName,
RiaDefines::RftBranchType branchType,
RimSummaryCase* summaryCase )
{
2023-03-06 14:34:22 +01:00
auto plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
2022-10-07 16:08:50 +02:00
plot->addPlot( plotTrack );
2022-10-27 11:17:41 +02:00
plotTrack->setDescription( trackName );
2022-10-07 16:08:50 +02:00
for ( const auto& resultName : resultNames )
{
auto curve = RicWellLogTools::addSummaryRftSegmentCurve( plotTrack, resultName, wellName, branchType, summaryCase );
curve->setNamingMethod( RiaDefines::ObjectNamingMethod::TEMPLATE );
QString templateText = RiaDefines::namingVariableResultName() + ", " + RiaDefines::namingVariableResultType();
curve->setCurveNameTemplateText( templateText );
2022-10-27 11:17:41 +02:00
if ( resultName == "SEGGRAT" || resultName == "CONGRAT" )
{
curve->setScaleFactor( 1e-3 );
}
curve->setFillStyle( Qt::SolidPattern );
2022-10-07 16:08:50 +02:00
curve->setIsStacked( true );
curve->updateAllRequiredEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicNewMultiPhaseRftSegmentPlotFeature::setupActionLook( QAction* actionToSetup )
{
2023-03-13 08:10:33 +01:00
actionToSetup->setText( "Create Multi Phase Segment Plot" );
2022-10-07 16:08:50 +02:00
actionToSetup->setIcon( QIcon( ":/WellLogCurve16x16.png" ) );
}