mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Several performance fixes (#9026)
* #9023 Performance: Use count instead of for loop * #9023 Analyzer: Cache vector names for categories * #9023 Performance : Use cached ensemble analyzer * #9023 Performance : Add min/max values to ensemble statistics * #9023 Performance : Improve statistics calculator * #9023 Performance : Use high performance toInt() * #9023 Performance : Build summary addresses in parallell
This commit is contained in:
@@ -1967,6 +1967,14 @@ bool RimEnsembleCurveSet::hasMeanData() const
|
||||
return m_ensembleStatCase->hasMeanData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<double, double> RimEnsembleCurveSet::minimumAndMaximumValues() const
|
||||
{
|
||||
return m_ensembleStatCase->minimumAndMaximumValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -155,6 +155,8 @@ public:
|
||||
bool hasP90Data() const override;
|
||||
bool hasMeanData() const override;
|
||||
|
||||
std::pair<double, double> minimumAndMaximumValues() const;
|
||||
|
||||
void appendColorGroup( caf::PdmUiOrdering& uiOrdering );
|
||||
|
||||
static void appendOptionItemsForSummaryAddresses( QList<caf::PdmOptionItemInfo>* options,
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase( RimEnsembleCurveSet* curveSet )
|
||||
: m_minimumValue( DOUBLE_INF )
|
||||
, m_maximumValue( -DOUBLE_INF )
|
||||
{
|
||||
m_curveSet = curveSet;
|
||||
}
|
||||
@@ -83,6 +85,14 @@ const std::vector<double>& RimEnsembleStatisticsCase::mean() const
|
||||
return m_meanData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::pair<double, double> RimEnsembleStatisticsCase::minimumAndMaximumValues() const
|
||||
{
|
||||
return { m_minimumValue, m_maximumValue };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -195,6 +205,11 @@ void RimEnsembleStatisticsCase::calculate( const std::vector<RimSummaryCase*> su
|
||||
m_p50Data.push_back( p50 );
|
||||
m_p90Data.push_back( p90 );
|
||||
m_meanData.push_back( mean );
|
||||
|
||||
const auto [min, max] = std::minmax_element( begin( valuesAtTimeStep ), end( valuesAtTimeStep ) );
|
||||
|
||||
m_maximumValue = std::max( m_maximumValue, *max );
|
||||
m_minimumValue = std::min( m_minimumValue, *min );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,8 @@ public:
|
||||
const std::vector<double>& p90() const;
|
||||
const std::vector<double>& mean() const;
|
||||
|
||||
const std::pair<double, double> minimumAndMaximumValues() const;
|
||||
|
||||
bool hasP10Data() const { return !m_p10Data.empty(); }
|
||||
bool hasP50Data() const { return !m_p50Data.empty(); }
|
||||
bool hasP90Data() const { return !m_p90Data.empty(); }
|
||||
@@ -72,4 +74,7 @@ private:
|
||||
std::vector<double> m_p50Data;
|
||||
std::vector<double> m_p90Data;
|
||||
std::vector<double> m_meanData;
|
||||
|
||||
double m_maximumValue;
|
||||
double m_minimumValue;
|
||||
};
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStatisticsTools.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RiaSummaryAddressAnalyzer.h"
|
||||
#include "RiaWeightedMeanCalculator.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
@@ -158,6 +159,7 @@ void RimSummaryCaseCollection::removeCase( RimSummaryCase* summaryCase, bool not
|
||||
m_cases.removeChild( summaryCase );
|
||||
|
||||
m_cachedSortedEnsembleParameters.clear();
|
||||
m_analyzer.reset();
|
||||
|
||||
caseRemoved.send( summaryCase );
|
||||
|
||||
@@ -184,6 +186,7 @@ void RimSummaryCaseCollection::addCase( RimSummaryCase* summaryCase )
|
||||
|
||||
m_cases.push_back( summaryCase );
|
||||
m_cachedSortedEnsembleParameters.clear();
|
||||
m_analyzer.reset();
|
||||
|
||||
// Update derived ensemble cases (if any)
|
||||
std::vector<RimDerivedEnsembleCaseCollection*> referringObjects;
|
||||
@@ -344,6 +347,7 @@ std::set<time_t> RimSummaryCaseCollection::ensembleTimeSteps() const
|
||||
}
|
||||
return allTimeSteps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -929,6 +933,21 @@ void RimSummaryCaseCollection::updateReferringCurveSets()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSummaryAddressAnalyzer* RimSummaryCaseCollection::addressAnalyzer()
|
||||
{
|
||||
if ( !m_analyzer )
|
||||
{
|
||||
m_analyzer = std::make_unique<RiaSummaryAddressAnalyzer>();
|
||||
|
||||
m_analyzer->appendAddresses( ensembleSummaryAddresses() );
|
||||
}
|
||||
|
||||
return m_analyzer.get();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -42,6 +43,7 @@ class RifReaderRftInterface;
|
||||
class RifReaderEnsembleStatisticsRft;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryAddressCollection;
|
||||
class RiaSummaryAddressAnalyzer;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -110,6 +112,8 @@ public:
|
||||
|
||||
void updateReferringCurveSets();
|
||||
|
||||
RiaSummaryAddressAnalyzer* addressAnalyzer();
|
||||
|
||||
private:
|
||||
RigEnsembleParameter createEnsembleParameter( const QString& paramName ) const;
|
||||
static void sortByBinnedVariation( std::vector<RigEnsembleParameter>& parameterVector );
|
||||
@@ -146,5 +150,6 @@ private:
|
||||
|
||||
size_t m_commonAddressCount; // if different address count among cases, set to 0
|
||||
|
||||
mutable std::vector<RigEnsembleParameter> m_cachedSortedEnsembleParameters;
|
||||
mutable std::vector<RigEnsembleParameter> m_cachedSortedEnsembleParameters;
|
||||
std::unique_ptr<RiaSummaryAddressAnalyzer> m_analyzer;
|
||||
};
|
||||
|
||||
@@ -981,7 +981,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
|
||||
for ( auto axis : plot->plotAxes() )
|
||||
{
|
||||
for ( auto curve : plot->summaryAndEnsembleCurves() )
|
||||
for ( auto curve : plot->summaryCurves() )
|
||||
{
|
||||
if ( curve->axisY() == axis->plotAxisType() )
|
||||
{
|
||||
@@ -1002,6 +1002,25 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto curveSet : plot->curveSets() )
|
||||
{
|
||||
if ( curveSet->axisY() == axis->plotAxisType() )
|
||||
{
|
||||
auto [minimum, maximum] = curveSet->minimumAndMaximumValues();
|
||||
|
||||
if ( axisRanges.count( axis->plotAxisType() ) == 0 )
|
||||
{
|
||||
axisRanges[axis->plotAxisType()] = std::make_pair( minimum, maximum );
|
||||
}
|
||||
else
|
||||
{
|
||||
auto& [currentMin, currentMax] = axisRanges[axis->plotAxisType()];
|
||||
axisRanges[axis->plotAxisType()] =
|
||||
std::make_pair( std::min( currentMin, minimum ), std::max( currentMax, maximum ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set all plots to use the global min/max values for each category
|
||||
|
||||
@@ -211,12 +211,29 @@ QList<caf::PdmOptionItemInfo>
|
||||
return options;
|
||||
}
|
||||
|
||||
auto addresses = adressesForSourceStepping();
|
||||
if ( !addresses.empty() )
|
||||
RiaSummaryAddressAnalyzer fallbackAnalyzer;
|
||||
RiaSummaryAddressAnalyzer* analyzer = nullptr;
|
||||
if ( !dataSourceSteppingObject()->curveSets().empty() )
|
||||
{
|
||||
auto first = dataSourceSteppingObject()->curveSets().front();
|
||||
analyzer = first->summaryCaseCollection()->addressAnalyzer();
|
||||
}
|
||||
|
||||
if ( !analyzer )
|
||||
{
|
||||
// No cached analyzer found. Fallback to population of a local analyzer. Try to avoid this, as the analysis
|
||||
// operation is quite expensive.
|
||||
|
||||
auto addresses = adressesForSourceStepping();
|
||||
fallbackAnalyzer.appendAddresses( addresses );
|
||||
analyzer = &fallbackAnalyzer;
|
||||
}
|
||||
|
||||
if ( analyzer )
|
||||
{
|
||||
if ( fieldNeedingOptions == &m_vectorName )
|
||||
{
|
||||
std::map<QString, QString> displayAndValueStrings = optionsForQuantity( addresses );
|
||||
auto displayAndValueStrings = optionsForQuantity( analyzer );
|
||||
|
||||
for ( const auto& displayAndValue : displayAndValueStrings )
|
||||
{
|
||||
@@ -268,10 +285,7 @@ QList<caf::PdmOptionItemInfo>
|
||||
|
||||
if ( category != RifEclipseSummaryAddress::SUMMARY_INVALID )
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
analyzer.appendAddresses( addresses );
|
||||
|
||||
identifierTexts = analyzer.identifierTexts( category, secondaryIdentifier );
|
||||
identifierTexts = analyzer->identifierTexts( category, secondaryIdentifier );
|
||||
}
|
||||
|
||||
if ( !identifierTexts.empty() )
|
||||
@@ -1175,9 +1189,6 @@ std::map<QString, QString> RimSummaryPlotSourceStepping::optionsForQuantity( std
|
||||
auto subset = RiaSummaryAddressAnalyzer::addressesForCategory( addresses, category );
|
||||
quantityAnalyzer.appendAddresses( subset );
|
||||
|
||||
RiaSummaryAddressAnalyzer analyzerForVisibleCurves;
|
||||
analyzerForVisibleCurves.appendAddresses( visibleCurveAddresses );
|
||||
|
||||
auto quantities = quantityAnalyzer.quantities();
|
||||
for ( const auto& s : quantities )
|
||||
{
|
||||
@@ -1190,6 +1201,36 @@ std::map<QString, QString> RimSummaryPlotSourceStepping::optionsForQuantity( std
|
||||
return displayAndValueStrings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString, QString> RimSummaryPlotSourceStepping::optionsForQuantity( RiaSummaryAddressAnalyzer* analyzser )
|
||||
{
|
||||
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD;
|
||||
|
||||
auto visibleCurveAddresses = addressesForCurvesInPlot();
|
||||
if ( !visibleCurveAddresses.empty() )
|
||||
{
|
||||
category = visibleCurveAddresses.begin()->category();
|
||||
}
|
||||
|
||||
std::map<QString, QString> displayAndValueStrings;
|
||||
|
||||
if ( analyzser )
|
||||
{
|
||||
auto vectorNames = analyzser->vectorNamesForCategory( category );
|
||||
|
||||
for ( const auto& s : vectorNames )
|
||||
{
|
||||
QString valueString = QString::fromStdString( s );
|
||||
|
||||
displayAndValueStrings[valueString] = valueString;
|
||||
}
|
||||
}
|
||||
|
||||
return displayAndValueStrings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -35,6 +35,7 @@ class RimSummaryCurve;
|
||||
class RifSummaryReaderInterface;
|
||||
class RimSummaryCaseCollection;
|
||||
class RifEclipseSummaryAddress;
|
||||
class RiaSummaryAddressAnalyzer;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -98,6 +99,7 @@ private:
|
||||
RimSummaryDataSourceStepping* dataSourceSteppingObject() const;
|
||||
|
||||
std::map<QString, QString> optionsForQuantity( std::set<RifEclipseSummaryAddress> addresses );
|
||||
std::map<QString, QString> optionsForQuantity( RiaSummaryAddressAnalyzer* analyzser );
|
||||
|
||||
private:
|
||||
caf::PdmPointer<caf::PdmObject> m_objectForSourceStepping;
|
||||
|
||||
Reference in New Issue
Block a user