#1279 Added <wellname>-Xf as tracer on connections with opposite flow thant the well type indicates.

This commit is contained in:
Jacob Støren 2017-03-06 16:33:29 +01:00
parent 0bccc883ff
commit 0428dbffa3
3 changed files with 156 additions and 94 deletions

View File

@ -35,6 +35,37 @@
CAF_PDM_SOURCE_INIT(RimFlowDiagSolution, "FlowDiagSolution");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool hasCrossFlowEnding(const QString& tracerName)
{
return tracerName.endsWith("-Xf");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString removeCrossFlowEnding(const QString& tracerName)
{
if (tracerName.endsWith("-Xf"))
{
return tracerName.left(tracerName.size() - 3);
}
else
{
return tracerName;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString addCrossFlowEnding(const QString& wellName)
{
return wellName + "-Xf";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -99,6 +130,7 @@ std::vector<QString> RimFlowDiagSolution::tracerNames()
for (size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx)
{
tracerNameSet.push_back(wellResults[wIdx]->m_wellName);
tracerNameSet.push_back(addCrossFlowEnding(wellResults[wIdx]->m_wellName));
}
}
@ -148,31 +180,36 @@ std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCel
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
if ( !wellResFrame.m_isOpen ) continue;
bool useWell = ( useInjectors && ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR) )
|| (!useInjectors && wellResFrame.m_productionType == RigWellResultFrame::PRODUCER);
if (wellResFrame.m_productionType == RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE) continue;
if (useWell)
bool isInjectorWell = (wellResFrame.m_productionType != RigWellResultFrame::PRODUCER);
std::string wellname = wellResults[wIdx]->m_wellName.toStdString();
std::string wellNameXf = addCrossFlowEnding(wellResults[wIdx]->m_wellName).toStdString();
std::vector<int>& tracerCells = tracersWithCells[wellname];
std::vector<int>& tracerCellsCrossFlow = tracersWithCells[wellNameXf];
for (const RigWellResultBranch& wBr: wellResFrame.m_wellResultBranches)
{
std::string wellname = wellResults[wIdx]->m_wellName.toStdString();
std::vector<int>& tracerCells = tracersWithCells[wellname];
for (const RigWellResultBranch& wBr: wellResFrame.m_wellResultBranches)
for (const RigWellResultPoint& wrp: wBr.m_branchResultPoints)
{
for (const RigWellResultPoint& wrp: wBr.m_branchResultPoints)
if (wrp.isValid() && wrp.m_isOpen
&& ( (useInjectors && wrp.flowRate() < 0.0) || (!useInjectors && wrp.flowRate() > 0.0) ) )
{
if (wrp.isValid() && wrp.m_isOpen
&& ( (useInjectors && wrp.flowRate() < 0.0) || (!useInjectors && wrp.flowRate() > 0.0) ) )
{
RigGridBase * grid = mainGrid->gridByIndex(wrp.m_gridIndex);
size_t reservoirCellIndex = grid->reservoirCellIndex(wrp.m_gridCellIndex);
RigGridBase * grid = mainGrid->gridByIndex(wrp.m_gridIndex);
size_t reservoirCellIndex = grid->reservoirCellIndex(wrp.m_gridCellIndex);
int cellActiveIndex = static_cast<int>(activeCellInfo->cellResultIndex(reservoirCellIndex));
int cellActiveIndex = static_cast<int>(activeCellInfo->cellResultIndex(reservoirCellIndex));
if ( useInjectors == isInjectorWell )
{
tracerCells.push_back(cellActiveIndex);
}
else
{
tracerCellsCrossFlow.push_back(cellActiveIndex);
}
}
}
}
@ -187,43 +224,49 @@ std::map<std::string, std::vector<int> > RimFlowDiagSolution::allTracerActiveCel
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(QString tracerName)
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(const QString& tracerName)
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
this->firstAncestorOrThisOfTypeAsserted(eclCase);
TracerStatusType tracerStatus = UNDEFINED;
if ( eclCase )
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
QString wellName = removeCrossFlowEnding(tracerName);
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
if ( wellResults[wIdx]->m_wellName != wellName ) continue;
tracerStatus = CLOSED;
for ( const RigWellResultFrame& wellResFrame : wellResults[wIdx]->m_wellCellsTimeSteps )
{
if ( wellResults[wIdx]->m_wellName == tracerName )
if (wellResFrame.m_isOpen)
{
tracerStatus = CLOSED;
for ( const RigWellResultFrame& wellResFrame : wellResults[wIdx]->m_wellCellsTimeSteps )
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
{
if (wellResFrame.m_isOpen)
{
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
{
if ( tracerStatus == PRODUCER ) tracerStatus = VARYING;
else tracerStatus = INJECTOR;
}
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
{
if ( tracerStatus == INJECTOR ) tracerStatus = VARYING;
else tracerStatus = PRODUCER;
}
}
if ( tracerStatus == VARYING ) break;
if ( tracerStatus == PRODUCER ) tracerStatus = VARYING;
else tracerStatus = INJECTOR;
}
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
{
if ( tracerStatus == INJECTOR ) tracerStatus = VARYING;
else tracerStatus = PRODUCER;
}
break;
}
if ( tracerStatus == VARYING ) break;
}
break;
}
if (hasCrossFlowEnding(tracerName))
{
if (tracerStatus == PRODUCER) tracerStatus = INJECTOR;
else if (tracerStatus == INJECTOR) tracerStatus = PRODUCER;
}
return tracerStatus;
@ -232,42 +275,44 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(Q
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex)
RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeStep(const QString& tracerName, size_t timeStepIndex)
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
this->firstAncestorOrThisOfTypeAsserted(eclCase);
if ( eclCase )
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
const cvf::Collection<RigSingleWellResultsData>& wellResults = eclCase->reservoirData()->wellResults();
QString wellName = removeCrossFlowEnding(tracerName);
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
if ( wellResults[wIdx]->m_wellName != wellName ) continue;
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
if (wellTimeStep == cvf::UNDEFINED_SIZE_T) return CLOSED;
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
{
if ( wellResults[wIdx]->m_wellName == tracerName )
if (!wellResFrame.m_isOpen) return CLOSED;
if ( wellResFrame.m_productionType == RigWellResultFrame::GAS_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::OIL_INJECTOR
|| wellResFrame.m_productionType == RigWellResultFrame::WATER_INJECTOR )
{
size_t wellTimeStep = wellResults[wIdx]->m_resultTimeStepIndexToWellTimeStepIndex[timeStepIndex];
if (wellTimeStep == cvf::UNDEFINED_SIZE_T) return CLOSED;
if (hasCrossFlowEnding(tracerName)) return PRODUCER;
const RigWellResultFrame& wellResFrame = wellResults[wIdx]->m_wellCellsTimeSteps[wellTimeStep];
{
if (!wellResFrame.m_isOpen) return CLOSED;
return INJECTOR;
}
else if ( wellResFrame.m_productionType == RigWellResultFrame::PRODUCER )
{
if (hasCrossFlowEnding(tracerName)) return INJECTOR;
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;
}
}
return PRODUCER;
}
else
{
return UNDEFINED;
}
}
}
@ -280,18 +325,20 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeSte
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName)
cvf::Color3f RimFlowDiagSolution::tracerColor(const QString& tracerName)
{
RimEclipseResultCase* eclCase;
this->firstAncestorOrThisOfType(eclCase);
QString wellName = removeCrossFlowEnding(tracerName);
if ( eclCase )
{
RimEclipseView* activeView = dynamic_cast<RimEclipseView*>(RiaApplication::instance()->activeReservoirView());
if (activeView)
{
RimEclipseWell* well = activeView->wellCollection->findWell(tracerName);
RimEclipseWell* well = activeView->wellCollection->findWell(wellName);
if (well)
{
return well->wellPipeColor();
@ -306,7 +353,7 @@ cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName)
for ( size_t wIdx = 0; wIdx < wellResults.size(); ++wIdx )
{
if ( wellResults[wIdx]->m_wellName == tracerName )
if ( wellResults[wIdx]->m_wellName == wellName )
{
return RiaColorTables::wellsPaletteColors().cycledColor3f(wIdx);
}
@ -314,9 +361,9 @@ cvf::Color3f RimFlowDiagSolution::tracerColor(QString tracerName)
}
}
if (tracerName == RIG_FLOW_TOTAL_NAME) return cvf::Color3f::LIGHT_GRAY;
if (tracerName == RIG_RESERVOIR_TRACER_NAME) return cvf::Color3f::LIGHT_GRAY;
if (tracerName == RIG_TINY_TRACER_GROUP_NAME) return cvf::Color3f::DARK_GRAY;
if (wellName == RIG_FLOW_TOTAL_NAME) return cvf::Color3f::LIGHT_GRAY;
if (wellName == RIG_RESERVOIR_TRACER_NAME) return cvf::Color3f::LIGHT_GRAY;
if (wellName == RIG_TINY_TRACER_GROUP_NAME) return cvf::Color3f::DARK_GRAY;
return cvf::Color3f::LIGHT_GRAY;
}

View File

@ -56,9 +56,9 @@ public:
UNDEFINED
};
TracerStatusType tracerStatusOverall(QString tracerName);
TracerStatusType tracerStatusInTimeStep(QString tracerName, size_t timeStepIndex);
cvf::Color3f tracerColor(QString tracerName);
TracerStatusType tracerStatusOverall(const QString& tracerName);
TracerStatusType tracerStatusInTimeStep(const QString& tracerName, size_t timeStepIndex);
cvf::Color3f tracerColor(const QString& tracerName);
protected:

View File

@ -239,14 +239,22 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
injectorCellSet.push_back(CellSet(CellSetID(tIt.first), tIt.second));
}
Solution injSol = m_opmFldData->fldToolbox->computeInjectionDiagnostics(injectorCellSet).fd;
for ( const CellSetID& tracerId: injSol.startPoints() )
try
{
CellSetValues tofVals = injSol.timeOfFlight(tracerId);
result.setTracerTOF(tracerId.to_string(), tofVals);
CellSetValues fracVals = injSol.concentration(tracerId);
result.setTracerFraction(tracerId.to_string(), fracVals);
Solution injSol = m_opmFldData->fldToolbox->computeInjectionDiagnostics(injectorCellSet).fd;
for ( const CellSetID& tracerId: injSol.startPoints() )
{
CellSetValues tofVals = injSol.timeOfFlight(tracerId);
result.setTracerTOF(tracerId.to_string(), tofVals);
CellSetValues fracVals = injSol.concentration(tracerId);
result.setTracerFraction(tracerId.to_string(), fracVals);
}
}
catch (...)
{
CVF_ASSERT(false);
}
}
@ -261,14 +269,21 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
prodjCellSet.push_back(CellSet(CellSetID(tIt.first), tIt.second));
}
Solution prodSol = m_opmFldData->fldToolbox->computeProductionDiagnostics(prodjCellSet).fd;
for ( const CellSetID& tracerId: prodSol.startPoints() )
try
{
CellSetValues tofVals = prodSol.timeOfFlight(tracerId);
result.setTracerTOF(tracerId.to_string(), tofVals);
CellSetValues fracVals = prodSol.concentration(tracerId);
result.setTracerFraction(tracerId.to_string(), fracVals);
Solution prodSol = m_opmFldData->fldToolbox->computeProductionDiagnostics(prodjCellSet).fd;
for ( const CellSetID& tracerId: prodSol.startPoints() )
{
CellSetValues tofVals = prodSol.timeOfFlight(tracerId);
result.setTracerTOF(tracerId.to_string(), tofVals);
CellSetValues fracVals = prodSol.concentration(tracerId);
result.setTracerFraction(tracerId.to_string(), fracVals);
}
}
catch (...)
{
CVF_ASSERT(false);
}
}