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-03-10 06:13:26 -06:00
|
|
|
#include "RiaApplication.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"
|
2017-10-13 06:44:53 -05:00
|
|
|
#include "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
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
RimEclipseView* RicShowContributingWellsFeatureImpl::manipulateSelectedView(RimEclipseResultCase* eclipseResultCase,
|
|
|
|
QString wellName,
|
|
|
|
int timeStep)
|
2017-03-10 06:13:26 -06:00
|
|
|
{
|
2019-03-27 13:19:19 -05:00
|
|
|
RimEclipseView* viewToManipulate = RicSelectOrCreateViewFeatureImpl::showViewSelection(
|
|
|
|
eclipseResultCase, "lastUsedWellAllocationView", "ContributingWells_" + wellName, "Show Contributing Wells in View");
|
2017-03-10 06:13:26 -06:00
|
|
|
|
2019-03-27 13:20:42 -05:00
|
|
|
if (!viewToManipulate) return nullptr;
|
2017-03-10 06:13:26 -06:00
|
|
|
|
|
|
|
RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(viewToManipulate, wellName, timeStep);
|
|
|
|
|
|
|
|
auto* feature = caf::CmdFeatureManager::instance()->getCommandFeature("RicShowMainWindowFeature");
|
|
|
|
feature->actionTriggered(false);
|
|
|
|
|
2017-08-17 06:49:51 -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
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05:00
|
|
|
void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimEclipseView* viewToModify,
|
|
|
|
const QString& wellName,
|
|
|
|
int timeStep)
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2017-03-10 07:45:07 -06: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
|
|
|
|
2017-10-13 02:29:42 -05:00
|
|
|
for (RimSimWellInView* w : viewToModify->wellCollection()->wells())
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
if (w->name() == wellName)
|
|
|
|
{
|
|
|
|
selectedWell = w;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-10 07:45:07 -06:00
|
|
|
CVF_ASSERT(selectedWell);
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
RimEclipseResultCase* eclipseResultCase = nullptr;
|
|
|
|
selectedWell->firstAncestorOrThisOfTypeAsserted(eclipseResultCase);
|
|
|
|
|
|
|
|
// 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();
|
2017-03-09 04:16:27 -06:00
|
|
|
if (!flowDiagSolution)
|
|
|
|
{
|
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);
|
2017-03-10 07:45:07 -06:00
|
|
|
CVF_ASSERT(flowDiagSolution);
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
RimFlowDiagSolution::TracerStatusType tracerStatus = flowDiagSolution->tracerStatusInTimeStep(selectedWell->name(), timeStep);
|
|
|
|
if (!(tracerStatus == RimFlowDiagSolution::INJECTOR || tracerStatus == RimFlowDiagSolution::PRODUCER))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2019-03-27 13:20:42 -05:00
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->setCurrentTimeStep(timeStep);
|
2017-06-13 08:41:52 -05:00
|
|
|
viewToModify->cellResult()->setResultType(RiaDefines::FLOW_DIAGNOSTICS);
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->cellResult()->setResultVariable("MaxFractionTracer");
|
|
|
|
viewToModify->cellResult()->setFlowSolution(flowDiagSolution);
|
2017-03-09 04:16:27 -06:00
|
|
|
|
|
|
|
switch (tracerStatus)
|
|
|
|
{
|
2019-03-27 13:20:42 -05:00
|
|
|
case RimFlowDiagSolution::PRODUCER:
|
|
|
|
viewToModify->cellResult()->setFlowDiagTracerSelectionType(RimEclipseResultDefinition::FLOW_TR_INJECTORS);
|
|
|
|
break;
|
|
|
|
case RimFlowDiagSolution::INJECTOR:
|
|
|
|
viewToModify->cellResult()->setFlowDiagTracerSelectionType(RimEclipseResultDefinition::FLOW_TR_PRODUCERS);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
CVF_ASSERT(false);
|
|
|
|
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
|
|
|
|
2017-10-13 06:44:53 -05:00
|
|
|
std::vector<QString> tracerNames = findContributingTracerNames(flowDiagSolution, selectedWell->simWellData(), timeStep);
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2017-10-13 02:29:42 -05:00
|
|
|
for (RimSimWellInView* w : viewToModify->wellCollection()->wells())
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
2019-03-27 13:20:42 -05: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
|
|
|
|
|
|
|
for (RimEclipsePropertyFilter* f : propertyFilterCollection->propertyFilters())
|
|
|
|
{
|
|
|
|
f->isActive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RimEclipsePropertyFilter* propertyFilter = new RimEclipsePropertyFilter();
|
|
|
|
propertyFilterCollection->propertyFilters().push_back(propertyFilter);
|
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
propertyFilter->resultDefinition()->setEclipseCase(viewToModify->eclipseCase());
|
2017-03-09 04:16:27 -06:00
|
|
|
propertyFilter->resultDefinition()->setTofAndSelectTracer(selectedWell->name());
|
|
|
|
propertyFilter->resultDefinition()->loadDataAndUpdate();
|
|
|
|
|
|
|
|
propertyFilterCollection->updateConnectedEditors();
|
|
|
|
|
2018-02-27 09:00:55 -06:00
|
|
|
Riu3DMainWindowTools::setExpanded(propertyFilterCollection);
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->faultCollection()->showFaultCollection = false;
|
|
|
|
viewToModify->faultCollection()->updateConnectedEditors();
|
2017-03-09 04:16:27 -06:00
|
|
|
|
2017-03-09 16:01:45 -06:00
|
|
|
viewToModify->updateCurrentTimeStepAndRedraw();
|
|
|
|
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
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-03-27 13:20:42 -05: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;
|
|
|
|
|
2017-10-13 06:44:53 -05:00
|
|
|
if (flowDiagSolution && simWellData->hasWellResult(timeStep))
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
RimFlowDiagSolution::TracerStatusType requestedTracerType = RimFlowDiagSolution::UNDEFINED;
|
|
|
|
|
2017-10-13 06:44:53 -05:00
|
|
|
const RigWellResultFrame::WellProductionType prodType = simWellData->wellProductionType(timeStep);
|
2019-03-27 13:20:42 -05:00
|
|
|
if (prodType == RigWellResultFrame::PRODUCER || prodType == RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE)
|
2017-03-09 04:16:27 -06:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|