Added functionality to update RelPerm and PVT plots when time step changes.

Also added line marker for current cell's pressure in PVT plots.
This commit is contained in:
sigurdp
2017-11-29 13:41:13 +01:00
parent 7f02791aba
commit 7c9a14f78c
14 changed files with 725 additions and 226 deletions

View File

@@ -39,6 +39,7 @@
#include "RiuMainWindow.h"
#include "RiuViewer.h"
#include "RiuTimeStepChangedHandler.h"
#include "cafDisplayCoordTransform.h"
#include "cafFrameAnimationControl.h"
@@ -354,9 +355,16 @@ void RimView::setCurrentTimeStepAndUpdate(int frameIndex)
//--------------------------------------------------------------------------------------------------
void RimView::setCurrentTimeStep(int frameIndex)
{
const int oldTimeStep = m_currentTimeStep;
m_currentTimeStep = frameIndex;
clampCurrentTimestep();
if (m_currentTimeStep != oldTimeStep)
{
RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this);
}
this->hasUserRequestedAnimation = true;
if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters())
{

View File

@@ -21,12 +21,14 @@ ${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h
${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.h
${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.h
${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h
${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.h
${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h
${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.h
${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.h
${CEE_CURRENT_LIST_DIR}RiuQwtPlotZoomer.h
${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.h
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.h
${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h
${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.h
${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.h
@@ -35,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.h
${CEE_CURRENT_LIST_DIR}RiuSelectionManager.h
${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.h
${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h
${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.h
${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h
${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.h
${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h
@@ -83,11 +86,13 @@ ${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.cpp
${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.cpp
${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.cpp
${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.cpp
${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.cpp
${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.cpp
${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.cpp
${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.cpp
${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.cpp
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.cpp
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.cpp
${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.cpp
${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.cpp
${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.cpp
@@ -96,6 +101,7 @@ ${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.cpp
${CEE_CURRENT_LIST_DIR}RiuSelectionManager.cpp
${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.cpp
${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.cpp
${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.cpp
${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.cpp
${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.cpp
${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.cpp

View File

@@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuPvtPlotPanel.h"
#include "RiuPvtPlotUpdater.h"
#include "RiuSummaryQwtPlot.h"
#include "RigFlowDiagSolverInterface.h"
@@ -67,7 +68,8 @@ public:
//--------------------------------------------------------------------------------------------------
RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent)
: QWidget(parent),
m_pressure(HUGE_VAL)
m_pressure(HUGE_VAL),
m_plotUpdater(new RiuPvtPlotUpdater(this))
{
m_phaseComboBox = new QComboBox(this);
m_phaseComboBox->setEditable(false);
@@ -164,6 +166,14 @@ void RiuPvtPlotPanel::clearPlot()
plotUiSelectedCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPvtPlotUpdater* RiuPvtPlotPanel::plotUpdater()
{
return m_plotUpdater.get();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -172,7 +182,7 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedFvfCurves;
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedViscosityCurves;
// Determine which curves to actually plot based on selection in GUI
// Determine which curves (phase) to actually plot based on selection in GUI
const int currComboIdx = m_phaseComboBox->currentIndex();
const RigFlowDiagSolverInterface::PvtCurve::Phase phaseToPlot = static_cast<const RigFlowDiagSolverInterface::PvtCurve::Phase>(m_phaseComboBox->itemData(currComboIdx).toInt());
@@ -199,13 +209,13 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
{
const QString plotTitle = phaseString + "Formation Volume Factor";
const QString yAxisTitle = phaseString + "Formation Volume Factor";
plotCurvesInQwt(selectedFvfCurves, m_pressure, plotTitle, yAxisTitle, m_fvfPlot);
plotCurvesInQwt(selectedFvfCurves, m_pressure, plotTitle, yAxisTitle, m_fvfPlot, &m_fvfPlotMarkers);
}
{
const QString plotTitle = phaseString + "Viscosity";
const QString yAxisTitle = phaseString + "Viscosity";
plotCurvesInQwt(selectedViscosityCurves, m_pressure, plotTitle, yAxisTitle, m_viscosityPlot);
plotCurvesInQwt(selectedViscosityCurves, m_pressure, plotTitle, yAxisTitle, m_viscosityPlot, &m_viscosityPlotMarkers);
}
@@ -214,10 +224,20 @@ void RiuPvtPlotPanel::plotUiSelectedCurves()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot)
void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
{
plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
plot->detachItems(QwtPlotItem::Rtti_PlotMarker);
// Workaround for detaching only plot markers that we have added
// Needed as long as the curve point tracker is also using plot markers for its marking
//plot->detachItems(QwtPlotItem::Rtti_PlotMarker);
for (QwtPlotMarker* marker : *myPlotMarkers)
{
marker->detach();
delete marker;
}
myPlotMarkers->clear();
for (size_t i = 0; i < curveArr.size(); i++)
{
@@ -253,10 +273,11 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterfa
lineMarker->setXValue(pressure);
lineMarker->setLineStyle(QwtPlotMarker::VLine);
lineMarker->setLinePen(QPen(Qt::black, 1, Qt::DashLine));
lineMarker->setLabel(QString("Pressure"));
lineMarker->setLabel(QString("PRESSURE"));
lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
lineMarker->setLabelOrientation(Qt::Vertical);
lineMarker->attach(plot);
myPlotMarkers->push_back(lineMarker);
}
plot->setTitle(plotTitle);
@@ -267,22 +288,6 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterfa
plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::addVerticalPressureMarkerLine(double pressureValue, QColor color, QwtPlot* plot)
{
QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(pressureValue);
lineMarker->setLineStyle(QwtPlotMarker::VLine);
lineMarker->setLinePen(QPen(color, 1, Qt::DashLine));
lineMarker->setLabel(QString("PRESSURE"));
lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight);
lineMarker->setLabelOrientation(Qt::Vertical);
lineMarker->attach(plot);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -22,9 +22,13 @@
#include <QWidget>
#include <memory>
class RiuPvtPlotUpdater;
class QDockWidget;
class QwtPlot;
class QComboBox;
class QwtPlotMarker;
//==================================================================================================
@@ -40,14 +44,14 @@ public:
RiuPvtPlotPanel(QDockWidget* parent);
virtual ~RiuPvtPlotPanel();
void setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, double pressure, QString cellReferenceText);
void clearPlot();
void setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, double pressure, QString cellReferenceText);
void clearPlot();
RiuPvtPlotUpdater* plotUpdater();
private:
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot);
static void addVerticalPressureMarkerLine(double pressureValue, QColor color, QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
private slots:
void slotPhaseComboCurrentIndexChanged(int);
@@ -59,9 +63,12 @@ private:
QString m_cellReferenceText;
QComboBox* m_phaseComboBox;
QwtPlot* m_fvfPlot;
QwtPlot* m_viscosityPlot;
std::vector<QwtPlotMarker*> m_fvfPlotMarkers;
std::vector<QwtPlotMarker*> m_viscosityPlotMarkers;
std::unique_ptr<RiuPvtPlotUpdater> m_plotUpdater;
};

View File

@@ -0,0 +1,166 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuPvtPlotUpdater.h"
#include "RiuPvtPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuSelectionManager.h"
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigActiveCellInfo.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RigCaseCellResultsData.h"
#include "RimView.h"
#include "RimEclipseView.h"
#include "RimEclipseResultCase.h"
#include "cvfBase.h"
//#include "cvfTrace.h"
//==================================================================================================
///
/// \class RiuPvtPlotUpdater
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuPvtPlotUpdater::RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel)
: m_targetPlotPanel(targetPlotPanel),
m_sourceEclipseViewOfLastPlot(NULL)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selectionItem)
{
if (!m_targetPlotPanel)
{
return;
}
m_sourceEclipseViewOfLastPlot = NULL;
bool mustClearPlot = true;
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(selectionItem);
const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL;
if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView)
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
{
mustClearPlot = false;
m_sourceEclipseViewOfLastPlot = eclipseView;
}
}
if (mustClearPlot)
{
m_targetPlotPanel->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotUpdater::updateOnTimeStepChanged(RimView* changedView)
{
if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible())
{
return;
}
// Don't update the plot if the view that changed time step is different from the view that was the source of the current plot
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(changedView);
if (!eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot)
{
return;
}
// Fetch the current global selection and only continue if the selection's view matches the view with time step change
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(RiuSelectionManager::instance()->selectedItem());
if (eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView)
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (!queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
{
m_targetPlotPanel->clearPlot();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel)
{
CVF_ASSERT(plotPanel);
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView.eclipseCase());
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL;
if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface())
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
{
//cvf::Trace::show("Update PVT plot for active cell index: %d", static_cast<int>(activeCellIndex));
std::vector<RigFlowDiagSolverInterface::PvtCurve> fvfCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_FVF, activeCellIndex);
std::vector<RigFlowDiagSolverInterface::PvtCurve> viscosityCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex);
QString cellRefText = CellLookupHelper::cellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex);
const size_t timeStepIndex = static_cast<size_t>(eclipseView.currentTimeStep());
// The following calls will read results from file in preparation for the queries below
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results(RiaDefines::MATRIX_MODEL);
cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "RS");
cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "RV");
cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "PRESSURE");
cvf::ref<RigResultAccessor> rsAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RS", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> rvAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "RV", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> pressureAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "PRESSURE", RiaDefines::DYNAMIC_NATIVE);
const double cellRS = rsAccessor.notNull() ? rsAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellRV = rvAccessor.notNull() ? rvAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellPressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
//cvf::Trace::show("cellRS = %f cellRV = %f cellPressure = %f", cellRS, cellRV, cellPressure);
plotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, cellPressure, cellRefText);
return true;
}
}
return false;
}

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <QString>
#include <QPointer>
class RiuSelectionItem;
class RiuPvtPlotPanel;
class RimView;
class RimEclipseView;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuPvtPlotUpdater
{
public:
RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel);
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void updateOnTimeStepChanged(RimView* changedView);
private:
static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel);
private:
QPointer<RiuPvtPlotPanel> m_targetPlotPanel;
const RimView* m_sourceEclipseViewOfLastPlot;
};

View File

@@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuSummaryQwtPlot.h"
#include "RiuQwtPlotWheelZoomer.h"
#include "RiuQwtPlotZoomer.h"
@@ -75,7 +76,8 @@ public:
RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel(QDockWidget* parent)
: QWidget(parent),
m_swat(HUGE_VAL),
m_sgas(HUGE_VAL)
m_sgas(HUGE_VAL),
m_plotUpdater(new RiuRelativePermeabilityPlotUpdater(this))
{
m_qwtPlot = new RelPermQwtPlot(this);
setPlotDefaults(m_qwtPlot);
@@ -146,17 +148,6 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
QwtLegend* legend = new QwtLegend(plot);
plot->insertLegend(legend, QwtPlot::BottomLegend);
//new RiuQwtPlotWheelZoomer(plot);
//{
// // Rubber-band zoom
// RiuQwtPlotZoomer* plotZoomer = new RiuQwtPlotZoomer(plot->canvas());
// plotZoomer->setRubberBandPen(QColor(Qt::black));
// plotZoomer->setTrackerMode(QwtPicker::AlwaysOff);
// plotZoomer->setTrackerPen(QColor(Qt::black));
// plotZoomer->initMousePattern(1);
//}
}
//--------------------------------------------------------------------------------------------------
@@ -191,7 +182,15 @@ void RiuRelativePermeabilityPlotPanel::clearPlot()
m_sgas = HUGE_VAL;
m_cellReferenceText.clear();
plotCurvesInQwt(m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot);
plotCurvesInQwt(m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot, &m_myPlotMarkers);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuRelativePermeabilityPlotUpdater* RiuRelativePermeabilityPlotPanel::plotUpdater()
{
return m_plotUpdater.get();
}
//--------------------------------------------------------------------------------------------------
@@ -217,16 +216,26 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
}
}
plotCurvesInQwt(selectedCurves, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot);
plotCurvesInQwt(selectedCurves, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot, &m_myPlotMarkers);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot)
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
{
plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
plot->detachItems(QwtPlotItem::Rtti_PlotMarker);
// Workaround for detaching only plot markers that we have added
// Needed as long as the curve point tracker is also using plot markers for its marking
//plot->detachItems(QwtPlotItem::Rtti_PlotMarker);
for (QwtPlotMarker* marker : *myPlotMarkers)
{
marker->detach();
delete marker;
}
myPlotMarkers->clear();
bool shouldEableRightYAxis = false;
@@ -276,7 +285,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROW ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOW)
{
addCurveConstSaturationIntersectionMarker(curve, swat, Qt::blue, plotCurveOnRightAxis, plot);
addCurveConstSaturationIntersectionMarker(curve, swat, Qt::blue, plotCurveOnRightAxis, plot, myPlotMarkers);
}
}
if (sgas != HUGE_VAL)
@@ -285,7 +294,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::KROG ||
curve.ident == RigFlowDiagSolverInterface::RelPermCurve::PCOG)
{
addCurveConstSaturationIntersectionMarker(curve, sgas, Qt::red, plotCurveOnRightAxis, plot);
addCurveConstSaturationIntersectionMarker(curve, sgas, Qt::red, plotCurveOnRightAxis, plot, myPlotMarkers);
}
}
}
@@ -294,11 +303,11 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
// Add vertical marker lines to indicate cell SWAT and/or SGAS saturations
if (swat != HUGE_VAL)
{
addVerticalSaturationMarkerLine(swat, "SWAT", Qt::blue, plot);
addVerticalSaturationMarkerLine(swat, "SWAT", Qt::blue, plot, myPlotMarkers);
}
if (sgas != HUGE_VAL)
{
addVerticalSaturationMarkerLine(sgas, "SGAS", Qt::red, plot);
addVerticalSaturationMarkerLine(sgas, "SGAS", Qt::red, plot, myPlotMarkers);
}
@@ -316,9 +325,6 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
plot->enableAxis(QwtPlot::yRight, shouldEableRightYAxis);
plot->replot();
//plot->setAxisScale(QwtPlot::xBottom, 0, 1);
//plot->setAxisScale(QwtPlot::yLeft, 0, 1);
}
@@ -357,7 +363,7 @@ QString RiuRelativePermeabilityPlotPanel::determineXAxisTitleFromCurveCollection
//--------------------------------------------------------------------------------------------------
/// Add a vertical labeled marker line at the specified saturation value
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot)
void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
{
QwtPlotMarker* lineMarker = new QwtPlotMarker;
lineMarker->setXValue(saturationValue);
@@ -368,12 +374,13 @@ void RiuRelativePermeabilityPlotPanel::addVerticalSaturationMarkerLine(double sa
lineMarker->setLabelOrientation(Qt::Vertical);
lineMarker->attach(plot);
myPlotMarkers->push_back(lineMarker);
}
//--------------------------------------------------------------------------------------------------
/// Add a marker at the intersection of the passed curve and the constant saturation value
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, bool plotCurveOnRightAxis, QwtPlot* plot)
void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, bool plotCurveOnRightAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers)
{
const double yVal = interpolatedCurveYValue(curve.xVals, curve.yVals, saturationValue);
if (yVal != HUGE_VAL)
@@ -392,6 +399,8 @@ void RiuRelativePermeabilityPlotPanel::addCurveConstSaturationIntersectionMarker
{
pointMarker->setYAxis(QwtPlot::yRight);
}
myPlotMarkers->push_back(pointMarker);
}
}

View File

@@ -22,10 +22,15 @@
#include <QWidget>
#include <memory>
class RiuRelativePermeabilityPlotUpdater;
class QDockWidget;
class QButtonGroup;
class QCheckBox;
class QwtPlot;
class QwtPlotMarker;
//==================================================================================================
@@ -40,18 +45,19 @@ class RiuRelativePermeabilityPlotPanel : public QWidget
public:
RiuRelativePermeabilityPlotPanel(QDockWidget* parent);
virtual ~RiuRelativePermeabilityPlotPanel();
void setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText);
void clearPlot();
void setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText);
void clearPlot();
RiuRelativePermeabilityPlotUpdater* plotUpdater();
private:
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static QColor curveColorFromIdent(RigFlowDiagSolverInterface::RelPermCurve::Ident ident);
static QString determineXAxisTitleFromCurveCollection(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr);
static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot);
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, bool plotCurveOnRightAxis, QwtPlot* plot);
static void addVerticalSaturationMarkerLine(double saturationValue, QString label, QColor color, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static void addCurveConstSaturationIntersectionMarker(const RigFlowDiagSolverInterface::RelPermCurve& curve, double saturationValue, QColor markerColor, bool plotCurveOnRightAxis, QwtPlot* plot, std::vector<QwtPlotMarker*>* myPlotMarkers);
static double interpolatedCurveYValue(const std::vector<double>& xVals, const std::vector<double>& yVals, double x);
private slots:
@@ -64,7 +70,11 @@ private:
double m_sgas;
QString m_cellReferenceText;
QwtPlot* m_qwtPlot;
std::vector<QwtPlotMarker*> m_myPlotMarkers;
QButtonGroup* m_selectedCurvesButtonGroup;
QCheckBox* m_showUnscaledCheckBox;
std::unique_ptr<RiuRelativePermeabilityPlotUpdater> m_plotUpdater;
};

View File

@@ -0,0 +1,211 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuSelectionManager.h"
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigActiveCellInfo.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RimView.h"
#include "RimEclipseView.h"
#include "RimEclipseResultCase.h"
#include "cvfBase.h"
//#include "cvfTrace.h"
//==================================================================================================
///
/// \class RiuRelativePermeabilityPlotUpdater
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel)
: m_targetPlotPanel(targetPlotPanel),
m_sourceEclipseViewOfLastPlot(NULL)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selectionItem)
{
if (!m_targetPlotPanel)
{
return;
}
m_sourceEclipseViewOfLastPlot = NULL;
bool mustClearPlot = true;
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(selectionItem);
const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL;
if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView)
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
{
mustClearPlot = false;
m_sourceEclipseViewOfLastPlot = eclipseView;
}
}
if (mustClearPlot)
{
m_targetPlotPanel->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged(RimView* changedView)
{
if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible())
{
return;
}
// Don't update the plot if the view that changed time step is different from the view that was the source of the current plot
const RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>(changedView);
if (!eclipseView || eclipseView != m_sourceEclipseViewOfLastPlot)
{
return;
}
// Fetch the current global selection and only continue if the selection's view matches the view with time step change
const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast<const RiuEclipseSelectionItem*>(RiuSelectionManager::instance()->selectedItem());
if (eclipseSelectionItem && eclipseSelectionItem->m_view == eclipseView)
{
const size_t gridIndex = eclipseSelectionItem->m_gridIndex;
const size_t gridLocalCellIndex = eclipseSelectionItem->m_gridLocalCellIndex;
if (!queryDataAndUpdatePlot(*eclipseView, gridIndex, gridLocalCellIndex, m_targetPlotPanel))
{
m_targetPlotPanel->clearPlot();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel)
{
CVF_ASSERT(plotPanel);
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView.eclipseCase());
if (eclipseResultCase && eclipseResultCase->flowDiagSolverInterface())
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseResultCase->eclipseCaseData(), gridIndex, gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
{
//cvf::Trace::show("Updating RelPerm plot for active cell index: %d", static_cast<int>(activeCellIndex));
std::vector<RigFlowDiagSolverInterface::RelPermCurve> relPermCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculateRelPermCurvesForActiveCell(activeCellIndex);
QString cellRefText = CellLookupHelper::cellReferenceText(eclipseResultCase->eclipseCaseData(), gridIndex, gridLocalCellIndex);
// Fetch SWAT and SGAS cell values for the selected cell
const size_t timeStepIndex = static_cast<size_t>(eclipseView.currentTimeStep());
cvf::ref<RigResultAccessor> swatAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseResultCase->eclipseCaseData(), gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SWAT", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> sgasAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseResultCase->eclipseCaseData(), gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SGAS", RiaDefines::DYNAMIC_NATIVE);
const double cellSWAT = swatAccessor.notNull() ? swatAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
const double cellSGAS = sgasAccessor.notNull() ? sgasAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
//cvf::Trace::show("cellSWAT = %f cellSGAS = %f", cellSWAT, cellSGAS);
plotPanel->setPlotData(relPermCurveArr, cellSWAT, cellSGAS, cellRefText);
return true;
}
}
return false;
}
//==================================================================================================
//
//
//
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t CellLookupHelper::mapToActiveCellIndex(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex)
{
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL;
if (grid && gridLocalCellIndex < grid->cellCount())
{
// Note!!
// Which type of porosity model to choose? Currently hard-code to MATRIX_MODEL
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
CVF_ASSERT(activeCellInfo);
const size_t reservoirCellIndex = grid->reservoirCellIndex(gridLocalCellIndex);
const size_t activeCellIndex = activeCellInfo->cellResultIndex(reservoirCellIndex);
return activeCellIndex;
}
return cvf::UNDEFINED_SIZE_T;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString CellLookupHelper::cellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex)
{
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL;
if (grid && gridLocalCellIndex < grid->cellCount())
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k))
{
// Adjust to 1-based Eclipse indexing
i++;
j++;
k++;
QString retText = QString("Grid index %1, Cell : [%2, %3, %4]").arg(gridIndex).arg(i).arg(j).arg(k);
return retText;
}
}
return QString();
}

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <QString>
#include <QPointer>
class RiuSelectionItem;
class RiuRelativePermeabilityPlotPanel;
class RimView;
class RimEclipseView;
class RigEclipseCaseData;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuRelativePermeabilityPlotUpdater
{
public:
RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel);
void updateOnSelectionChanged(const RiuSelectionItem* selectionItem);
void updateOnTimeStepChanged(RimView* changedView);
private:
static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel);
private:
QPointer<RiuRelativePermeabilityPlotPanel> m_targetPlotPanel;
const RimView* m_sourceEclipseViewOfLastPlot;
};
//==================================================================================================
//
//
//
//==================================================================================================
class CellLookupHelper
{
public:
static size_t mapToActiveCellIndex(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex);
static QString cellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex);
};

View File

@@ -27,11 +27,7 @@
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigTimeHistoryResultAccessor.h"
#include "RigGridBase.h"
#include "RigActiveCellInfo.h"
#include "RiuFemTimeHistoryResultAccessor.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
@@ -40,7 +36,6 @@
#include "RimGeoMechResultDefinition.h"
#include "RimGeoMechView.h"
#include "RimProject.h"
#include "RimEclipseResultCase.h"
#include "RiuFemResultTextBuilder.h"
#include "RiuMainWindow.h"
@@ -49,8 +44,8 @@
#include "RiuSelectionManager.h"
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuPvtPlotPanel.h"
#include "cvfTrace.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuPvtPlotUpdater.h"
#include <QStatusBar>
@@ -58,61 +53,6 @@
//==================================================================================================
//
//
//
//==================================================================================================
class CellLookupHelper
{
public:
static size_t mapToActiveCellIndex(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex)
{
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL;
if (grid && gridLocalCellIndex < grid->cellCount())
{
// Note!!
// Which type of porosity model to choose? Currently hard-code to MATRIX_MODEL
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL);
CVF_ASSERT(activeCellInfo);
const size_t reservoirCellIndex = grid->reservoirCellIndex(gridLocalCellIndex);
const size_t activeCellIndex = activeCellInfo->cellResultIndex(reservoirCellIndex);
return activeCellIndex;
}
return cvf::UNDEFINED_SIZE_T;
}
static QString cellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex)
{
const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0;
const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL;
if (grid && gridLocalCellIndex < grid->cellCount())
{
size_t i = 0;
size_t j = 0;
size_t k = 0;
if (grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k))
{
// Adjust to 1-based Eclipse indexing
i++;
j++;
k++;
QString retText = QString("Grid index %1, Cell : [%2, %3, %4]").arg(gridIndex).arg(i).arg(j).arg(k);
return retText;
}
}
return QString();
}
};
//==================================================================================================
//
//
@@ -141,8 +81,11 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const
{
RiuMainWindow::instance()->resultPlot()->deleteAllCurves();
updateRelativePermeabilityPlot(NULL);
updatePvtPlot(NULL);
RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater = RiuMainWindow::instance()->relativePermeabilityPlotPanel()->plotUpdater();
relPermPlotUpdater->updateOnSelectionChanged(NULL);
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnSelectionChanged(NULL);
updateResultInfo(NULL);
@@ -156,8 +99,11 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item
{
addCurveFromSelectionItem(item);
updateRelativePermeabilityPlot(item);
updatePvtPlot(item);
RiuRelativePermeabilityPlotUpdater* relPermUpdater = RiuMainWindow::instance()->relativePermeabilityPlotPanel()->plotUpdater();
relPermUpdater->updateOnSelectionChanged(item);
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnSelectionChanged(item);
updateResultInfo(item);
@@ -311,105 +257,6 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuSelectionIte
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::updateRelativePermeabilityPlot(const RiuSelectionItem* selectionItem) const
{
RiuRelativePermeabilityPlotPanel* relPermPlotPanel = RiuMainWindow::instance()->relativePermeabilityPlotPanel();
if (!relPermPlotPanel)
{
return;
}
bool mustClearPlot = true;
if (relPermPlotPanel->isVisible() && selectionItem && selectionItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
{
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(selectionItem);
const RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView->eclipseCase());
if (eclipseResultCase && eclipseResultCase->flowDiagSolverInterface())
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
{
//cvf::Trace::show("Updating RelPerm plot for active cell index: %d", static_cast<int>(activeCellIndex));
std::vector<RigFlowDiagSolverInterface::RelPermCurve> relPermCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculateRelPermCurvesForActiveCell(activeCellIndex);
QString cellRefText = CellLookupHelper::cellReferenceText(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex);
// Fetch SWAT and SGAS cell values for the selected cell
const size_t timeStepIndex = static_cast<size_t>(eclipseView->currentTimeStep());
cvf::ref<RigResultAccessor> swatAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SWAT", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> sgasAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SGAS", RiaDefines::DYNAMIC_NATIVE);
const double cellSWAT = swatAccessor.notNull() ? swatAccessor->cellScalar(eclipseSelectionItem->m_gridLocalCellIndex) : HUGE_VAL;
const double cellSGAS = sgasAccessor.notNull() ? sgasAccessor->cellScalar(eclipseSelectionItem->m_gridLocalCellIndex) : HUGE_VAL;
//cvf::Trace::show("cellSWAT = %f cellSGAS = %f", cellSWAT, cellSGAS);
relPermPlotPanel->setPlotData(relPermCurveArr, cellSWAT, cellSGAS, cellRefText);
mustClearPlot = false;
}
}
}
if (mustClearPlot)
{
relPermPlotPanel->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuSelectionChangedHandler::updatePvtPlot(const RiuSelectionItem* selectionItem) const
{
RiuPvtPlotPanel* pvtPlotPanel = RiuMainWindow::instance()->pvtPlotPanel();
if (!pvtPlotPanel)
{
return;
}
bool mustClearPlot = true;
if (pvtPlotPanel->isVisible() && selectionItem && selectionItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
{
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(selectionItem);
const RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p();
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView->eclipseCase());
if (eclipseResultCase && eclipseResultCase->flowDiagSolverInterface())
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
{
//cvf::Trace::show("Update PVT plots for active cell index: %d", static_cast<int>(activeCellIndex));
std::vector<RigFlowDiagSolverInterface::PvtCurve> fvfCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_FVF, activeCellIndex);
std::vector<RigFlowDiagSolverInterface::PvtCurve> viscosityCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex);
QString cellRefText = CellLookupHelper::cellReferenceText(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex);
//const size_t timeStepIndex = static_cast<size_t>(eclipseView->currentTimeStep());
//cvf::ref<RigResultAccessor> pressureAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "PRESSURE", RiaDefines::DYNAMIC_NATIVE);
//const double cellPressure = pressureAccessor.notNull() ? pressureAccessor->cellScalar(eclipseSelectionItem->m_gridLocalCellIndex) : HUGE_VAL;
const double cellPressure = HUGE_VAL;
pvtPlotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, cellPressure, cellRefText);
mustClearPlot = false;
}
}
}
if (mustClearPlot)
{
pvtPlotPanel->clearPlot();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -40,8 +40,6 @@ private:
void addCurveFromSelectionItem(const RiuSelectionItem* itemAdded) const;
void addCurveFromSelectionItem(const RiuEclipseSelectionItem* selectionItem) const;
void addCurveFromSelectionItem(const RiuGeoMechSelectionItem* selectionItem) const;
void updateRelativePermeabilityPlot(const RiuSelectionItem* selectionItem) const;
void updatePvtPlot(const RiuSelectionItem* selectionItem) const;
void scheduleUpdateForAllVisibleViews() const;
void updateResultInfo(const RiuSelectionItem* itemAdded) const;

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiuTimeStepChangedHandler.h"
#include "RiuMainWindow.h"
#include "RiuRelativePermeabilityPlotPanel.h"
#include "RiuRelativePermeabilityPlotUpdater.h"
#include "RiuPvtPlotPanel.h"
#include "RiuPvtPlotUpdater.h"
#include "RimView.h"
#include "cvfBase.h"
#include "cvfTrace.h"
#include "cvfDebugTimer.h"
//==================================================================================================
///
/// \class RiuTimeStepChangedHandler
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuTimeStepChangedHandler::RiuTimeStepChangedHandler()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiuTimeStepChangedHandler* RiuTimeStepChangedHandler::instance()
{
static RiuTimeStepChangedHandler* singletonInstance = new RiuTimeStepChangedHandler;
return singletonInstance;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuTimeStepChangedHandler::handleTimeStepChanged(RimView* changedView) const
{
//cvf::Trace::show("handleTimeStepChanged() viewName: %s timeStep:%d", changedView->name().toLatin1().data(), changedView->currentTimeStep());
//cvf::DebugTimer tim("handleTimeStepChanged()");
RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater = RiuMainWindow::instance()->relativePermeabilityPlotPanel()->plotUpdater();
relPermPlotUpdater->updateOnTimeStepChanged(changedView);
RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater();
pvtPlotUpdater->updateOnTimeStepChanged(changedView);
//tim.reportTimeMS("done");
}

View File

@@ -0,0 +1,39 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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
class RimView;
//==================================================================================================
//
//
//
//==================================================================================================
class RiuTimeStepChangedHandler
{
public:
static RiuTimeStepChangedHandler* instance();
void handleTimeStepChanged(RimView* changedView) const;
private:
RiuTimeStepChangedHandler();
};