#1048 Added derived result: Tracer with max fraction

This commit is contained in:
Jacob Støren 2017-01-03 09:27:25 +01:00
parent 7c24522478
commit 22143969c1
8 changed files with 93 additions and 8 deletions

View File

@ -309,7 +309,7 @@ void RimEclipsePropertyFilter::computeResultValueRange()
if ( resultDefinition->hasCategoryResult() )
{
setCategoryValues(results->uniqueCellScalarValues(resAddr, timeStep));
setCategoryNames(resultDefinition->flowDiagSolution()->tracerNames());
}
}
}

View File

@ -334,7 +334,7 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
RimFlowDiagSolution* flowSol = m_flowSolutionUiField();
if (flowSol)
{
std::set<QString> tracerNames = flowSol->tracerNames();
std::vector<QString> tracerNames = flowSol->tracerNames();
std::map<QString, QString> prefixedTracerNamesMap;
for ( const QString& tracerName : tracerNames )
{

View File

@ -1029,7 +1029,7 @@ void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, R
if ( resultColors->hasCategoryResult() )
{
resultColors->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(resAddr, m_currentTimeStep));
resultColors->legendConfig()->setNamedCategories(resultColors->flowDiagSolution()->tracerNames());
}
m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend());

View File

@ -75,12 +75,12 @@ RigFlowDiagResults* RimFlowDiagSolution::flowDiagResults()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::set<QString> RimFlowDiagSolution::tracerNames()
std::vector<QString> RimFlowDiagSolution::tracerNames()
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
std::set<QString> tracerNameSet;
std::vector<QString> tracerNameSet;
if (eclCase)
{
@ -88,7 +88,7 @@ std::set<QString> RimFlowDiagSolution::tracerNames()
for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx)
{
tracerNameSet.insert(wellResults[wIdx]->m_wellName);
tracerNameSet.push_back(wellResults[wIdx]->m_wellName);
}
}

View File

@ -41,7 +41,7 @@ public:
QString userDescription() { return m_userDescription();}
RigFlowDiagResults* flowDiagResults();
std::set<QString> tracerNames();
std::vector<QString> tracerNames();
std::map<std::string, std::vector<int> > allInjectorTracerActiveCellIndices(size_t timeStepIndex);
std::map<std::string, std::vector<int> > allProducerTracerActiveCellIndices(size_t timeStepIndex);

View File

@ -747,6 +747,26 @@ void RimLegendConfig::setNamedCategoriesInverse(const std::vector<QString>& cate
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimLegendConfig::setNamedCategories(const std::vector<QString>& categoryNames)
{
std::vector<int> nameIndices;
std::vector<cvf::String> names;
for ( int i = 0; i < categoryNames.size(); ++i )
{
nameIndices.push_back(i);
names.push_back(cvfqt::Utils::toString(categoryNames[i]));
}
m_categories = nameIndices;
m_categoryNames = names;
updateLegend();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -106,6 +106,7 @@ public:
void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero);
void setIntegerCategories(const std::vector<int>& categories);
void setNamedCategoriesInverse(const std::vector<QString>& categoryNames);
void setNamedCategories(const std::vector<QString>& categoryNames);
void setTitle(const cvf::String& title);

View File

@ -248,8 +248,72 @@ std::vector<double>* RigFlowDiagResults::calculateDerivedResult(const RigFlowDia
return &commPI;
}
else if ( resVarAddr.variableName == RIG_FLD_MAX_FRACTION_TRACER_RESNAME )
{
std::vector<int> selectedTracerIdxToGlobalTracerIdx;
{
selectedTracerIdxToGlobalTracerIdx.resize(resVarAddr.selectedTracerNames.size(), -1);
return nullptr; // Todo
std::vector<QString> allTracerNames = m_flowDiagSolution->tracerNames();
int selTracerIdx = 0;
for ( const std::string& tracerName: resVarAddr.selectedTracerNames )
{
for ( int globIdx = 0; globIdx < allTracerNames.size(); ++globIdx )
{
if ( allTracerNames[globIdx].toStdString() == tracerName )
{
selectedTracerIdxToGlobalTracerIdx[selTracerIdx] = globIdx;
break;
}
}
++selTracerIdx;
}
}
RigFlowDiagResultFrames* maxFractionTracerIdxFrames = this->createScalarResult(resVarAddr);
std::vector<double>& maxFractionTracerIdx = maxFractionTracerIdxFrames->frameData(frameIndex);
{
std::vector<const std::vector<double>* > fractions = findResultsForSelectedTracers(resVarAddr,
frameIndex,
RIG_FLD_CELL_FRACTION_RESNAME,
RimFlowDiagSolution::UNDEFINED);
maxFractionTracerIdx.resize(activeCellCount, HUGE_VAL);
std::vector<double> maxFraction;
maxFraction.resize(activeCellCount, -HUGE_VAL);
for ( size_t frIdx = 0; frIdx < fractions.size(); ++frIdx )
{
const std::vector<double> * fr = fractions[frIdx];
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if ( (*fr)[acIdx] == HUGE_VAL) continue;
if ( maxFraction[acIdx] < (*fr)[acIdx] )
{
maxFraction[acIdx] = (*fr)[acIdx];
maxFractionTracerIdx[acIdx] = frIdx;
}
}
}
}
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
{
if (maxFractionTracerIdx[acIdx] == HUGE_VAL) continue;
double selectedTracerIdx = static_cast<int>( maxFractionTracerIdx[acIdx]);
maxFractionTracerIdx[acIdx] = selectedTracerIdxToGlobalTracerIdx[selectedTracerIdx];
}
return &maxFractionTracerIdx;
}
return nullptr;
}