#1172 Well Alloc plot: Sorted the tracers according to contribution.

This commit is contained in:
Jacob Støren 2017-02-13 13:34:08 +01:00
parent 92f4abe7c2
commit df35335744
4 changed files with 33 additions and 10 deletions

View File

@ -27,7 +27,10 @@
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords, const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds, const std::map<QString, const std::vector<double>* >& tracerCellFractionValues, const RigEclCellIndexCalculator cellIndexCalculator): RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds,
const std::map<QString, const std::vector<double>* >& tracerCellFractionValues,
const RigEclCellIndexCalculator cellIndexCalculator):
m_pipeBranchesCLCoords(pipeBranchesCLCoords), m_pipeBranchesCLCoords(pipeBranchesCLCoords),
m_pipeBranchesCellIds(pipeBranchesCellIds), m_pipeBranchesCellIds(pipeBranchesCellIds),
m_tracerCellFractionValues(&tracerCellFractionValues), m_tracerCellFractionValues(&tracerCellFractionValues),
@ -39,6 +42,8 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto
m_tracerNames.push_back(RIG_RESERVOIR_TRACER_NAME); m_tracerNames.push_back(RIG_RESERVOIR_TRACER_NAME);
calculateAccumulatedFlowPrConnection(0, 1); calculateAccumulatedFlowPrConnection(0, 1);
sortTracers();
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -58,7 +63,7 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<double>& RigAccWellFlowCalculator::accumulatedTotalFlowPrConnection(size_t branchIdx) const std::vector<double>& RigAccWellFlowCalculator::accumulatedTotalFlowPrConnection(size_t branchIdx)
{ {
CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find(RIG_FLOW_TOTAL_NAME) != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end()); CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find(RIG_FLOW_TOTAL_NAME) != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end());
@ -68,7 +73,7 @@ const std::vector<double>& RigAccWellFlowCalculator::accumulatedTotalFlowPrConne
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<double>& RigAccWellFlowCalculator::accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx) const std::vector<double>& RigAccWellFlowCalculator::accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx)
{ {
CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find(tracerName) != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end()); CVF_ASSERT(m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.find(tracerName) != m_accConnectionFlowPrBranch[branchIdx].accConnFlowFractionsPrTracer.end());
@ -78,7 +83,7 @@ const std::vector<double>& RigAccWellFlowCalculator::accumulatedTracerFlowPrConn
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
const std::vector<size_t>& RigAccWellFlowCalculator::connectionNumbersFromTop(size_t branchIdx) const std::vector<size_t>& RigAccWellFlowCalculator::connectionNumbersFromTop(size_t branchIdx) const
{ {
return m_accConnectionFlowPrBranch[branchIdx].connectionNumbersFromTop; return m_accConnectionFlowPrBranch[branchIdx].connectionNumbersFromTop;
} }
@ -250,3 +255,20 @@ std::vector<size_t> RigAccWellFlowCalculator::findDownstreamBranchIdxs(const Rig
return downStreamBranchIdxs; return downStreamBranchIdxs;
} }
void RigAccWellFlowCalculator::sortTracers()
{
std::multimap<double, QString> sortedTracers;
for (const QString& tracerName: m_tracerNames)
{
const std::vector<double>& mainBranchAccFlow = accumulatedTracerFlowPrConnection(tracerName, 0);
double totalFlow = 0.0;
if (mainBranchAccFlow.size()) totalFlow = - abs( mainBranchAccFlow.back() ); // Based on size in reverse order (biggest to least)
sortedTracers.insert({totalFlow, tracerName});
}
m_tracerNames.clear();
for (const auto& tracerPair : sortedTracers)
{
m_tracerNames.push_back(tracerPair.second);
}
}

View File

@ -65,17 +65,17 @@ public:
RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords, RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds); const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds);
const std::vector<double>& accumulatedTotalFlowPrConnection( size_t branchIdx); const std::vector<double>& accumulatedTotalFlowPrConnection( size_t branchIdx);// const;
const std::vector<double>& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx); const std::vector<double>& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx);// const;
const std::vector<size_t>& connectionNumbersFromTop(size_t branchIdx); const std::vector<size_t>& connectionNumbersFromTop(size_t branchIdx) const;
const std::vector<QString>& tracerNames() { return m_tracerNames;} const std::vector<QString>& tracerNames() const { return m_tracerNames;}
private: private:
void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop); void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop);
std::vector<size_t> wrpToConnectionIndexFromBottom( const std::vector<RigWellResultPoint> &branchCells); std::vector<size_t> wrpToConnectionIndexFromBottom( const std::vector<RigWellResultPoint> &branchCells);
static size_t connectionIndexFromTop( const std::vector<size_t>& resPointToConnectionIndexFromBottom, size_t clSegIdx); static size_t connectionIndexFromTop( const std::vector<size_t>& resPointToConnectionIndexFromBottom, size_t clSegIdx);
std::vector<size_t> findDownstreamBranchIdxs( const RigWellResultPoint& connectionPoint); std::vector<size_t> findDownstreamBranchIdxs( const RigWellResultPoint& connectionPoint);
void sortTracers();
const std::vector< std::vector <cvf::Vec3d> >& m_pipeBranchesCLCoords; const std::vector< std::vector <cvf::Vec3d> >& m_pipeBranchesCLCoords;
const std::vector< std::vector <RigWellResultPoint> >& m_pipeBranchesCellIds; const std::vector< std::vector <RigWellResultPoint> >& m_pipeBranchesCellIds;

View File

@ -143,6 +143,7 @@ void RiuWellAllocationPlot::addLegendItem(const QString& name, const cvf::Color3
m_legendWidget->addItem(name, sliceColor, value); m_legendWidget->addItem(name, sliceColor, value);
m_legendWidget->updateGeometry(); m_legendWidget->updateGeometry();
m_legendWidget->update();
} }

View File

@ -371,7 +371,7 @@ void Nightcharts::drawLegend(QPainter *painter)
float x = lX+dist; float x = lX+dist;
float y = lY+dist+i*(painter->fontMetrics().height()+2*dist); float y = lY+dist+i*(painter->fontMetrics().height()+2*dist);
painter->drawRect(x,y,painter->fontMetrics().height(),painter->fontMetrics().height()); painter->drawRect(x,y,painter->fontMetrics().height(),painter->fontMetrics().height());
painter->drawText(x+painter->fontMetrics().height()+dist,y+painter->fontMetrics().height()/2+dist,pieces[i].pname + " (" + QString::number(pieces[i].pPerc, 'd', 0)+"%)"); painter->drawText(x+painter->fontMetrics().height()+dist,y+painter->fontMetrics().height()/2+dist,pieces[i].pname + " (" + QString::number(pieces[i].pPerc, 'd', 1)+"%)");
} }
break; break;
} }