From 8027f3d5c413392d589dcf93f8ce565de906e387 Mon Sep 17 00:00:00 2001 From: astridkbjorke Date: Fri, 25 Aug 2017 13:28:42 +0200 Subject: [PATCH] #1787 Adding files for calculator of number of flooded pore volumes. Starting calculating by only considering neighbour cells. --- .../ReservoirDataModel/CMakeLists_files.cmake | 3 + ...igNumberOfFloodedPoreVolumesCalculator.cpp | 185 ++++++++++++++++++ .../RigNumberOfFloodedPoreVolumesCalculator.h | 55 ++++++ ...berOfFloodedPoreVolumesCalculator-Test.cpp | 28 +++ 4 files changed, 271 insertions(+) create mode 100644 ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h create mode 100644 ApplicationCode/UnitTests/RigNumberOfFloodedPoreVolumesCalculator-Test.cpp diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index f21b8e7ef7..91ba5e8701 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -62,6 +62,8 @@ ${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.h ${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.h ${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.h ${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.h +${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h + ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) @@ -130,6 +132,7 @@ ${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.cpp ${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.cpp ${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.cpp ${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.cpp +${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp ) if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp new file mode 100644 index 0000000000..8887171ecc --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -0,0 +1,185 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigNumberOfFloodedPoreVolumesCalculator.h" + + +#include "RigMainGrid.h" +#include +#include "RimReservoirCellResultsStorage.h" +#include "RigEclipseCaseData.h" +#include "RimEclipseCase.h" +#include "RiaPorosityModel.h" +#include "RigEclipseCaseData.h" +#include "RigCaseCellResultsData.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigNumberOfFloodedPoreVolumesCalculator::RigNumberOfFloodedPoreVolumesCalculator(RigMainGrid* mainGrid, + RimEclipseCase* caseToApply, + std::vector tracerNames ) +{ + RigEclipseCaseData* eclipseCaseData = caseToApply->eclipseCaseData(); + RiaDefines::PorosityModelType porosityModel = RiaDefines::MATRIX_MODEL; + RimReservoirCellResultsStorage* gridCellResults = caseToApply->results(porosityModel); + + size_t scalarResultIndexPorv = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PORV"); + const std::vector* porvResults = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexPorv, 0)); + + size_t scalarResultIndexFlrWatI = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "FLRWATI+"); + size_t scalarResultIndexFlrWatJ = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "FLRWATJ+"); + size_t scalarResultIndexFlrWatK = gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "FLRWATK+"); + + std::vector scalarResultIndexTracers; + for (std::string tracerName : tracerNames) + { + scalarResultIndexTracers.push_back(gridCellResults->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "FLRWATI+")); + } + + + std::vector timeStepDates = caseToApply->timeStepDates(); + + + for (size_t timeStep = 1; timeStep < timeStepDates.size(); timeStep++) + { + const std::vector* flrWatResultI = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlrWatI, timeStep)); + const std::vector* flrWatResultJ = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlrWatJ, timeStep)); + const std::vector* flrWatResultK = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(scalarResultIndexFlrWatK, timeStep)); + + size_t totalNumberOfCells = flrWatResultI->size(); + std::vector FwI(totalNumberOfCells); + std::vector FwJ(totalNumberOfCells); + std::vector FwK(totalNumberOfCells); + + std::vector summedTracerValues(totalNumberOfCells); + //sum all tracers at current timestep + for (size_t tracerIndex : scalarResultIndexTracers) + { + const std::vector* tracerResult = &(eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(tracerIndex, timeStep)); + + for (size_t i = 0; i < summedTracerValues.size(); i++) + { + summedTracerValues[i] += tracerResult->at(i); + } + } + + distributeNeighbourCellFlow(mainGrid, + totalNumberOfCells, + summedTracerValues, + flrWatResultI, + FwI, + flrWatResultJ, + FwJ, + flrWatResultK, + FwK); + + //TODO: Add NNC contributions + + + + + } + + + + + + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMainGrid* mainGrid, + size_t totalNumberOfCells, + std::vector summedTracerValues, + const std::vector* flrWatResultI, + std::vector &FwI, + const std::vector* flrWatResultJ, + std::vector &FwJ, + const std::vector* flrWatResultK, + std::vector &FwK) +{ + for (size_t globalCellIndex = 0; globalCellIndex < totalNumberOfCells; globalCellIndex++) + { + size_t i, j, k; + mainGrid->ijkFromCellIndex(globalCellIndex, &i, &j, &k); //TODO: Generalize grid!!!! + + if (i < mainGrid->cellCountI()) + { + size_t globalCellIndexPosINeightbour = mainGrid->cellIndexFromIJK(i + 1, j, k); + + if (flrWatResultI->at(globalCellIndex) > 0) + { + //Flow out of cell globalCellIndex, into cell i+1 + FwI[globalCellIndexPosINeightbour] += flrWatResultI->at(globalCellIndex) * summedTracerValues[globalCellIndex]; + } + else if (flrWatResultI->at(globalCellIndex) < 0 && i < mainGrid->cellCountI()) + { + //Flow into cell globelCellIndex, from cell i+1 + FwI[globalCellIndex] += flrWatResultI->at(globalCellIndex) * summedTracerValues[globalCellIndexPosINeightbour]; + } + } + } + + for (size_t globalCellIndex = 0; globalCellIndex < totalNumberOfCells; globalCellIndex++) + { + size_t i, j, k; + mainGrid->ijkFromCellIndex(globalCellIndex, &i, &j, &k); //TODO: Generalize grid!!!! + + if (i < mainGrid->cellCountI()) + { + size_t globalCellIndexPosJNeightbour = mainGrid->cellIndexFromIJK(i, j + 1, k); + + if (flrWatResultJ->at(globalCellIndex) > 0) + { + //Flow out of cell globalCellIndex, into cell i+1 + FwJ[globalCellIndexPosJNeightbour] += flrWatResultJ->at(globalCellIndex) * summedTracerValues[globalCellIndex]; + } + else if (flrWatResultJ->at(globalCellIndex) < 0 && i < mainGrid->cellCountI()) + { + //Flow into cell globelCellIndex, from cell i+1 + FwJ[globalCellIndex] += flrWatResultJ->at(globalCellIndex) * summedTracerValues[globalCellIndexPosJNeightbour]; + } + } + } + + for (size_t globalCellIndex = 0; globalCellIndex < totalNumberOfCells; globalCellIndex++) + { + size_t i, j, k; + mainGrid->ijkFromCellIndex(globalCellIndex, &i, &j, &k); //TODO: Generalize grid!!!! + + if (i < mainGrid->cellCountI()) + { + size_t globalCellIndexPosKNeightbour = mainGrid->cellIndexFromIJK(i, j, k + 1); + + if (flrWatResultK->at(globalCellIndex) > 0) + { + //Flow out of cell globalCellIndex, into cell i+1 + FwK[globalCellIndexPosKNeightbour] += flrWatResultK->at(globalCellIndex) * summedTracerValues[globalCellIndex]; + } + else if (flrWatResultK->at(globalCellIndex) < 0 && i < mainGrid->cellCountI()) + { + //Flow into cell globelCellIndex, from cell i+1 + FwK[globalCellIndex] += flrWatResultK->at(globalCellIndex) * summedTracerValues[globalCellIndexPosKNeightbour]; + } + } + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h new file mode 100644 index 0000000000..1725d0e403 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +class RimEclipseCase; +class RigMainGrid; + +//================================================================================================== +/// +//================================================================================================== + +class RigNumberOfFloodedPoreVolumesCalculator +{ + +public: + explicit RigNumberOfFloodedPoreVolumesCalculator(RigMainGrid* mainGrid, + RimEclipseCase* caseToApply, + std::vector tracerNames + ); + + void distributeNeighbourCellFlow(RigMainGrid* mainGrid, + size_t totalNumberOfCells, + std::vector summedTracerValues, + const std::vector* flrWatResultI, + std::vector &FwI, + const std::vector* flrWatResultJ, + std::vector &FwJ, + const std::vector* flrWatResultK, + std::vector &FwK); + + +private: + +}; + diff --git a/ApplicationCode/UnitTests/RigNumberOfFloodedPoreVolumesCalculator-Test.cpp b/ApplicationCode/UnitTests/RigNumberOfFloodedPoreVolumesCalculator-Test.cpp new file mode 100644 index 0000000000..ed13fd4048 --- /dev/null +++ b/ApplicationCode/UnitTests/RigNumberOfFloodedPoreVolumesCalculator-Test.cpp @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "gtest/gtest.h" + +#include "RigNumberOfFloodedPoreVolumesCalculator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigNumberOfFloodedPoreVolumesCalculator, floodedPoreVolumeTest) +{ + +}