Skip to content

Commit

Permalink
#7415 Memory usage: Use float for summary data values
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Feb 23, 2021
1 parent 1a28e71 commit 7e3a234
Show file tree
Hide file tree
Showing 39 changed files with 172 additions and 133 deletions.
4 changes: 2 additions & 2 deletions ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ bool RiaSummaryCurveDefinition::isEnsembleCurve() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition,
gsl::not_null<std::vector<double>*> values )
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition,
gsl::not_null<std::vector<float>*> values )
{
if ( !curveDefinition.summaryAddress().isValid() ) return;
if ( !curveDefinition.summaryCase() ) return;
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/Application/RiaSummaryCurveDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class RiaSummaryCurveDefinition
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 void resultValues( const RiaSummaryCurveDefinition& curveDefinition, gsl::not_null<std::vector<float>*> values );
static const std::vector<time_t>& timeSteps( const RiaSummaryCurveDefinition& curveDefinition );

QString curveDefinitionText() const;
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,10 @@ QString RiaSummaryTools::findSuitableEnsembleName( const QStringList& summaryCas
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<std::vector<time_t>, std::vector<double>>
std::pair<std::vector<time_t>, std::vector<float>>
RiaSummaryTools::resampledValuesForPeriod( const RifEclipseSummaryAddress& address,
const std::vector<time_t>& timeSteps,
std::vector<double>& values,
std::vector<float>& values,
RiaQDateTimeTools::DateTimePeriod period )
{
RiaTimeHistoryCurveResampler resampler;
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/Application/Tools/RiaSummaryTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class RiaSummaryTools

static QString findSuitableEnsembleName( const QStringList& summaryCaseFileNames );

static std::pair<std::vector<time_t>, std::vector<double>>
static std::pair<std::vector<time_t>, std::vector<float>>
resampledValuesForPeriod( const RifEclipseSummaryAddress& address,
const std::vector<time_t>& timeSteps,
std::vector<double>& values,
std::vector<float>& values,
RiaQDateTimeTools::DateTimePeriod period );
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,17 @@ RiaTimeHistoryCurveResampler::RiaTimeHistoryCurveResampler()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::setCurveData( const std::vector<double>& values, const std::vector<time_t>& timeSteps )
void RiaTimeHistoryCurveResampler::setCurveDataDouble( const std::vector<double>& values,
const std::vector<time_t>& timeSteps )
{
auto floatValues = std::vector<float>( std::begin( values ), std::end( values ) );
setCurveData( floatValues, timeSteps );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaTimeHistoryCurveResampler::setCurveData( const std::vector<float>& values, const std::vector<time_t>& timeSteps )
{
if ( values.empty() || timeSteps.empty() )
{
Expand Down Expand Up @@ -91,7 +101,7 @@ const std::vector<time_t>& RiaTimeHistoryCurveResampler::resampledTimeSteps() co
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RiaTimeHistoryCurveResampler::resampledValues() const
const std::vector<float>& RiaTimeHistoryCurveResampler::resampledValues() const
{
return m_values;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ class RiaTimeHistoryCurveResampler
public:
RiaTimeHistoryCurveResampler();

void setCurveData( const std::vector<double>& values, const std::vector<time_t>& timeSteps );
void setCurveDataDouble( const std::vector<double>& values, const std::vector<time_t>& timeSteps );
void setCurveData( const std::vector<float>& values, const std::vector<time_t>& timeSteps );

void resampleAndComputePeriodEndValues( RiaQDateTimeTools::DateTimePeriod period );
void resampleAndComputeWeightedMeanValues( RiaQDateTimeTools::DateTimePeriod period );

const std::vector<time_t>& resampledTimeSteps() const;
const std::vector<double>& resampledValues() const;
const std::vector<float>& resampledValues() const;

static std::vector<time_t>
timeStepsFromTimeRange( RiaQDateTimeTools::DateTimePeriod period, time_t minTime, time_t maxTime );
Expand All @@ -54,8 +55,8 @@ class RiaTimeHistoryCurveResampler
inline double interpolatedValue( time_t t, time_t t1, double v1, time_t t2, double v2 );

private:
std::pair<std::vector<double>, std::vector<time_t>> m_originalValues;
std::pair<std::vector<float>, std::vector<time_t>> m_originalValues;

std::vector<time_t> m_timeSteps;
std::vector<double> m_values;
std::vector<float> m_values;
};
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ void RicExportFractureCompletionsImpl::getWellPressuresAndInitialProductionTimeS

if ( summaryCase && summaryCase->summaryReader() )
{
std::vector<double> values;
std::vector<float> values;
if ( summaryCase->summaryReader()->values( wbhpPressureAddress, &values ) )
{
std::vector<time_t> summaryTimeSteps = summaryCase->summaryReader()->timeSteps( wbhpPressureAddress );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ bool RifColumnBasedUserData::parse( const QString& data, QString* errorText )
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifColumnBasedUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifColumnBasedUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
if ( search != m_mapFromAddressToResultIndex.end() )
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifColumnBasedUserData.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RifColumnBasedUserData : public RifSummaryReaderInterface

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;

bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;

std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifCsvUserData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ bool RifCsvUserData::parse( const QString& fileName, const AsciiDataParseOptions
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifCsvUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifCsvUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
auto search = m_mapFromAddressToResultIndex.find( resultAddress );
if ( search != m_mapFromAddressToResultIndex.end() )
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifCsvUserData.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RifCsvUserData : public RifSummaryReaderInterface

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;

bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;

std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const std::vector<time_t>& RifDerivedEnsembleReader::timeSteps( const RifEclipse
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifDerivedEnsembleReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifDerivedEnsembleReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
if ( !resultAddress.isValid() ) return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RifDerivedEnsembleReader : public RifSummaryReaderInterface
RifSummaryReaderInterface* sourceSummaryReader2 );

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ const std::vector<time_t>& RifEnsembleStatisticsReader::timeSteps( const RifEcli
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifEnsembleStatisticsReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifEnsembleStatisticsReader::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
if ( !validateAddress( resultAddress ) ) return false;

const std::vector<double>* sourceData = nullptr;
auto quantityName = resultAddress.ensembleStatisticsQuantityName();
const std::vector<float>* sourceData = nullptr;
auto quantityName = resultAddress.ensembleStatisticsQuantityName();

if ( quantityName == ENSEMBLE_STAT_P10_QUANTITY_NAME )
sourceData = &m_ensembleStatCase->p10();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class RifEnsembleStatisticsReader : public RifSummaryReaderInterface
RifEnsembleStatisticsReader( RimEnsembleStatisticsCase* ensStatCase );

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;

RiaDefines::EclipseUnitSystem unitSystem() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool RifKeywordVectorUserData::parse( const QString& data, const QString& custom
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifKeywordVectorUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifKeywordVectorUserData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
auto search = m_mapFromAddressToVectorIndex.find( resultAddress );
if ( search == m_mapFromAddressToVectorIndex.end() ) return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class RifKeywordVectorUserData : public RifSummaryReaderInterface

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;

bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;

std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;
Expand Down
16 changes: 8 additions & 8 deletions ApplicationLibCode/FileInterface/RifReaderEclipseSummary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,14 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode( const ecl::smspec_node& ertSu
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
assert( m_ecl_sum != nullptr );

values->clear();
values->reserve( timeStepCount() );

const std::vector<double>& cachedValues = m_valuesCache->getValues( resultAddress );
const std::vector<float>& cachedValues = m_valuesCache->getValues( resultAddress );
if ( !cachedValues.empty() )
{
values->insert( values->begin(), cachedValues.begin(), cachedValues.end() );
Expand All @@ -451,8 +451,8 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr
RifEclipseSummaryAddress nativeAdrHistory = resultAddress;
nativeAdrHistory.setQuantityName( quantityNoHistory );

std::vector<double> nativeValues;
std::vector<double> historyValues;
std::vector<float> nativeValues;
std::vector<float> historyValues;

if ( !this->values( nativeAdrHistory, &nativeValues ) ) return false;
if ( !this->values( nativeAdrNoHistory, &historyValues ) ) return false;
Expand All @@ -461,7 +461,7 @@ bool RifReaderEclipseSummary::values( const RifEclipseSummaryAddress& resultAddr

for ( size_t i = 0; i < nativeValues.size(); i++ )
{
double diff = nativeValues[i] - historyValues[i];
float diff = nativeValues[i] - historyValues[i];
values->push_back( diff );
m_valuesCache->insertValues( resultAddress, *values );
}
Expand Down Expand Up @@ -641,7 +641,7 @@ RiaDefines::EclipseUnitSystem RifReaderEclipseSummary::unitSystem() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double> RifReaderEclipseSummary::ValuesCache::EMPTY_VECTOR;
const std::vector<float> RifReaderEclipseSummary::ValuesCache::EMPTY_VECTOR;

//--------------------------------------------------------------------------------------------------
///
Expand All @@ -661,15 +661,15 @@ RifReaderEclipseSummary::ValuesCache::~ValuesCache()
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseSummary::ValuesCache::insertValues( const RifEclipseSummaryAddress& address,
const std::vector<double>& values )
const std::vector<float>& values )
{
m_cachedValues[address] = values;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RifReaderEclipseSummary::ValuesCache::getValues( const RifEclipseSummaryAddress& address ) const
const std::vector<float>& RifReaderEclipseSummary::ValuesCache::getValues( const RifEclipseSummaryAddress& address ) const
{
if ( m_cachedValues.find( address ) != m_cachedValues.end() )
{
Expand Down
10 changes: 5 additions & 5 deletions ApplicationLibCode/FileInterface/RifReaderEclipseSummary.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;

bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
RiaDefines::EclipseUnitSystem unitSystem() const override;
QStringList warnings() const { return m_warnings; }
Expand Down Expand Up @@ -109,17 +109,17 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface
//==================================================================================================
class ValuesCache
{
static const std::vector<double> EMPTY_VECTOR;
static const std::vector<float> EMPTY_VECTOR;

public:
ValuesCache();
~ValuesCache();

void insertValues( const RifEclipseSummaryAddress& address, const std::vector<double>& values );
const std::vector<double>& getValues( const RifEclipseSummaryAddress& address ) const;
void insertValues( const RifEclipseSummaryAddress& address, const std::vector<float>& values );
const std::vector<float>& getValues( const RifEclipseSummaryAddress& address ) const;

private:
std::map<const RifEclipseSummaryAddress, std::vector<double>> m_cachedValues;
std::map<const RifEclipseSummaryAddress, std::vector<float>> m_cachedValues;
};

std::unique_ptr<ValuesCache> m_valuesCache;
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifReaderObservedData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ bool RifReaderObservedData::open( const QString& h
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const
bool RifReaderObservedData::values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const
{
size_t columnIndex = m_allResultAddresses.size();

Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/FileInterface/RifReaderObservedData.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class RifReaderObservedData : public RifSummaryReaderInterface

const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;

bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const override;

std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class RifSummaryReaderInterface : public cvf::Object

virtual const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const = 0;

virtual bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const = 0;
virtual bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<float>* values ) const = 0;

virtual std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const = 0;
virtual RiaDefines::EclipseUnitSystem unitSystem() const = 0;
Expand Down
Loading

0 comments on commit 7e3a234

Please sign in to comment.