2017-08-09 08:09:19 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017- Statoil ASA
|
|
|
|
//
|
|
|
|
// ResInsight is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RigTofAccumulatedPhaseFractionsCalculator.h"
|
|
|
|
|
|
|
|
#include "RigEclipseCaseData.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimReservoirCellResultsStorage.h"
|
|
|
|
#include "RigResultAccessor.h"
|
|
|
|
#include "RigResultAccessorFactory.h"
|
|
|
|
#include "RigSingleWellResultsData.h"
|
|
|
|
#include "RigFlowDiagResultAddress.h"
|
|
|
|
#include "RimFlowDiagSolution.h"
|
|
|
|
#include "RigFlowDiagResults.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RigTofAccumulatedPhaseFractionsCalculator::computeTOFaccumulations()
|
|
|
|
{
|
|
|
|
RigEclipseCaseData* eclipseCaseData = m_case->eclipseCaseData();
|
|
|
|
|
|
|
|
RifReaderInterface::PorosityModelResultType porosityModel = RifReaderInterface::MATRIX_RESULTS;
|
|
|
|
|
|
|
|
|
|
|
|
RimReservoirCellResultsStorage* gridCellResults = m_case->results(porosityModel);
|
|
|
|
|
|
|
|
size_t scalarResultIndexSwat = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT");
|
|
|
|
size_t scalarResultIndexSoil = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL");
|
|
|
|
size_t scalarResultIndexSgas = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS");
|
|
|
|
size_t scalarResultIndexPorv = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PORV");
|
|
|
|
|
2017-08-09 08:41:55 -05:00
|
|
|
const std::vector<double>* swatResults = &(eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSwat, m_timeStep));
|
|
|
|
const std::vector<double>* soilResults = &(eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSoil, m_timeStep));
|
|
|
|
const std::vector<double>* sgasResults = &(eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSgas, m_timeStep));
|
|
|
|
const std::vector<double>* porvResults = &(eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexPorv, m_timeStep));
|
2017-08-09 08:09:19 -05:00
|
|
|
|
|
|
|
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(porosityModel);
|
|
|
|
|
|
|
|
std::string resultNameTof = "TOF";
|
2017-08-09 08:41:55 -05:00
|
|
|
const std::vector<double>* tofData = m_flowDiagSolution->flowDiagResults()->resultValues(RigFlowDiagResultAddress(resultNameTof,
|
|
|
|
m_wellName.toStdString()),
|
|
|
|
m_timeStep);
|
2017-08-09 08:09:19 -05:00
|
|
|
|
|
|
|
std::string resultNameFraction = "Fraction";
|
2017-08-09 08:41:55 -05:00
|
|
|
const std::vector<double>* fractionData = m_flowDiagSolution->flowDiagResults()->resultValues(RigFlowDiagResultAddress(resultNameFraction,
|
|
|
|
m_wellName.toStdString()),
|
|
|
|
m_timeStep);
|
2017-08-09 08:09:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
std::vector<double> accumulatedPhaseFractionSwat;
|
|
|
|
std::vector<double> accumulatedPhaseFractionSoil;
|
|
|
|
std::vector<double> accumulatedPhaseFractionSgas;
|
|
|
|
std::vector<double> tofInIncreasingOrder;
|
|
|
|
|
|
|
|
|
2017-08-10 04:02:54 -05:00
|
|
|
sortTofAndCalculateAccPhaseFraction(tofData,
|
|
|
|
fractionData,
|
|
|
|
porvResults,
|
|
|
|
swatResults,
|
|
|
|
soilResults,
|
|
|
|
sgasResults,
|
|
|
|
accumulatedPhaseFractionSwat,
|
|
|
|
accumulatedPhaseFractionSoil,
|
|
|
|
accumulatedPhaseFractionSgas,
|
|
|
|
tofInIncreasingOrder);
|
|
|
|
|
2017-08-09 08:09:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
}
|
2017-08-10 04:02:54 -05:00
|
|
|
|
2017-08-10 04:41:36 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
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::vector<double>& tofInIncreasingOrder,
|
|
|
|
std::vector<double>& accumulatedPhaseFractionSwat,
|
|
|
|
std::vector<double>& accumulatedPhaseFractionSoil,
|
|
|
|
std::vector<double>& accumulatedPhaseFractionSgas)
|
|
|
|
|
|
|
|
{
|
2017-08-10 06:07:17 -05:00
|
|
|
std::map<double, std::vector<int> > tofAndIndexMap;
|
2017-08-10 04:41:36 -05:00
|
|
|
|
|
|
|
for (int i = 0; i < tofData->size(); i++)
|
|
|
|
{
|
2017-08-10 06:07:17 -05:00
|
|
|
auto it = tofAndIndexMap.find(tofData->at(i));
|
|
|
|
if (it == tofAndIndexMap.end())
|
|
|
|
{
|
|
|
|
//Key does not exist
|
|
|
|
std::vector<int> vectorOfIndexes;
|
|
|
|
vectorOfIndexes.push_back(i);
|
|
|
|
tofAndIndexMap[tofData->at(i)] = vectorOfIndexes;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//Key does exisit
|
|
|
|
std::vector<int> vectorOfIndexes = it->second;
|
|
|
|
vectorOfIndexes.push_back(i);
|
|
|
|
tofAndIndexMap[tofData->at(i)] = vectorOfIndexes;
|
|
|
|
}
|
2017-08-10 04:41:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
double fractionPorvSum = 0.0;
|
|
|
|
double fractionPorvPhaseSumSwat = 0.0;
|
|
|
|
double fractionPorvPhaseSumSoil = 0.0;
|
|
|
|
double fractionPorvPhaseSumSgas = 0.0;
|
|
|
|
|
2017-08-10 06:07:17 -05:00
|
|
|
for (auto element : tofAndIndexMap)
|
2017-08-10 04:41:36 -05:00
|
|
|
{
|
|
|
|
double tofValue = element.first;
|
2017-08-10 06:07:17 -05:00
|
|
|
for (int index : element.second)
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
2017-08-10 04:41:36 -05:00
|
|
|
|
2017-08-10 06:07:17 -05:00
|
|
|
tofInIncreasingOrder.push_back(tofValue);
|
2017-08-10 04:41:36 -05:00
|
|
|
accumulatedPhaseFractionSwat.push_back(fractionPorvPhaseSumSwat / fractionPorvSum);
|
|
|
|
accumulatedPhaseFractionSoil.push_back(fractionPorvPhaseSumSoil / fractionPorvSum);
|
|
|
|
accumulatedPhaseFractionSgas.push_back(fractionPorvPhaseSumSgas / fractionPorvSum);
|
|
|
|
}
|
|
|
|
}
|