2017-01-12 06:16:46 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// 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 "RimWellAllocationPlot.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-01-23 01:51:50 -06:00
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RigSimulationWellCenterLineCalculator.h"
|
|
|
|
#include "RigSingleWellResultsData.h"
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
#include "RimEclipseResultCase.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
#include "RimEclipseView.h"
|
2017-01-13 02:50:43 -06:00
|
|
|
#include "RimEclipseWell.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
#include "RimEclipseWellCollection.h"
|
2017-01-23 01:51:50 -06:00
|
|
|
#include "RimFlowDiagSolution.h"
|
|
|
|
#include "RimTotalWellAllocationPlot.h"
|
|
|
|
#include "RimWellLogPlot.h"
|
|
|
|
#include "RimWellLogTrack.h"
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-01-12 06:16:46 -06:00
|
|
|
#include "RiuMainPlotWindow.h"
|
|
|
|
#include "RiuWellAllocationPlot.h"
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellAllocationPlot, "WellAllocationPlot");
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellAllocationPlot::RimWellAllocationPlot()
|
|
|
|
{
|
2017-01-13 02:50:43 -06:00
|
|
|
CAF_PDM_InitObject("Well Allocation Plot", ":/newIcon16x16.png", "", "");
|
2017-01-12 06:16:46 -06:00
|
|
|
|
2017-01-13 02:50:43 -06:00
|
|
|
CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Flow Diagnostics Plot"), "Name", "", "", "");
|
2017-01-13 06:32:02 -06:00
|
|
|
m_userName.uiCapability()->setUiReadOnly(true);
|
|
|
|
|
2017-01-12 06:16:46 -06:00
|
|
|
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
|
2017-01-23 04:10:09 -06:00
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
|
|
|
|
m_case.uiCapability()->setUiTreeChildrenHidden(true);
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&m_timeStep, "PlotTimeStep", 0, "Time Step", "", "", "");
|
|
|
|
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution", "", "", "");
|
2017-01-17 06:06:57 -06:00
|
|
|
|
2017-01-19 10:39:43 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "");
|
|
|
|
m_accumulatedWellFlowPlot.uiCapability()->setUiHidden(true);
|
|
|
|
m_accumulatedWellFlowPlot = new RimWellLogPlot;
|
2017-01-23 04:10:09 -06:00
|
|
|
|
2017-01-23 01:51:50 -06:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_totalWellAllocationPlot, "TotalWellFlowPlot", "Total Well Flow", "", "", "");
|
|
|
|
m_totalWellAllocationPlot.uiCapability()->setUiHidden(true);
|
|
|
|
|
|
|
|
m_totalWellAllocationPlot = new RimTotalWellAllocationPlot;
|
|
|
|
|
2017-01-20 04:38:18 -06:00
|
|
|
this->setAsPlotMdiWindow();
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellAllocationPlot::~RimWellAllocationPlot()
|
|
|
|
{
|
2017-01-20 04:38:18 -06:00
|
|
|
removeMdiWindowFromMdiArea();
|
2017-01-19 10:39:43 -06:00
|
|
|
|
|
|
|
delete m_accumulatedWellFlowPlot();
|
2017-01-23 01:51:50 -06:00
|
|
|
delete m_totalWellAllocationPlot();
|
2017-01-12 06:16:46 -06:00
|
|
|
|
2017-01-17 06:06:57 -06:00
|
|
|
deleteViewWidget();
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-23 04:10:09 -06:00
|
|
|
void RimWellAllocationPlot::setFromSimulationWell(RimEclipseWell* simWell)
|
2017-01-12 06:16:46 -06:00
|
|
|
{
|
2017-01-23 04:10:09 -06:00
|
|
|
RimEclipseView* eclView;
|
|
|
|
simWell->firstAncestorOrThisOfType(eclView);
|
|
|
|
RimEclipseResultCase* eclCase;
|
|
|
|
simWell->firstAncestorOrThisOfType(eclCase);
|
|
|
|
|
|
|
|
m_case = eclCase;
|
|
|
|
m_wellName = simWell->wellResults()->m_wellName;
|
|
|
|
m_timeStep = eclView->currentTimeStep();
|
|
|
|
|
|
|
|
m_flowDiagSolution = eclView->cellResult()->flowDiagSolution();
|
2017-01-13 02:50:43 -06:00
|
|
|
|
2017-01-13 06:32:02 -06:00
|
|
|
updateFromWell();
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-17 06:06:57 -06:00
|
|
|
void RimWellAllocationPlot::deleteViewWidget()
|
2017-01-12 06:16:46 -06:00
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
if (m_wellAllocationPlotWidget)
|
2017-01-13 02:50:43 -06:00
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
m_wellAllocationPlotWidget->deleteLater();
|
|
|
|
m_wellAllocationPlotWidget = nullptr;
|
2017-01-13 02:50:43 -06:00
|
|
|
}
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellAllocationPlot::updateFromWell()
|
|
|
|
{
|
2017-01-23 04:10:09 -06:00
|
|
|
if (!m_case) return;
|
|
|
|
|
|
|
|
const RigSingleWellResultsData* wellResults = nullptr;
|
|
|
|
wellResults = m_case->reservoirData()->findWellResult(m_wellName);
|
|
|
|
|
|
|
|
if (!wellResults) return;
|
|
|
|
|
2017-01-19 11:04:36 -06:00
|
|
|
int branchCount = 0;
|
2017-01-19 10:39:43 -06:00
|
|
|
|
|
|
|
const RigWellResultFrame* wellResultFrame = nullptr;
|
2017-01-23 04:10:09 -06:00
|
|
|
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
|
|
|
|
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-01-23 04:10:09 -06:00
|
|
|
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(m_case->reservoirData(),
|
|
|
|
wellResults,
|
|
|
|
m_timeStep,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
pipeBranchesCLCoords,
|
|
|
|
pipeBranchesCellIds);
|
|
|
|
|
|
|
|
branchCount = static_cast<int>(pipeBranchesCLCoords.size());
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-01-19 11:04:36 -06:00
|
|
|
int existingTrackCount = static_cast<int>(accumulatedWellFlowPlot()->trackCount());
|
2017-01-23 04:10:09 -06:00
|
|
|
accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + m_wellName + ")");
|
2017-01-19 10:39:43 -06:00
|
|
|
|
|
|
|
int neededExtraTrackCount = branchCount - existingTrackCount;
|
|
|
|
for (int etc = 0; etc < neededExtraTrackCount; ++etc)
|
|
|
|
{
|
|
|
|
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
|
|
|
accumulatedWellFlowPlot()->addTrack(plotTrack);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int etc = branchCount; etc < existingTrackCount; ++etc)
|
|
|
|
{
|
|
|
|
accumulatedWellFlowPlot()->removeTrackByIndex(accumulatedWellFlowPlot()->trackCount()- 1);
|
|
|
|
}
|
|
|
|
|
2017-01-20 10:29:24 -06:00
|
|
|
|
2017-01-19 10:39:43 -06:00
|
|
|
for (size_t brIdx = 0; brIdx < branchCount; ++brIdx)
|
|
|
|
{
|
|
|
|
RimWellLogTrack* plotTrack = accumulatedWellFlowPlot()->trackByIndex(brIdx);
|
|
|
|
|
2017-01-20 10:29:24 -06:00
|
|
|
plotTrack->setDescription(QString("Branch %1").arg(brIdx+1));
|
2017-01-19 10:39:43 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-01-23 04:10:09 -06:00
|
|
|
// Todo: Calculate curve data
|
|
|
|
|
|
|
|
setDescription("Well Allocation (" + m_wellName + ")");
|
2017-01-19 10:39:43 -06:00
|
|
|
accumulatedWellFlowPlot()->updateConnectedEditors();
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|
|
|
|
|
2017-01-12 06:16:46 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QWidget* RimWellAllocationPlot::viewWidget()
|
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
return m_wellAllocationPlotWidget;
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-13 02:50:43 -06:00
|
|
|
void RimWellAllocationPlot::zoomAll()
|
2017-01-12 06:16:46 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-19 10:39:43 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogPlot* RimWellAllocationPlot::accumulatedWellFlowPlot()
|
|
|
|
{
|
|
|
|
return m_accumulatedWellFlowPlot();
|
|
|
|
}
|
|
|
|
|
2017-01-23 01:51:50 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimTotalWellAllocationPlot* RimWellAllocationPlot::totalWellFlowPlot()
|
|
|
|
{
|
|
|
|
return m_totalWellAllocationPlot();
|
|
|
|
}
|
|
|
|
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimWellAllocationPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> options;
|
|
|
|
|
2017-01-23 04:10:09 -06:00
|
|
|
if (fieldNeedingOptions == &m_wellName)
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2017-01-23 04:10:09 -06:00
|
|
|
std::set<QString> sortedWellNames;
|
|
|
|
if ( m_case )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2017-01-23 04:10:09 -06:00
|
|
|
const cvf::Collection<RigSingleWellResultsData>& wellRes = m_case->reservoirData()->wellResults();
|
2017-01-13 06:32:02 -06:00
|
|
|
|
2017-01-23 04:10:09 -06:00
|
|
|
for ( size_t wIdx = 0; wIdx < wellRes.size(); ++wIdx )
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
2017-01-23 04:10:09 -06:00
|
|
|
sortedWellNames.insert(wellRes[wIdx]->m_wellName);
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-23 04:10:09 -06:00
|
|
|
QIcon simWellIcon(":/Well.png");
|
|
|
|
for ( const QString& wname: sortedWellNames )
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(wname, wname, false, simWellIcon));
|
|
|
|
}
|
|
|
|
|
2017-01-13 06:32:02 -06:00
|
|
|
if (options.size() == 0)
|
|
|
|
{
|
|
|
|
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
|
|
|
|
}
|
|
|
|
}
|
2017-01-23 04:10:09 -06:00
|
|
|
else if (fieldNeedingOptions == &m_timeStep)
|
|
|
|
{
|
|
|
|
QStringList timeStepNames;
|
|
|
|
|
|
|
|
if (m_case)
|
|
|
|
{
|
|
|
|
timeStepNames = m_case->timeStepStrings();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < timeStepNames.size(); i++)
|
|
|
|
{
|
|
|
|
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
|
|
|
}
|
|
|
|
}
|
2017-01-13 06:32:02 -06:00
|
|
|
|
|
|
|
return options;
|
|
|
|
}
|
|
|
|
|
2017-01-12 06:16:46 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2017-01-20 09:25:05 -06:00
|
|
|
RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
2017-01-12 06:16:46 -06:00
|
|
|
|
2017-01-20 09:25:05 -06:00
|
|
|
if (changedField == &m_userName ||
|
2017-01-12 06:16:46 -06:00
|
|
|
changedField == &m_showPlotTitle)
|
|
|
|
{
|
2017-01-20 04:38:18 -06:00
|
|
|
updateMdiWindowTitle();
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
2017-01-23 04:10:09 -06:00
|
|
|
else if (changedField == &m_wellName)
|
2017-01-13 06:32:02 -06:00
|
|
|
{
|
|
|
|
updateFromWell();
|
|
|
|
}
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QImage RimWellAllocationPlot::snapshotWindowContent()
|
|
|
|
{
|
|
|
|
QImage image;
|
|
|
|
|
2017-01-13 02:50:43 -06:00
|
|
|
// TODO
|
2017-01-12 06:16:46 -06:00
|
|
|
|
|
|
|
return image;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellAllocationPlot::setDescription(const QString& description)
|
|
|
|
{
|
|
|
|
m_userName = description;
|
2017-01-20 04:38:18 -06:00
|
|
|
this->updateMdiWindowTitle();
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QString RimWellAllocationPlot::description() const
|
|
|
|
{
|
|
|
|
return m_userName();
|
|
|
|
}
|
|
|
|
|
2017-01-13 06:32:02 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellAllocationPlot::loadDataAndUpdate()
|
|
|
|
{
|
2017-01-20 04:38:18 -06:00
|
|
|
updateMdiWindowVisibility();
|
2017-01-20 02:44:12 -06:00
|
|
|
updateFromWell();
|
2017-01-13 06:32:02 -06:00
|
|
|
}
|
|
|
|
|
2017-01-12 06:16:46 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-01-17 06:06:57 -06:00
|
|
|
QWidget* RimWellAllocationPlot::createViewWidget(QWidget* mainWindowParent)
|
2017-01-12 06:16:46 -06:00
|
|
|
{
|
2017-01-17 06:06:57 -06:00
|
|
|
m_wellAllocationPlotWidget = new RiuWellAllocationPlot(this, mainWindowParent);
|
|
|
|
return m_wellAllocationPlotWidget;
|
2017-01-12 06:16:46 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|