From 3b1775ad4d0b0536ba467ebaac6c9a2a218c7ec1 Mon Sep 17 00:00:00 2001 From: sigurdp Date: Tue, 28 Nov 2017 09:12:12 +0100 Subject: [PATCH] #1994 PVT Plot: Removed water phase from plot, started implementing display of pressure marker, but this is not yet active. --- .../RigFlowDiagSolverInterface.cpp | 4 +- .../RigFlowDiagSolverInterface.h | 2 +- .../UserInterface/RiuPvtPlotPanel.cpp | 54 +++++++++++++++---- .../UserInterface/RiuPvtPlotPanel.h | 6 ++- .../RiuSelectionChangedHandler.cpp | 13 +++-- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 5ca9e13893..0885a12f94 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -682,8 +682,8 @@ std::vector RigFlowDiagSolverInterface::ca // Requesting FVF or Viscosity const Opm::ECLPVT::RawCurve rawCurveType = (pvtCurveType == PvtCurveType::PVT_CT_FVF) ? Opm::ECLPVT::RawCurve::FVF : Opm::ECLPVT::RawCurve::Viscosity; - const std::array queryPhaseArr = { Opm::ECLPhaseIndex::Vapour, Opm::ECLPhaseIndex::Liquid, Opm::ECLPhaseIndex::Aqua }; - const std::array mapToPhaseArr = { PvtCurve::GAS, PvtCurve::OIL, PvtCurve::WATER }; + const std::array queryPhaseArr = { Opm::ECLPhaseIndex::Vapour, Opm::ECLPhaseIndex::Liquid }; + const std::array mapToPhaseArr = { PvtCurve::GAS, PvtCurve::OIL }; for (size_t i = 0; i < queryPhaseArr.size(); i++) { diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h index 172852ec3e..100d296f72 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.h @@ -95,7 +95,7 @@ public: struct PvtCurve { - enum Phase { OIL, GAS, WATER }; + enum Phase { OIL, GAS }; Phase phase; std::vector xVals; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp index 15d0e13cbe..51c3909a6c 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp @@ -29,6 +29,7 @@ #include "qwt_plot_curve.h" #include "qwt_legend.h" #include "qwt_symbol.h" +#include "qwt_plot_marker.h" #include #include @@ -65,13 +66,13 @@ public: /// //-------------------------------------------------------------------------------------------------- RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent) -: QWidget(parent) +: QWidget(parent), + m_pressure(HUGE_VAL) { m_phaseComboBox = new QComboBox(this); m_phaseComboBox->setEditable(false); m_phaseComboBox->addItem("Oil", QVariant(RigFlowDiagSolverInterface::PvtCurve::OIL)); m_phaseComboBox->addItem("Gas", QVariant(RigFlowDiagSolverInterface::PvtCurve::GAS)); - m_phaseComboBox->addItem("Water", QVariant(RigFlowDiagSolverInterface::PvtCurve::WATER)); QHBoxLayout* comboLayout = new QHBoxLayout(); comboLayout->addWidget(new QLabel("Phase:")); @@ -129,12 +130,13 @@ void RiuPvtPlotPanel::setPlotDefaults(QwtPlot* plot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotPanel::setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, QString cellReferenceText) +void RiuPvtPlotPanel::setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, double pressure, QString cellReferenceText) { //cvf::Trace::show("RiuPvtPlotPanel::setPlotData()"); m_allFvfCurvesArr = fvfCurveArr; m_allViscosityCurvesArr = viscosityCurveArr; + m_pressure = pressure; m_cellReferenceText = cellReferenceText; @@ -155,6 +157,7 @@ void RiuPvtPlotPanel::clearPlot() m_allFvfCurvesArr.clear(); m_allViscosityCurvesArr.clear(); + m_pressure = HUGE_VAL; m_cellReferenceText.clear(); @@ -192,18 +195,17 @@ void RiuPvtPlotPanel::plotUiSelectedCurves() QString phaseString = ""; if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::GAS) phaseString = "Gas "; else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::OIL) phaseString = "Oil "; - else if (phaseToPlot == RigFlowDiagSolverInterface::PvtCurve::WATER) phaseString = "Water "; { const QString plotTitle = phaseString + "Formation Volume Factor"; - const QString yAxisTitle = ""; - plotCurvesInQwt(selectedFvfCurves, plotTitle, yAxisTitle, m_fvfPlot); + const QString yAxisTitle = phaseString + "Formation Volume Factor"; + plotCurvesInQwt(selectedFvfCurves, m_pressure, plotTitle, yAxisTitle, m_fvfPlot); } { const QString plotTitle = phaseString + "Viscosity"; const QString yAxisTitle = phaseString + "Viscosity"; - plotCurvesInQwt(selectedViscosityCurves, plotTitle, yAxisTitle, m_viscosityPlot); + plotCurvesInQwt(selectedViscosityCurves, m_pressure, plotTitle, yAxisTitle, m_viscosityPlot); } @@ -212,9 +214,10 @@ void RiuPvtPlotPanel::plotUiSelectedCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector& curveArr, QString plotTitle, QString yAxisTitle, QwtPlot* plot) +void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot) { plot->detachItems(QwtPlotItem::Rtti_PlotCurve); + plot->detachItems(QwtPlotItem::Rtti_PlotMarker); for (size_t i = 0; i < curveArr.size(); i++) { @@ -229,15 +232,32 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vectorsetPen(curvePen); qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); + QwtSymbol* curveSymbol = new QwtSymbol(QwtSymbol::Ellipse); + curveSymbol->setSize(6, 6); + curveSymbol->setPen(curvePen); + curveSymbol->setBrush(Qt::NoBrush); + qwtCurve->setSymbol(curveSymbol); + qwtCurve->attach(plot); } + // Add vertical marker lines to indicate cell pressure + if (pressure != HUGE_VAL) + { + QwtPlotMarker* lineMarker = new QwtPlotMarker; + lineMarker->setXValue(pressure); + lineMarker->setLineStyle(QwtPlotMarker::VLine); + lineMarker->setLinePen(QPen(Qt::black, 1, Qt::DashLine)); + lineMarker->setLabel(QString("Pressure")); + lineMarker->setLabelAlignment(Qt::AlignTop | Qt::AlignRight); + lineMarker->setLabelOrientation(Qt::Vertical); + lineMarker->attach(plot); + } plot->setTitle(plotTitle); @@ -247,6 +267,22 @@ void RiuPvtPlotPanel::plotCurvesInQwt(const std::vectorreplot(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h index 3abe53a5ed..71e505e8e5 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.h @@ -40,13 +40,14 @@ public: RiuPvtPlotPanel(QDockWidget* parent); virtual ~RiuPvtPlotPanel(); - void setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, QString cellReferenceText); + void setPlotData(const std::vector& fvfCurveArr, const std::vector& viscosityCurveArr, double pressure, QString cellReferenceText); void clearPlot(); private: void plotUiSelectedCurves(); static void setPlotDefaults(QwtPlot* plot); - static void plotCurvesInQwt(const std::vector& curveArr, QString plotTitle, QString yAxisTitle, QwtPlot* plot); + static void plotCurvesInQwt(const std::vector& curveArr, double pressure, QString plotTitle, QString yAxisTitle, QwtPlot* plot); + static void addVerticalPressureMarkerLine(double pressureValue, QColor color, QwtPlot* plot); private slots: void slotPhaseComboCurrentIndexChanged(int); @@ -54,6 +55,7 @@ private slots: private: std::vector m_allFvfCurvesArr; std::vector m_allViscosityCurvesArr; + double m_pressure; QString m_cellReferenceText; QComboBox* m_phaseComboBox; diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index a2b1c9d4e3..60e1b24408 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -377,20 +377,27 @@ void RiuSelectionChangedHandler::updatePvtPlot(const RiuSelectionItem* selection if (pvtPlotPanel->isVisible() && selectionItem && selectionItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT) { const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast(selectionItem); - RimEclipseResultCase* eclipseResultCase = dynamic_cast(eclipseSelectionItem->m_view->eclipseCase()); + const RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); + + RimEclipseResultCase* eclipseResultCase = dynamic_cast(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(activeCellIndex)); + //cvf::Trace::show("Update PVT plots for active cell index: %d", static_cast(activeCellIndex)); std::vector fvfCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_FVF, activeCellIndex); std::vector viscosityCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtCurvesForActiveCell(RigFlowDiagSolverInterface::PVT_CT_VISCOSITY, activeCellIndex); QString cellRefText = CellLookupHelper::cellReferenceText(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex); - pvtPlotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, cellRefText); + //const size_t timeStepIndex = static_cast(eclipseView->currentTimeStep()); + //cvf::ref 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; } }