#1108, #1110, #1116 Pie chart Well Allocation Factors now working.

This commit is contained in:
Jacob Støren
2017-02-02 11:22:02 +01:00
parent 7abdc38d92
commit eee43ccf0f
4 changed files with 105 additions and 152 deletions

View File

@@ -32,6 +32,7 @@
#include "RiuMainPlotWindow.h"
#include "RiuNightchartsWidget.h"
#include "RiuWellAllocationPlot.h"
#include "cvfColor3.h"
CAF_PDM_SOURCE_INIT(RimTotalWellAllocationPlot, "TotalWellAllocationPlot");
@@ -48,7 +49,6 @@ RimTotalWellAllocationPlot::RimTotalWellAllocationPlot()
m_userName.uiCapability()->setUiReadOnly(true);
CAF_PDM_InitField(&m_showPlotTitle, "ShowPlotTitle", true, "Show Plot Title", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_simulationWell, "SimulationWell", "Simulation Well", "", "", "");
}
@@ -62,15 +62,6 @@ RimTotalWellAllocationPlot::~RimTotalWellAllocationPlot()
deleteViewWidget();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::setSimulationWell(RimEclipseWell* simWell)
{
m_simulationWell = simWell;
updateFromWell();
}
//--------------------------------------------------------------------------------------------------
///
@@ -84,60 +75,6 @@ void RimTotalWellAllocationPlot::deleteViewWidget()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::updateFromWell()
{
/*
QString simName = "None";
int branchCount = 0;
const RigWellResultFrame* wellResultFrame = nullptr;
if (m_simulationWell && m_simulationWell->wellResults() )// && Timestep Ok )
{
simName = m_simulationWell->name();
wellResultFrame = &(m_simulationWell->wellResults()->wellResultFrame(1));
branchCount = static_cast<int>( wellResultFrame->m_wellResultBranches.size());
// // Todo : Use this instead, and use to calculate accumulated flow
//
// size_t timeStep = 0; // make field
// std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
// std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
// m_simulationWell->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds);
// branchCount = static_cast<int>( pipeBranchesCLCoords.size());
}
int existingTrackCount = static_cast<int>(accumulatedWellFlowPlot()->trackCount());
accumulatedWellFlowPlot()->setDescription("Accumulated Well Flow (" + simName + ")");
int neededExtraTrackCount = branchCount - existingTrackCount;
for (int etc = 0; etc < neededExtraTrackCount; ++etc)
{
RimWellLogTrack* plotTrack = new RimWellLogTrack();
accumulatedWellFlowPlot()->addTrack(plotTrack);
}
for (int etc = branchCount; etc < existingTrackCount; ++etc)
{
accumulatedWellFlowPlot()->removeTrackByIndex(accumulatedWellFlowPlot()->trackCount()- 1);
}
for (size_t brIdx = 0; brIdx < branchCount; ++brIdx)
{
RimWellLogTrack* plotTrack = accumulatedWellFlowPlot()->trackByIndex(brIdx);
plotTrack->setDescription(QString("Branch %1").arg(brIdx+1));
}
setDescription("Well Allocation (" + simName + ")");
accumulatedWellFlowPlot()->updateConnectedEditors();
*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -153,39 +90,6 @@ void RimTotalWellAllocationPlot::zoomAll()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimTotalWellAllocationPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
{
QList<caf::PdmOptionItemInfo> options;
if (fieldNeedingOptions == &m_simulationWell)
{
RimView* activeView = RiaApplication::instance()->activeReservoirView();
RimEclipseView* eclView = dynamic_cast<RimEclipseView*>(activeView);
if (eclView && eclView->wellCollection())
{
RimEclipseWellCollection* coll = eclView->wellCollection();
caf::PdmChildArrayField<RimEclipseWell*>& eclWells = coll->wells;
QIcon simWellIcon(":/Well.png");
for (RimEclipseWell* eclWell : eclWells)
{
options.push_back(caf::PdmOptionItemInfo(eclWell->name(), eclWell, false, simWellIcon));
}
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", nullptr));
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
@@ -199,10 +103,7 @@ void RimTotalWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* cha
{
updateMdiWindowTitle();
}
else if (changedField == &m_simulationWell)
{
updateFromWell();
}
}
@@ -235,13 +136,34 @@ QString RimTotalWellAllocationPlot::description() const
return m_userName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::addSlice(const QString& name, const cvf::Color3f& color, float value)
{
QColor sliceColor(color.rByte(), color.gByte(), color.bByte());
m_wellTotalAllocationPlotWidget->addItem(name, sliceColor, value);
m_wellTotalAllocationPlotWidget->update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::clearSlices()
{
m_wellTotalAllocationPlotWidget->clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimTotalWellAllocationPlot::loadDataAndUpdate()
{
updateMdiWindowVisibility();
updateFromWell();
}
//--------------------------------------------------------------------------------------------------
@@ -250,12 +172,6 @@ void RimTotalWellAllocationPlot::loadDataAndUpdate()
QWidget* RimTotalWellAllocationPlot::createViewWidget(QWidget* mainWindowParent)
{
m_wellTotalAllocationPlotWidget = new RiuNightchartsWidget(mainWindowParent);
m_wellTotalAllocationPlotWidget->addItem("Item1", QColor(200, 10, 50), 34);
m_wellTotalAllocationPlotWidget->addItem("Item2", Qt::green, 27);
m_wellTotalAllocationPlotWidget->addItem("Item3", Qt::cyan, 14);
m_wellTotalAllocationPlotWidget->addItem("Item4", Qt::yellow, 7);
m_wellTotalAllocationPlotWidget->addItem("Item5", Qt::blue, 4);
return m_wellTotalAllocationPlotWidget;
}

View File

@@ -36,6 +36,10 @@ namespace caf {
class PdmOptionItemInfo;
}
namespace cvf {
class cvf::Color3f;
}
//==================================================================================================
///
@@ -49,39 +53,31 @@ public:
RimTotalWellAllocationPlot();
virtual ~RimTotalWellAllocationPlot();
void setSimulationWell(RimEclipseWell* simWell);
void setDescription(const QString& description);
QString description() const;
void loadDataAndUpdate();
void addSlice(const QString& name, const cvf::Color3f& color, float value);
void clearSlices();
// RimViewWindow overrides
virtual QWidget* viewWidget() override;
virtual void zoomAll() override;
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override;
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;
virtual void deleteViewWidget() override;
protected:
// RimViewWindow overrides
virtual void loadDataAndUpdate() override;
virtual QImage snapshotWindowContent() override;
// Overridden PDM methods
virtual caf::PdmFieldHandle* userDescriptionField() { return &m_userName; }
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual QImage snapshotWindowContent() override;
private:
void updateFromWell();
private:
caf::PdmField<bool> m_showPlotTitle;
caf::PdmField<QString> m_userName;
caf::PdmPtrField<RimEclipseWell*> m_simulationWell;
QPointer<RiuNightchartsWidget> m_wellTotalAllocationPlotWidget;
};

View File

@@ -225,53 +225,88 @@ void RimWellAllocationPlot::updateFromWell()
accumulatedWellFlowPlot()->addTrack(plotTrack);
std::vector<double> connNumbers;
{
const std::vector<size_t>& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx);
for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast<double>(conNumb));
}
if ( m_flowDiagSolution )
{
std::vector<double> connNumbers;
{
const std::vector<size_t>& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx);
for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast<double>(conNumb));
}
std::vector<QString> tracerNames = wfCalculator->tracerNames();
for (const QString& tracerName: tracerNames)
{
const std::vector<double>& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, brIdx);
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
curve->setFlowValues(tracerName, connNumbers, accFlow);
curve->setColor( m_flowDiagSolution->tracerColor(tracerName));
plotTrack->addCurve(curve);
curve->loadDataAndUpdate();
addStackedCurve(tracerName, connNumbers, accFlow, plotTrack);
}
}
else
{
std::vector<double> connNumbers;
{
const std::vector<size_t>& connNumbersSize_t = wfCalculator->connectionNumbersFromTop(brIdx);
for ( size_t conNumb : connNumbersSize_t ) connNumbers.push_back(static_cast<double>(conNumb));
}
const std::vector<double>& accFlow = wfCalculator->accumulatedTotalFlowPrConnection(brIdx);
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
curve->setFlowValues("Total", connNumbers, accFlow);
curve->setColor( cvf::Color3f::DARK_GRAY);
plotTrack->addCurve(curve);
curve->loadDataAndUpdate();
addStackedCurve("Total", connNumbers, accFlow, plotTrack);
}
}
/// Pie chart
m_totalWellAllocationPlot->clearSlices();
std::vector<QString> tracerNames = wfCalculator->tracerNames();
std::vector<std::pair<QString, double> > tracerWithValues;
for (const QString& tracerName: tracerNames)
{
const std::vector<double>& accFlow = wfCalculator->accumulatedTracerFlowPrConnection(tracerName, 0);
tracerWithValues.push_back(std::make_pair(tracerName, accFlow.back()));
}
float sumTracerVals = 0.0f;
for ( const auto& tracerVal:tracerWithValues)
{
sumTracerVals += tracerVal.second;
}
if ( sumTracerVals != 0.0f )
{
for ( const auto& tracerVal:tracerWithValues )
{
cvf::Color3f color;
if ( m_flowDiagSolution )
color = m_flowDiagSolution->tracerColor(tracerVal.first);
else
color = cvf::Color3f::DARK_GRAY;
m_totalWellAllocationPlot->addSlice(tracerVal.first, color, 100*tracerVal.second/sumTracerVals);
}
}
m_totalWellAllocationPlot->updateConnectedEditors();
setDescription("Well Allocation (" + m_wellName + ")");
accumulatedWellFlowPlot()->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellAllocationPlot::addStackedCurve(const QString& tracerName,
const std::vector<double>& connNumbers,
const std::vector<double>& accFlow,
RimWellLogTrack* plotTrack)
{
RimWellFlowRateCurve* curve = new RimWellFlowRateCurve;
curve->setFlowValues(tracerName, connNumbers, accFlow);
if ( m_flowDiagSolution )
curve->setColor(m_flowDiagSolution->tracerColor(tracerName));
else
curve->setColor(cvf::Color3f::DARK_GRAY);
plotTrack->addCurve(curve);
curve->loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -33,6 +33,7 @@ class RimFlowDiagSolution;
class RimTotalWellAllocationPlot;
class RimWellLogPlot;
class RiuWellAllocationPlot;
class RimWellLogTrack;
namespace caf {
class PdmOptionItemInfo;
@@ -80,6 +81,11 @@ protected:
private:
void updateFromWell();
void addStackedCurve(const QString& tracerName,
const std::vector<double>& connNumbers,
const std::vector<double>& accFlow,
RimWellLogTrack* plotTrack);
// RimViewWindow overrides
virtual QWidget* createViewWidget(QWidget* mainWindowParent) override;