diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/CMakeLists_files.cmake b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/CMakeLists_files.cmake index e2f30ca139..548a3e719d 100644 --- a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/CMakeLists_files.cmake +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/CMakeLists_files.cmake @@ -5,6 +5,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RigIndexIjkResultCalculator.h ${CMAKE_CURRENT_LIST_DIR}/RigOilVolumeResultCalculator.h + ${CMAKE_CURRENT_LIST_DIR}/RigCellVolumeResultCalculator.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -14,6 +15,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RigIndexIjkResultCalculator.cpp ${CMAKE_CURRENT_LIST_DIR}/RigOilVolumeResultCalculator.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCellVolumeResultCalculator.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp new file mode 100644 index 0000000000..471fcfc1a1 --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.cpp @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- Equinor 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 "RigCellVolumeResultCalculator.h" +#include "RiaDefines.h" +#include "RiaResultNames.h" +#include "RigActiveCellInfo.h" +#include "RigCaseCellResultsData.h" +#include "RigCell.h" +#include "RigEclipseResultInfo.h" +#include "RigMainGrid.h" + +//================================================================================================== +/// +//================================================================================================== +RigCellVolumeResultCalculator::RigCellVolumeResultCalculator( RigCaseCellResultsData& resultsData ) + : RigEclipseResultCalculator( resultsData ) +{ +} + +//================================================================================================== +/// +//================================================================================================== +RigCellVolumeResultCalculator::~RigCellVolumeResultCalculator() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCellVolumeResultCalculator::isMatching( const RigEclipseResultAddress& resVarAddr ) const +{ + return resVarAddr.resultName() == RiaResultNames::riCellVolumeResultName() && + resVarAddr.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCellVolumeResultCalculator::calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) +{ + size_t cellVolIdx = m_resultsData->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, + RiaResultNames::riCellVolumeResultName() ), + false ); + + if ( m_resultsData->m_cellScalarResults[cellVolIdx].empty() ) + { + m_resultsData->m_cellScalarResults[cellVolIdx].resize( 1 ); + } + std::vector& cellVolumeResults = m_resultsData->m_cellScalarResults[cellVolIdx][0]; + + size_t cellResultCount = m_resultsData->m_activeCellInfo->reservoirActiveCellCount(); + cellVolumeResults.resize( cellResultCount, std::numeric_limits::infinity() ); + +#pragma omp parallel for + for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_resultsData->m_ownerMainGrid->globalCellArray().size() ); + nativeResvCellIndex++ ) + { + size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex ); + if ( resultIndex != cvf::UNDEFINED_SIZE_T ) + { + const RigCell& cell = m_resultsData->m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; + if ( !cell.subGrid() ) + { + cellVolumeResults[resultIndex] = cell.volume(); + } + } + } + + // Clear oil volume so it will have to be recalculated. + m_resultsData->clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::riOilVolumeResultName() ); +} diff --git a/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.h b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.h new file mode 100644 index 0000000000..57a79e3f6d --- /dev/null +++ b/ApplicationLibCode/ReservoirDataModel/ResultCalculators/RigCellVolumeResultCalculator.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- Equinor 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 "RigEclipseResultCalculator.h" + +class RigCaseCellResultsData; +class RigEclipseResultAddress; + +//================================================================================================== +/// +//================================================================================================== +class RigCellVolumeResultCalculator : public RigEclipseResultCalculator +{ +public: + RigCellVolumeResultCalculator( RigCaseCellResultsData& resultsData ); + ~RigCellVolumeResultCalculator() override; + bool isMatching( const RigEclipseResultAddress& resVarAddr ) const override; + void calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) override; +}; diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp index ae729eaeba..b787ae826a 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -28,6 +28,7 @@ #include "RiaResultNames.h" #include "RigAllanDiagramData.h" #include "RigCaseCellResultCalculator.h" +#include "RigCellVolumeResultCalculator.h" #include "RigEclipseAllanFaultsStatCalc.h" #include "RigEclipseCaseData.h" #include "RigEclipseMultiPropertyStatCalc.h" @@ -2612,36 +2613,9 @@ double RigCaseCellResultsData::darchysValue() //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::computeCellVolumes() { - size_t cellVolIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE, - RiaResultNames::riCellVolumeResultName() ), - false ); - - if ( m_cellScalarResults[cellVolIdx].empty() ) - { - m_cellScalarResults[cellVolIdx].resize( 1 ); - } - std::vector& cellVolumeResults = m_cellScalarResults[cellVolIdx][0]; - - size_t cellResultCount = m_activeCellInfo->reservoirActiveCellCount(); - cellVolumeResults.resize( cellResultCount, std::numeric_limits::infinity() ); - -#pragma omp parallel for - for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast( m_ownerMainGrid->globalCellArray().size() ); - nativeResvCellIndex++ ) - { - size_t resultIndex = activeCellInfo()->cellResultIndex( nativeResvCellIndex ); - if ( resultIndex != cvf::UNDEFINED_SIZE_T ) - { - const RigCell& cell = m_ownerMainGrid->globalCellArray()[nativeResvCellIndex]; - if ( !cell.subGrid() ) - { - cellVolumeResults[resultIndex] = cell.volume(); - } - } - } - - // Clear oil volume so it will have to be recalculated. - clearScalarResult( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::riOilVolumeResultName() ); + RigEclipseResultAddress addr( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::riCellVolumeResultName() ); + RigCellVolumeResultCalculator calculator( *this ); + calculator.calculate( addr, 0 ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h index 9b2eb2cfdb..df6b7ffbd4 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -158,6 +158,7 @@ private: friend class RigMobilePoreVolumeResultCalculator; friend class RigIndexIjkResultCalculator; friend class RigOilVolumeResultCalculator; + friend class RigCellVolumeResultCalculator; size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ); size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );