mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Working on adding SWAT and SGAS markers to RelPerm plot, #2061
This commit is contained in:
parent
da56696a26
commit
5f5abdf347
@ -625,16 +625,16 @@ std::vector<RigFlowDiagSolverInterface::RelPermCurve> RigFlowDiagSolverInterface
|
||||
|
||||
for (size_t i = 0; i < graphArr.size(); i++)
|
||||
{
|
||||
const RelPermCurve::Ident curveIdent = curveIdentNameArr[i].first;
|
||||
const std::string curveName = curveIdentNameArr[i].second;
|
||||
|
||||
const Opm::FlowDiagnostics::Graph& srcGraph = graphArr[i];
|
||||
if (srcGraph.first.size() > 0)
|
||||
{
|
||||
const RelPermCurve::Ident curveIdent = curveIdentNameArr[i].first;
|
||||
const std::string curveName = curveIdentNameArr[i].second;
|
||||
std::vector<double> xVals = srcGraph.first;
|
||||
const std::vector<double>& yVals = srcGraph.second;
|
||||
|
||||
// According to Issue https://github.com/OPM/ResInsight/issues/2014,
|
||||
// we need to modify the x values to be 1 - x
|
||||
// According to Issue https://github.com/OPM/ResInsight/issues/2014, we need to modify the x values to be 1 - x
|
||||
if (curveIdent == RelPermCurve::KROW || curveIdent == RelPermCurve::KROG)
|
||||
{
|
||||
for (size_t i = 0; i < xVals.size(); i++)
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "qwt_plot_curve.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_symbol.h"
|
||||
#include "qwt_plot_marker.h"
|
||||
|
||||
#include <QDockWidget>
|
||||
#include <QHBoxLayout>
|
||||
@ -71,7 +72,9 @@ public:
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuRelativePermeabilityPlotPanel::RiuRelativePermeabilityPlotPanel(QDockWidget* parent)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
m_swat(HUGE_VAL),
|
||||
m_sgas(HUGE_VAL)
|
||||
{
|
||||
m_qwtPlot = new RelPermQwtPlot(this);
|
||||
setPlotDefaults(m_qwtPlot);
|
||||
@ -159,11 +162,13 @@ void RiuRelativePermeabilityPlotPanel::setPlotDefaults(QwtPlot* plot)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, QString cellReferenceText)
|
||||
void RiuRelativePermeabilityPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText)
|
||||
{
|
||||
//cvf::Trace::show("Set RelPerm plot data");
|
||||
|
||||
m_allCurvesArr = relPermCurves;
|
||||
m_swat = swat;
|
||||
m_sgas = sgas;
|
||||
m_cellReferenceText = cellReferenceText;
|
||||
|
||||
plotUiSelectedCurves();
|
||||
@ -182,9 +187,11 @@ void RiuRelativePermeabilityPlotPanel::clearPlot()
|
||||
}
|
||||
|
||||
m_allCurvesArr.clear();
|
||||
m_swat = HUGE_VAL;
|
||||
m_sgas = HUGE_VAL;
|
||||
m_cellReferenceText.clear();
|
||||
|
||||
plotCurvesInQwt(m_allCurvesArr, m_cellReferenceText, m_qwtPlot);
|
||||
plotCurvesInQwt(m_allCurvesArr, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -192,8 +199,8 @@ void RiuRelativePermeabilityPlotPanel::clearPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
|
||||
{
|
||||
// Determine which curves to actually plot based on selection in GUI
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> selectedCurves;
|
||||
|
||||
for (size_t i = 0; i < m_allCurvesArr.size(); i++)
|
||||
{
|
||||
const RigFlowDiagSolverInterface::RelPermCurve::Ident curveIdent = m_allCurvesArr[i].ident;
|
||||
@ -203,15 +210,16 @@ void RiuRelativePermeabilityPlotPanel::plotUiSelectedCurves()
|
||||
}
|
||||
}
|
||||
|
||||
plotCurvesInQwt(selectedCurves, m_cellReferenceText, m_qwtPlot);
|
||||
plotCurvesInQwt(selectedCurves, m_swat, m_sgas, m_cellReferenceText, m_qwtPlot);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, QString cellReferenceText, QwtPlot* plot)
|
||||
void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot)
|
||||
{
|
||||
plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
|
||||
plot->detachItems(QwtPlotItem::Rtti_PlotMarker);
|
||||
|
||||
bool enableRightYAxis = false;
|
||||
|
||||
@ -227,17 +235,16 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
|
||||
|
||||
qwtCurve->setStyle(QwtPlotCurve::Lines);
|
||||
|
||||
QwtPlot::Axis yAxis = QwtPlot::yLeft;
|
||||
bool plotOnRightAxis = false;
|
||||
Qt::GlobalColor curveClr = Qt::magenta;
|
||||
bool plotCurveOnRightAxis = false;
|
||||
QColor curveClr = Qt::magenta;
|
||||
switch (curve.ident)
|
||||
{
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KRW: curveClr = Qt::blue; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KRG: curveClr = Qt::red; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KROW: curveClr = Qt::darkGreen; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KROG: curveClr = Qt::green; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::PCOW: curveClr = Qt::darkGreen; plotOnRightAxis = true; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::PCOG: curveClr = Qt::green; plotOnRightAxis = true; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KROW: curveClr = QColor(0, 150, 200); break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::KROG: curveClr = QColor(225, 110, 0); break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::PCOW: curveClr = QColor(0, 150, 200); plotCurveOnRightAxis = true; break;
|
||||
case RigFlowDiagSolverInterface::RelPermCurve::PCOG: curveClr = QColor(225, 110, 0); plotCurveOnRightAxis = true; break;
|
||||
}
|
||||
|
||||
QPen curvePen;
|
||||
@ -250,7 +257,7 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
|
||||
|
||||
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
|
||||
|
||||
if (plotOnRightAxis)
|
||||
if (plotCurveOnRightAxis)
|
||||
{
|
||||
QwtSymbol* curveSymbol = new QwtSymbol(QwtSymbol::Ellipse);
|
||||
curveSymbol->setSize(10, 10);
|
||||
@ -265,6 +272,26 @@ void RiuRelativePermeabilityPlotPanel::plotCurvesInQwt(const std::vector<RigFlow
|
||||
qwtCurve->attach(plot);
|
||||
}
|
||||
|
||||
|
||||
if (swat != HUGE_VAL)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker("SWAT");
|
||||
marker->setXValue(swat);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
marker->setLinePen(QPen(Qt::blue, 1, Qt::DashLine));
|
||||
marker->attach(plot);
|
||||
}
|
||||
|
||||
if (sgas != HUGE_VAL)
|
||||
{
|
||||
QwtPlotMarker* marker = new QwtPlotMarker("SGAS");
|
||||
marker->setXValue(sgas);
|
||||
marker->setLineStyle(QwtPlotMarker::VLine);
|
||||
marker->setLinePen(QPen(Qt::red, 1, Qt::DashLine));
|
||||
marker->attach(plot);
|
||||
}
|
||||
|
||||
|
||||
QString title = "Relative Permeability";
|
||||
if (!cellReferenceText.isEmpty())
|
||||
{
|
||||
|
@ -40,19 +40,21 @@ public:
|
||||
RiuRelativePermeabilityPlotPanel(QDockWidget* parent);
|
||||
virtual ~RiuRelativePermeabilityPlotPanel();
|
||||
|
||||
void setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, QString cellReferenceText);
|
||||
void setPlotData(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& relPermCurves, double swat, double sgas, QString cellReferenceText);
|
||||
void clearPlot();
|
||||
|
||||
private:
|
||||
void plotUiSelectedCurves();
|
||||
static void setPlotDefaults(QwtPlot* plot);
|
||||
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, QString cellReferenceText, QwtPlot* plot);
|
||||
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::RelPermCurve>& curveArr, double swat, double sgas, QString cellReferenceText, QwtPlot* plot);
|
||||
|
||||
private slots:
|
||||
void slotButtonInButtonGroupClicked(int);
|
||||
|
||||
private:
|
||||
std::vector<RigFlowDiagSolverInterface::RelPermCurve> m_allCurvesArr;
|
||||
double m_swat;
|
||||
double m_sgas;
|
||||
QString m_cellReferenceText;
|
||||
QwtPlot* m_qwtPlot;
|
||||
QButtonGroup* m_selectedCurvesButtonGroup;
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "RigGridBase.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RiuFemTimeHistoryResultAccessor.h"
|
||||
#include "RigResultAccessor.h"
|
||||
#include "RigResultAccessorFactory.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
@ -48,7 +50,7 @@
|
||||
#include "RiuRelativePermeabilityPlotPanel.h"
|
||||
#include "RiuPvtPlotPanel.h"
|
||||
|
||||
//#include "cvfTrace.h"
|
||||
#include "cvfTrace.h"
|
||||
|
||||
#include <QStatusBar>
|
||||
|
||||
@ -326,18 +328,28 @@ void RiuSelectionChangedHandler::updateRelativePermeabilityPlot(const RiuSelecti
|
||||
if (relPermPlotPanel->isVisible() && selectionItem && selectionItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast<const RiuEclipseSelectionItem*>(selectionItem);
|
||||
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseSelectionItem->m_view->eclipseCase());
|
||||
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));
|
||||
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);
|
||||
|
||||
relPermPlotPanel->setPlotData(relPermCurveArr, cellRefText);
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user