mirror of
https://github.com/OPM/ResInsight.git
synced 2024-12-29 10:21:54 -06:00
Refactor: extract oil volume computation.
This commit is contained in:
parent
07eb1e9f4e
commit
6a37c5a5d0
@ -4,6 +4,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigFaultDistanceResultCalculator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigIndexIjkResultCalculator.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigOilVolumeResultCalculator.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -12,6 +13,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigFaultDistanceResultCalculator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigIndexIjkResultCalculator.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigOilVolumeResultCalculator.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,91 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RigOilVolumeResultCalculator.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaResultNames.h"
|
||||
#include "RigActiveCellInfo.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCell.h"
|
||||
#include "RigEclipseResultInfo.h"
|
||||
#include "RigMainGrid.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
RigOilVolumeResultCalculator::RigOilVolumeResultCalculator( RigCaseCellResultsData& resultsData )
|
||||
: RigEclipseResultCalculator( resultsData )
|
||||
{
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
RigOilVolumeResultCalculator::~RigOilVolumeResultCalculator()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigOilVolumeResultCalculator::isMatching( const RigEclipseResultAddress& resVarAddr ) const
|
||||
{
|
||||
return resVarAddr.resultName() == RiaResultNames::riOilVolumeResultName() &&
|
||||
resVarAddr.resultCatType() == RiaDefines::ResultCatType::DYNAMIC_NATIVE;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigOilVolumeResultCalculator::calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex )
|
||||
{
|
||||
size_t cellVolIdx = m_resultsData->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE,
|
||||
RiaResultNames::riCellVolumeResultName() ),
|
||||
false );
|
||||
const std::vector<double>& cellVolumeResults = m_resultsData->m_cellScalarResults[cellVolIdx][0];
|
||||
|
||||
size_t soilIdx = m_resultsData->findOrLoadKnownScalarResult(
|
||||
RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) );
|
||||
size_t oilVolIdx = m_resultsData->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
|
||||
RiaResultNames::riOilVolumeResultName() ),
|
||||
false );
|
||||
m_resultsData->m_cellScalarResults[oilVolIdx].resize( m_resultsData->maxTimeStepCount() );
|
||||
|
||||
size_t cellResultCount = m_resultsData->m_activeCellInfo->reservoirActiveCellCount();
|
||||
for ( size_t timeStepIdx = 0; timeStepIdx < m_resultsData->maxTimeStepCount(); timeStepIdx++ )
|
||||
{
|
||||
const std::vector<double>& soilResults = m_resultsData->m_cellScalarResults[soilIdx][timeStepIdx];
|
||||
std::vector<double>& oilVolumeResults = m_resultsData->m_cellScalarResults[oilVolIdx][timeStepIdx];
|
||||
oilVolumeResults.resize( cellResultCount, 0u );
|
||||
|
||||
#pragma omp parallel for
|
||||
for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast<int>( m_resultsData->m_ownerMainGrid->globalCellArray().size() );
|
||||
nativeResvCellIndex++ )
|
||||
{
|
||||
size_t resultIndex = m_resultsData->activeCellInfo()->cellResultIndex( nativeResvCellIndex );
|
||||
if ( resultIndex != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
if ( resultIndex < soilResults.size() && resultIndex < cellVolumeResults.size() )
|
||||
{
|
||||
CVF_ASSERT( soilResults.at( resultIndex ) <= 1.01 );
|
||||
oilVolumeResults[resultIndex] = std::max( 0.0, soilResults.at( resultIndex ) * cellVolumeResults.at( resultIndex ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "RigEclipseResultCalculator.h"
|
||||
|
||||
class RigCaseCellResultsData;
|
||||
class RigEclipseResultAddress;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RigOilVolumeResultCalculator : public RigEclipseResultCalculator
|
||||
{
|
||||
public:
|
||||
RigOilVolumeResultCalculator( RigCaseCellResultsData& resultsData );
|
||||
~RigOilVolumeResultCalculator() override;
|
||||
bool isMatching( const RigEclipseResultAddress& resVarAddr ) const override;
|
||||
void calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) override;
|
||||
};
|
@ -38,6 +38,7 @@
|
||||
#include "RigIndexIjkResultCalculator.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigMobilePoreVolumeResultCalculator.h"
|
||||
#include "RigOilVolumeResultCalculator.h"
|
||||
#include "RigSoilResultCalculator.h"
|
||||
#include "RigStatisticsDataCache.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
@ -2648,40 +2649,10 @@ void RigCaseCellResultsData::computeCellVolumes()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseCellResultsData::computeOilVolumes()
|
||||
{
|
||||
size_t cellVolIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE,
|
||||
RiaResultNames::riCellVolumeResultName() ),
|
||||
false );
|
||||
const std::vector<double>& cellVolumeResults = m_cellScalarResults[cellVolIdx][0];
|
||||
|
||||
size_t soilIdx =
|
||||
this->findOrLoadKnownScalarResult( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::soil() ) );
|
||||
size_t oilVolIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
|
||||
RiaResultNames::riOilVolumeResultName() ),
|
||||
false );
|
||||
m_cellScalarResults[oilVolIdx].resize( this->maxTimeStepCount() );
|
||||
|
||||
size_t cellResultCount = m_activeCellInfo->reservoirActiveCellCount();
|
||||
for ( size_t timeStepIdx = 0; timeStepIdx < this->maxTimeStepCount(); timeStepIdx++ )
|
||||
{
|
||||
const std::vector<double>& soilResults = m_cellScalarResults[soilIdx][timeStepIdx];
|
||||
std::vector<double>& oilVolumeResults = m_cellScalarResults[oilVolIdx][timeStepIdx];
|
||||
oilVolumeResults.resize( cellResultCount, 0u );
|
||||
|
||||
#pragma omp parallel for
|
||||
for ( int nativeResvCellIndex = 0; nativeResvCellIndex < static_cast<int>( m_ownerMainGrid->globalCellArray().size() );
|
||||
nativeResvCellIndex++ )
|
||||
{
|
||||
size_t resultIndex = activeCellInfo()->cellResultIndex( nativeResvCellIndex );
|
||||
if ( resultIndex != cvf::UNDEFINED_SIZE_T )
|
||||
{
|
||||
if ( resultIndex < soilResults.size() && resultIndex < cellVolumeResults.size() )
|
||||
{
|
||||
CVF_ASSERT( soilResults.at( resultIndex ) <= 1.01 );
|
||||
oilVolumeResults[resultIndex] = std::max( 0.0, soilResults.at( resultIndex ) * cellVolumeResults.at( resultIndex ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
RigEclipseResultAddress addr( RiaDefines::ResultCatType::DYNAMIC_NATIVE, RiaResultNames::riOilVolumeResultName() );
|
||||
RigOilVolumeResultCalculator calculator( *this );
|
||||
// Computes for all time steps
|
||||
calculator.calculate( addr, -1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -157,6 +157,7 @@ private:
|
||||
friend class RigFaultDistanceResultCalculator;
|
||||
friend class RigMobilePoreVolumeResultCalculator;
|
||||
friend class RigIndexIjkResultCalculator;
|
||||
friend class RigOilVolumeResultCalculator;
|
||||
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
|
||||
|
||||
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );
|
||||
|
Loading…
Reference in New Issue
Block a user