diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 5de8991289..11a518dc7f 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -901,13 +901,12 @@ bool RifEclipseInputFileTools::readDataFromKeyword( ecl_kw_type* eclipseK RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName ); caseData->results( RiaDefines::MATRIX_MODEL )->createResultEntry( resAddr, false ); - std::vector>& newPropertyData = caseData->results( RiaDefines::MATRIX_MODEL ) - ->modifiableCellScalarResultTimesteps( resAddr ); + auto newPropertyData = caseData->results( RiaDefines::MATRIX_MODEL )->modifiableCellScalarResultTimesteps( resAddr ); - newPropertyData.push_back( std::vector() ); - newPropertyData[0].resize( ecl_kw_get_size( eclipseKeywordData ), HUGE_VAL ); + newPropertyData->push_back( std::vector() ); + newPropertyData->at( 0 ).resize( ecl_kw_get_size( eclipseKeywordData ), HUGE_VAL ); - ecl_kw_get_data_as_double( eclipseKeywordData, newPropertyData[0].data() ); + ecl_kw_get_data_as_double( eclipseKeywordData, newPropertyData->at( 0 ).data() ); return true; } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 144e270128..81fda69f0a 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -78,15 +78,15 @@ bool RifReaderMockModel::open( const QString& fileName, RigEclipseCaseData* ecli cellResults->setTimeStepInfos( resAddr, staticResultTimeStepInfos ); } -#define ADD_INPUT_PROPERTY( Name ) \ - { \ - QString resultName( Name ); \ - RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName ); \ - cellResults->createResultEntry( resAddr, false ); \ - cellResults->setTimeStepInfos( resAddr, staticResultTimeStepInfos ); \ - cellResults->modifiableCellScalarResultTimesteps( resAddr ).resize( 1 ); \ - std::vector& values = cellResults->modifiableCellScalarResultTimesteps( resAddr )[0]; \ - this->inputProperty( resultName, &values ); \ +#define ADD_INPUT_PROPERTY( Name ) \ + { \ + QString resultName( Name ); \ + RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName ); \ + cellResults->createResultEntry( resAddr, false ); \ + cellResults->setTimeStepInfos( resAddr, staticResultTimeStepInfos ); \ + cellResults->modifiableCellScalarResultTimesteps( resAddr )->resize( 1 ); \ + std::vector& values = cellResults->modifiableCellScalarResultTimesteps( resAddr )->at( 0 ); \ + this->inputProperty( resultName, &values ); \ } ADD_INPUT_PROPERTY( "PORO" ); diff --git a/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp b/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp index 6b886bceb8..0b94341949 100644 --- a/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp +++ b/ApplicationCode/GrpcInterface/RiaGrpcPropertiesService.cpp @@ -36,6 +36,8 @@ #include "Rim3dView.h" #include "RimEclipseCase.h" +#include + using namespace rips; #define NUM_CONCURRENT_CLIENT_TO_SERVER_STREAMS 10 @@ -110,12 +112,14 @@ public: resultData->createResultEntry( m_resultAddress, true ); RigEclipseResultAddress addrToMaxTimeStepCountResult; - size_t timeStepCount = resultData->maxTimeStepCount( &addrToMaxTimeStepCountResult ); + size_t timeStepCount = std::max( (size_t)1, + resultData->maxTimeStepCount( &addrToMaxTimeStepCountResult ) ); + const std::vector timeStepInfos = resultData->timeStepInfos( addrToMaxTimeStepCountResult ); resultData->setTimeStepInfos( m_resultAddress, timeStepInfos ); auto scalarResultFrames = resultData->modifiableCellScalarResultTimesteps( m_resultAddress ); - scalarResultFrames.resize( timeStepCount ); + scalarResultFrames->resize( timeStepCount ); if ( timeStep < resultData->timeStepCount( m_resultAddress ) ) { initResultAccess( caseData, request->grid_index(), m_porosityModel, timeStep, m_resultAddress ); @@ -243,7 +247,7 @@ protected: RigEclipseResultAddress resVarAddr ) override { auto activeCellInfo = caseData->activeCellInfo( porosityModel ); - m_resultValues = &( caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex ) ); + m_resultValues = caseData->results( porosityModel )->modifiableCellScalarResult( resVarAddr, timeStepIndex ); if ( m_resultValues->empty() ) { m_resultValues->resize( activeCellInfo->reservoirCellResultCount() ); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp index 12f4b4bbca..bf58446473 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCaseEvaluator.cpp @@ -56,13 +56,13 @@ void RimEclipseStatisticsCaseEvaluator::addNamedResult( RigCaseCellResultsData* destinationCellResults->createResultEntry( resAddr, true ); destinationCellResults->setTimeStepInfos( resAddr, sourceTimeStepInfos ); - std::vector>& dataValues = destinationCellResults->modifiableCellScalarResultTimesteps( resAddr ); - dataValues.resize( sourceTimeStepInfos.size() ); + std::vector>* dataValues = destinationCellResults->modifiableCellScalarResultTimesteps( resAddr ); + dataValues->resize( sourceTimeStepInfos.size() ); // Initializes the size of the destination dataset to active union cell count for ( size_t i = 0; i < sourceTimeStepInfos.size(); i++ ) { - dataValues[i].resize( activeUnionCellCount, HUGE_VAL ); + dataValues->at( i ).resize( activeUnionCellCount, HUGE_VAL ); } } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 299087873e..ad33f0af76 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -285,9 +285,7 @@ void RimReservoirCellResultsStorage::setCellResults( RigCaseCellResultsData* cel for ( size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx ) { - std::vector* data = nullptr; - - data = &( m_cellResults->modifiableCellScalarResult( resAddr, tsIdx ) ); + std::vector* data = m_cellResults->modifiableCellScalarResult( resAddr, tsIdx ); quint64 cellCount = 0; stream >> cellCount; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp index 66020deef7..77aa766fb8 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultCalculator.cpp @@ -112,13 +112,13 @@ bool RigCaseCellResultCalculator::computeDifference( RigEclipseCaseData* // Initialize difference result with infinity for correct number of time steps and values per time step { const std::vector>& srcFrames = sourceCaseResults->cellScalarResults( nativeAddress ); - std::vector>& diffResultFrames = sourceCaseResults->modifiableCellScalarResultTimesteps( + std::vector>* diffResultFrames = sourceCaseResults->modifiableCellScalarResultTimesteps( address ); - diffResultFrames.resize( srcFrames.size() ); + diffResultFrames->resize( srcFrames.size() ); for ( size_t fIdx = 0; fIdx < srcFrames.size(); ++fIdx ) { const std::vector& srcVals = srcFrames[fIdx]; - std::vector& dstVals = diffResultFrames[fIdx]; + std::vector& dstVals = diffResultFrames->at( fIdx ); dstVals.resize( srcVals.size(), std::numeric_limits::infinity() ); } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index ff4d1a8e67..dc51bfbc31 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -249,20 +249,20 @@ const std::vector>& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector>& +std::vector>* RigCaseCellResultsData::modifiableCellScalarResultTimesteps( const RigEclipseResultAddress& resVarAddr ) { size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); CVF_TIGHT_ASSERT( scalarResultIndex < resultCount() ); - return m_cellScalarResults[scalarResultIndex]; + return &( m_cellScalarResults[scalarResultIndex] ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector& RigCaseCellResultsData::modifiableCellScalarResult( const RigEclipseResultAddress& resVarAddr, +std::vector* RigCaseCellResultsData::modifiableCellScalarResult( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) { size_t scalarResultIndex = findScalarResultIndexFromAddress( resVarAddr ); @@ -270,7 +270,7 @@ std::vector& RigCaseCellResultsData::modifiableCellScalarResult( const R CVF_TIGHT_ASSERT( scalarResultIndex < resultCount() ); CVF_TIGHT_ASSERT( timeStepIndex < m_cellScalarResults[scalarResultIndex].size() ); - return m_cellScalarResults[scalarResultIndex][timeStepIndex]; + return &( m_cellScalarResults[scalarResultIndex][timeStepIndex] ); } //-------------------------------------------------------------------------------------------------- @@ -609,8 +609,8 @@ void RigCaseCellResultsData::setTimeStepInfos( const RigEclipseResultAddress& m_resultInfos[findScalarResultIndexFromAddress( resVarAddr )].setTimeStepInfos( timeStepInfos ); - std::vector>& dataValues = this->modifiableCellScalarResultTimesteps( resVarAddr ); - dataValues.resize( timeStepInfos.size() ); + std::vector>* dataValues = this->modifiableCellScalarResultTimesteps( resVarAddr ); + dataValues->resize( timeStepInfos.size() ); } //-------------------------------------------------------------------------------------------------- @@ -1605,7 +1605,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep( size_t timeStepIndex ) } } - std::vector& soilForTimeStep = this->modifiableCellScalarResult( SOILAddr, timeStepIndex ); + std::vector* soilForTimeStep = this->modifiableCellScalarResult( SOILAddr, timeStepIndex ); #pragma omp parallel for for ( int idx = 0; idx < static_cast( soilResultValueCount ); idx++ ) @@ -1626,7 +1626,7 @@ void RigCaseCellResultsData::computeSOILForTimeStep( size_t timeStepIndex ) soilValue -= ssolForTimeStep->at( idx ); } - soilForTimeStep[idx] = soilValue; + soilForTimeStep->at( idx ) = soilValue; } } @@ -2802,7 +2802,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF false, totalGlobCellCount ); - std::vector& fnData = + std::vector* fnData = this->modifiableCellScalarResult( RigEclipseResultAddress( RiaDefines::FORMATION_NAMES, RiaDefines::activeFormationNamesResultName() ), 0 ); @@ -2811,7 +2811,7 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF { for ( size_t cIdx = 0; cIdx < totalGlobCellCount; ++cIdx ) { - fnData[cIdx] = HUGE_VAL; + fnData->at( cIdx ) = HUGE_VAL; } return; @@ -2827,11 +2827,11 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF int formNameIdx = activeFormationNames->formationIndexFromKLayerIdx( k ); if ( formNameIdx != -1 ) { - fnData[cIdx] = formNameIdx; + fnData->at( cIdx ) = formNameIdx; } else { - fnData[cIdx] = HUGE_VAL; + fnData->at( cIdx ) = HUGE_VAL; } } @@ -2846,11 +2846,11 @@ void RigCaseCellResultsData::setActiveFormationNames( RigFormationNames* activeF int formNameIdx = activeFormationNames->formationIndexFromKLayerIdx( k ); if ( formNameIdx != -1 ) { - fnData[cIdx] = formNameIdx; + fnData->at( cIdx ) = formNameIdx; } else { - fnData[cIdx] = HUGE_VAL; + fnData->at( cIdx ) = HUGE_VAL; } } } @@ -3064,9 +3064,9 @@ void RigCaseCellResultsData::copyResultsMetaDataFromMainCase( RigEclipseCaseData cellResultsStorage->setTimeStepInfos( resVarAddr, timeStepInfos ); - std::vector>& dataValues = cellResultsStorage->modifiableCellScalarResultTimesteps( + std::vector>* dataValues = cellResultsStorage->modifiableCellScalarResultTimesteps( resVarAddr ); - dataValues.resize( timeStepInfos.size() ); + dataValues->resize( timeStepInfos.size() ); } } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 9a909dc7aa..1902a3747e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -68,8 +68,8 @@ public: const std::vector>& cellScalarResults( const RigEclipseResultAddress& resVarAddr ) const; const std::vector& cellScalarResults( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ) const; - std::vector>& modifiableCellScalarResultTimesteps( const RigEclipseResultAddress& resVarAddr ); - std::vector& modifiableCellScalarResult( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ); + std::vector>* modifiableCellScalarResultTimesteps( const RigEclipseResultAddress& resVarAddr ); + std::vector* modifiableCellScalarResult( const RigEclipseResultAddress& resVarAddr, size_t timeStepIndex ); bool isUsingGlobalActiveIndex( const RigEclipseResultAddress& resVarAddr ) const; diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp index 9396f3ecb1..f7c66f5eb6 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp @@ -52,18 +52,17 @@ cvf::ref RigResultModifierFactory::createResultModifier( RigE return nullptr; } - std::vector>& scalarSetResults = eclipseCase->results( porosityModel ) - ->modifiableCellScalarResultTimesteps( resVarAddr ); + auto scalarSetResults = eclipseCase->results( porosityModel )->modifiableCellScalarResultTimesteps( resVarAddr ); - if ( timeStepIndex >= scalarSetResults.size() ) + if ( timeStepIndex >= scalarSetResults->size() ) { return nullptr; } std::vector* resultValues = nullptr; - if ( timeStepIndex < scalarSetResults.size() ) + if ( timeStepIndex < scalarSetResults->size() ) { - resultValues = &( scalarSetResults[timeStepIndex] ); + resultValues = &( scalarSetResults->at( timeStepIndex ) ); } bool useGlobalActiveIndex = eclipseCase->results( porosityModel )->isUsingGlobalActiveIndex( resVarAddr ); diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index b6ee12aa36..36fbdee7cb 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -466,9 +466,8 @@ private: results->createResultEntry( resAddr, true ); } - std::vector>* scalarResultFrames = nullptr; - scalarResultFrames = &( results->modifiableCellScalarResultTimesteps( resAddr ) ); - size_t timeStepCount = results->maxTimeStepCount(); + std::vector>* scalarResultFrames = results->modifiableCellScalarResultTimesteps( resAddr ); + size_t timeStepCount = results->maxTimeStepCount(); scalarResultFrames->resize( timeStepCount ); return true; diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index 2c68fabee0..98b4944faf 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -79,9 +79,8 @@ public: { if ( rimCase->results( porosityModelEnum )->ensureKnownResultLoaded( RigEclipseResultAddress( propertyName ) ) ) { - scalarResultFrames = &( - rimCase->results( porosityModelEnum ) - ->modifiableCellScalarResultTimesteps( RigEclipseResultAddress( propertyName ) ) ); + scalarResultFrames = rimCase->results( porosityModelEnum ) + ->modifiableCellScalarResultTimesteps( RigEclipseResultAddress( propertyName ) ); } } @@ -449,8 +448,7 @@ public: rimCase->results( m_porosityModelEnum )->setTimeStepInfos( eclResAddr, timeStepInfos ); } - scalarResultFrames = &( - rimCase->results( m_porosityModelEnum )->modifiableCellScalarResultTimesteps( eclResAddr ) ); + scalarResultFrames = rimCase->results( m_porosityModelEnum )->modifiableCellScalarResultTimesteps( eclResAddr ); size_t timeStepCount = rimCase->results( m_porosityModelEnum )->maxTimeStepCount(); scalarResultFrames->resize( timeStepCount ); @@ -703,9 +701,10 @@ public: // Adjust the result data if only one time step is requested so the result behaves like a static result if ( m_requestedTimesteps.size() == 1 && m_currentEclResultAddress.isValid() ) { - std::vector>* scalarResultFrames = nullptr; - scalarResultFrames = &( m_currentReservoir->results( m_porosityModelEnum ) - ->modifiableCellScalarResultTimesteps( m_currentEclResultAddress ) ); + std::vector>* scalarResultFrames = m_currentReservoir + ->results( m_porosityModelEnum ) + ->modifiableCellScalarResultTimesteps( + m_currentEclResultAddress ); size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for ( size_t i = 0; i < scalarResultFrames->size(); i++ ) { @@ -866,8 +865,8 @@ public: } m_currentResultAddress = resAddr; - scalarResultFrames = &( - rimCase->results( m_porosityModelEnum )->modifiableCellScalarResultTimesteps( m_currentResultAddress ) ); + scalarResultFrames = rimCase->results( m_porosityModelEnum ) + ->modifiableCellScalarResultTimesteps( m_currentResultAddress ); size_t timeStepCount = rimCase->results( m_porosityModelEnum )->maxTimeStepCount(); scalarResultFrames->resize( timeStepCount ); @@ -1093,10 +1092,10 @@ public: // Adjust the result data if only one time step is requested so the result behaves like a static result if ( m_requestedTimesteps.size() == 1 && m_currentResultAddress.isValid() ) { - std::vector>* scalarResultFrames = nullptr; - scalarResultFrames = &( m_currentReservoir->results( m_porosityModelEnum ) - ->modifiableCellScalarResultTimesteps( - RigEclipseResultAddress( m_currentResultAddress ) ) ); + auto scalarResultFrames = m_currentReservoir->results( m_porosityModelEnum ) + ->modifiableCellScalarResultTimesteps( + RigEclipseResultAddress( m_currentResultAddress ) ); + size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for ( size_t i = 0; i < scalarResultFrames->size(); i++ ) {