#1126 Adding first implementation of calculator for TOF-accumulated phaase fraction. Not yet tested or called from any code.

This commit is contained in:
astridkbjorke
2017-08-09 15:09:19 +02:00
parent efb79ac753
commit a61882d092
4 changed files with 199 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ ${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.h
${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.h
${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.h
${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.h
${CEE_CURRENT_LIST_DIR}RigTOFaccumulatedPhaseFractionsPlot.h
)
@@ -110,6 +112,7 @@ ${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.cpp
${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.cpp
${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.cpp
${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.cpp
${CEE_CURRENT_LIST_DIR}RigTOFaccumulatedPhaseFractionsPlot.cpp
)

View File

@@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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");
std::vector<double>& swatResults = eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSwat, m_timeStep);
std::vector<double>& soilResults = eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSoil, m_timeStep);
std::vector<double>& sgasResults = eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexSgas, m_timeStep);
std::vector<double>& porvResults = eclipseCaseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndexPorv, m_timeStep);
const RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(porosityModel);
std::string resultNameTof = "TOF";
const std::vector<double>* tofData = m_flowDiagSolution->flowDiagResults()->resultValues(RigFlowDiagResultAddress(resultNameTof, m_wellName.toStdString()),
m_timeStep);
std::string resultNameFraction = "Fraction";
const std::vector<double>* fractionData = m_flowDiagSolution->flowDiagResults()->resultValues(RigFlowDiagResultAddress(resultNameFraction, m_wellName.toStdString()),
m_timeStep);
sortTofAndCalculateAccPhaseFraction(tofData, fractionData, porvResults, swatResults, soilResults, sgasResults);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigTofAccumulatedPhaseFractionsCalculator::sortTofAndCalculateAccPhaseFraction(const std::vector<double>* tofData, const std::vector<double>* fractionData, std::vector<double>& porvResults, std::vector<double>& swatResults, std::vector<double>& soilResults, 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);
fractionPorvSum += fractionData->at(index) * porvResults[index];
fractionPorvPhaseSumSwat += fractionData->at(index) * porvResults[index] * swatResults[index];
fractionPorvPhaseSumSoil += fractionData->at(index) * porvResults[index] * soilResults[index];
fractionPorvPhaseSumSgas += fractionData->at(index) * porvResults[index] * sgasResults[index];
accumulatedPhaseFractionSwat.push_back(fractionPorvPhaseSumSwat / fractionPorvSum);
accumulatedPhaseFractionSoil.push_back(fractionPorvPhaseSumSoil / fractionPorvSum);
accumulatedPhaseFractionSgas.push_back(fractionPorvPhaseSumSgas / fractionPorvSum);
}
}

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include "cvfBase.h"
#include "cvfVector3.h"
#include <array>
#include "RimFlowDiagSolution.h"
class RimEclipseCase;
//==================================================================================================
///
//==================================================================================================
class RigTofAccumulatedPhaseFractionsCalculator
{
public:
void computeTOFaccumulations();
void sortTofAndCalculateAccPhaseFraction(const std::vector<double>* tofData, const std::vector<double>* fractionData, std::vector<double>& porvResults, std::vector<double>& swatResults, std::vector<double>& soilResults, std::vector<double>& sgasResults);
private:
RimEclipseCase* m_case;
QString m_wellName;
caf::PdmField<int> m_timeStep;
caf::PdmPtrField<RimFlowDiagSolution*> m_flowDiagSolution;
};

View File

@@ -0,0 +1,29 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "gtest/gtest.h"
#include "RigTofAccumulatedPhaseFractionsCalculator.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigTofAccumulatedPhaseFractionsCalculator, sortTofAndCalculateAccPhaseFraction)
{
//TODO
}