mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
First working version of well distribution plots
This commit is contained in:
parent
4ce07ebb23
commit
3f36826662
@ -14,6 +14,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellRftEnsembleCurveSet.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDistributionPlot.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDistributionPlotCollection.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -31,6 +32,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellRftEnsembleCurveSet.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDistributionPlot.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimWellDistributionPlotCollection.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimWellAllocationPlot.h"
|
||||
#include "RimWellDistributionPlot.h"
|
||||
#include "RimWellDistributionPlotCollection.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
#include "cvfAssert.h"
|
||||
@ -43,8 +44,11 @@ RimFlowPlotCollection::RimFlowPlotCollection()
|
||||
CAF_PDM_InitFieldNoDefault( &m_defaultWellAllocPlot, "DefaultWellAllocationPlot", "", "", "", "" );
|
||||
m_defaultWellAllocPlot.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wellDistributionPlot, "WellDistributionPlot", "", "", "", "" );
|
||||
m_wellDistributionPlot.uiCapability()->setUiHidden( true );
|
||||
//CAF_PDM_InitFieldNoDefault( &m_dbgWellDistributionPlot, "DbgWellDistributionPlot", "", "", "", "" );
|
||||
//m_dbgWellDistributionPlot.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_wellDistributionPlotCollection, "WellDistributionPlotCollection", "", "", "", "" );
|
||||
m_wellDistributionPlotCollection.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_storedWellAllocPlots,
|
||||
"StoredWellAllocationPlots",
|
||||
@ -82,6 +86,8 @@ void RimFlowPlotCollection::closeDefaultPlotWindowAndDeletePlots()
|
||||
}
|
||||
|
||||
delete m_flowCharacteristicsPlot;
|
||||
//delete m_dbgWellDistributionPlot;
|
||||
delete m_wellDistributionPlotCollection;
|
||||
|
||||
m_storedWellAllocPlots.deleteAllChildObjects();
|
||||
m_storedFlowCharacteristicsPlots.deleteAllChildObjects();
|
||||
@ -92,7 +98,7 @@ void RimFlowPlotCollection::closeDefaultPlotWindowAndDeletePlots()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFlowPlotCollection::loadDataAndUpdate()
|
||||
{
|
||||
caf::ProgressInfo plotProgress( m_storedWellAllocPlots.size() + m_storedFlowCharacteristicsPlots.size() + 2, "" );
|
||||
caf::ProgressInfo plotProgress( m_storedWellAllocPlots.size() + m_storedFlowCharacteristicsPlots.size() + 3, "" );
|
||||
|
||||
if ( m_defaultWellAllocPlot ) m_defaultWellAllocPlot->loadDataAndUpdate();
|
||||
plotProgress.incrementProgress();
|
||||
@ -114,9 +120,14 @@ void RimFlowPlotCollection::loadDataAndUpdate()
|
||||
m_flowCharacteristicsPlot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
if ( m_wellDistributionPlot )
|
||||
//if ( m_dbgWellDistributionPlot )
|
||||
//{
|
||||
// m_dbgWellDistributionPlot->loadDataAndUpdate();
|
||||
//}
|
||||
|
||||
if ( m_wellDistributionPlotCollection )
|
||||
{
|
||||
m_wellDistributionPlot->loadDataAndUpdate();
|
||||
m_wellDistributionPlotCollection->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
@ -195,8 +206,14 @@ void RimFlowPlotCollection::ensureDefaultFlowPlotsAreCreated()
|
||||
m_flowCharacteristicsPlot = new RimFlowCharacteristicsPlot;
|
||||
}
|
||||
|
||||
if ( !m_wellDistributionPlot() )
|
||||
//if ( !m_dbgWellDistributionPlot() )
|
||||
//{
|
||||
// m_dbgWellDistributionPlot = new RimWellDistributionPlot;
|
||||
// m_dbgWellDistributionPlot->setAsPlotMdiWindow();
|
||||
//}
|
||||
|
||||
if ( !m_wellDistributionPlotCollection() )
|
||||
{
|
||||
m_wellDistributionPlot = new RimWellDistributionPlot;
|
||||
m_wellDistributionPlotCollection = new RimWellDistributionPlotCollection;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
class RimWellAllocationPlot;
|
||||
class RimFlowCharacteristicsPlot;
|
||||
class RimWellDistributionPlot;
|
||||
class RimWellDistributionPlotCollection;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -49,9 +51,10 @@ public:
|
||||
void ensureDefaultFlowPlotsAreCreated();
|
||||
|
||||
private:
|
||||
caf::PdmChildField<RimFlowCharacteristicsPlot*> m_flowCharacteristicsPlot;
|
||||
caf::PdmChildField<RimWellAllocationPlot*> m_defaultWellAllocPlot;
|
||||
caf::PdmChildField<RimWellDistributionPlot*> m_wellDistributionPlot;
|
||||
caf::PdmChildArrayField<RimWellAllocationPlot*> m_storedWellAllocPlots;
|
||||
caf::PdmChildArrayField<RimFlowCharacteristicsPlot*> m_storedFlowCharacteristicsPlots;
|
||||
caf::PdmChildField<RimFlowCharacteristicsPlot*> m_flowCharacteristicsPlot;
|
||||
caf::PdmChildField<RimWellAllocationPlot*> m_defaultWellAllocPlot;
|
||||
//caf::PdmChildField<RimWellDistributionPlot*> m_dbgWellDistributionPlot;
|
||||
caf::PdmChildField<RimWellDistributionPlotCollection*> m_wellDistributionPlotCollection;
|
||||
caf::PdmChildArrayField<RimWellAllocationPlot*> m_storedWellAllocPlots;
|
||||
caf::PdmChildArrayField<RimFlowCharacteristicsPlot*> m_storedFlowCharacteristicsPlots;
|
||||
};
|
||||
|
@ -26,19 +26,22 @@
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "RiuQwtPlotTools.h"
|
||||
#include "RiuQwtPlotWidget.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_legend_label.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QTextBrowser>
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfTrace.h"
|
||||
#include "cvfDebugTimer.h"
|
||||
//#include "cvfBase.h"
|
||||
//#include "cvfTrace.h"
|
||||
//#include "cvfDebugTimer.h"
|
||||
|
||||
#include <array>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -52,19 +55,19 @@ CAF_PDM_SOURCE_INIT(RimWellDistributionPlot, "WellDistributionPlot");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellDistributionPlot::RimWellDistributionPlot()
|
||||
RimWellDistributionPlot::RimWellDistributionPlot(RiaDefines::PhaseType phase)
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::RimWellDistributionPlot()");
|
||||
//cvf::Trace::show("RimWellDistributionPlot::RimWellDistributionPlot()");
|
||||
|
||||
CAF_PDM_InitObject("Well Distribution Plot", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_case, "Case", "Case", "", "", "");
|
||||
CAF_PDM_InitField(&m_timeStepIndex, "TimeStepIndex", -1, "Time Step", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
|
||||
CAF_PDM_InitField(&m_phase, "Phase", caf::AppEnum<RiaDefines::PhaseType>(phase), "Phase", "", "", "");
|
||||
|
||||
m_showWindow = false;
|
||||
|
||||
setAsPlotMdiWindow();
|
||||
m_showPlotLegends = true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -77,27 +80,131 @@ RimWellDistributionPlot::~RimWellDistributionPlot()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimWellDistributionPlot::viewWidget()
|
||||
void RimWellDistributionPlot::setDataSourceParameters(RimEclipseResultCase* eclipseResultCase, int timeStepIndex, QString targetWellName)
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::viewWidget()");
|
||||
return m_myViewWidget;
|
||||
m_case = eclipseResultCase;
|
||||
m_timeStepIndex = timeStepIndex;
|
||||
m_wellName = targetWellName;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QImage RimWellDistributionPlot::snapshotWindowContent()
|
||||
RiuQwtPlotWidget* RimWellDistributionPlot::viewer()
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::snapshotWindowContent()");
|
||||
return QImage();
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::zoomAll()
|
||||
void RimWellDistributionPlot::setAutoScaleXEnabled(bool /*enabled*/)
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::zoomAll()");
|
||||
//cvf::Trace::show("RimWellDistributionPlot::setAutoScaleXEnabled()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::setAutoScaleYEnabled(bool /*enabled*/)
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::setAutoScaleYEnabled()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::updateAxes()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::updateAxes()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::updateLegend()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::updateLegend()");
|
||||
|
||||
if (!m_plotWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// For now we always show the legend when in multiplot mode
|
||||
bool doShowLegend = true;
|
||||
if (isMdiWindow())
|
||||
{
|
||||
doShowLegend = m_showPlotLegends;
|
||||
}
|
||||
|
||||
if (doShowLegend)
|
||||
{
|
||||
QwtLegend* legend = new QwtLegend(m_plotWidget);
|
||||
m_plotWidget->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plotWidget->insertLegend(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::updateZoomInQwt()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::updateZoomInQwt()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::updateZoomFromQwt()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::updateZoomFromQwt()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimWellDistributionPlot::asciiDataForPlotExport() const
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::asciiDataForPlotExport()");
|
||||
return QString();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::reattachAllCurves()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::reattachAllCurves()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::detachAllCurves()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::detachAllCurves()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObject* RimWellDistributionPlot::findPdmObjectFromQwtCurve(const QwtPlotCurve* /*curve*/) const
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::findPdmObjectFromQwtCurve()");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::onAxisSelected(int /*axis*/, bool /*toggle*/)
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::onAxisSelected()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -111,51 +218,68 @@ QString RimWellDistributionPlot::description() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimWellDistributionPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
QWidget* RimWellDistributionPlot::viewWidget()
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
|
||||
|
||||
m_myViewWidget = new QWidget(mainWindowParent);
|
||||
|
||||
QGridLayout* gridLayout = new QGridLayout(m_myViewWidget);
|
||||
|
||||
m_textBrowser = new QTextBrowser;
|
||||
m_textBrowser->setText("<center><h1>NotYet</h1></center>");
|
||||
gridLayout->addWidget(m_textBrowser, 0, 0);
|
||||
|
||||
m_plotWidgets[0] = constructNewPlotWidget();
|
||||
m_plotWidgets[1] = constructNewPlotWidget();
|
||||
m_plotWidgets[2] = constructNewPlotWidget();
|
||||
|
||||
gridLayout->addWidget(m_plotWidgets[0], 1, 0);
|
||||
gridLayout->addWidget(m_plotWidgets[1], 0, 1);
|
||||
gridLayout->addWidget(m_plotWidgets[2], 1, 1);
|
||||
|
||||
onLoadDataAndUpdate();
|
||||
|
||||
return m_myViewWidget;
|
||||
//cvf::Trace::show("RimWellDistributionPlot::viewWidget()");
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QwtPlot* RimWellDistributionPlot::constructNewPlotWidget()
|
||||
QImage RimWellDistributionPlot::snapshotWindowContent()
|
||||
{
|
||||
class MyQwtPlot : public QwtPlot
|
||||
//cvf::Trace::show("RimWellDistributionPlot::snapshotWindowContent()");
|
||||
|
||||
QImage image;
|
||||
|
||||
if (m_plotWidget)
|
||||
{
|
||||
public:
|
||||
MyQwtPlot(QWidget* parent) : QwtPlot(parent) {}
|
||||
QSize sizeHint() const override { return QSize(100, 100); }
|
||||
QSize minimumSizeHint() const override { return QSize(0, 0); }
|
||||
};
|
||||
QPixmap pix = m_plotWidget->grab();
|
||||
image = pix.toImage();
|
||||
}
|
||||
|
||||
QwtPlot* plotWidget = new MyQwtPlot(nullptr);
|
||||
RiuQwtPlotTools::setCommonPlotBehaviour(plotWidget);
|
||||
return image;
|
||||
}
|
||||
|
||||
QwtLegend* legend = new QwtLegend(plotWidget);
|
||||
plotWidget->insertLegend(legend, QwtPlot::BottomLegend);
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::zoomAll()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::zoomAll()");
|
||||
}
|
||||
|
||||
return plotWidget;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::doRemoveFromCollection()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::doRemoveFromCollection()");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RimWellDistributionPlot::createViewWidget(QWidget* mainWindowParent)
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::createViewWidget()");
|
||||
|
||||
// It seems we risk being called multiple times
|
||||
if (m_plotWidget)
|
||||
{
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
m_plotWidget = new RiuQwtPlotWidget(this, mainWindowParent);
|
||||
|
||||
m_plotWidget->setAutoReplot(false);
|
||||
m_plotWidget->setDraggable(false);
|
||||
|
||||
updateLegend();
|
||||
onLoadDataAndUpdate();
|
||||
|
||||
return m_plotWidget;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -163,21 +287,80 @@ QwtPlot* RimWellDistributionPlot::constructNewPlotWidget()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::deleteViewWidget()
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::deleteViewWidget()");
|
||||
//cvf::Trace::show("RimWellDistributionPlot::deleteViewWidget()");
|
||||
|
||||
if (m_myViewWidget)
|
||||
if (m_plotWidget)
|
||||
{
|
||||
m_myViewWidget->deleteLater();
|
||||
m_myViewWidget = nullptr;
|
||||
m_plotWidget->setParent(nullptr);
|
||||
delete m_plotWidget;
|
||||
m_plotWidget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::populatePlotWidgetWithCurveData(const RigTofWellDistributionCalculator& calculator, RiaDefines::PhaseType phase, const RimFlowDiagSolution& flowDiagSolution, QwtPlot* plotWidget)
|
||||
void RimWellDistributionPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::populatePlotWidgetWithCurves(phase=%d '%s')", phase, phase == RiaDefines::OIL_PHASE ? "oil" : (phase == RiaDefines::GAS_PHASE ? "gas" : "water"));
|
||||
//cvf::Trace::show("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
||||
//cvf::DebugTimer tim("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
||||
|
||||
if (isMdiWindow())
|
||||
{
|
||||
updateMdiWindowVisibility();
|
||||
}
|
||||
else
|
||||
{
|
||||
updateParentLayout();
|
||||
}
|
||||
|
||||
if (!m_plotWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
m_plotWidget->detachItems(QwtPlotItem::Rtti_PlotCurve);
|
||||
|
||||
updateLegend();
|
||||
|
||||
if (m_case)
|
||||
{
|
||||
//tim.reportLapTimeMS("about to start calc");
|
||||
RigTofWellDistributionCalculator calc(m_case, m_wellName, m_timeStepIndex, m_phase());
|
||||
//tim.reportLapTimeMS("calc");
|
||||
|
||||
//calc.groupSmallContributions(0.005);
|
||||
//tim.reportLapTimeMS("group");
|
||||
|
||||
const RimFlowDiagSolution* flowDiagSolution = m_case->defaultFlowDiagSolution();
|
||||
|
||||
populatePlotWidgetWithCurveData(calc, *flowDiagSolution, m_plotWidget);
|
||||
}
|
||||
|
||||
QString phaseString = "N/A";
|
||||
if (m_phase == RiaDefines::OIL_PHASE) phaseString = "Oil";
|
||||
else if (m_phase == RiaDefines::GAS_PHASE) phaseString = "Gas";
|
||||
else if (m_phase == RiaDefines::WATER_PHASE) phaseString = "Water";
|
||||
|
||||
const QString timeStepName = m_case ? m_case->timeStepName(m_timeStepIndex) : "N/A";
|
||||
|
||||
const QString plotTitleStr = QString("%1 Distribution: %2, %3").arg(phaseString).arg(m_wellName).arg(timeStepName);
|
||||
m_plotWidget->setTitle(plotTitleStr);
|
||||
|
||||
m_plotWidget->setAxisTitleText(QwtPlot::xBottom, "TOF [years]");
|
||||
m_plotWidget->setAxisTitleText(QwtPlot::yLeft, "Reservoir Volume [m3]");
|
||||
m_plotWidget->setAxisTitleEnabled(QwtPlot::xBottom, true);
|
||||
m_plotWidget->setAxisTitleEnabled(QwtPlot::yLeft, true);
|
||||
|
||||
m_plotWidget->scheduleReplot();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::populatePlotWidgetWithCurveData(const RigTofWellDistributionCalculator& calculator, const RimFlowDiagSolution& flowDiagSolution, RiuQwtPlotWidget* plotWidget)
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlot::populatePlotWidgetWithCurves()");
|
||||
|
||||
// Currently select this value so that the grid appears on top of the curves
|
||||
const double baseCurveZValue = 9.5;
|
||||
@ -191,33 +374,33 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData(const RigTofWellDi
|
||||
const std::vector<double>& tofValuesDays = calculator.sortedUniqueTOFValues();
|
||||
if (tofValuesDays.size() == 0)
|
||||
{
|
||||
cvf::Trace::show("No TOF values!");
|
||||
//cvf::Trace::show("No TOF values!");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<double> tofValuesYears;
|
||||
for (double tofDays : tofValuesDays)
|
||||
{
|
||||
const double tofYears = tofDays/365.2425;
|
||||
const double tofYears = tofDays / 365.2425;
|
||||
tofValuesYears.push_back(tofYears);
|
||||
}
|
||||
|
||||
cvf::Trace::show("numTofValues: %d (min, max: %f, %f)", static_cast<int>(tofValuesYears.size()), tofValuesYears.front(), tofValuesYears.back());
|
||||
//cvf::Trace::show("numTofValues: %d (min, max: %f, %f)", static_cast<int>(tofValuesYears.size()), tofValuesYears.front(), tofValuesYears.back());
|
||||
|
||||
const size_t numWells = calculator.contributingWellCount();
|
||||
cvf::Trace::show("numContribWells: %d", static_cast<int>(numWells));
|
||||
//cvf::Trace::show("numContribWells: %d", static_cast<int>(numWells));
|
||||
|
||||
std::vector<double> yVals(tofValuesYears.size(), 0);
|
||||
|
||||
for (size_t i = 0; i < numWells; i++)
|
||||
{
|
||||
QString wellName = calculator.contributingWellName(i);
|
||||
const std::vector<double>& volArr = calculator.accumulatedPhaseVolumeForContributingWell(phase, i);
|
||||
const std::vector<double>& volArr = calculator.accumulatedVolumeForContributingWell(i);
|
||||
|
||||
cvf::Color3f cvfClr = flowDiagSolution.tracerColor(wellName);
|
||||
QColor qtClr = RiaColorTools::toQColor(cvfClr);
|
||||
|
||||
cvf::Trace::show("wellName min, max: %s %f, %f", wellName.toStdString().c_str(), volArr.front(), volArr.back());
|
||||
//cvf::Trace::show("wellName min, max: %s %f, %f", wellName.toStdString().c_str(), volArr.front(), volArr.back());
|
||||
|
||||
for (size_t j = 0; j < yVals.size(); j++)
|
||||
{
|
||||
@ -233,76 +416,6 @@ void RimWellDistributionPlot::populatePlotWidgetWithCurveData(const RigTofWellDi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::onLoadDataAndUpdate()
|
||||
{
|
||||
cvf::Trace::show("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
||||
cvf::DebugTimer tim("RimWellDistributionPlot::onLoadDataAndUpdate()");
|
||||
|
||||
updateMdiWindowVisibility();
|
||||
|
||||
if (!m_myViewWidget)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CVF_ASSERT(m_textBrowser);
|
||||
|
||||
QString str = "<center><h1>MyViewWidget</h1></center>";
|
||||
str += "<br><br>";
|
||||
|
||||
const QString caseName = m_case ? m_case->caseUserDescription() : "N/A";
|
||||
|
||||
str += QString("case: %1<br>").arg(caseName);
|
||||
str += QString("timeStepIndex: %1<br>").arg(m_timeStepIndex);
|
||||
str += QString("wellName: %1<br>").arg(m_wellName);
|
||||
|
||||
m_textBrowser->setText(str);
|
||||
|
||||
|
||||
for (QwtPlot* plotWidget : m_plotWidgets)
|
||||
{
|
||||
plotWidget->detachItems(QwtPlotItem::Rtti_PlotCurve);
|
||||
}
|
||||
|
||||
if (m_case)
|
||||
{
|
||||
tim.reportLapTimeMS("about to start calc");
|
||||
RigTofWellDistributionCalculator calc(m_case, m_wellName, m_timeStepIndex);
|
||||
tim.reportLapTimeMS("calc");
|
||||
|
||||
const QString timeStepName = m_case->timeStepName(m_timeStepIndex);
|
||||
|
||||
const RimFlowDiagSolution* flowDiagSolution = m_case->defaultFlowDiagSolution();
|
||||
for (int i = 0; i < m_plotWidgets.size(); i++)
|
||||
{
|
||||
const RiaDefines::PhaseType phase = static_cast<RiaDefines::PhaseType>(i);
|
||||
|
||||
QwtPlot* plotWidget = m_plotWidgets[i];
|
||||
populatePlotWidgetWithCurveData(calc, phase, *flowDiagSolution, plotWidget);
|
||||
|
||||
QString phaseString = "N/A";
|
||||
if (phase == RiaDefines::OIL_PHASE) phaseString = "Oil";
|
||||
else if (phase == RiaDefines::GAS_PHASE) phaseString = "Gas";
|
||||
else if (phase == RiaDefines::WATER_PHASE) phaseString = "Water";
|
||||
|
||||
plotWidget->setAxisTitle(QwtPlot::xBottom, "TOF [years]");
|
||||
plotWidget->setAxisTitle(QwtPlot::yLeft, "Reservoir Volume [m3]");
|
||||
|
||||
const QString plotTitle = QString("%1 Distribution: %2, %3").arg(phaseString).arg(m_wellName).arg(timeStepName);
|
||||
plotWidget->setTitle(plotTitle);
|
||||
}
|
||||
}
|
||||
|
||||
for (QwtPlot* plotWidget : m_plotWidgets)
|
||||
{
|
||||
plotWidget->replot();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -312,16 +425,18 @@ void RimWellDistributionPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiO
|
||||
group->add(&m_case);
|
||||
group->add(&m_timeStepIndex);
|
||||
group->add(&m_wellName);
|
||||
group->add(&m_phase);
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
RimPlot::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
//uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimWellDistributionPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* /*useOptionsOnly*/)
|
||||
QList<caf::PdmOptionItemInfo> RimWellDistributionPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
QList<caf::PdmOptionItemInfo> options = RimPlot::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
||||
|
||||
if (fieldNeedingOptions == &m_case)
|
||||
{
|
||||
@ -381,12 +496,14 @@ QList<caf::PdmOptionItemInfo> RimWellDistributionPlot::calculateValueOptions(con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
RimPlot::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (changedField == &m_case)
|
||||
{
|
||||
fixupDependentFieldsAfterCaseChange();
|
||||
}
|
||||
|
||||
onLoadDataAndUpdate();
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,21 +18,18 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimPlotWindow.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <array>
|
||||
|
||||
class RimEclipseResultCase;
|
||||
class RimFlowDiagSolution;
|
||||
class RigTofWellDistributionCalculator;
|
||||
class RiuQwtPlotWidget;
|
||||
|
||||
class QTextBrowser;
|
||||
class QwtPlot;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
@ -40,26 +37,41 @@ class QwtPlot;
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimWellDistributionPlot : public RimPlotWindow
|
||||
class RimWellDistributionPlot : public RimPlot
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellDistributionPlot();
|
||||
explicit RimWellDistributionPlot(RiaDefines::PhaseType phase = RiaDefines::OIL_PHASE);
|
||||
~RimWellDistributionPlot() override;
|
||||
|
||||
void setDataSourceParameters(RimEclipseResultCase* eclipseResultCase, int timeStepIndex, QString targetWellName);
|
||||
|
||||
// RimPlot implementations
|
||||
virtual RiuQwtPlotWidget* viewer() override;
|
||||
virtual void setAutoScaleXEnabled(bool enabled) override;
|
||||
virtual void setAutoScaleYEnabled(bool enabled) override;
|
||||
virtual void updateAxes() override;
|
||||
virtual void updateLegend() override;
|
||||
virtual void updateZoomInQwt() override;
|
||||
virtual void updateZoomFromQwt() override;
|
||||
virtual QString asciiDataForPlotExport() const override;
|
||||
virtual void reattachAllCurves() override;
|
||||
virtual void detachAllCurves() override;
|
||||
virtual caf::PdmObject* findPdmObjectFromQwtCurve(const QwtPlotCurve* curve) const override;
|
||||
virtual void onAxisSelected(int axis, bool toggle) override;
|
||||
|
||||
// RimPlotWindow implementations
|
||||
virtual QString description() const override;
|
||||
virtual QString description() const override;
|
||||
|
||||
// RimViewWindow implementations
|
||||
virtual QWidget* viewWidget() override;
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
virtual void zoomAll() override;
|
||||
virtual QWidget* viewWidget() override;
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
virtual void zoomAll() override;
|
||||
|
||||
private:
|
||||
// RimPlotWindow overrides
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
// RimPlot implementations
|
||||
virtual void doRemoveFromCollection() override;
|
||||
|
||||
// RimViewWindow implementations
|
||||
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
|
||||
@ -67,18 +79,18 @@ private:
|
||||
virtual void onLoadDataAndUpdate() override;
|
||||
|
||||
private:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fixupDependentFieldsAfterCaseChange();
|
||||
static QwtPlot* constructNewPlotWidget();
|
||||
static void populatePlotWidgetWithCurveData(const RigTofWellDistributionCalculator& calculator, RiaDefines::PhaseType phase, const RimFlowDiagSolution& flowDiagSolution, QwtPlot* plotWidget);
|
||||
|
||||
static void populatePlotWidgetWithCurveData(const RigTofWellDistributionCalculator& calculator, const RimFlowDiagSolution& flowDiagSolution, RiuQwtPlotWidget* plotWidget);
|
||||
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimEclipseResultCase*> m_case;
|
||||
caf::PdmField<int> m_timeStepIndex;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmPtrField<RimEclipseResultCase*> m_case;
|
||||
caf::PdmField<int> m_timeStepIndex;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField< caf::AppEnum<RiaDefines::PhaseType>> m_phase;
|
||||
|
||||
QPointer<QWidget> m_myViewWidget;
|
||||
QPointer<QTextBrowser> m_textBrowser;
|
||||
std::array<QPointer<QwtPlot>, 3> m_plotWidgets;
|
||||
QPointer<RiuQwtPlotWidget> m_plotWidget;
|
||||
};
|
||||
|
@ -0,0 +1,245 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RimWellDistributionPlotCollection.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimWellDistributionPlot.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
#include "RigTofWellDistributionCalculator.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
#include "RiuQwtPlotTools.h"
|
||||
|
||||
#include "qwt_plot.h"
|
||||
#include "qwt_legend.h"
|
||||
#include "qwt_plot_curve.h"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QGridLayout>
|
||||
#include <QTextBrowser>
|
||||
|
||||
//#include "cvfBase.h"
|
||||
//#include "cvfTrace.h"
|
||||
//#include "cvfDebugTimer.h"
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimWellDistributionPlotCollection, "WellDistributionPlotCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()
|
||||
: RimMultiPlotWindow(true)
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlotCollection::RimWellDistributionPlotCollection()");
|
||||
|
||||
CAF_PDM_InitObject("Well Distribution Plots", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_case, "Case", "Case", "", "", "");
|
||||
CAF_PDM_InitField(&m_timeStepIndex, "TimeStepIndex", -1, "Time Step", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
|
||||
|
||||
m_plotWindowTitle = "Well Distribution Plots";
|
||||
m_columnCountEnum = RimMultiPlotWindow::COLUMNS_UNLIMITED;
|
||||
|
||||
m_showPlotLegends = false;
|
||||
m_showWindow = false;
|
||||
|
||||
setAcceptDrops(false);
|
||||
setAsPlotMdiWindow();
|
||||
|
||||
addPlot(new RimWellDistributionPlot(RiaDefines::OIL_PHASE));
|
||||
addPlot(new RimWellDistributionPlot(RiaDefines::GAS_PHASE));
|
||||
addPlot(new RimWellDistributionPlot(RiaDefines::WATER_PHASE));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellDistributionPlotCollection::~RimWellDistributionPlotCollection()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::onLoadDataAndUpdate()
|
||||
{
|
||||
//cvf::Trace::show("RimWellDistributionPlotCollection::onLoadDataAndUpdate()");
|
||||
|
||||
RimMultiPlotWindow::onLoadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Plot Data");
|
||||
group->add(&m_case);
|
||||
group->add(&m_timeStepIndex);
|
||||
group->add(&m_wellName);
|
||||
|
||||
//RimMultiPlotWindow::defineUiOrdering(uiConfigName, uiOrdering);
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimWellDistributionPlotCollection::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly)
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options = RimMultiPlotWindow::calculateValueOptions(fieldNeedingOptions, useOptionsOnly);
|
||||
|
||||
if (fieldNeedingOptions == &m_case)
|
||||
{
|
||||
RimProject* ownerProj = nullptr;
|
||||
firstAncestorOrThisOfType(ownerProj);
|
||||
if (ownerProj)
|
||||
{
|
||||
std::vector<RimEclipseResultCase*> caseArr;
|
||||
ownerProj->descendantsIncludingThisOfType(caseArr);
|
||||
for (RimEclipseResultCase* c : caseArr)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(c->caseUserDescription(), c, true, c->uiIconProvider()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (fieldNeedingOptions == &m_timeStepIndex)
|
||||
{
|
||||
if (m_case && m_case->eclipseCaseData())
|
||||
{
|
||||
const QStringList timeStepNames = m_case->timeStepStrings();
|
||||
for (int i = 0; i < timeStepNames.size(); i++)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.size() == 0)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo("None", -1));
|
||||
}
|
||||
}
|
||||
|
||||
else if (fieldNeedingOptions == &m_wellName)
|
||||
{
|
||||
if (m_case && m_case->eclipseCaseData())
|
||||
{
|
||||
caf::QIconProvider simWellIcon(":/Well.png");
|
||||
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
|
||||
for (const QString& name : sortedWellNameSet)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo(name, name, true, simWellIcon));
|
||||
}
|
||||
}
|
||||
|
||||
if (options.size() == 0)
|
||||
{
|
||||
options.push_back(caf::PdmOptionItemInfo("None", QVariant()));
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
||||
{
|
||||
if (changedField == &m_case)
|
||||
{
|
||||
fixupDependentFieldsAfterCaseChange();
|
||||
}
|
||||
|
||||
bool shouldRecalculatePlotData = false;
|
||||
if (changedField == &m_case ||
|
||||
changedField == &m_timeStepIndex ||
|
||||
changedField == &m_wellName)
|
||||
{
|
||||
applyPlotDataParametersToContainedPlots();
|
||||
shouldRecalculatePlotData = true;
|
||||
}
|
||||
|
||||
RimMultiPlotWindow::fieldChangedByUi(changedField, oldValue, newValue);
|
||||
|
||||
if (shouldRecalculatePlotData)
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::applyPlotDataParametersToContainedPlots()
|
||||
{
|
||||
const size_t numPlots = plotCount();
|
||||
for (size_t i = 0; i < numPlots; i++)
|
||||
{
|
||||
// Dirty usage of dyn_cast, but type is lost when adding the plots to our base class
|
||||
RimWellDistributionPlot* aPlot = dynamic_cast<RimWellDistributionPlot*>(plotByIndex(i));
|
||||
if (aPlot)
|
||||
{
|
||||
aPlot->setDataSourceParameters(m_case, m_timeStepIndex, m_wellName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellDistributionPlotCollection::fixupDependentFieldsAfterCaseChange()
|
||||
{
|
||||
int newTimeStepIndex = -1;
|
||||
QString newWellName;
|
||||
|
||||
if (m_case)
|
||||
{
|
||||
const int timeStepCount = m_case->timeStepStrings().size();
|
||||
if (timeStepCount > 0)
|
||||
{
|
||||
newTimeStepIndex = timeStepCount - 1;
|
||||
}
|
||||
|
||||
const std::set<QString> sortedWellNameSet = m_case->eclipseCaseData()->findSortedWellNames();
|
||||
if (sortedWellNameSet.size() > 0)
|
||||
{
|
||||
newWellName = *sortedWellNameSet.begin();
|
||||
}
|
||||
}
|
||||
|
||||
m_timeStepIndex = newTimeStepIndex;
|
||||
m_wellName = newWellName;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,67 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- Equinor 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 "RimMultiPlotWindow.h"
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
#include <array>
|
||||
|
||||
class RimEclipseResultCase;
|
||||
class RimFlowDiagSolution;
|
||||
class RigTofWellDistributionCalculator;
|
||||
|
||||
class QTextBrowser;
|
||||
class QwtPlot;
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimWellDistributionPlotCollection : public RimMultiPlotWindow
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimWellDistributionPlotCollection();
|
||||
~RimWellDistributionPlotCollection() override;
|
||||
|
||||
private:
|
||||
// RimPlotWindow overrides
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
||||
virtual void onLoadDataAndUpdate() override;
|
||||
|
||||
private:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
void fixupDependentFieldsAfterCaseChange();
|
||||
void applyPlotDataParametersToContainedPlots();
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimEclipseResultCase*> m_case;
|
||||
caf::PdmField<int> m_timeStepIndex;
|
||||
caf::PdmField<QString> m_wellName;
|
||||
};
|
@ -33,8 +33,6 @@
|
||||
#include "RimFlowDiagSolution.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
|
||||
#include "cvfTrace.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
|
||||
@ -48,7 +46,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseResultCase* caseToApply, QString targetWellname, size_t timeStepIndex)
|
||||
RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseResultCase* caseToApply, QString targetWellname, size_t timeStepIndex, RiaDefines::PhaseType phase)
|
||||
{
|
||||
CVF_ASSERT(caseToApply);
|
||||
|
||||
@ -62,14 +60,21 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseRes
|
||||
CVF_ASSERT(flowDiagResults);
|
||||
|
||||
const std::vector<double>* porvResults = eclipseCaseData->resultValues(RiaDefines::MATRIX_MODEL, RiaDefines::STATIC_NATIVE, "PORV", 0);
|
||||
const std::vector<double>* swatResults = eclipseCaseData->resultValues( RiaDefines::MATRIX_MODEL, RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex);
|
||||
const std::vector<double>* soilResults = eclipseCaseData->resultValues( RiaDefines::MATRIX_MODEL, RiaDefines::DYNAMIC_NATIVE, "SOIL", timeStepIndex);
|
||||
const std::vector<double>* sgasResults = eclipseCaseData->resultValues( RiaDefines::MATRIX_MODEL, RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex);
|
||||
if (!porvResults)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QString phaseResultName;
|
||||
if (phase == RiaDefines::WATER_PHASE) phaseResultName = "SWAT";
|
||||
else if (phase == RiaDefines::OIL_PHASE) phaseResultName = "SOIL";
|
||||
else if (phase == RiaDefines::GAS_PHASE) phaseResultName = "SGAS";
|
||||
const std::vector<double>* phaseResults = eclipseCaseData->resultValues(RiaDefines::MATRIX_MODEL, RiaDefines::DYNAMIC_NATIVE, phaseResultName, timeStepIndex);
|
||||
if (!phaseResults)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const RigFlowDiagResultAddress resultAddrTof("TOF", RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, targetWellname.toStdString());
|
||||
const RigFlowDiagResultAddress resultAddrFraction("Fraction", RigFlowDiagResultAddress::PhaseSelection::PHASE_ALL, targetWellname.toStdString());
|
||||
const std::vector<double>* tofData = flowDiagResults->resultValues(resultAddrTof, timeStepIndex);
|
||||
@ -96,9 +101,7 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseRes
|
||||
continue;
|
||||
}
|
||||
|
||||
double accumulatedVol_wat = 0;
|
||||
double accumulatedVol_oil = 0;
|
||||
double accumulatedVol_gas = 0;
|
||||
double accumulatedVolForSpecifiedPhase = 0;
|
||||
|
||||
ContribWellEntry contribWellEntry;
|
||||
contribWellEntry.name = contribWellName;
|
||||
@ -119,15 +122,10 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseRes
|
||||
}
|
||||
|
||||
const double volAllPhasesThisCell = porv * targetWellFractionVal*contribWellFractionVal;
|
||||
|
||||
if (swatResults) accumulatedVol_wat += swatResults->at(cellIndex)*volAllPhasesThisCell;
|
||||
if (soilResults) accumulatedVol_oil += soilResults->at(cellIndex)*volAllPhasesThisCell;
|
||||
if (sgasResults) accumulatedVol_gas += sgasResults->at(cellIndex)*volAllPhasesThisCell;
|
||||
accumulatedVolForSpecifiedPhase += phaseResults->at(cellIndex)*volAllPhasesThisCell;
|
||||
}
|
||||
|
||||
contribWellEntry.accumulatedVolAlongTof_wat.push_back(accumulatedVol_wat);
|
||||
contribWellEntry.accumulatedVolAlongTof_oil.push_back(accumulatedVol_oil);
|
||||
contribWellEntry.accumulatedVolAlongTof_gas.push_back(accumulatedVol_gas);
|
||||
contribWellEntry.accumulatedVolAlongTof.push_back(accumulatedVolForSpecifiedPhase);
|
||||
}
|
||||
|
||||
m_contributingWells.push_back(contribWellEntry);
|
||||
@ -140,6 +138,52 @@ RigTofWellDistributionCalculator::RigTofWellDistributionCalculator(RimEclipseRes
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTofWellDistributionCalculator::groupSmallContributions(double smallContribThreshold)
|
||||
{
|
||||
if (m_tofInIncreasingOrder.size() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double totalVolAtLastTof = 0;
|
||||
for (const ContribWellEntry& entry : m_contributingWells)
|
||||
{
|
||||
totalVolAtLastTof += entry.accumulatedVolAlongTof.back();
|
||||
}
|
||||
|
||||
std::vector<ContribWellEntry> sourceEntryArr = std::move(m_contributingWells);
|
||||
|
||||
ContribWellEntry groupEntry;
|
||||
groupEntry.name = "Other";
|
||||
groupEntry.accumulatedVolAlongTof.resize(m_tofInIncreasingOrder.size(), 0);
|
||||
bool anySmallContribsDetected = false;
|
||||
|
||||
for (const ContribWellEntry& sourceEntry : sourceEntryArr)
|
||||
{
|
||||
const double volAtLastTof = sourceEntry.accumulatedVolAlongTof.back();
|
||||
if (volAtLastTof >= totalVolAtLastTof*smallContribThreshold)
|
||||
{
|
||||
m_contributingWells.push_back(sourceEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (size_t i = 0; i < groupEntry.accumulatedVolAlongTof.size(); i++)
|
||||
{
|
||||
groupEntry.accumulatedVolAlongTof[i] += sourceEntry.accumulatedVolAlongTof[i];
|
||||
}
|
||||
anySmallContribsDetected = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (anySmallContribsDetected)
|
||||
{
|
||||
m_contributingWells.push_back(groupEntry);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -231,22 +275,10 @@ const QString& RigTofWellDistributionCalculator::contributingWellName(size_t con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RigTofWellDistributionCalculator::accumulatedPhaseVolumeForContributingWell(RiaDefines::PhaseType phase, size_t contributingWellIndex) const
|
||||
const std::vector<double>& RigTofWellDistributionCalculator::accumulatedVolumeForContributingWell(size_t contributingWellIndex) const
|
||||
{
|
||||
CVF_ASSERT(contributingWellIndex < m_contributingWells.size());
|
||||
const ContribWellEntry& entry = m_contributingWells[contributingWellIndex];
|
||||
|
||||
if (phase == RiaDefines::WATER_PHASE)
|
||||
{
|
||||
return entry.accumulatedVolAlongTof_wat;
|
||||
}
|
||||
else if (phase == RiaDefines::OIL_PHASE)
|
||||
{
|
||||
return entry.accumulatedVolAlongTof_oil;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entry.accumulatedVolAlongTof_gas;
|
||||
}
|
||||
return entry.accumulatedVolAlongTof;
|
||||
}
|
||||
|
||||
|
@ -39,13 +39,15 @@ class QString;
|
||||
class RigTofWellDistributionCalculator
|
||||
{
|
||||
public:
|
||||
RigTofWellDistributionCalculator(RimEclipseResultCase* caseToApply, QString targetWellname, size_t timeStepIndex);
|
||||
RigTofWellDistributionCalculator(RimEclipseResultCase* caseToApply, QString targetWellname, size_t timeStepIndex, RiaDefines::PhaseType phase);
|
||||
|
||||
void groupSmallContributions(double smallContribThreshold);
|
||||
|
||||
const std::vector<double>& sortedUniqueTOFValues() const;
|
||||
|
||||
size_t contributingWellCount() const;
|
||||
const QString& contributingWellName(size_t contribWellIndex) const;
|
||||
const std::vector<double>& accumulatedPhaseVolumeForContributingWell(RiaDefines::PhaseType phase, size_t contributingWellIndex) const;
|
||||
const std::vector<double>& accumulatedVolumeForContributingWell(size_t contributingWellIndex) const;
|
||||
|
||||
private:
|
||||
static std::map<double, std::vector<size_t>> buildSortedTofToCellIndicesMap(const std::vector<double>& tofData);
|
||||
@ -54,9 +56,7 @@ private:
|
||||
struct ContribWellEntry
|
||||
{
|
||||
QString name;
|
||||
std::vector<double> accumulatedVolAlongTof_wat; // All these three have same size as m_tofInIncreasingOrder
|
||||
std::vector<double> accumulatedVolAlongTof_oil; //
|
||||
std::vector<double> accumulatedVolAlongTof_gas; //
|
||||
std::vector<double> accumulatedVolAlongTof; // This array has same size as m_tofInIncreasingOrder
|
||||
};
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user