mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#10648 Refactor summary reader: return std::vector<double> instead of taking ptr.
This commit is contained in:
parent
263e39b97b
commit
d177491843
@ -204,15 +204,16 @@ void RiaSummaryCurveDefinition::setIdentifierText( SummaryCategory category, con
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition, gsl::not_null<std::vector<double>*> values )
|
||||
std::vector<double> RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition )
|
||||
{
|
||||
if ( !curveDefinition.summaryAddressY().isValid() ) return;
|
||||
if ( !curveDefinition.summaryCaseY() ) return;
|
||||
if ( !curveDefinition.summaryAddressY().isValid() ) return {};
|
||||
if ( !curveDefinition.summaryCaseY() ) return {};
|
||||
|
||||
RifSummaryReaderInterface* reader = curveDefinition.summaryCaseY()->summaryReader();
|
||||
if ( !reader ) return;
|
||||
if ( !reader ) return {};
|
||||
|
||||
reader->values( curveDefinition.summaryAddressY(), values );
|
||||
auto [isOk, values] = reader->values( curveDefinition.summaryAddressY() );
|
||||
return values;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -66,7 +66,7 @@ public:
|
||||
bool operator<( const RiaSummaryCurveDefinition& other ) const;
|
||||
|
||||
// TODO: Consider moving to a separate tools class
|
||||
static void resultValues( const RiaSummaryCurveDefinition& curveDefinition, gsl::not_null<std::vector<double>*> values );
|
||||
static std::vector<double> resultValues( const RiaSummaryCurveDefinition& curveDefinition );
|
||||
static std::vector<time_t> timeSteps( const RiaSummaryCurveDefinition& curveDefinition );
|
||||
|
||||
QString curveDefinitionText() const;
|
||||
|
@ -454,8 +454,8 @@ void RicExportFractureCompletionsImpl::getWellPressuresAndInitialProductionTimeS
|
||||
|
||||
if ( summaryCase && summaryCase->summaryReader() )
|
||||
{
|
||||
std::vector<double> values;
|
||||
if ( summaryCase->summaryReader()->values( wbhpPressureAddress, &values ) )
|
||||
auto [isOk, values] = summaryCase->summaryReader()->values( wbhpPressureAddress );
|
||||
if ( isOk )
|
||||
{
|
||||
std::vector<time_t> summaryTimeSteps = summaryCase->summaryReader()->timeSteps( wbhpPressureAddress );
|
||||
CVF_ASSERT( values.size() == summaryTimeSteps.size() );
|
||||
|
@ -72,28 +72,31 @@ bool RifColumnBasedUserData::parse( const QString& data, QString* errorText )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifColumnBasedUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifColumnBasedUserData::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
|
||||
|
||||
if ( search != m_mapFromAddressToResultIndex.end() )
|
||||
{
|
||||
std::pair<size_t, size_t> tableColIndices = search->second;
|
||||
|
||||
const Column* ci = m_parser->columnInfo( tableColIndices.first, tableColIndices.second );
|
||||
if ( !ci ) return false;
|
||||
if ( !ci ) return { false, {} };
|
||||
|
||||
if ( !ci->values.empty() )
|
||||
{
|
||||
values->reserve( ci->values.size() );
|
||||
values.reserve( ci->values.size() );
|
||||
|
||||
for ( const auto& v : ci->values )
|
||||
{
|
||||
values->push_back( v );
|
||||
values.push_back( v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -44,7 +44,7 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
@ -49,25 +49,26 @@ RifCsvSummaryReader::~RifCsvSummaryReader()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCsvSummaryReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifCsvSummaryReader::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
|
||||
if ( search != m_mapFromAddressToResultIndex.end() )
|
||||
{
|
||||
size_t columnIndex = search->second;
|
||||
|
||||
const Column* ci = m_parser->columnInfo( columnIndex );
|
||||
if ( !ci ) return false;
|
||||
if ( !ci ) return { false, {} };
|
||||
|
||||
values->clear();
|
||||
values->reserve( ci->values.size() );
|
||||
values.reserve( ci->values.size() );
|
||||
for ( double val : ci->values )
|
||||
{
|
||||
values->push_back( val );
|
||||
values.push_back( val );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
|
@ -69,25 +69,25 @@ bool RifCsvUserData::parse( const QString& fileName, const AsciiDataParseOptions
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCsvUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifCsvUserData::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
|
||||
std::vector<double> values;
|
||||
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
|
||||
if ( search != m_mapFromAddressToResultIndex.end() )
|
||||
{
|
||||
size_t columnIndex = search->second;
|
||||
|
||||
const Column* ci = m_parser->columnInfo( columnIndex );
|
||||
if ( !ci ) return false;
|
||||
if ( !ci ) return { false, {} };
|
||||
|
||||
values->clear();
|
||||
values->reserve( ci->values.size() );
|
||||
values.reserve( ci->values.size() );
|
||||
for ( double val : ci->values )
|
||||
{
|
||||
values->push_back( val );
|
||||
values.push_back( val );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
|
@ -70,20 +70,22 @@ std::vector<time_t> RifDerivedEnsembleReader::timeSteps( const RifEclipseSummary
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifDerivedEnsembleReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifDerivedEnsembleReader::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
if ( !resultAddress.isValid() ) return false;
|
||||
if ( !resultAddress.isValid() ) return { false, {} };
|
||||
|
||||
if ( m_derivedCase->needsCalculation( resultAddress ) )
|
||||
{
|
||||
m_derivedCase->calculate( resultAddress );
|
||||
}
|
||||
|
||||
auto dataValues = m_derivedCase->values( resultAddress );
|
||||
values->clear();
|
||||
values->reserve( dataValues.size() );
|
||||
|
||||
std::vector<double> values;
|
||||
values.reserve( dataValues.size() );
|
||||
for ( auto val : dataValues )
|
||||
values->push_back( val );
|
||||
return true;
|
||||
values.push_back( val );
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -34,10 +34,10 @@ public:
|
||||
RifSummaryReaderInterface* sourceSummaryReader1,
|
||||
RifSummaryReaderInterface* sourceSummaryReader2 );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
private:
|
||||
RimDerivedSummaryCase* m_derivedCase;
|
||||
|
@ -256,19 +256,17 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode( const ecl::smspec_node& ertSu
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEclEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifEclEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
CVF_ASSERT( values );
|
||||
if ( m_timeSteps.empty() ) return { true, {} };
|
||||
|
||||
if ( m_timeSteps.empty() ) return true;
|
||||
|
||||
values->clear();
|
||||
values->reserve( m_timeSteps.size() );
|
||||
std::vector<double> values;
|
||||
values.reserve( m_timeSteps.size() );
|
||||
|
||||
if ( m_ecl_SmSpec )
|
||||
{
|
||||
int variableIndex = indexFromAddress( resultAddress );
|
||||
if ( variableIndex < 0 ) return false;
|
||||
if ( variableIndex < 0 ) return { false, {} };
|
||||
|
||||
const ecl::smspec_node& ertSumVarNode = ecl_smspec_iget_node_w_node_index( m_ecl_SmSpec, variableIndex );
|
||||
int paramsIndex = ertSumVarNode.get_params_index();
|
||||
@ -279,12 +277,12 @@ bool RifEclEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress
|
||||
{
|
||||
int dataSize = double_vector_size( dataValues );
|
||||
const double* dataPtr = double_vector_get_const_ptr( dataValues );
|
||||
values->insert( values->end(), dataPtr, dataPtr + dataSize );
|
||||
values.insert( values.end(), dataPtr, dataPtr + dataSize );
|
||||
double_vector_free( dataValues );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -50,9 +50,9 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
private:
|
||||
int indexFromAddress( const RifEclipseSummaryAddress& resultAddress ) const;
|
||||
|
@ -176,17 +176,18 @@ bool RifKeywordVectorUserData::parse( const QString& data, const QString& custom
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifKeywordVectorUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifKeywordVectorUserData::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
auto search = m_mapFromAddressToVectorIndex.find( resultAddress );
|
||||
if ( search == m_mapFromAddressToVectorIndex.end() ) return false;
|
||||
if ( search == m_mapFromAddressToVectorIndex.end() ) return { false, {} };
|
||||
|
||||
std::vector<double> values;
|
||||
for ( const auto& v : m_parser->keywordBasedVectors()[search->second].values )
|
||||
{
|
||||
values->push_back( v );
|
||||
values.push_back( v );
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
@ -64,14 +64,14 @@ std::vector<time_t> RifMultipleSummaryReaders::timeSteps( const RifEclipseSummar
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifMultipleSummaryReaders::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifMultipleSummaryReaders::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
for ( const auto& r : m_readers )
|
||||
{
|
||||
if ( r->hasAddress( resultAddress ) ) return r->values( resultAddress, values );
|
||||
if ( r->hasAddress( resultAddress ) ) return r->values( resultAddress );
|
||||
}
|
||||
|
||||
return false;
|
||||
return { false, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -35,10 +35,10 @@ public:
|
||||
void addReader( RifSummaryReaderInterface* reader );
|
||||
void removeReader( RifSummaryReaderInterface* reader );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
void rebuildMetaData();
|
||||
|
||||
|
@ -148,26 +148,27 @@ std::vector<time_t> RifOpmCommonEclipseSummary::timeSteps( const RifEclipseSumma
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifOpmCommonEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
auto it = m_summaryAddressToKeywordMap.find( resultAddress );
|
||||
if ( it != m_summaryAddressToKeywordMap.end() )
|
||||
{
|
||||
auto keyword = it->second;
|
||||
std::vector<double> values;
|
||||
auto keyword = it->second;
|
||||
if ( m_enhancedReader )
|
||||
{
|
||||
auto fileValues = m_enhancedReader->get( keyword );
|
||||
values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
values.insert( values.begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
else if ( m_standardReader )
|
||||
{
|
||||
auto fileValues = m_standardReader->get( keyword );
|
||||
values->insert( values->begin(), fileValues.begin(), fileValues.end() );
|
||||
values.insert( values.begin(), fileValues.begin(), fileValues.end() );
|
||||
}
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
return false;
|
||||
return { false, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -72,10 +72,10 @@ public:
|
||||
|
||||
bool open( const QString& fileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
private:
|
||||
void buildMetaData();
|
||||
|
@ -91,7 +91,7 @@ std::vector<time_t> RifOpmHdf5Summary::timeSteps( const RifEclipseSummaryAddress
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmHdf5Summary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifOpmHdf5Summary::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
if ( m_eSmry && m_hdf5Reader )
|
||||
{
|
||||
@ -103,14 +103,13 @@ bool RifOpmHdf5Summary::values( const RifEclipseSummaryAddress& resultAddress, s
|
||||
|
||||
if ( smspecIndex != std::numeric_limits<size_t>::max() )
|
||||
{
|
||||
*values = m_hdf5Reader->values( vectorName, static_cast<int>( smspecIndex ) );
|
||||
|
||||
return true;
|
||||
std::vector<double> values = m_hdf5Reader->values( vectorName, static_cast<int>( smspecIndex ) );
|
||||
return { true, values };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return { false, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -56,10 +56,10 @@ public:
|
||||
|
||||
bool open( const QString& headerFileName, bool includeRestartFiles, RiaThreadSafeLogger* threadSafeLogger );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
private:
|
||||
void buildMetaData();
|
||||
|
@ -59,8 +59,7 @@ void RifProjectSummaryDataWriter::importFromSourceSummaryReader( const RifSummar
|
||||
m_startTime = { ts.day(), ts.month(), ts.year(), ts.hour(), ts.minutes(), ts.seconds(), 0 };
|
||||
}
|
||||
|
||||
std::vector<double> values;
|
||||
reader->values( summaryAddress, &values );
|
||||
auto [isOk, values] = reader->values( summaryAddress );
|
||||
|
||||
const auto& unitString = reader->unitName( summaryAddress );
|
||||
|
||||
|
@ -159,21 +159,18 @@ bool RifReaderEclipseSummary::open( const QString& headerFileName, RiaThreadSafe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
CVF_ASSERT( values );
|
||||
if ( timeSteps( resultAddress ).empty() ) return { false, {} };
|
||||
|
||||
if ( timeSteps( resultAddress ).empty() ) return false;
|
||||
|
||||
values->clear();
|
||||
values->reserve( timeSteps( resultAddress ).size() );
|
||||
std::vector<double> values;
|
||||
values.reserve( timeSteps( resultAddress ).size() );
|
||||
|
||||
const std::vector<double>& cachedValues = m_valuesCache->getValues( resultAddress );
|
||||
if ( !cachedValues.empty() )
|
||||
{
|
||||
values->insert( values->begin(), cachedValues.begin(), cachedValues.end() );
|
||||
|
||||
return true;
|
||||
values.insert( values.begin(), cachedValues.begin(), cachedValues.end() );
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
if ( m_differenceAddresses.count( resultAddress ) )
|
||||
@ -188,35 +185,33 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr
|
||||
RifEclipseSummaryAddress nativeAdrHistory = resultAddress;
|
||||
nativeAdrHistory.setVectorName( quantityNoHistory );
|
||||
|
||||
std::vector<double> nativeValues;
|
||||
std::vector<double> historyValues;
|
||||
auto [nativeValuesOk, nativeValues] = this->values( nativeAdrHistory );
|
||||
if ( !nativeValuesOk ) return { false, {} };
|
||||
|
||||
if ( !this->values( nativeAdrHistory, &nativeValues ) ) return false;
|
||||
if ( !this->values( nativeAdrNoHistory, &historyValues ) ) return false;
|
||||
auto [nativeAdrNoHistoryOk, historyValues] = this->values( nativeAdrNoHistory );
|
||||
if ( !nativeAdrNoHistoryOk ) return { false, {} };
|
||||
|
||||
if ( nativeValues.size() != historyValues.size() ) return false;
|
||||
if ( nativeValues.size() != historyValues.size() ) return { false, {} };
|
||||
|
||||
for ( size_t i = 0; i < nativeValues.size(); i++ )
|
||||
{
|
||||
double diff = nativeValues[i] - historyValues[i];
|
||||
values->push_back( diff );
|
||||
m_valuesCache->insertValues( resultAddress, *values );
|
||||
values.push_back( diff );
|
||||
m_valuesCache->insertValues( resultAddress, values );
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
auto reader = currentSummaryReader();
|
||||
if ( reader )
|
||||
{
|
||||
auto status = reader->values( resultAddress, values );
|
||||
|
||||
if ( status ) m_valuesCache->insertValues( resultAddress, *values );
|
||||
|
||||
return status;
|
||||
auto [status, values] = reader->values( resultAddress );
|
||||
if ( status ) m_valuesCache->insertValues( resultAddress, values );
|
||||
return { status, values };
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -51,9 +51,9 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
static std::string differenceIdentifier() { return "_DIFF"; }
|
||||
static const std::string historyIdentifier() { return "H"; }
|
||||
|
@ -114,7 +114,7 @@ bool RifReaderObservedData::open( const QString&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
size_t columnIndex = m_allResultAddresses.size();
|
||||
|
||||
@ -128,6 +128,7 @@ bool RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddres
|
||||
i++;
|
||||
}
|
||||
|
||||
std::vector<double> values;
|
||||
if ( columnIndex != m_allResultAddresses.size() )
|
||||
{
|
||||
const Column* col = m_asciiParser->columnInfo( columnIndex );
|
||||
@ -135,12 +136,12 @@ bool RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddres
|
||||
{
|
||||
for ( auto& v : col->values )
|
||||
{
|
||||
values->push_back( v );
|
||||
values.push_back( v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
|
||||
virtual std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const = 0;
|
||||
|
||||
virtual bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const = 0;
|
||||
virtual std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const = 0;
|
||||
|
||||
virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0;
|
||||
virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0;
|
||||
|
@ -43,12 +43,12 @@ std::vector<time_t> RifSummaryReaderMultipleFiles::timeSteps( const RifEclipseSu
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSummaryReaderMultipleFiles::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifSummaryReaderMultipleFiles::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
std::vector<double> values;
|
||||
for ( const auto& reader : m_summaryReaders )
|
||||
{
|
||||
std::vector<double> readerValues;
|
||||
reader->values( resultAddress, &readerValues );
|
||||
auto [isOk, readerValues] = reader->values( resultAddress );
|
||||
|
||||
if ( readerValues.empty() )
|
||||
{
|
||||
@ -60,19 +60,18 @@ bool RifSummaryReaderMultipleFiles::values( const RifEclipseSummaryAddress& resu
|
||||
// https://github.com/OPM/ResInsight/issues/7065
|
||||
|
||||
std::vector<double> zeros( reader->timeSteps( {} ).size(), 0.0 );
|
||||
|
||||
readerValues = zeros;
|
||||
}
|
||||
|
||||
auto valueCount = timeStepCount( reader.get() );
|
||||
readerValues.resize( valueCount );
|
||||
|
||||
values->insert( values->end(), readerValues.begin(), readerValues.end() );
|
||||
values.insert( values.end(), readerValues.begin(), readerValues.end() );
|
||||
}
|
||||
|
||||
CAF_ASSERT( m_aggregatedTimeSteps.size() == values->size() );
|
||||
CAF_ASSERT( m_aggregatedTimeSteps.size() == values.size() );
|
||||
|
||||
return true;
|
||||
return { true, values };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -39,10 +39,10 @@ public:
|
||||
|
||||
bool createReadersAndImportMetaData( RiaThreadSafeLogger* threadSafeLogger );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
private:
|
||||
size_t timeStepCount( RifSummaryReaderInterface* reader ) const;
|
||||
|
@ -341,9 +341,7 @@ void RimAnalysisPlot::maxMinValueFromAddress( const RifEclipseSummaryAddress&
|
||||
|
||||
if ( reader->hasAddress( address ) )
|
||||
{
|
||||
std::vector<double> values;
|
||||
reader->values( address, &values );
|
||||
|
||||
auto [isOk, values] = reader->values( address );
|
||||
const std::vector<time_t>& timesteps = reader->timeSteps( address );
|
||||
|
||||
if ( !timesteps.empty() && !values.empty() )
|
||||
@ -1174,8 +1172,7 @@ void RimAnalysisPlot::applyFilter( const RimPlotDataFilterItem* filter,
|
||||
|
||||
if ( reader->hasAddress( addrToFilterValue ) )
|
||||
{
|
||||
std::vector<double> values;
|
||||
reader->values( addrToFilterValue, &values );
|
||||
auto [isOk, values] = reader->values( addrToFilterValue );
|
||||
const std::vector<time_t>& timesteps = reader->timeSteps( addrToFilterValue );
|
||||
|
||||
if ( filter->consideredTimeStepsType() == RimPlotDataFilterItem::ALL_TIMESTEPS )
|
||||
@ -1445,7 +1442,8 @@ void RimAnalysisPlot::addDataToChartBuilder( RiuGroupedBarChartBuilder& chartBui
|
||||
{
|
||||
timeSteps = reader->timeSteps( curveDef.summaryAddressY() );
|
||||
|
||||
reader->values( curveDef.summaryAddressY(), &values );
|
||||
auto [isOk, readValues] = reader->values( curveDef.summaryAddressY() );
|
||||
values.swap( readValues );
|
||||
}
|
||||
|
||||
if ( timeSteps.empty() || values.empty() ) continue;
|
||||
|
@ -534,10 +534,10 @@ void RimCorrelationMatrixPlot::createMatrix()
|
||||
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
|
||||
if ( reader )
|
||||
{
|
||||
std::vector<double> values;
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( address, &values ) )
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
auto [isOk, values] = reader->values( address );
|
||||
if ( isOk )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( address );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
|
@ -261,11 +261,10 @@ void RimParameterResultCrossPlot::createPoints()
|
||||
|
||||
if ( !summaryCase->caseRealizationParameters() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( address, &values ) )
|
||||
auto [isOk, values] = reader->values( address );
|
||||
if ( isOk )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( address );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
|
@ -159,8 +159,7 @@ double RimSimWellInViewTools::extractValueForTimeStep( RifSummaryReaderInterface
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
std::vector<double> values;
|
||||
summaryReader->values( addr, &values );
|
||||
auto [isOkReader, values] = summaryReader->values( addr );
|
||||
std::vector<time_t> timeSteps = summaryReader->timeSteps( addr );
|
||||
if ( values.empty() || timeSteps.empty() )
|
||||
{
|
||||
|
@ -332,8 +332,7 @@ std::optional<std::pair<std::vector<double>, std::vector<time_t>>>
|
||||
|
||||
RiaSummaryCurveDefinition curveDef( summaryCase, v.summaryAddress, false );
|
||||
|
||||
std::vector<double> curveValues;
|
||||
RiaSummaryCurveDefinition::resultValues( curveDef, &curveValues );
|
||||
std::vector<double> curveValues = RiaSummaryCurveDefinition::resultValues( curveDef );
|
||||
|
||||
std::vector<time_t> curveTimeSteps = RiaSummaryCurveDefinition::timeSteps( curveDef );
|
||||
|
||||
|
@ -52,18 +52,16 @@ std::vector<time_t> RifCalculatedSummaryCurveReader::timeSteps( const RifEclipse
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifCalculatedSummaryCurveReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RifCalculatedSummaryCurveReader::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
RimSummaryCalculation* calc = findCalculationByName( resultAddress );
|
||||
if ( calc && m_summaryCase )
|
||||
{
|
||||
RimSummaryCalculationAddress address( resultAddress );
|
||||
*values = calc->values( m_summaryCase, address );
|
||||
|
||||
return true;
|
||||
return { true, calc->values( m_summaryCase, address ) };
|
||||
}
|
||||
|
||||
return false;
|
||||
return { false, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -35,9 +35,9 @@ class RifCalculatedSummaryCurveReader : public RifSummaryReaderInterface
|
||||
public:
|
||||
explicit RifCalculatedSummaryCurveReader( RimSummaryCalculationCollection* calculationCollection, RimSummaryCase* summaryCase );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
void buildMetaData();
|
||||
|
||||
|
@ -205,16 +205,12 @@ std::pair<std::vector<time_t>, std::vector<double>> RimDerivedSummaryCase::calcu
|
||||
|
||||
if ( reader1->hasAddress( address ) && !reader2->hasAddress( address ) )
|
||||
{
|
||||
std::vector<double> summaryValues;
|
||||
reader1->values( address, &summaryValues );
|
||||
|
||||
auto [isOk, summaryValues] = reader1->values( address );
|
||||
return ResultPair( reader1->timeSteps( address ), summaryValues );
|
||||
}
|
||||
else if ( !reader1->hasAddress( address ) && reader2->hasAddress( address ) )
|
||||
{
|
||||
std::vector<double> summaryValues;
|
||||
reader2->values( address, &summaryValues );
|
||||
|
||||
auto [isOk, summaryValues] = reader2->values( address );
|
||||
if ( m_operator == DerivedSummaryOperator::DERIVED_OPERATOR_SUB )
|
||||
{
|
||||
for ( auto& v : summaryValues )
|
||||
@ -226,18 +222,15 @@ std::pair<std::vector<time_t>, std::vector<double>> RimDerivedSummaryCase::calcu
|
||||
return ResultPair( reader2->timeSteps( address ), summaryValues );
|
||||
}
|
||||
|
||||
RiaTimeHistoryCurveMerger merger;
|
||||
std::vector<double> values1;
|
||||
std::vector<double> values2;
|
||||
|
||||
reader1->values( address, &values1 );
|
||||
reader2->values( address, &values2 );
|
||||
auto [isOk1, values1] = reader1->values( address );
|
||||
auto [isOk2, values2] = reader2->values( address );
|
||||
|
||||
if ( values1.empty() && values2.empty() )
|
||||
{
|
||||
return ResultPair();
|
||||
}
|
||||
|
||||
RiaTimeHistoryCurveMerger merger;
|
||||
merger.addCurveData( reader1->timeSteps( address ), values1 );
|
||||
merger.addCurveData( reader2->timeSteps( address ), values2 );
|
||||
merger.computeInterpolatedValues();
|
||||
|
@ -36,7 +36,7 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleCrossPlotStatisticsCase::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RimEnsembleCrossPlotStatisticsCase::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
if ( m_adrX.isValid() )
|
||||
{
|
||||
@ -44,23 +44,22 @@ bool RimEnsembleCrossPlotStatisticsCase::values( const RifEclipseSummaryAddress&
|
||||
auto it = stringToTest.find( m_adrX.vectorName() );
|
||||
if ( it != std::string::npos )
|
||||
{
|
||||
*values = m_binnedXValues;
|
||||
return true;
|
||||
return { true, m_binnedXValues };
|
||||
}
|
||||
}
|
||||
|
||||
auto quantityName = resultAddress.ensembleStatisticsVectorName();
|
||||
|
||||
if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP10() )
|
||||
*values = m_p10Data;
|
||||
return { true, m_p10Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP50() )
|
||||
*values = m_p50Data;
|
||||
return { true, m_p50Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP90() )
|
||||
*values = m_p90Data;
|
||||
return { true, m_p90Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameMean() )
|
||||
*values = m_meanData;
|
||||
return { true, m_meanData };
|
||||
|
||||
return true;
|
||||
return { true, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -142,12 +141,10 @@ void RimEnsembleCrossPlotStatisticsCase::calculate( const std::vector<RimSummary
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( inputAddressX );
|
||||
|
||||
std::vector<double> valuesX;
|
||||
reader->values( inputAddressX, &valuesX );
|
||||
auto [isXOk, valuesX] = values( inputAddressX );
|
||||
if ( valuesX.empty() ) continue;
|
||||
|
||||
std::vector<double> valuesY;
|
||||
reader->values( inputAddressY, &valuesY );
|
||||
auto [isYOk, valuesY] = reader->values( inputAddressY );
|
||||
if ( valuesY.empty() ) continue;
|
||||
|
||||
if ( !includeIncompleteCurves && timeSteps.size() != valuesX.size() ) continue;
|
||||
|
@ -50,9 +50,9 @@ public:
|
||||
RifSummaryReaderInterface* summaryReader() override;
|
||||
RiaDefines::EclipseUnitSystem unitSystem() const override;
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
private:
|
||||
void clearData();
|
||||
|
@ -73,20 +73,20 @@ bool RimEnsembleStatisticsCase::hasMeanData() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEnsembleStatisticsCase::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
|
||||
std::pair<bool, std::vector<double>> RimEnsembleStatisticsCase::values( const RifEclipseSummaryAddress& resultAddress ) const
|
||||
{
|
||||
auto quantityName = resultAddress.ensembleStatisticsVectorName();
|
||||
|
||||
if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP10() )
|
||||
*values = m_p10Data;
|
||||
return { true, m_p10Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP50() )
|
||||
*values = m_p50Data;
|
||||
return { true, m_p50Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameP90() )
|
||||
*values = m_p90Data;
|
||||
return { true, m_p90Data };
|
||||
else if ( quantityName == RifEclipseSummaryAddressDefines::statisticsNameMean() )
|
||||
*values = m_meanData;
|
||||
return { true, m_meanData };
|
||||
|
||||
return true;
|
||||
return { true, {} };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -152,8 +152,7 @@ void RimEnsembleStatisticsCase::calculate( const std::vector<RimSummaryCase*>& s
|
||||
if ( reader )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( inputAddress );
|
||||
std::vector<double> values;
|
||||
reader->values( inputAddress, &values );
|
||||
auto [isOk, values] = reader->values( inputAddress );
|
||||
|
||||
if ( values.empty() ) continue;
|
||||
|
||||
|
@ -45,9 +45,9 @@ public:
|
||||
|
||||
void calculate( const std::vector<RimSummaryCase*>& sumCases, const RifEclipseSummaryAddress& inputAddress, bool includeIncompleteCurves );
|
||||
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::vector<time_t> timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::pair<bool, std::vector<double>> values( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
||||
|
||||
static std::vector<RimSummaryCase*> validSummaryCases( const std::vector<RimSummaryCase*>& allSumCases,
|
||||
const RifEclipseSummaryAddress& inputAddress,
|
||||
|
@ -123,11 +123,9 @@ double RimObjectiveFunction::value( RimSummaryCase*
|
||||
const std::vector<time_t>& allTimeSteps = readerInterface->timeSteps( vectorSummaryAddressDiff );
|
||||
std::vector<size_t> timeStepsForEvaluation = timeStepIndicesForEvaluation( allTimeSteps, timeConfig );
|
||||
|
||||
std::vector<double> summaryDiffValues;
|
||||
std::vector<double> summaryHistoryValues;
|
||||
|
||||
if ( readerInterface->values( vectorSummaryAddressDiff, &summaryDiffValues ) &&
|
||||
readerInterface->values( vectorSummaryAddressHistory, &summaryHistoryValues ) )
|
||||
auto [summaryDiffOk, summaryDiffValues] = readerInterface->values( vectorSummaryAddressDiff );
|
||||
auto [summaryHistoryOk, summaryHistoryValues] = readerInterface->values( vectorSummaryAddressHistory );
|
||||
if ( summaryDiffOk && summaryHistoryOk )
|
||||
{
|
||||
const double functionValue = computeFunctionValue( summaryDiffValues, summaryHistoryValues, timeStepsForEvaluation );
|
||||
|
||||
|
@ -523,11 +523,10 @@ std::vector<std::pair<RigEnsembleParameter, double>>
|
||||
|
||||
if ( !summaryCase->caseRealizationParameters() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
double closestValue = std::numeric_limits<double>::infinity();
|
||||
time_t closestTimeStep = 0;
|
||||
if ( reader->values( address, &values ) )
|
||||
auto [isOk, values] = reader->values( address );
|
||||
if ( isOk )
|
||||
{
|
||||
const std::vector<time_t>& timeSteps = reader->timeSteps( address );
|
||||
for ( size_t i = 0; i < timeSteps.size(); ++i )
|
||||
@ -967,8 +966,7 @@ void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& ad
|
||||
{
|
||||
if ( !s->summaryReader() ) continue;
|
||||
|
||||
std::vector<double> values;
|
||||
s->summaryReader()->values( address, &values );
|
||||
auto [isOk, values] = s->summaryReader()->values( address );
|
||||
if ( values.empty() ) continue;
|
||||
|
||||
const auto [min, max] = std::minmax_element( values.begin(), values.end() );
|
||||
|
@ -298,15 +298,13 @@ std::string RimSummaryCurve::unitNameX() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimSummaryCurve::valuesY() const
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
RifSummaryReaderInterface* reader = valuesSummaryReaderY();
|
||||
|
||||
if ( !reader ) return values;
|
||||
if ( !reader ) return {};
|
||||
|
||||
RifEclipseSummaryAddress addr = m_yValuesSummaryAddress()->address();
|
||||
reader->values( addr, &values );
|
||||
|
||||
auto [isOk, values] = reader->values( addr );
|
||||
if ( values.empty() ) return values;
|
||||
|
||||
RimSummaryPlot* plot = firstAncestorOrThisOfTypeAsserted<RimSummaryPlot>();
|
||||
@ -342,18 +340,13 @@ RifEclipseSummaryAddress RimSummaryCurve::errorSummaryAddressY() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimSummaryCurve::errorValuesY() const
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
RifSummaryReaderInterface* reader = valuesSummaryReaderY();
|
||||
|
||||
if ( !reader ) return values;
|
||||
if ( !reader ) return {};
|
||||
|
||||
RifEclipseSummaryAddress addr = errorSummaryAddressY();
|
||||
if ( reader->hasAddress( addr ) )
|
||||
{
|
||||
reader->values( addr, &values );
|
||||
}
|
||||
if ( !reader->hasAddress( addr ) ) return {};
|
||||
|
||||
auto [isOk, values] = reader->values( addr );
|
||||
return values;
|
||||
}
|
||||
|
||||
@ -362,17 +355,17 @@ std::vector<double> RimSummaryCurve::errorValuesY() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimSummaryCurve::valuesX() const
|
||||
{
|
||||
std::vector<double> values;
|
||||
RifSummaryReaderInterface* reader = m_xValuesSummaryCase()->summaryReader();
|
||||
if ( !reader ) return {};
|
||||
|
||||
if ( m_xValuesSummaryCase() && m_xValuesSummaryCase()->summaryReader() )
|
||||
RifEclipseSummaryAddress addr = m_xValuesSummaryAddress()->address();
|
||||
if ( m_xValuesSummaryCase() )
|
||||
{
|
||||
RifSummaryReaderInterface* reader = m_xValuesSummaryCase()->summaryReader();
|
||||
|
||||
RifEclipseSummaryAddress addr = m_xValuesSummaryAddress()->address();
|
||||
reader->values( addr, &values );
|
||||
auto [isOk, values] = reader->values( addr );
|
||||
return values;
|
||||
}
|
||||
|
||||
return values;
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -641,15 +634,10 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
{
|
||||
if ( m_xValuesSummaryAddress()->address().category() == SummaryCategory::SUMMARY_ENSEMBLE_STATISTICS )
|
||||
{
|
||||
std::vector<double> curveValuesX;
|
||||
std::vector<double> curveValuesY;
|
||||
|
||||
// Read x and y values from ensemble statistics (not time steps are read)
|
||||
RifSummaryReaderInterface* reader = m_xValuesSummaryCase()->summaryReader();
|
||||
|
||||
reader->values( m_xValuesSummaryAddress->address(), &curveValuesX );
|
||||
reader->values( m_yValuesSummaryAddress->address(), &curveValuesY );
|
||||
|
||||
auto [isOkX, curveValuesX] = reader->values( m_xValuesSummaryAddress->address() );
|
||||
auto [isOkY, curveValuesY] = reader->values( m_yValuesSummaryAddress->address() );
|
||||
setSamplesFromXYValues( curveValuesX, curveValuesY, useLogarithmicScale );
|
||||
}
|
||||
else
|
||||
@ -696,7 +684,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot )
|
||||
{
|
||||
auto reader = summaryCaseY()->summaryReader();
|
||||
errAddress = reader->errorAddress( summaryAddressY() );
|
||||
reader->values( errAddress, &errValues );
|
||||
errValues = reader->values( errAddress ).second;
|
||||
}
|
||||
|
||||
if ( errAddress.isValid() )
|
||||
|
@ -944,14 +944,14 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
{
|
||||
auto readValues = []( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr )
|
||||
{
|
||||
std::vector<double> values;
|
||||
if ( summaryCase && summaryCase->summaryReader() )
|
||||
{
|
||||
RifSummaryReaderInterface* reader = summaryCase->summaryReader();
|
||||
reader->values( addr, &values );
|
||||
auto [isOk, values] = reader->values( addr );
|
||||
return values;
|
||||
}
|
||||
|
||||
return values;
|
||||
return std::vector<double>();
|
||||
};
|
||||
|
||||
auto findMinMaxForSummaryCase = [readValues]( RimSummaryCase* summaryCase, RifEclipseSummaryAddress addr, bool onlyPositiveValues )
|
||||
|
@ -695,8 +695,7 @@ void RimSummaryTable::createTableData()
|
||||
QString unitName;
|
||||
for ( const auto& adr : summaryAddresses )
|
||||
{
|
||||
std::vector<double> values;
|
||||
summaryReader->values( adr, &values );
|
||||
auto [isOk, values] = summaryReader->values( adr );
|
||||
const std::vector<time_t> timeSteps = summaryReader->timeSteps( adr );
|
||||
const QString vectorName = QString::fromStdString( adr.vectorName() );
|
||||
const QString categoryName = getCategoryNameFromAddress( adr );
|
||||
|
@ -55,18 +55,16 @@ caf::PdmObjectHandle* RimSummaryCase_summaryVectorValues::execute()
|
||||
|
||||
auto adr = RifEclipseSummaryAddress::fromEclipseTextAddressParseErrorTokens( m_addressString().toStdString() );
|
||||
|
||||
std::vector<double> values;
|
||||
|
||||
if ( sumReader )
|
||||
{
|
||||
bool isOk = sumReader->values( adr, &values );
|
||||
if ( !isOk )
|
||||
auto [isOk, values] = sumReader->values( adr );
|
||||
if ( isOk )
|
||||
{
|
||||
// Error message
|
||||
return RimcDataContainerDouble::create( values );
|
||||
}
|
||||
}
|
||||
|
||||
return RimcDataContainerDouble::create( values );
|
||||
return RimcDataContainerDouble::create( {} );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -210,9 +208,7 @@ caf::PdmObjectHandle* RimSummaryCase_resampleValues::execute()
|
||||
|
||||
if ( sumReader )
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
bool isOk = sumReader->values( adr, &values );
|
||||
auto [isOk, values] = sumReader->values( adr );
|
||||
if ( !isOk )
|
||||
{
|
||||
// Error message
|
||||
|
@ -105,9 +105,7 @@ TEST( HDFTests, ReadOpmSummaryData )
|
||||
{
|
||||
if ( itemCount++ < 10 )
|
||||
{
|
||||
std::vector<double> values;
|
||||
hdf5SummaryReader.values( adr, &values );
|
||||
|
||||
auto [isOk, values] = hdf5SummaryReader.values( adr );
|
||||
totalValueCount += values.size();
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,7 @@ TEST( DISABLED_RifSummaryDataTest, OpmCommonAllData )
|
||||
size_t i = 0;
|
||||
for ( auto adr : reader.allResultAddresses() )
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
reader.values( adr, &values );
|
||||
auto [isOk, values] = reader.values( adr );
|
||||
totalValuesRead += values.size();
|
||||
i++;
|
||||
if ( i > maxCount ) break;
|
||||
@ -94,9 +92,7 @@ TEST( DISABLED_RifSummaryDataTest, LibEclAllData )
|
||||
size_t i = 0;
|
||||
for ( auto adr : reader.allResultAddresses() )
|
||||
{
|
||||
std::vector<double> values;
|
||||
|
||||
reader.values( adr, &values );
|
||||
auto [isOk, values] = reader.values( adr );
|
||||
totalValuesRead += values.size();
|
||||
|
||||
i++;
|
||||
|
Loading…
Reference in New Issue
Block a user