#1994 First cut implementing PVT plots

This commit is contained in:
sigurdp 2017-11-27 09:08:09 +01:00
parent 3624b416fe
commit aa1bbbe2d9
6 changed files with 191 additions and 50 deletions

View File

@ -38,6 +38,10 @@
#include <QMessageBox>
#include "cafProgressInfo.h"
#include "cvfTrace.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -124,7 +128,15 @@ public:
m_poreVolume = m_eclGraph->poreVolume();
m_eclSaturationFunc.reset(new Opm::ECLSaturationFunc(*m_eclGraph, initData));
//m_eclPvtCurveCollection.reset(new Opm::ECLPVT::ECLPvtCurveCollection(*m_eclGraph, initData));
try
{
m_eclPvtCurveCollection.reset(new Opm::ECLPVT::ECLPvtCurveCollection(*m_eclGraph, initData));
}
catch (...)
{
cvf::Trace::show("Exception trying to construct ECLPvtCurveCollection instance");
}
}
std::unique_ptr<Opm::ECLGraph> m_eclGraph;
@ -135,7 +147,7 @@ public:
std::unique_ptr<Opm::ECLRestartData> m_unifiedRestartData;
std::unique_ptr<Opm::ECLSaturationFunc> m_eclSaturationFunc;
// std::unique_ptr<Opm::ECLPVT::ECLPvtCurveCollection> m_eclPvtCurveCollection;
std::unique_ptr<Opm::ECLPVT::ECLPvtCurveCollection> m_eclPvtCurveCollection;
};
@ -651,7 +663,7 @@ std::vector<RigFlowDiagSolverInterface::RelPermCurve> RigFlowDiagSolverInterface
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigFlowDiagSolverInterface::PvtCurve> RigFlowDiagSolverInterface::calculatePvtFvfCurvesForActiveCell(size_t activeCellIndex)
std::vector<RigFlowDiagSolverInterface::PvtCurve> RigFlowDiagSolverInterface::calculatePvtCurvesForActiveCell(PvtCurveType pvtCurveType, size_t activeCellIndex)
{
std::vector<PvtCurve> retCurveArr;
@ -660,21 +672,33 @@ std::vector<RigFlowDiagSolverInterface::PvtCurve> RigFlowDiagSolverInterface::ca
return retCurveArr;
}
//CVF_ASSERT(m_opmFlowDiagStaticData.notNull());
//CVF_ASSERT(m_opmFlowDiagStaticData->m_eclPvtCurveCollection);
CVF_ASSERT(m_opmFlowDiagStaticData.notNull());
if (!m_opmFlowDiagStaticData->m_eclPvtCurveCollection)
{
return retCurveArr;
}
//{
// Opm::FlowDiagnostics::Graph graph = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::FVF, Opm::ECLPhaseIndex::Vapour, static_cast<int>(activeCellIndex));
// retCurveDataArr.push_back({ "FVF_Gas", graph.first, graph.second });
//}
//{
// Opm::FlowDiagnostics::Graph graph = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::FVF, Opm::ECLPhaseIndex::Liquid, static_cast<int>(activeCellIndex));
// retCurveDataArr.push_back({ "FVF_Oil", graph.first, graph.second });
//}
//{
// Opm::FlowDiagnostics::Graph graph = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(Opm::ECLPVT::RawCurve::FVF, Opm::ECLPhaseIndex::Aqua, static_cast<int>(activeCellIndex));
// retCurveDataArr.push_back({ "FVF_Water", graph.first, graph.second });
//}
// 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<Opm::ECLPhaseIndex, 3> queryPhaseArr = { Opm::ECLPhaseIndex::Vapour, Opm::ECLPhaseIndex::Liquid, Opm::ECLPhaseIndex::Aqua };
const std::array<PvtCurve::Phase, 3> mapToPhaseArr = { PvtCurve::GAS, PvtCurve::OIL, PvtCurve::WATER };
for (size_t i = 0; i < queryPhaseArr.size(); i++)
{
const Opm::ECLPhaseIndex queryPhaseIndex = queryPhaseArr[i];
const PvtCurve::Phase mapToPhase = mapToPhaseArr[i];
std::vector<Opm::FlowDiagnostics::Graph> graphArr = m_opmFlowDiagStaticData->m_eclPvtCurveCollection->getPvtCurve(rawCurveType, queryPhaseIndex, static_cast<int>(activeCellIndex));
for (Opm::FlowDiagnostics::Graph srcGraph : graphArr)
{
if (srcGraph.first.size() > 0)
{
retCurveArr.push_back({ mapToPhase, srcGraph.first, srcGraph.second });
}
}
}
return retCurveArr;
}

View File

@ -87,12 +87,17 @@ public:
std::vector<double> yVals;
};
enum PvtCurveType
{
PVT_CT_FVF,
PVT_CT_VISCOSITY
};
struct PvtCurve
{
enum Ident { FVT_OIL, FVT_GAS, FVT_WATER };
enum Phase { OIL, GAS, WATER };
Ident ident;
std::string name;
Phase phase;
std::vector<double> xVals;
std::vector<double> yVals;
};
@ -112,7 +117,7 @@ public:
double max_pv_fraction);
std::vector<RelPermCurve> calculateRelPermCurvesForActiveCell(size_t activeCellIndex);
std::vector<PvtCurve> calculatePvtFvfCurvesForActiveCell(size_t activeCellIndex);
std::vector<PvtCurve> calculatePvtCurvesForActiveCell(PvtCurveType pvtCurveType, size_t activeCellIndex);
private:
std::string getInitFileName() const;

View File

@ -136,6 +136,7 @@ list(APPEND QT_MOC_HEADERS
${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.h
${CEE_CURRENT_LIST_DIR}RiuMainWindow.h
${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h
${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h
${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h
${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h
${CEE_CURRENT_LIST_DIR}RiuViewer.h

View File

@ -28,6 +28,7 @@
#include "qwt_plot.h"
#include "qwt_plot_curve.h"
#include "qwt_legend.h"
#include "qwt_symbol.h"
#include <QDockWidget>
#include <QHBoxLayout>
@ -68,32 +69,37 @@ RiuPvtPlotPanel::RiuPvtPlotPanel(QDockWidget* parent)
{
m_phaseComboBox = new QComboBox(this);
m_phaseComboBox->setEditable(false);
m_phaseComboBox->addItem("Oil", QVariant("oil"));
m_phaseComboBox->addItem("Gas", QVariant("gas"));
m_phaseComboBox->addItem("Water", QVariant("water"));
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"));
comboLayout->addWidget(new QLabel("Phase:"));
comboLayout->addWidget(m_phaseComboBox);
comboLayout->addStretch(1);
comboLayout->setContentsMargins(5, 5, 0, 0);
m_fvfPlot = new PvtQwtPlot(this);
m_viscosityPlot = new PvtQwtPlot(this);
setPlotDefaults(m_fvfPlot);
setPlotDefaults(m_viscosityPlot);
m_fvfPlot->setTitle("Formation Volume Factor - N/A");
m_viscosityPlot->setTitle("Viscosity - N/A");
QHBoxLayout* plotLayout = new QHBoxLayout();
plotLayout->addWidget(m_fvfPlot);
plotLayout->addWidget(m_viscosityPlot);
plotLayout->setSpacing(0);
plotLayout->setContentsMargins(0, 0, 0, 0);
QVBoxLayout* mainLayout = new QVBoxLayout();
mainLayout->addLayout(comboLayout);
mainLayout->addLayout(plotLayout);
mainLayout->setContentsMargins(0, 0, 0, 0);
setLayout(mainLayout);
connect(m_phaseComboBox, SIGNAL(currentIndexChanged(int)), SLOT(slotPhaseComboCurrentIndexChanged(int)));
plotUiSelectedCurves();
}
//--------------------------------------------------------------------------------------------------
@ -118,19 +124,21 @@ void RiuPvtPlotPanel::setPlotDefaults(QwtPlot* plot)
plot->setAxisMaxMinor(QwtPlot::xBottom, 2);
plot->setAxisMaxMinor(QwtPlot::yLeft, 3);
QwtLegend* legend = new QwtLegend(plot);
plot->insertLegend(legend, QwtPlot::BottomLegend);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::setPlotData(QString cellReferenceText)
void RiuPvtPlotPanel::setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, QString cellReferenceText)
{
//cvf::Trace::show("RiuPvtPlotPanel::setPlotData()");
m_allFvfCurvesArr = fvfCurveArr;
m_allViscosityCurvesArr = viscosityCurveArr;
m_cellReferenceText = cellReferenceText;
plotUiSelectedCurves();
}
//--------------------------------------------------------------------------------------------------
@ -140,17 +148,110 @@ void RiuPvtPlotPanel::clearPlot()
{
//cvf::Trace::show("RiuPvtPlotPanel::clearPlot()");
if (m_cellReferenceText.isEmpty())
if (m_allFvfCurvesArr.empty() && m_allViscosityCurvesArr.empty() && m_cellReferenceText.isEmpty())
{
return;
}
m_allFvfCurvesArr.clear();
m_allViscosityCurvesArr.clear();
m_cellReferenceText.clear();
//m_fvfPlot->detachItems(QwtPlotItem::Rtti_PlotItem, true);
//m_viscosityPlot->detachItems(QwtPlotItem::Rtti_PlotItem, true);
//m_fvfPlot->replot();
//m_viscosityPlot->replot();
plotUiSelectedCurves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::plotUiSelectedCurves()
{
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedFvfCurves;
std::vector<RigFlowDiagSolverInterface::PvtCurve> selectedViscosityCurves;
// Determine which curves 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());
for (RigFlowDiagSolverInterface::PvtCurve curve : m_allFvfCurvesArr)
{
if (curve.phase == phaseToPlot)
{
selectedFvfCurves.push_back(curve);
}
}
for (RigFlowDiagSolverInterface::PvtCurve curve : m_allViscosityCurvesArr)
{
if (curve.phase == phaseToPlot)
{
selectedViscosityCurves.push_back(curve);
}
}
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 plotTitle = phaseString + "Viscosity";
const QString yAxisTitle = phaseString + "Viscosity";
plotCurvesInQwt(selectedViscosityCurves, plotTitle, yAxisTitle, m_viscosityPlot);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, QString plotTitle, QString yAxisTitle, QwtPlot* plot)
{
plot->detachItems(QwtPlotItem::Rtti_PlotCurve);
for (size_t i = 0; i < curveArr.size(); i++)
{
const RigFlowDiagSolverInterface::PvtCurve& curve = curveArr[i];
QwtPlotCurve* qwtCurve = new QwtPlotCurve();
CVF_ASSERT(curve.xVals.size() == curve.yVals.size());
qwtCurve->setSamples(curve.xVals.data(), curve.yVals.data(), static_cast<int>(curve.xVals.size()));
qwtCurve->setStyle(QwtPlotCurve::Lines);
QColor curveClr = Qt::magenta;
if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::GAS) curveClr = QColor(Qt::red);
else if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::OIL) curveClr = QColor(Qt::green);
else if (curve.phase == RigFlowDiagSolverInterface::PvtCurve::WATER) curveClr = QColor(Qt::blue);
const QPen curvePen(curveClr);
qwtCurve->setPen(curvePen);
qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
qwtCurve->attach(plot);
}
plot->setTitle(plotTitle);
plot->setAxisTitle(QwtPlot::xBottom, "Pressure");
plot->setAxisTitle(QwtPlot::yLeft, yAxisTitle);
plot->replot();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiuPvtPlotPanel::slotPhaseComboCurrentIndexChanged(int)
{
plotUiSelectedCurves();
}

View File

@ -18,9 +18,9 @@
#pragma once
#include <QWidget>
#include "RigFlowDiagSolverInterface.h"
class RigFlowDiagSolverInterface;
#include <QWidget>
class QDockWidget;
class QwtPlot;
@ -34,22 +34,32 @@ class QComboBox;
//==================================================================================================
class RiuPvtPlotPanel : public QWidget
{
Q_OBJECT
public:
RiuPvtPlotPanel(QDockWidget* parent);
virtual ~RiuPvtPlotPanel();
void setPlotData(QString cellReferenceText);
void setPlotData(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& fvfCurveArr, const std::vector<RigFlowDiagSolverInterface::PvtCurve>& viscosityCurveArr, QString cellReferenceText);
void clearPlot();
private:
static void setPlotDefaults(QwtPlot* plot);
void plotUiSelectedCurves();
static void setPlotDefaults(QwtPlot* plot);
static void plotCurvesInQwt(const std::vector<RigFlowDiagSolverInterface::PvtCurve>& curveArr, QString plotTitle, QString yAxisTitle, QwtPlot* plot);
private slots:
void slotPhaseComboCurrentIndexChanged(int);
private:
QComboBox* m_phaseComboBox;
QwtPlot* m_fvfPlot;
QwtPlot* m_viscosityPlot;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allFvfCurvesArr;
std::vector<RigFlowDiagSolverInterface::PvtCurve> m_allViscosityCurvesArr;
QString m_cellReferenceText;
QComboBox* m_phaseComboBox;
QwtPlot* m_fvfPlot;
QwtPlot* m_viscosityPlot;
QString m_cellReferenceText;
};

View File

@ -383,14 +383,14 @@ void RiuSelectionChangedHandler::updatePvtPlot(const RiuSelectionItem* selection
size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseResultCase->eclipseCaseData(), eclipseSelectionItem->m_gridIndex, eclipseSelectionItem->m_gridLocalCellIndex);
if (activeCellIndex != cvf::UNDEFINED_SIZE_T)
{
//cvf::Trace::show("Update PVT plot for active cell index: %d", static_cast<int>(activeCellIndex));
cvf::Trace::show("Update PVT plots for active cell index: %d", static_cast<int>(activeCellIndex));
//std::vector<RigFlowDiagSolverInterface::PvtCurve> fvfCurveArr = eclipseResultCase->flowDiagSolverInterface()->calculatePvtFvfCurvesForActiveCell(activeCellIndex);
//cvf::Trace::show("Got %d fvf curves", static_cast<int>(fvfCurveArr.size()));
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);
pvtPlotPanel->setPlotData(cellRefText);
pvtPlotPanel->setPlotData(fvfCurveArr, viscosityCurveArr, cellRefText);
mustClearPlot = false;
}
}