mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1288 Show contributing wells from 3D view without using well alloc plot
This commit is contained in:
parent
03af1d5e5f
commit
7e4906fced
@ -9,6 +9,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.h
|
||||
${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.h
|
||||
)
|
||||
|
||||
@ -17,6 +18,7 @@ ${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.cpp
|
||||
)
|
||||
|
||||
|
@ -18,11 +18,11 @@
|
||||
|
||||
#include "RicShowContributingWellsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimView.h"
|
||||
#include "RicShowContributingWellsFeatureImpl.h"
|
||||
|
||||
#include "cafCmdFeatureManager.h"
|
||||
#include "RimEclipseWell.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
@ -33,19 +33,10 @@ CAF_CMD_SOURCE_INIT(RicShowContributingWellsFeature, "RicShowContributingWellsFe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicShowContributingWellsFeature::isCommandEnabled()
|
||||
{
|
||||
RimView* activeView = RiaApplication::instance()->activeReservoirView();
|
||||
if (!activeView) return false;
|
||||
std::vector<RimEclipseWell*> collection;
|
||||
caf::SelectionManager::instance()->objectsByType(&collection);
|
||||
|
||||
RimEclipseResultCase* eclCase = nullptr;
|
||||
activeView->firstAncestorOrThisOfType(eclCase);
|
||||
if (eclCase)
|
||||
{
|
||||
std::vector<RimFlowDiagSolution*> flowSols = eclCase->flowDiagSolutions();
|
||||
if (flowSols.size() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (collection.size() == 1) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -55,21 +46,16 @@ bool RicShowContributingWellsFeature::isCommandEnabled()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowContributingWellsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
// First, shot the well allocation plot
|
||||
// Then, use the feature to show contributing wells as this is based on the previous feature
|
||||
std::vector<RimEclipseWell*> collection;
|
||||
caf::SelectionManager::instance()->objectsByType(&collection);
|
||||
|
||||
std::vector<std::string> commandIds;
|
||||
commandIds.push_back("RicShowWellAllocationPlotFeature");
|
||||
commandIds.push_back("RicShowContributingWellsFromPlotFeature");
|
||||
CAF_ASSERT(collection.size() == 1);
|
||||
|
||||
for (auto commandId : commandIds)
|
||||
{
|
||||
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature(commandId);
|
||||
if (feature)
|
||||
{
|
||||
feature->actionTriggered(false);
|
||||
}
|
||||
}
|
||||
RimEclipseWell* well = collection[0];
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
well->firstAncestorOrThisOfTypeAsserted(eclipseView);
|
||||
|
||||
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(eclipseView, well->name());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -0,0 +1,213 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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 "RicShowContributingWellsFeatureImpl.h"
|
||||
|
||||
#include "RigFlowDiagResultAddress.h"
|
||||
#include "RigSingleWellResultsData.h"
|
||||
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimEclipseWell.h"
|
||||
#include "RimEclipseWellCollection.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimFaultCollection.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafAssert.h"
|
||||
#include "cafCmdFeature.h"
|
||||
#include "cafCmdFeatureManager.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName)
|
||||
{
|
||||
CAF_ASSERT(selectedWell);
|
||||
|
||||
RimEclipseView* eclipseView = viewToModify;
|
||||
|
||||
RimEclipseWell* selectedWell = nullptr;
|
||||
|
||||
for (RimEclipseWell* w : eclipseView->wellCollection()->wells())
|
||||
{
|
||||
if (w->name() == wellName)
|
||||
{
|
||||
selectedWell = w;
|
||||
}
|
||||
}
|
||||
|
||||
CAF_ASSERT(selectedWell);
|
||||
|
||||
RimEclipseResultCase* eclipseResultCase = nullptr;
|
||||
selectedWell->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
|
||||
|
||||
// Use the active flow diag solutions, or the first one as default
|
||||
RimFlowDiagSolution* flowDiagSolution = eclipseView->cellResult()->flowDiagSolution();
|
||||
if (!flowDiagSolution)
|
||||
{
|
||||
std::vector<RimFlowDiagSolution*> flowSolutions = eclipseResultCase->flowDiagSolutions();
|
||||
if (flowSolutions.size()) flowDiagSolution = flowSolutions.front();
|
||||
}
|
||||
|
||||
CAF_ASSERT(flowDiagSolution);
|
||||
|
||||
int timeStep = eclipseView->currentTimeStep();
|
||||
|
||||
RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep(selectedWell->name(), timeStep);
|
||||
|
||||
if (!(tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::PRODUCER))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
eclipseView->cellResult()->setResultType(RimDefines::FLOW_DIAGNOSTICS);
|
||||
eclipseView->cellResult()->setResultVariable("MaxFractionTracer");
|
||||
|
||||
switch (tracerStatus)
|
||||
{
|
||||
case RimFlowDiagSolution::PRODUCER:
|
||||
eclipseView->cellResult()->setFlowDiagTracerSelectionType(RimEclipseResultDefinition::FLOW_TR_INJECTORS);
|
||||
break;
|
||||
case RimFlowDiagSolution::INJECTOR:
|
||||
eclipseView->cellResult()->setFlowDiagTracerSelectionType(RimEclipseResultDefinition::FLOW_TR_PRODUCERS);
|
||||
break;
|
||||
|
||||
default:
|
||||
CVF_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
eclipseView->cellResult()->loadDataAndUpdate();
|
||||
eclipseView->cellResult()->updateConnectedEditors();
|
||||
|
||||
std::vector<QString> tracerNames = findContributingTracerNames(flowDiagSolution, selectedWell->wellResults(), timeStep);
|
||||
|
||||
for (RimEclipseWell* w : eclipseView->wellCollection()->wells())
|
||||
{
|
||||
if (std::find(tracerNames.begin(), tracerNames.end(), w->name()) != tracerNames.end()
|
||||
|| selectedWell->name() == w->name())
|
||||
{
|
||||
w->showWell = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
w->showWell = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Disable all existing property filters, and
|
||||
// create a new property filter based on TOF for current well
|
||||
|
||||
RimEclipsePropertyFilterCollection* propertyFilterCollection = eclipseView->eclipsePropertyFilterCollection();
|
||||
|
||||
for (RimEclipsePropertyFilter* f : propertyFilterCollection->propertyFilters())
|
||||
{
|
||||
f->isActive = false;
|
||||
}
|
||||
|
||||
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
|
||||
propertyFilterCollection->propertyFilters().push_back(propertyFilter);
|
||||
|
||||
propertyFilter->resultDefinition()->setEclipseCase(eclipseView->eclipseCase());
|
||||
propertyFilter->resultDefinition()->setTofAndSelectTracer(selectedWell->name());
|
||||
propertyFilter->resultDefinition()->loadDataAndUpdate();
|
||||
|
||||
propertyFilterCollection->updateConnectedEditors();
|
||||
|
||||
RiuMainWindow::instance()->setExpanded(propertyFilterCollection, true);
|
||||
|
||||
eclipseView->faultCollection()->showFaultCollection = false;
|
||||
eclipseView->faultCollection()->updateConnectedEditors();
|
||||
|
||||
eclipseView->scheduleCreateDisplayModelAndRedraw();
|
||||
|
||||
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicShowMainWindowFeature");
|
||||
feature->actionTriggered(false);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RicShowContributingWellsFeatureImpl::contributingTracers(RimEclipseWell* well)
|
||||
{
|
||||
CAF_ASSERT(well);
|
||||
|
||||
RimEclipseView* eclipseView = nullptr;
|
||||
well->firstAncestorOrThisOfTypeAsserted(eclipseView);
|
||||
|
||||
RimEclipseResultCase* eclipseResultCase = nullptr;
|
||||
well->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
|
||||
|
||||
// Use the active flow diag solutions, or the first one as default
|
||||
RimFlowDiagSolution* flowDiagSolution = eclipseView->cellResult()->flowDiagSolution();
|
||||
if (!flowDiagSolution)
|
||||
{
|
||||
std::vector<RimFlowDiagSolution*> flowSolutions = eclipseResultCase->flowDiagSolutions();
|
||||
if (flowSolutions.size()) flowDiagSolution = flowSolutions.front();
|
||||
}
|
||||
|
||||
CAF_ASSERT(flowDiagSolution);
|
||||
|
||||
int timeStep = eclipseView->currentTimeStep();
|
||||
|
||||
return findContributingTracerNames(flowDiagSolution, well->wellResults(), timeStep);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RicShowContributingWellsFeatureImpl::findContributingTracerNames(
|
||||
const RimFlowDiagSolution* flowDiagSolution,
|
||||
const RigSingleWellResultsData* wellResults,
|
||||
int timeStep)
|
||||
{
|
||||
std::vector<QString> tracerCellFractionValues;
|
||||
|
||||
if (flowDiagSolution && wellResults->hasWellResult(timeStep))
|
||||
{
|
||||
RimFlowDiagSolution::TracerStatusType requestedTracerType = RimFlowDiagSolution::UNDEFINED;
|
||||
|
||||
const RigWellResultFrame::WellProductionType prodType = wellResults->wellProductionType(timeStep);
|
||||
if ( prodType == RigWellResultFrame::PRODUCER
|
||||
|| prodType == RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE)
|
||||
{
|
||||
requestedTracerType = RimFlowDiagSolution::INJECTOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
requestedTracerType = RimFlowDiagSolution::PRODUCER;
|
||||
}
|
||||
|
||||
std::vector<QString> tracerNames = flowDiagSolution->tracerNames();
|
||||
for (const QString& tracerName : tracerNames)
|
||||
{
|
||||
if (flowDiagSolution->tracerStatusInTimeStep(tracerName, timeStep) == requestedTracerType)
|
||||
{
|
||||
tracerCellFractionValues.push_back(tracerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tracerCellFractionValues;
|
||||
}
|
||||
|
@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2017 Statoil 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RimEclipseWell;
|
||||
class RimEclipseView;
|
||||
class RimFlowDiagSolution;
|
||||
class RigSingleWellResultsData;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicShowContributingWellsFeatureImpl
|
||||
{
|
||||
public:
|
||||
static void modifyViewToShowContributingWells(RimEclipseView* viewToModify, const QString& wellName);
|
||||
|
||||
private:
|
||||
static std::vector<QString> contributingTracers(RimEclipseWell* well);
|
||||
static std::vector<QString> findContributingTracerNames(
|
||||
const RimFlowDiagSolution* flowDiagSolution,
|
||||
const RigSingleWellResultsData* wellResults,
|
||||
int timeStep);
|
||||
};
|
||||
|
||||
|
@ -424,6 +424,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
else if (dynamic_cast<RimEclipseWell*>(uiItem))
|
||||
{
|
||||
commandIds << "RicPlotProductionRateFeature";
|
||||
commandIds << "RicShowContributingWellsFeature";
|
||||
commandIds << "Separator";
|
||||
commandIds << "RicEclipseWellShowLabelFeature";
|
||||
commandIds << "RicEclipseWellShowHeadFeature";
|
||||
|
Loading…
Reference in New Issue
Block a user