mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1048 Added derived result: Sum of tracer fractions
This commit is contained in:
parent
a12f6f758e
commit
a9b1cb4849
@ -185,56 +185,21 @@ std::vector<double>* RigFlowDiagResults::calculateDerivedResult(const RigFlowDia
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RigFlowDiagResultFrames* averageTofFrames = this->createScalarResult(resVarAddr);
|
|
||||||
std::vector<double>& averageTof = averageTofFrames->frameData(frameIndex);
|
|
||||||
size_t activeCellCount = this->activeCellInfo(resVarAddr)->reservoirActiveCellCount();
|
size_t activeCellCount = this->activeCellInfo(resVarAddr)->reservoirActiveCellCount();
|
||||||
averageTof.resize(activeCellCount, HUGE_VAL);
|
|
||||||
|
|
||||||
std::vector<double> injectorTotalFractions;
|
std::vector<double> injectorTotalFractions;
|
||||||
std::vector<double> injectorFractMultTof;
|
std::vector<double> injectorFractMultTof;
|
||||||
{
|
|
||||||
injectorTotalFractions.resize(activeCellCount, 0.0);
|
|
||||||
injectorFractMultTof.resize(activeCellCount, 0.0);
|
|
||||||
|
|
||||||
for ( size_t iIdx = 0; iIdx < injectorFractions.size() ; ++iIdx )
|
calculateSumOfFractionAndFractionMultTOF(activeCellCount, injectorFractions, injectorTOFs, &injectorTotalFractions, &injectorFractMultTof);
|
||||||
{
|
|
||||||
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> producerTotalFractions;
|
||||||
std::vector<double> producerFractMultTof;
|
std::vector<double> producerFractMultTof;
|
||||||
{
|
calculateSumOfFractionAndFractionMultTOF(activeCellCount, producerFractions, producerTOFs, &producerTotalFractions, &producerFractMultTof);
|
||||||
producerTotalFractions.resize(activeCellCount, 0.0);
|
|
||||||
producerFractMultTof.resize(activeCellCount, 0.0);
|
|
||||||
|
|
||||||
for ( size_t iIdx = 0; iIdx < producerFractions.size() ; ++iIdx )
|
RigFlowDiagResultFrames* averageTofFrames = this->createScalarResult(resVarAddr);
|
||||||
{
|
std::vector<double>& averageTof = averageTofFrames->frameData(frameIndex);
|
||||||
const std::vector<double> * prodFr = producerFractions[iIdx];
|
averageTof.resize(activeCellCount, HUGE_VAL);
|
||||||
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)
|
for (size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx)
|
||||||
{
|
{
|
||||||
@ -253,10 +218,71 @@ std::vector<double>* RigFlowDiagResults::calculateDerivedResult(const RigFlowDia
|
|||||||
|
|
||||||
return &averageTof;
|
return &averageTof;
|
||||||
}
|
}
|
||||||
|
else if (resVarAddr.variableName == RIG_FLD_CELL_FRACTION_RESNAME)
|
||||||
|
{
|
||||||
|
std::vector<const std::vector<double>* > fractions;
|
||||||
|
for ( const std::string& tracerName: resVarAddr.selectedTracerNames )
|
||||||
|
{
|
||||||
|
fractions.push_back(findOrCalculateResult(RigFlowDiagResultAddress(RIG_FLD_CELL_FRACTION_RESNAME, tracerName), frameIndex));
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t activeCellCount = this->activeCellInfo(resVarAddr)->reservoirActiveCellCount();
|
||||||
|
|
||||||
|
RigFlowDiagResultFrames* sumOfFractionsFrames = this->createScalarResult(resVarAddr);
|
||||||
|
std::vector<double>& sumOfFractions = sumOfFractionsFrames->frameData(frameIndex);
|
||||||
|
sumOfFractions.resize(activeCellCount, HUGE_VAL);
|
||||||
|
|
||||||
|
for ( size_t iIdx = 0; iIdx < fractions.size() ; ++iIdx )
|
||||||
|
{
|
||||||
|
const std::vector<double> * frInj = fractions[iIdx];
|
||||||
|
|
||||||
|
if ( ! (frInj) ) continue;
|
||||||
|
|
||||||
|
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
|
||||||
|
{
|
||||||
|
if ( (*frInj)[acIdx] == HUGE_VAL ) continue;
|
||||||
|
|
||||||
|
if ((sumOfFractions)[acIdx] == HUGE_VAL) (sumOfFractions)[acIdx] = 0.0;
|
||||||
|
|
||||||
|
(sumOfFractions)[acIdx] += (*frInj)[acIdx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &sumOfFractions;
|
||||||
|
}
|
||||||
|
|
||||||
return nullptr; // Todo
|
return nullptr; // Todo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
void RigFlowDiagResults::calculateSumOfFractionAndFractionMultTOF(size_t activeCellCount,
|
||||||
|
const std::vector<const std::vector<double> *> & fractions,
|
||||||
|
const std::vector<const std::vector<double> *> & TOFs,
|
||||||
|
std::vector<double> *sumOfFractions,
|
||||||
|
std::vector<double> *fractionMultTOF)
|
||||||
|
{
|
||||||
|
sumOfFractions->resize(activeCellCount, 0.0);
|
||||||
|
fractionMultTOF->resize(activeCellCount, 0.0);
|
||||||
|
|
||||||
|
for ( size_t iIdx = 0; iIdx < fractions.size() ; ++iIdx )
|
||||||
|
{
|
||||||
|
const std::vector<double> * frInj = fractions[iIdx];
|
||||||
|
const std::vector<double> * tofInj = TOFs[iIdx];
|
||||||
|
|
||||||
|
if ( ! (frInj && tofInj) ) continue;
|
||||||
|
|
||||||
|
for ( size_t acIdx = 0 ; acIdx < activeCellCount; ++acIdx )
|
||||||
|
{
|
||||||
|
if ( (*frInj)[acIdx] == HUGE_VAL ) continue;
|
||||||
|
|
||||||
|
(*sumOfFractions)[acIdx] += (*frInj)[acIdx];
|
||||||
|
(*fractionMultTOF)[acIdx] += (*frInj)[acIdx] * (*tofInj)[acIdx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -63,6 +63,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
|
const std::vector<double>* findOrCalculateResult (const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
|
||||||
std::vector<double>* calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
|
std::vector<double>* calculateDerivedResult(const RigFlowDiagResultAddress& resVarAddr, size_t frameIndex);
|
||||||
|
|
||||||
|
void calculateSumOfFractionAndFractionMultTOF(size_t activeCellCount,
|
||||||
|
const std::vector<const std::vector<double> *>& injectorFractions,
|
||||||
|
const std::vector<const std::vector<double> *>& injectorTOFs,
|
||||||
|
std::vector<double> *injectorTotalFractions,
|
||||||
|
std::vector<double> *injectorFractMultTof);
|
||||||
|
|
||||||
RigStatisticsDataCache* statistics(const RigFlowDiagResultAddress& resVarAddr);
|
RigStatisticsDataCache* statistics(const RigFlowDiagResultAddress& resVarAddr);
|
||||||
|
|
||||||
void calculateFractionWeightedTOF (size_t timeStepIdx, std::set<std::string> selectedTracerNames);
|
void calculateFractionWeightedTOF (size_t timeStepIdx, std::set<std::string> selectedTracerNames);
|
||||||
|
Loading…
Reference in New Issue
Block a user