Refactor: extract mobile pore volume computation.

This commit is contained in:
Kristian Bendiksen
2023-04-17 16:03:52 +02:00
parent be12016128
commit 89dca9eec9
5 changed files with 159 additions and 52 deletions

View File

@@ -2,12 +2,14 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RigSoilResultCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RigFaultDistanceResultCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.h
)
set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigSoilResultCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigFaultDistanceResultCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigMobilePoreVolumeResultCalculator.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RigMobilePoreVolumeResultCalculator.h"
#include "RiaDefines.h"
#include "RiaResultNames.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigCell.h"
#include "RigEclipseResultInfo.h"
#include "RigMainGrid.h"
#include "RiaLogging.h"
//==================================================================================================
///
//==================================================================================================
RigMobilePoreVolumeResultCalculator::RigMobilePoreVolumeResultCalculator( RigCaseCellResultsData& resultsData )
: RigEclipseResultCalculator( resultsData )
{
}
//==================================================================================================
///
//==================================================================================================
RigMobilePoreVolumeResultCalculator::~RigMobilePoreVolumeResultCalculator()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigMobilePoreVolumeResultCalculator::isMatching( const RigEclipseResultAddress& resVarAddr ) const
{
return resVarAddr.resultName() == RiaResultNames::mobilePoreVolumeName() &&
resVarAddr.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigMobilePoreVolumeResultCalculator::calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex )
{
std::vector<double> porvDataTemp;
std::vector<double> swcrDataTemp;
std::vector<double> multpvDataTemp;
const std::vector<double>* porvResults = nullptr;
const std::vector<double>* swcrResults = nullptr;
const std::vector<double>* multpvResults = nullptr;
porvResults =
RigCaseCellResultsData::getResultIndexableStaticResult( m_resultsData->activeCellInfo(), m_resultsData, "PORV", porvDataTemp );
if ( !porvResults || porvResults->empty() )
{
RiaLogging::error( "Assumed PORV, but not data was found." );
return;
}
swcrResults =
RigCaseCellResultsData::getResultIndexableStaticResult( m_resultsData->activeCellInfo(), m_resultsData, "SWCR", swcrDataTemp );
multpvResults =
RigCaseCellResultsData::getResultIndexableStaticResult( m_resultsData->activeCellInfo(), m_resultsData, "MULTPV", multpvDataTemp );
size_t mobPVIdx = m_resultsData->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE,
RiaResultNames::mobilePoreVolumeName() ),
false );
std::vector<double>& mobPVResults = m_resultsData->m_cellScalarResults[mobPVIdx][0];
// Set up output container to correct number of results
mobPVResults.resize( porvResults->size() );
if ( multpvResults && swcrResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *multpvResults )[vIdx] * ( *porvResults )[vIdx] * ( 1.0 - ( *swcrResults )[vIdx] );
}
}
else if ( !multpvResults && swcrResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *porvResults )[vIdx] * ( 1.0 - ( *swcrResults )[vIdx] );
}
}
else if ( !swcrResults && multpvResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *multpvResults )[vIdx] * ( *porvResults )[vIdx];
}
}
else
{
mobPVResults.assign( porvResults->begin(), porvResults->end() );
}
}

View File

@@ -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 RigMobilePoreVolumeResultCalculator : public RigEclipseResultCalculator
{
public:
RigMobilePoreVolumeResultCalculator( RigCaseCellResultsData& resultsData );
~RigMobilePoreVolumeResultCalculator() override;
bool isMatching( const RigEclipseResultAddress& resVarAddr ) const override;
void calculate( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) override;
};

View File

@@ -36,6 +36,7 @@
#include "RigFaultDistanceResultCalculator.h"
#include "RigFormationNames.h"
#include "RigMainGrid.h"
#include "RigMobilePoreVolumeResultCalculator.h"
#include "RigSoilResultCalculator.h"
#include "RigStatisticsDataCache.h"
#include "RigStatisticsMath.h"
@@ -2762,58 +2763,9 @@ void RigCaseCellResultsData::computeOilVolumes()
//--------------------------------------------------------------------------------------------------
void RigCaseCellResultsData::computeMobilePV()
{
std::vector<double> porvDataTemp;
std::vector<double> swcrDataTemp;
std::vector<double> multpvDataTemp;
const std::vector<double>* porvResults = nullptr;
const std::vector<double>* swcrResults = nullptr;
const std::vector<double>* multpvResults = nullptr;
porvResults = RigCaseCellResultsData::getResultIndexableStaticResult( this->activeCellInfo(), this, "PORV", porvDataTemp );
if ( !porvResults || porvResults->empty() )
{
RiaLogging::error( "Assumed PORV, but not data was found." );
return;
}
swcrResults = RigCaseCellResultsData::getResultIndexableStaticResult( this->activeCellInfo(), this, "SWCR", swcrDataTemp );
multpvResults = RigCaseCellResultsData::getResultIndexableStaticResult( this->activeCellInfo(), this, "MULTPV", multpvDataTemp );
size_t mobPVIdx = this->findOrCreateScalarResultIndex( RigEclipseResultAddress( RiaDefines::ResultCatType::STATIC_NATIVE,
RiaResultNames::mobilePoreVolumeName() ),
false );
std::vector<double>& mobPVResults = m_cellScalarResults[mobPVIdx][0];
// Set up output container to correct number of results
mobPVResults.resize( porvResults->size() );
if ( multpvResults && swcrResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *multpvResults )[vIdx] * ( *porvResults )[vIdx] * ( 1.0 - ( *swcrResults )[vIdx] );
}
}
else if ( !multpvResults && swcrResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *porvResults )[vIdx] * ( 1.0 - ( *swcrResults )[vIdx] );
}
}
else if ( !swcrResults && multpvResults )
{
for ( size_t vIdx = 0; vIdx < porvResults->size(); ++vIdx )
{
mobPVResults[vIdx] = ( *multpvResults )[vIdx] * ( *porvResults )[vIdx];
}
}
else
{
mobPVResults.assign( porvResults->begin(), porvResults->end() );
}
RigEclipseResultAddress addr( RiaDefines::ResultCatType::STATIC_NATIVE, RiaResultNames::mobilePoreVolumeName() );
RigMobilePoreVolumeResultCalculator calculator( *this );
calculator.calculate( addr, 0 );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -155,6 +155,7 @@ private:
friend class RimEclipseStatisticsCaseEvaluator;
friend class RigSoilResultCalculator;
friend class RigFaultDistanceResultCalculator;
friend class RigMobilePoreVolumeResultCalculator;
size_t findOrLoadKnownScalarResultForTimeStep( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex );
size_t findOrCreateScalarResultIndex( const RigEclipseResultAddress& resVarAddr, bool needsToBeStored );