RelPerm Plot: Show SATNUM in plot title, #2189

This commit is contained in:
sigurdp 2017-11-30 11:27:38 +01:00
parent e3a794d898
commit 636b68cf52
5 changed files with 56 additions and 48 deletions

View File

@ -132,7 +132,7 @@ void RiuPvtPlotPanel::setPlotDefaults(QwtPlot* plot)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, double pressure, QString cellReferenceText)
void RiuPvtPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, double pressure)
{
//cvf::Trace::show("RiuPvtPlotPanel::setPlotData()");
@ -140,8 +140,6 @@ void RiuPvtPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::
m_allViscosityCurvesArr = viscosityCurveArr;
m_pressure = pressure;
m_cellReferenceText = cellReferenceText;
plotUiSelectedCurves();
}
@ -152,7 +150,7 @@ void RiuPvtPlotPanel::clearPlot()
{
//cvf::Trace::show("RiuPvtPlotPanel::clearPlot()");
if (m_allFvfCurvesArr.empty() && m_allViscosityCurvesArr.empty() && m_cellReferenceText.isEmpty())
if (m_allFvfCurvesArr.empty() && m_allViscosityCurvesArr.empty())
{
return;
}
@ -161,8 +159,6 @@ void RiuPvtPlotPanel::clearPlot()
m_allViscosityCurvesArr.clear();
m_pressure = HUGE_VAL;
m_cellReferenceText.clear();
plotUiSelectedCurves();
}

View File

@ -44,7 +44,7 @@ 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 setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, double pressure);
void clearPlot();
RiuPvtPlotUpdater* plotUpdater();
@ -60,7 +60,6 @@ private:
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allFvfCurvesArr;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allViscosityCurvesArr;
double m_pressure;
QString m_cellReferenceText;
QComboBox* m_phaseComboBox;

View File

@ -137,8 +137,6 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView
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
@ -155,7 +153,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView
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);
plotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, cellPressure);
return true;
}

View File

@ -25,6 +25,7 @@
#include "RigActiveCellInfo.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RigCaseCellResultsData.h"
#include "RimView.h"
#include "RimEclipseView.h"
@ -125,23 +126,33 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse
CVF_ASSERT(plotPanel);
RimEclipseResultCase* eclipseResultCase = dynamic_cast<RimEclipseResultCase*>(eclipseView.eclipseCase());
if (eclipseResultCase && eclipseResultCase->flowDiagSolverInterface())
RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL;
if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface())
{
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseResultCase->eclipseCaseData(), gridIndex, gridLocalCellIndex);
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(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);
// Make sure we load the results that we'll query below
RigCaseCellResultsData* cellResultsData = eclipseCaseData->results(RiaDefines::MATRIX_MODEL);
cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT");
cellResultsData->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS");
cellResultsData->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "SATNUM");
// 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);
cvf::ref<RigResultAccessor> swatAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SWAT", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> sgasAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SGAS", RiaDefines::DYNAMIC_NATIVE);
cvf::ref<RigResultAccessor> satnumAccessor = RigResultAccessorFactory::createFromNameAndType(eclipseCaseData, gridIndex, RiaDefines::MATRIX_MODEL, timeStepIndex, "SATNUM", RiaDefines::STATIC_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);
const double cellSATNUM = satnumAccessor.notNull() ? satnumAccessor->cellScalar(gridLocalCellIndex) : HUGE_VAL;
//cvf::Trace::show("cellSWAT = %f cellSGAS = %f cellSATNUM = %f", cellSWAT, cellSGAS, cellSATNUM);
QString cellRefText = constructCellReferenceText(eclipseCaseData, gridIndex, gridLocalCellIndex, cellSATNUM);
plotPanel->setPlotData(relPermCurveArr, cellSWAT, cellSGAS, cellRefText);
@ -152,6 +163,39 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double satnum)
{
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);
if (satnum != HUGE_VAL)
{
retText += QString(" (SATNUM=%1)").arg(satnum);
}
return retText;
}
}
return QString();
}
//==================================================================================================
//
@ -181,32 +225,3 @@ size_t CellLookupHelper::mapToActiveCellIndex(const RigEclipseCaseData* eclipseC
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

@ -42,7 +42,8 @@ public:
void updateOnTimeStepChanged(RimView* changedView);
private:
static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel);
static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel);
static QString constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double satnum);
private:
QPointer<RiuRelativePermeabilityPlotPanel> m_targetPlotPanel;
@ -60,7 +61,6 @@ 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);
};