mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1048 Added weighted average TOF calculation
This commit is contained in:
parent
0864c2708d
commit
60cb1d4ce0
@ -311,7 +311,7 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
|
||||
{
|
||||
if ( fieldNeedingOptions == &m_resultVariableUiField )
|
||||
{
|
||||
optionItems.push_back(caf::PdmOptionItemInfo("Time Of Flight (Weighted Sum)", RIG_FLD_TOF_RESNAME));
|
||||
optionItems.push_back(caf::PdmOptionItemInfo("Time Of Flight (Average)", RIG_FLD_TOF_RESNAME));
|
||||
optionItems.push_back(caf::PdmOptionItemInfo("Tracer Cell Fraction (Sum)", RIG_FLD_CELL_FRACTION_RESNAME));
|
||||
optionItems.push_back(caf::PdmOptionItemInfo("Max Fraction Tracer", RIG_FLD_MAX_FRACTION_TRACER_RESNAME));
|
||||
optionItems.push_back(caf::PdmOptionItemInfo("Injector Producer Communication", RIG_FLD_COMMUNICATION_RESNAME));
|
||||
@ -338,11 +338,11 @@ QList<caf::PdmOptionItemInfo> RimEclipseResultDefinition::calculateValueOptions(
|
||||
std::map<QString, QString> prefixedTracerNamesMap;
|
||||
for ( const QString& tracerName : tracerNames )
|
||||
{
|
||||
RimFlowDiagSolution::TracerStatusType status = flowSol->tracerStatus(tracerName);
|
||||
RimFlowDiagSolution::TracerStatusType status = flowSol->tracerStatusOverall(tracerName);
|
||||
QString prefix;
|
||||
switch (status)
|
||||
{
|
||||
case RimFlowDiagSolution::INJECTOR: prefix = "I : "; break;
|
||||
case RimFlowDiagSolution::INJECTOR: prefix = "I : "; break;
|
||||
case RimFlowDiagSolution::PRODUCER: prefix = "P : "; break;
|
||||
case RimFlowDiagSolution::VARYING: prefix = "I/P: "; break;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCel
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatus(QString tracerName)
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(QString tracerName)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
@ -213,6 +213,49 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatus(QString
|
||||
return tracerStatus;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex)
|
||||
{
|
||||
RimEclipseResultCase* eclCase;
|
||||
this->firstAncestorOrThisOfType(eclCase);
|
||||
|
||||
if ( eclCase )
|
||||
{
|
||||
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
|
||||
|
||||
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
|
||||
{
|
||||
if ( wellResults[wIdx]->m_wellName == tracerName )
|
||||
{
|
||||
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
|
||||
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
|
||||
{
|
||||
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|
||||
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
|
||||
{
|
||||
return INJECTOR;
|
||||
}
|
||||
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
|
||||
{
|
||||
return PRODUCER;
|
||||
}
|
||||
else
|
||||
{
|
||||
return UNDEFINED;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT(false);
|
||||
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -54,7 +54,8 @@ public:
|
||||
UNDEFINED
|
||||
};
|
||||
|
||||
TracerStatusType tracerStatus(QString tracerName);
|
||||
TracerStatusType tracerStatusOverall(QString tracerName);
|
||||
TracerStatusType tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex);
|
||||
|
||||
|
||||
protected:
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
selectedTracerNames.insert(tracerName);
|
||||
}
|
||||
|
||||
bool isNativeResult() { return ( ( (variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME) ) && selectedTracerNames.size() <= 1); }
|
||||
bool isNativeResult() const { return ( ( (variableName == RIG_FLD_TOF_RESNAME) || (variableName == RIG_FLD_CELL_FRACTION_RESNAME) ) && selectedTracerNames.size() <= 1); }
|
||||
|
||||
std::string variableName;
|
||||
std::set<std::string> selectedTracerNames;
|
||||
|
@ -158,6 +158,102 @@ RigFlowDiagResultFrames* RigFlowDiagResults::findScalarResult(const RigFlowDiagR
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double>* RigFlowDiagResults::calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex)
|
||||
{
|
||||
if (resVarAddr.isNativeResult()) return nullptr;
|
||||
|
||||
|
||||
if (resVarAddr.variableName == RIG_FLD_TOF_RESNAME)
|
||||
{
|
||||
std::vector<const std::vector<double>* > injectorTOFs;
|
||||
std::vector<const std::vector<double>* > injectorFractions;
|
||||
|
||||
std::vector<const std::vector<double>* > producerTOFs;
|
||||
std::vector<const std::vector<double>* > producerFractions;
|
||||
|
||||
for (const std::string& tracerName: resVarAddr.selectedTracerNames)
|
||||
{
|
||||
RimFlowDiagSolution::TracerStatusType tracerType = m_flowDiagSolution->tracerStatusInTimeStep(QString::fromStdString(tracerName), frameIndex);
|
||||
|
||||
if ( tracerType == RimFlowDiagSolution::INJECTOR )
|
||||
{
|
||||
injectorTOFs.push_back( findOrCalculateResult(RigFlowDiagResultAddress(RIG_FLD_TOF_RESNAME, tracerName), frameIndex));
|
||||
injectorFractions.push_back(findOrCalculateResult(RigFlowDiagResultAddress(RIG_FLD_CELL_FRACTION_RESNAME, tracerName), frameIndex));
|
||||
}
|
||||
else if ( tracerType == RimFlowDiagSolution::PRODUCER )
|
||||
{
|
||||
producerTOFs.push_back(findOrCalculateResult(RigFlowDiagResultAddress(RIG_FLD_TOF_RESNAME, tracerName), frameIndex));
|
||||
producerFractions.push_back(findOrCalculateResult(RigFlowDiagResultAddress(RIG_FLD_CELL_FRACTION_RESNAME, tracerName), frameIndex));
|
||||
}
|
||||
}
|
||||
|
||||
RigFlowDiagResultFrames* averageTofFrames = this->createScalarResult(resVarAddr);
|
||||
std::vector<double>& averageTof = averageTofFrames->frameData(frameIndex);
|
||||
size_t activeCellCount = this->activeCellInfo(resVarAddr)->reservoirActiveCellCount();
|
||||
averageTof.resize(activeCellCount, HUGE_VAL);
|
||||
|
||||
std::vector<double> injectorTotalFractions;
|
||||
std::vector<double> injectorFractMultTof;
|
||||
{
|
||||
injectorTotalFractions.resize(activeCellCount, 0.0);
|
||||
injectorFractMultTof.resize(activeCellCount, 0.0);
|
||||
|
||||
for ( size_t iIdx = 0; iIdx < injectorFractions.size() ; ++iIdx )
|
||||
{
|
||||
const std::vector<double> * frInj = injectorFractions[iIdx];
|
||||
const std::vector<double> * tofInj = injectorTOFs[iIdx];
|
||||
|
||||
if ( ! (frInj && tofInj) ) continue;
|
||||
|
||||
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
|
||||
{
|
||||
if( (*frInj)[acIdx] == HUGE_VAL ) continue;
|
||||
|
||||
injectorTotalFractions[acIdx] += (*frInj)[acIdx];
|
||||
injectorFractMultTof[acIdx] += (*frInj)[acIdx] * (*tofInj)[acIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> producerTotalFractions;
|
||||
std::vector<double> producerFractMultTof;
|
||||
{
|
||||
producerTotalFractions.resize(activeCellCount, 0.0);
|
||||
producerFractMultTof.resize(activeCellCount, 0.0);
|
||||
|
||||
for ( size_t iIdx = 0; iIdx < producerFractions.size() ; ++iIdx )
|
||||
{
|
||||
const std::vector<double> * prodFr = producerFractions[iIdx];
|
||||
const std::vector<double> * prodTof = producerTOFs[iIdx];
|
||||
|
||||
if ( ! (prodFr && prodTof) ) continue;
|
||||
|
||||
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
|
||||
{
|
||||
if ( (*prodFr)[acIdx] == HUGE_VAL ) continue;
|
||||
|
||||
producerTotalFractions[acIdx] += (*prodFr)[acIdx];
|
||||
producerFractMultTof[acIdx] += (*prodFr)[acIdx] * (*prodTof)[acIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx)
|
||||
{
|
||||
if ( injectorTotalFractions[acIdx] == 0.0 && producerTotalFractions[acIdx] == 0.0 )
|
||||
{
|
||||
averageTof[acIdx] = HUGE_VAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
double retVal = 0.0;
|
||||
if (injectorTotalFractions[acIdx] != 0.0) retVal += (1.0/injectorTotalFractions[acIdx]) * injectorFractMultTof[acIdx];
|
||||
if (producerTotalFractions[acIdx] != 0.0) retVal += (1.0/producerTotalFractions[acIdx]) * producerFractMultTof[acIdx];
|
||||
averageTof[acIdx] = retVal;
|
||||
}
|
||||
}
|
||||
|
||||
return &averageTof;
|
||||
}
|
||||
|
||||
return nullptr; // Todo
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user