mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1172 Calculated a grouped tracer contribution value of the tracers below a certain threshold.
This commit is contained in:
parent
43faf00cfa
commit
ed31dab152
@ -70,6 +70,8 @@ RimWellAllocationPlot::RimWellAllocationPlot()
|
||||
CAF_PDM_InitField(&m_timeStep, "PlotTimeStep", 0, "Time Step", "", "", "");
|
||||
CAF_PDM_InitField(&m_wellName, "WellName", QString("None"), "Well", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_flowDiagSolution, "FlowDiagSolution", "Flow Diag Solution", "", "", "");
|
||||
CAF_PDM_InitField(&m_groupSmallContributions, "GroupSmallContributions", true, "Group Small Contributions", "", "", "");
|
||||
CAF_PDM_InitField(&m_smallContributionsThreshold, "SmallContributionsThreshold", 0.005, "Threshold", "", "", "");
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_accumulatedWellFlowPlot, "AccumulatedWellFlowPlot", "Accumulated Well Flow", "", "", "");
|
||||
m_accumulatedWellFlowPlot.uiCapability()->setUiHidden(true);
|
||||
@ -181,6 +183,9 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
pipeBranchesCellIds);
|
||||
std::unique_ptr< RigAccWellFlowCalculator > wfCalculator;
|
||||
std::map<QString, const std::vector<double>* > tracerCellFractionValues;
|
||||
double smallContributionThreshold = 0.0;
|
||||
if (m_groupSmallContributions()) smallContributionThreshold = m_smallContributionsThreshold;
|
||||
|
||||
|
||||
if ( m_flowDiagSolution && wellResults->hasWellResult(m_timeStep))
|
||||
{
|
||||
@ -214,7 +219,8 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords,
|
||||
pipeBranchesCellIds,
|
||||
tracerCellFractionValues,
|
||||
cellIdxCalc));
|
||||
cellIdxCalc,
|
||||
smallContributionThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +229,8 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
if (pipeBranchesCLCoords.size() > 0)
|
||||
{
|
||||
wfCalculator.reset(new RigAccWellFlowCalculator(pipeBranchesCLCoords,
|
||||
pipeBranchesCellIds));
|
||||
pipeBranchesCellIds,
|
||||
smallContributionThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
@ -243,8 +250,6 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
|
||||
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
||||
|
||||
// TODO: Description is overwritten by RimWellLogPlot::updateTrackNames()
|
||||
// Add flag to control if this behavior
|
||||
plotTrack->setDescription(QString("Branch %1").arg(brIdx + 1));
|
||||
|
||||
accumulatedWellFlowPlot()->addTrack(plotTrack);
|
||||
@ -285,24 +290,9 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
|
||||
if (wfCalculator)
|
||||
{
|
||||
std::vector<QString> tracerNames = wfCalculator->tracerNames();
|
||||
std::vector<std::pair<QString, double> > tracerWithValues;
|
||||
std::vector<std::pair<QString, double> > totalTracerFractions = wfCalculator->totalTracerFractions() ;
|
||||
|
||||
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 )
|
||||
for ( const auto& tracerVal : totalTracerFractions )
|
||||
{
|
||||
cvf::Color3f color;
|
||||
if ( m_flowDiagSolution )
|
||||
@ -310,9 +300,10 @@ void RimWellAllocationPlot::updateFromWell()
|
||||
else
|
||||
color = cvf::Color3f::DARK_GRAY;
|
||||
|
||||
m_totalWellAllocationPlot->addSlice(tracerVal.first, color, 100*tracerVal.second/sumTracerVals);
|
||||
if (m_wellAllocationPlotWidget) m_wellAllocationPlotWidget->addLegendItem(tracerVal.first, color, 100*tracerVal.second/sumTracerVals);
|
||||
}
|
||||
double tracerPercent = 100*tracerVal.second;
|
||||
|
||||
m_totalWellAllocationPlot->addSlice(tracerVal.first, color, tracerPercent);
|
||||
if ( m_wellAllocationPlotWidget ) m_wellAllocationPlotWidget->addLegendItem(tracerVal.first, color, tracerPercent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -592,7 +583,9 @@ void RimWellAllocationPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedF
|
||||
else if ( changedField == &m_wellName
|
||||
|| changedField == &m_case
|
||||
|| changedField == &m_timeStep
|
||||
|| changedField == &m_flowDiagSolution)
|
||||
|| changedField == &m_flowDiagSolution
|
||||
|| changedField == &m_groupSmallContributions
|
||||
|| changedField == &m_smallContributionsThreshold )
|
||||
{
|
||||
loadDataAndUpdate();
|
||||
}
|
||||
@ -614,6 +607,14 @@ QImage RimWellAllocationPlot::snapshotWindowContent()
|
||||
return image;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimWellAllocationPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
||||
{
|
||||
m_smallContributionsThreshold.uiCapability()->setUiReadOnly(!m_groupSmallContributions());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -81,6 +81,9 @@ protected:
|
||||
|
||||
virtual QImage snapshotWindowContent() override;
|
||||
|
||||
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
|
||||
|
||||
private:
|
||||
void updateFromWell();
|
||||
void updateWellFlowPlotXAxisTitle(RimWellLogTrack* plotTrack);
|
||||
@ -106,6 +109,8 @@ private:
|
||||
caf::PdmField<QString> m_wellName;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
|
||||
caf::PdmField<bool> m_groupSmallContributions;
|
||||
caf::PdmField<double> m_smallContributionsThreshold;
|
||||
|
||||
QPointer<RiuWellAllocationPlot> m_wellAllocationPlotWidget;
|
||||
|
||||
|
@ -30,11 +30,13 @@
|
||||
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):
|
||||
const RigEclCellIndexCalculator cellIndexCalculator,
|
||||
double smallContribThreshold):
|
||||
m_pipeBranchesCLCoords(pipeBranchesCLCoords),
|
||||
m_pipeBranchesCellIds(pipeBranchesCellIds),
|
||||
m_tracerCellFractionValues(&tracerCellFractionValues),
|
||||
m_cellIndexCalculator(cellIndexCalculator)
|
||||
m_cellIndexCalculator(cellIndexCalculator),
|
||||
m_smallContributionsThreshold(smallContribThreshold)
|
||||
{
|
||||
m_accConnectionFlowPrBranch.resize(m_pipeBranchesCellIds.size());
|
||||
for ( const auto& it: (*m_tracerCellFractionValues) ) m_tracerNames.push_back(it.first);
|
||||
@ -43,17 +45,20 @@ RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vecto
|
||||
|
||||
calculateAccumulatedFlowPrConnection(0, 1);
|
||||
sortTracers();
|
||||
|
||||
groupSmallContributions();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords, const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds):
|
||||
RigAccWellFlowCalculator::RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds,
|
||||
double smallContribThreshold ):
|
||||
m_pipeBranchesCLCoords(pipeBranchesCLCoords),
|
||||
m_pipeBranchesCellIds(pipeBranchesCellIds),
|
||||
m_tracerCellFractionValues(nullptr),
|
||||
m_cellIndexCalculator(RigEclCellIndexCalculator(nullptr, nullptr))
|
||||
m_cellIndexCalculator(RigEclCellIndexCalculator(nullptr, nullptr)),
|
||||
m_smallContributionsThreshold(smallContribThreshold)
|
||||
{
|
||||
m_accConnectionFlowPrBranch.resize(m_pipeBranchesCellIds.size());
|
||||
m_tracerNames.push_back(RIG_FLOW_TOTAL_NAME);
|
||||
@ -88,6 +93,48 @@ const std::vector<size_t>& RigAccWellFlowCalculator::connectionNumbersFromTop(si
|
||||
return m_accConnectionFlowPrBranch[branchIdx].connectionNumbersFromTop;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<QString, double> > RigAccWellFlowCalculator::totalWellFlowPrTracer()
|
||||
{
|
||||
std::vector<QString> tracerNames = this->tracerNames();
|
||||
std::vector<std::pair<QString, double> > tracerWithValues;
|
||||
|
||||
for (const QString& tracerName: tracerNames)
|
||||
{
|
||||
const std::vector<double>& accFlow = this->accumulatedTracerFlowPrConnection(tracerName, 0);
|
||||
tracerWithValues.push_back(std::make_pair(tracerName, accFlow.back()));
|
||||
}
|
||||
|
||||
return tracerWithValues;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<QString, double> > RigAccWellFlowCalculator::totalTracerFractions()
|
||||
{
|
||||
std::vector<std::pair<QString, double> > totalFlows = totalWellFlowPrTracer();
|
||||
|
||||
float sumTracerFlows = 0.0f;
|
||||
for ( const auto& tracerVal : totalFlows)
|
||||
{
|
||||
sumTracerFlows += tracerVal.second;
|
||||
}
|
||||
|
||||
if (sumTracerFlows == 0.0) totalFlows.clear();
|
||||
|
||||
for (auto& tracerPair : totalFlows)
|
||||
{
|
||||
tracerPair.second = tracerPair.second/sumTracerFlows;
|
||||
}
|
||||
|
||||
return totalFlows;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -255,6 +302,10 @@ std::vector<size_t> RigAccWellFlowCalculator::findDownstreamBranchIdxs(const Rig
|
||||
return downStreamBranchIdxs;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
void RigAccWellFlowCalculator::sortTracers()
|
||||
{
|
||||
std::multimap<double, QString> sortedTracers;
|
||||
@ -272,3 +323,63 @@ void RigAccWellFlowCalculator::sortTracers()
|
||||
m_tracerNames.push_back(tracerPair.second);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigAccWellFlowCalculator::groupSmallContributions()
|
||||
{
|
||||
// Concatenate small tracers into an "Other" group
|
||||
|
||||
if ( m_smallContributionsThreshold > 0.0 )
|
||||
{
|
||||
std::vector<std::pair<QString, double> > totalTracerFractions = this->totalTracerFractions();
|
||||
|
||||
if ( totalTracerFractions.size() < 5 ) return; // No grouping for few legend items
|
||||
|
||||
std::vector<QString> tracersToGroup;
|
||||
|
||||
for ( const auto& tracerPair : totalTracerFractions )
|
||||
{
|
||||
if ( tracerPair.second <= m_smallContributionsThreshold ) tracersToGroup.push_back(tracerPair.first);
|
||||
}
|
||||
|
||||
if ( tracersToGroup.size() < 2 ) return; // Must at least group two ...
|
||||
|
||||
for ( BranchResult& brRes : m_accConnectionFlowPrBranch )
|
||||
{
|
||||
std::vector<double> groupedConnectionValues(brRes.connectionNumbersFromTop.size(), 0.0);
|
||||
for ( const QString& tracername:tracersToGroup )
|
||||
{
|
||||
auto it = brRes.accConnFlowFractionsPrTracer.find(tracername);
|
||||
if ( it != brRes.accConnFlowFractionsPrTracer.end() )
|
||||
{
|
||||
const std::vector<double>& tracerVals = it->second;
|
||||
for ( size_t cIdx = 0; cIdx < groupedConnectionValues.size(); ++cIdx )
|
||||
{
|
||||
groupedConnectionValues[cIdx] += tracerVals[cIdx];
|
||||
}
|
||||
}
|
||||
brRes.accConnFlowFractionsPrTracer.erase(it);
|
||||
}
|
||||
|
||||
brRes.accConnFlowFractionsPrTracer[RIG_TINY_TRACER_GROUP_NAME] = groupedConnectionValues;
|
||||
}
|
||||
|
||||
std::vector<QString> filteredTracernames;
|
||||
for ( const QString& tracerName: m_tracerNames )
|
||||
{
|
||||
bool isDeleted = false;
|
||||
for ( const QString& deletedTracerName: tracersToGroup )
|
||||
{
|
||||
if ( tracerName == deletedTracerName ) { isDeleted = true; break; }
|
||||
}
|
||||
|
||||
if ( !isDeleted ) filteredTracernames.push_back(tracerName);
|
||||
}
|
||||
|
||||
m_tracerNames.swap(filteredTracernames);
|
||||
m_tracerNames.push_back(RIG_TINY_TRACER_GROUP_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,28 +60,37 @@ public:
|
||||
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);
|
||||
const RigEclCellIndexCalculator cellIndexCalculator,
|
||||
double smallContribThreshold);
|
||||
|
||||
RigAccWellFlowCalculator(const std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds);
|
||||
const std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds,
|
||||
double smallContribThreshold);
|
||||
|
||||
const std::vector<double>& accumulatedTotalFlowPrConnection( size_t branchIdx);// const;
|
||||
const std::vector<double>& accumulatedTracerFlowPrConnection(const QString& tracerName, size_t branchIdx);// const;
|
||||
const std::vector<size_t>& connectionNumbersFromTop(size_t branchIdx) const;
|
||||
const std::vector<QString>& tracerNames() const { return m_tracerNames;}
|
||||
|
||||
std::vector<std::pair<QString, double> > totalTracerFractions();
|
||||
private:
|
||||
|
||||
void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop);
|
||||
std::vector<size_t> wrpToConnectionIndexFromBottom( const std::vector<RigWellResultPoint> &branchCells);
|
||||
static size_t connectionIndexFromTop( const std::vector<size_t>& resPointToConnectionIndexFromBottom, size_t clSegIdx);
|
||||
std::vector<size_t> findDownstreamBranchIdxs( const RigWellResultPoint& connectionPoint);
|
||||
|
||||
std::vector<std::pair<QString, double> > totalWellFlowPrTracer() ;
|
||||
void sortTracers();
|
||||
|
||||
void groupSmallContributions();
|
||||
|
||||
const std::vector< std::vector <cvf::Vec3d> >& m_pipeBranchesCLCoords;
|
||||
const std::vector< std::vector <RigWellResultPoint> >& m_pipeBranchesCellIds;
|
||||
const std::map<QString, const std::vector<double>* >* m_tracerCellFractionValues;
|
||||
RigEclCellIndexCalculator m_cellIndexCalculator;
|
||||
std::vector<QString> m_tracerNames;
|
||||
double m_smallContributionsThreshold;
|
||||
|
||||
struct BranchResult
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user