2017-03-09 04:16:27 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-03-27 13:20:42 -05:00
|
|
|
//
|
2017-03-09 04:16:27 -06: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-03-27 13:20:42 -05:00
|
|
|
//
|
2017-03-09 04:16:27 -06: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-03-27 13:20:42 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-03-09 04:16:27 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicShowContributingWellsFeatureImpl.h"
|
|
|
|
|
2017-08-17 06:49:51 -05:00
|
|
|
#include "RicSelectOrCreateViewFeatureImpl.h"
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2017-03-09 04:16:27 -06:00
|
|
|
#include "RigFlowDiagResultAddress.h"
|
2024-10-30 11:23:08 -05:00
|
|
|
#include "Well/RigSimWellData.h"
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
#include "RimEclipsePropertyFilter.h"
|
|
|
|
#include "RimEclipsePropertyFilterCollection.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
|
|
|
#include "RimEclipseView.h"
|
2017-10-15 14:20:03 -05:00
|
|
|
#include "RimFaultInViewCollection.h"
|
2017-03-10 06:13:26 -06:00
|
|
|
#include "RimFlowDiagSolution.h"
|
|
|
|
#include "RimProject.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimSimWellInView.h"
|
2019-03-27 13:20:42 -05:00
|
|
|
#include "RimSimWellInViewCollection.h"
|
2017-03-10 06:13:26 -06:00
|
|
|
#include "RimViewManipulator.h"
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2018-02-27 09:00:55 -06:00
|
|
|
#include "Riu3DMainWindowTools.h"
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
#include "cafCmdFeature.h"
|
|
|
|
#include "cafCmdFeatureManager.h"
|
2017-03-10 06:13:26 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-10 06:13:26 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
RimEclipseView*
|
|
|
|
RicShowContributingWellsFeatureImpl::manipulateSelectedView( RimEclipseResultCase* eclipseResultCase, QString wellName, int timeStep )
|
2017-03-10 06:13:26 -06:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
RimEclipseView* viewToManipulate = RicSelectOrCreateViewFeatureImpl::showViewSelection( eclipseResultCase,
|
|
|
|
"lastUsedWellAllocationView",
|
|
|
|
"ContributingWells_" + wellName,
|
|
|
|
"Show Contributing Wells in View" );
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !viewToManipulate ) return nullptr;
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells( viewToManipulate, wellName, timeStep );
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature( "RicShowMainWindowFeature" );
|
|
|
|
feature->actionTriggered( false );
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicSelectOrCreateViewFeatureImpl::focusView( viewToManipulate );
|
2017-03-10 06:13:26 -06:00
|
|
|
|
|
|
|
return viewToManipulate;
|
|
|
|
}
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-09 04:16:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells( RimEclipseView* viewToModify, const QString& wellName, int timeStep )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( viewToModify );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2017-10-13 02:29:42 -05:00
|
|
|
RimSimWellInView* selectedWell = nullptr;
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimSimWellInView* w : viewToModify->wellCollection()->wells() )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( w->name() == wellName )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
selectedWell = w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( selectedWell );
|
2021-04-05 11:18:34 -05:00
|
|
|
if ( !selectedWell ) return;
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2023-05-12 14:41:34 -05:00
|
|
|
RimEclipseResultCase* eclipseResultCase = selectedWell->firstAncestorOrThisOfTypeAsserted<RimEclipseResultCase>();
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
// Use the active flow diag solutions, or the first one as default
|
2017-03-09 16:01:45 -06:00
|
|
|
RimFlowDiagSolution* flowDiagSolution = viewToModify->cellResult()->flowDiagSolution();
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !flowDiagSolution )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2017-03-09 16:01:45 -06:00
|
|
|
flowDiagSolution = eclipseResultCase->defaultFlowDiagSolution();
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
|
2019-03-27 13:20:42 -05:00
|
|
|
// assert(flowDiagSolution);
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( flowDiagSolution );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep( selectedWell->name(), timeStep );
|
2023-06-26 06:12:41 -05:00
|
|
|
if ( tracerStatus != RimFlowDiagSolution::TracerStatusType::INJECTOR && tracerStatus != RimFlowDiagSolution::TracerStatusType::PRODUCER )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
viewToModify->setCurrentTimeStep( timeStep );
|
2020-04-23 16:25:22 -05:00
|
|
|
viewToModify->cellResult()->setResultType( RiaDefines::ResultCatType::FLOW_DIAGNOSTICS );
|
2019-09-06 03:40:57 -05:00
|
|
|
viewToModify->cellResult()->setResultVariable( "MaxFractionTracer" );
|
|
|
|
viewToModify->cellResult()->setFlowSolution( flowDiagSolution );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
switch ( tracerStatus )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2021-04-05 11:18:34 -05:00
|
|
|
case RimFlowDiagSolution::TracerStatusType::PRODUCER:
|
2023-05-11 01:37:58 -05:00
|
|
|
viewToModify->cellResult()->setFlowDiagTracerSelectionType( RimEclipseResultDefinition::FlowTracerSelectionType::FLOW_TR_INJECTORS );
|
2019-03-27 13:20:42 -05:00
|
|
|
break;
|
2021-04-05 11:18:34 -05:00
|
|
|
case RimFlowDiagSolution::TracerStatusType::INJECTOR:
|
2023-05-11 01:37:58 -05:00
|
|
|
viewToModify->cellResult()->setFlowDiagTracerSelectionType( RimEclipseResultDefinition::FlowTracerSelectionType::FLOW_TR_PRODUCERS );
|
2019-03-27 13:20:42 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2019-09-06 03:40:57 -05:00
|
|
|
CVF_ASSERT( false );
|
2019-03-27 13:20:42 -05:00
|
|
|
break;
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->cellResult()->loadDataAndUpdate();
|
|
|
|
viewToModify->cellResult()->updateConnectedEditors();
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
std::vector<QString> tracerNames = findContributingTracerNames( flowDiagSolution, selectedWell->simWellData(), timeStep );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimSimWellInView* w : viewToModify->wellCollection()->wells() )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
if ( std::find( tracerNames.begin(), tracerNames.end(), w->name() ) != tracerNames.end() || selectedWell->name() == w->name() )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
w->showWell = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w->showWell = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable all existing property filters, and
|
|
|
|
// create a new property filter based on TOF for current well
|
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
RimEclipsePropertyFilterCollection* propertyFilterCollection = viewToModify->eclipsePropertyFilterCollection();
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipsePropertyFilter* f : propertyFilterCollection->propertyFilters() )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2021-01-11 11:47:09 -06:00
|
|
|
f->setActive( false );
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
|
2022-11-29 06:46:29 -06:00
|
|
|
propertyFilterCollection->propertyFiltersField().push_back( propertyFilter );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
propertyFilter->resultDefinition()->setEclipseCase( viewToModify->eclipseCase() );
|
|
|
|
propertyFilter->resultDefinition()->setTofAndSelectTracer( selectedWell->name() );
|
2017-03-09 04:16:27 -06:00
|
|
|
propertyFilter->resultDefinition()->loadDataAndUpdate();
|
|
|
|
|
|
|
|
propertyFilterCollection->updateConnectedEditors();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
Riu3DMainWindowTools::setExpanded( propertyFilterCollection );
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2023-06-05 00:33:04 -05:00
|
|
|
viewToModify->faultCollection()->setActive( false );
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->faultCollection()->updateConnectedEditors();
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2019-11-01 04:13:32 -05:00
|
|
|
viewToModify->updateDisplayModelForCurrentTimeStepAndRedraw();
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->scheduleCreateDisplayModelAndRedraw();
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
///
|
2017-03-09 04:16:27 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2023-02-26 03:48:40 -06:00
|
|
|
std::vector<QString> RicShowContributingWellsFeatureImpl::findContributingTracerNames( const RimFlowDiagSolution* flowDiagSolution,
|
|
|
|
const RigSimWellData* simWellData,
|
|
|
|
int timeStep )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
std::vector<QString> tracerCellFractionValues;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( flowDiagSolution && simWellData->hasWellResult( timeStep ) )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2021-04-05 11:18:34 -05:00
|
|
|
RimFlowDiagSolution::TracerStatusType requestedTracerType = RimFlowDiagSolution::TracerStatusType::UNDEFINED;
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2021-05-26 03:56:21 -05:00
|
|
|
const RiaDefines::WellProductionType prodType = simWellData->wellProductionType( timeStep );
|
2023-02-26 03:48:40 -06:00
|
|
|
if ( prodType == RiaDefines::WellProductionType::PRODUCER || prodType == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2021-04-05 11:18:34 -05:00
|
|
|
requestedTracerType = RimFlowDiagSolution::TracerStatusType::INJECTOR;
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-05 11:18:34 -05:00
|
|
|
requestedTracerType = RimFlowDiagSolution::TracerStatusType::PRODUCER;
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<QString> tracerNames = flowDiagSolution->tracerNames();
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const QString& tracerName : tracerNames )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( flowDiagSolution->tracerStatusInTimeStep( tracerName, timeStep ) == requestedTracerType )
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
tracerCellFractionValues.push_back( tracerName );
|
2017-03-09 04:16:27 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tracerCellFractionValues;
|
|
|
|
}
|