mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1126 Adding unit test
This commit is contained in:
parent
40addb9a10
commit
42245b22af
@ -68,54 +68,24 @@ void RigTofAccumulatedPhaseFractionsCalculator::computeTOFaccumulations()
|
||||
m_timeStep);
|
||||
|
||||
|
||||
sortTofAndCalculateAccPhaseFraction(tofData, fractionData, porvResults, swatResults, soilResults, sgasResults);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigTofAccumulatedPhaseFractionsCalculator::sortTofAndCalculateAccPhaseFraction(const std::vector<double>* tofData,
|
||||
const std::vector<double>* fractionData,
|
||||
const std::vector<double>* porvResults,
|
||||
const std::vector<double>* swatResults,
|
||||
const std::vector<double>* soilResults,
|
||||
const std::vector<double>* sgasResults)
|
||||
{
|
||||
std::map<double, int> tofAndIndexMap;
|
||||
|
||||
for (int i = 0; i < tofData->size(); i++)
|
||||
{
|
||||
tofAndIndexMap[tofData->at(i)] = i;
|
||||
}
|
||||
|
||||
|
||||
double fractionPorvSum = 0.0;
|
||||
double fractionPorvPhaseSumSwat = 0.0;
|
||||
double fractionPorvPhaseSumSoil = 0.0;
|
||||
double fractionPorvPhaseSumSgas = 0.0;
|
||||
|
||||
std::vector<double> accumulatedPhaseFractionSwat;
|
||||
std::vector<double> accumulatedPhaseFractionSoil;
|
||||
std::vector<double> accumulatedPhaseFractionSgas;
|
||||
std::vector<double> tofInIncreasingOrder;
|
||||
|
||||
|
||||
for (auto element : tofAndIndexMap) //todo - check handling of several cells have same tof value
|
||||
{
|
||||
int index = element.second;
|
||||
double tofValue = element.first;
|
||||
tofInIncreasingOrder.push_back(tofValue);
|
||||
sortTofAndCalculateAccPhaseFraction(tofData,
|
||||
fractionData,
|
||||
porvResults,
|
||||
swatResults,
|
||||
soilResults,
|
||||
sgasResults,
|
||||
accumulatedPhaseFractionSwat,
|
||||
accumulatedPhaseFractionSoil,
|
||||
accumulatedPhaseFractionSgas,
|
||||
tofInIncreasingOrder);
|
||||
|
||||
|
||||
fractionPorvSum += fractionData->at(index) * porvResults->at(index);
|
||||
fractionPorvPhaseSumSwat += fractionData->at(index) * porvResults->at(index) * swatResults->at(index);
|
||||
fractionPorvPhaseSumSoil += fractionData->at(index) * porvResults->at(index) * soilResults->at(index);
|
||||
fractionPorvPhaseSumSgas += fractionData->at(index) * porvResults->at(index) * sgasResults->at(index);
|
||||
|
||||
accumulatedPhaseFractionSwat.push_back(fractionPorvPhaseSumSwat / fractionPorvSum);
|
||||
accumulatedPhaseFractionSoil.push_back(fractionPorvPhaseSumSoil / fractionPorvSum);
|
||||
accumulatedPhaseFractionSgas.push_back(fractionPorvPhaseSumSgas / fractionPorvSum);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,11 @@ public:
|
||||
const std::vector<double>* porvResults,
|
||||
const std::vector<double>* swatResults,
|
||||
const std::vector<double>* soilResults,
|
||||
const std::vector<double>* sgasResults);
|
||||
const std::vector<double>* sgasResults,
|
||||
std::vector<double>& tofInIncreasingOrder,
|
||||
std::vector<double>& accumulatedPhaseFractionSwat,
|
||||
std::vector<double>& accumulatedPhaseFractionSoil,
|
||||
std::vector<double>& accumulatedPhaseFractionSgas);
|
||||
|
||||
private:
|
||||
RimEclipseCase* m_case;
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
#include "RigTofAccumulatedPhaseFractionsCalculator.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -36,9 +35,9 @@ TEST(RigTofAccumulatedPhaseFractionsCalculator, sortTofAndCalculateAccPhaseFract
|
||||
fractionDataVector.push_back(0.02);
|
||||
|
||||
std::vector<double> porvResultVector;
|
||||
porvResultVector.push_back(0.002);
|
||||
porvResultVector.push_back(0.2);
|
||||
porvResultVector.push_back(0.02);
|
||||
porvResultVector.push_back(1);
|
||||
porvResultVector.push_back(1);
|
||||
porvResultVector.push_back(1.5);
|
||||
|
||||
std::vector<double> swatResultVector;
|
||||
swatResultVector.push_back(0.1);
|
||||
@ -55,12 +54,29 @@ TEST(RigTofAccumulatedPhaseFractionsCalculator, sortTofAndCalculateAccPhaseFract
|
||||
sgasResultVector.push_back(0.1);
|
||||
sgasResultVector.push_back(0.3);
|
||||
|
||||
|
||||
std::vector<double> accumulatedPhaseFractionSwat;
|
||||
std::vector<double> accumulatedPhaseFractionSoil;
|
||||
std::vector<double> accumulatedPhaseFractionSgas;
|
||||
std::vector<double> tofInIncreasingOrder;
|
||||
|
||||
RigTofAccumulatedPhaseFractionsCalculator::sortTofAndCalculateAccPhaseFraction(&(tofDataVector),
|
||||
&(fractionDataVector),
|
||||
&(porvResultVector),
|
||||
&(swatResultVector),
|
||||
&(soilResultVector),
|
||||
&(sgasResultVector));
|
||||
&(sgasResultVector),
|
||||
tofInIncreasingOrder,
|
||||
accumulatedPhaseFractionSwat,
|
||||
accumulatedPhaseFractionSoil,
|
||||
accumulatedPhaseFractionSgas
|
||||
);
|
||||
|
||||
EXPECT_EQ(1, 1);
|
||||
}
|
||||
EXPECT_LT(tofInIncreasingOrder[0], tofInIncreasingOrder[1]);
|
||||
EXPECT_LT(tofInIncreasingOrder[1], tofInIncreasingOrder[2]);
|
||||
|
||||
EXPECT_DOUBLE_EQ(accumulatedPhaseFractionSwat[0], 0.1000);
|
||||
EXPECT_DOUBLE_EQ(accumulatedPhaseFractionSoil[1], 0.1125);
|
||||
EXPECT_LT(accumulatedPhaseFractionSgas[2] - 0.13017, 0.00001);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user