More refactoring as preparation to #1171 and #1120

This commit is contained in:
Jacob Støren 2017-02-17 17:15:48 +01:00
parent 48599f7a94
commit ccd5294ded
2 changed files with 48 additions and 33 deletions

View File

@ -253,40 +253,12 @@ void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branc
}
// Accumulate the connection-cell's fraction flows
std::vector<double> flowPrTracer(m_tracerNames.size(), 0.0);
if ( m_tracerCellFractionValues )
std::vector<double> flowPrTracer = calculateFlowPrTracer(branchCells, clSegIdx);
for (size_t tIdx = 0; tIdx < flowPrTracer.size(); ++tIdx)
{
if ( branchCells[clSegIdx].isCell() && branchCells[clSegIdx].m_isOpen )
{
size_t resCellIndex = m_cellIndexCalculator.resultCellIndex(branchCells[clSegIdx].m_gridIndex,
branchCells[clSegIdx].m_gridCellIndex);
size_t tracerIdx = 0;
double totalTracerFractionInCell = 0.0;
for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) )
{
double cellTracerFraction = (*tracerFractionIt.second)[resCellIndex];
if (cellTracerFraction != HUGE_VAL && cellTracerFraction == cellTracerFraction)
{
double tracerFlow = cellTracerFraction * branchCells[clSegIdx].flowRate();
flowPrTracer[tracerIdx] = tracerFlow;
accFlowPrTracer[tracerIdx] += tracerFlow;
totalTracerFractionInCell += cellTracerFraction;
}
tracerIdx++;
}
double reservoirFraction = 1.0 - totalTracerFractionInCell;
double reservoirTracerFlow = reservoirFraction * branchCells[clSegIdx].flowRate();
flowPrTracer[tracerIdx] = reservoirTracerFlow;
accFlowPrTracer[tracerIdx] += reservoirTracerFlow;
}
}
else
{
accFlowPrTracer[0] += branchCells[clSegIdx].flowRate();
flowPrTracer[0] = branchCells[clSegIdx].flowRate();
accFlowPrTracer[tIdx] += flowPrTracer[tIdx];
}
// Add the total accumulated (fraction) flows from any branches connected to this cell
@ -324,7 +296,6 @@ void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branc
tracerIdx++;
}
connNumbersFromTop.push_back(connNumFromTop);
}
@ -333,6 +304,47 @@ void RigAccWellFlowCalculator::calculateAccumulatedFlowPrConnection(size_t branc
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RigAccWellFlowCalculator::calculateFlowPrTracer(const std::vector<RigWellResultPoint>& branchCells,
int clSegIdx)
{
std::vector<double> flowPrTracer(m_tracerNames.size(), 0.0);
if ( m_tracerCellFractionValues )
{
if ( branchCells[clSegIdx].isCell() && branchCells[clSegIdx].m_isOpen )
{
size_t resCellIndex = m_cellIndexCalculator.resultCellIndex(branchCells[clSegIdx].m_gridIndex,
branchCells[clSegIdx].m_gridCellIndex);
size_t tracerIdx = 0;
double totalTracerFractionInCell = 0.0;
for ( const auto & tracerFractionIt: (*m_tracerCellFractionValues) )
{
double cellTracerFraction = (*tracerFractionIt.second)[resCellIndex];
if ( cellTracerFraction != HUGE_VAL && cellTracerFraction == cellTracerFraction )
{
double tracerFlow = cellTracerFraction * branchCells[clSegIdx].flowRate();
flowPrTracer[tracerIdx] = tracerFlow;
totalTracerFractionInCell += cellTracerFraction;
}
tracerIdx++;
}
double reservoirFraction = 1.0 - totalTracerFractionInCell;
double reservoirTracerFlow = reservoirFraction * branchCells[clSegIdx].flowRate();
flowPrTracer[tracerIdx] = reservoirTracerFlow;
}
}
else
{
flowPrTracer[0] = branchCells[clSegIdx].flowRate();
}
return flowPrTracer;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -79,6 +79,9 @@ public:
private:
void calculateAccumulatedFlowPrConnection( size_t branchIdx, size_t startConnectionNumberFromTop);
std::vector<double> calculateFlowPrTracer(const std::vector<RigWellResultPoint> &branchCells, int clSegIdx);
void calculateFlowPrPseudoLength(size_t branchIdx, double startPseudoLengthFromTop);
void sortTracers();
void groupSmallContributions();