mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9023 Performance : Use cached analyzer
Remove min max from RimSummaryCaseCollection Guard null pointer access Improve default behaviour for axis range control
This commit is contained in:
@@ -1967,14 +1967,6 @@ bool RimEnsembleCurveSet::hasMeanData() const
|
||||
return m_ensembleStatCase->hasMeanData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::pair<double, double> RimEnsembleCurveSet::minimumAndMaximumValues() const
|
||||
{
|
||||
return m_ensembleStatCase->minimumAndMaximumValues();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -155,8 +155,6 @@ 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,8 +39,6 @@
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleStatisticsCase::RimEnsembleStatisticsCase( RimEnsembleCurveSet* curveSet )
|
||||
: m_minimumValue( DOUBLE_INF )
|
||||
, m_maximumValue( -DOUBLE_INF )
|
||||
{
|
||||
m_curveSet = curveSet;
|
||||
}
|
||||
@@ -85,14 +83,6 @@ const std::vector<double>& RimEnsembleStatisticsCase::mean() const
|
||||
return m_meanData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::pair<double, double> RimEnsembleStatisticsCase::minimumAndMaximumValues() const
|
||||
{
|
||||
return { m_minimumValue, m_maximumValue };
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -205,11 +195,6 @@ 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,8 +40,6 @@ 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(); }
|
||||
@@ -74,7 +72,4 @@ private:
|
||||
std::vector<double> m_p50Data;
|
||||
std::vector<double> m_p90Data;
|
||||
std::vector<double> m_meanData;
|
||||
|
||||
double m_maximumValue;
|
||||
double m_minimumValue;
|
||||
};
|
||||
|
||||
@@ -959,18 +959,24 @@ void RimSummaryCaseCollection::computeMinMax( const RifEclipseSummaryAddress& ad
|
||||
double maximumValue( -std::numeric_limits<double>::infinity() );
|
||||
|
||||
std::vector<double> values;
|
||||
for ( auto s : m_cases() )
|
||||
for ( const auto& s : m_cases() )
|
||||
{
|
||||
if ( !s->summaryReader() ) continue;
|
||||
|
||||
s->summaryReader()->values( address, &values );
|
||||
const auto [min, max] = std::minmax_element( begin( values ), end( values ) );
|
||||
if ( values.empty() ) continue;
|
||||
|
||||
const auto [min, max] = std::minmax_element( values.begin(), values.end() );
|
||||
|
||||
minimumValue = std::min( *min, minimumValue );
|
||||
maximumValue = std::max( *max, maximumValue );
|
||||
}
|
||||
|
||||
setMinMax( address, minimumValue, maximumValue );
|
||||
if ( minimumValue != std::numeric_limits<double>::infinity() &&
|
||||
maximumValue != -std::numeric_limits<double>::infinity() )
|
||||
{
|
||||
setMinMax( address, minimumValue, maximumValue );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1136,12 +1142,7 @@ void RimSummaryCaseCollection::buildChildNodes()
|
||||
{
|
||||
if ( m_dataVectorFolders->isEmpty() )
|
||||
{
|
||||
for ( auto& smcase : m_cases )
|
||||
{
|
||||
m_dataVectorFolders->updateFolderStructure( smcase->summaryReader()->allResultAddresses(),
|
||||
smcase->caseId(),
|
||||
m_ensembleId );
|
||||
}
|
||||
m_dataVectorFolders->updateFolderStructure( ensembleSummaryAddresses(), -1, m_ensembleId );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -230,14 +230,11 @@ void RimSummaryMultiPlot::handleDroppedObjects( const std::vector<caf::PdmObject
|
||||
auto adrColl = dynamic_cast<RimSummaryAddressCollection*>( o );
|
||||
if ( adrColl )
|
||||
{
|
||||
if ( objects.size() == 1 )
|
||||
if ( objects.size() == 1 && adrColl->isFolder() )
|
||||
{
|
||||
if ( adrColl->isFolder() )
|
||||
{
|
||||
// If a folder is selected, return all sub items in folder
|
||||
auto childObjects = adrColl->subFolders();
|
||||
addressCollections.insert( addressCollections.end(), childObjects.begin(), childObjects.end() );
|
||||
}
|
||||
// If a folder is selected, return all sub items in folder
|
||||
auto childObjects = adrColl->subFolders();
|
||||
addressCollections.insert( addressCollections.end(), childObjects.begin(), childObjects.end() );
|
||||
}
|
||||
else
|
||||
addressCollections.push_back( adrColl );
|
||||
@@ -731,28 +728,21 @@ void RimSummaryMultiPlot::setDefaultRangeAggregationSteppingDimension()
|
||||
analyzer.appendAddresses( addresses );
|
||||
}
|
||||
|
||||
auto rangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
auto rangeAggregation = AxisRangeAggregation::NONE;
|
||||
if ( analyzer.quantities().size() == 1 && summaryPlots().size() > 1 )
|
||||
{
|
||||
// Many plots, single summary vector
|
||||
rangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
}
|
||||
|
||||
if ( !analyzer.wellNames().empty() )
|
||||
{
|
||||
rangeAggregation = AxisRangeAggregation::WELLS;
|
||||
}
|
||||
else if ( !analyzer.groupNames().empty() )
|
||||
{
|
||||
rangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
}
|
||||
else if ( !analyzer.regionNumbers().empty() )
|
||||
{
|
||||
rangeAggregation = AxisRangeAggregation::REGIONS;
|
||||
}
|
||||
else if ( !analyzer.aquifers().empty() )
|
||||
{
|
||||
rangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
}
|
||||
else if ( !analyzer.blocks().empty() )
|
||||
{
|
||||
rangeAggregation = AxisRangeAggregation::SUB_PLOTS;
|
||||
}
|
||||
|
||||
auto stepDimension = RimSummaryDataSourceStepping::SourceSteppingDimension::VECTOR;
|
||||
if ( analyzer.wellNames().size() == 1 )
|
||||
@@ -920,35 +910,41 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
else if ( axisRangeAggregation == AxisRangeAggregation::WELLS ||
|
||||
axisRangeAggregation == AxisRangeAggregation::REGIONS )
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
RiaSummaryAddressAnalyzer fallbackAnalyzer;
|
||||
RiaSummaryAddressAnalyzer* analyzer = nullptr;
|
||||
|
||||
if ( curve->summaryCaseY() )
|
||||
{
|
||||
auto ensemble = curve->summaryCaseY()->ensemble();
|
||||
if ( ensemble )
|
||||
{
|
||||
analyzer.appendAddresses( ensemble->ensembleSummaryAddresses() );
|
||||
analyzer = ensemble->addressAnalyzer();
|
||||
}
|
||||
else
|
||||
{
|
||||
analyzer.appendAddresses( curve->summaryCaseY()->summaryReader()->allResultAddresses() );
|
||||
fallbackAnalyzer.appendAddresses( curve->summaryCaseY()->summaryReader()->allResultAddresses() );
|
||||
analyzer = &fallbackAnalyzer;
|
||||
}
|
||||
}
|
||||
|
||||
if ( axisRangeAggregation == AxisRangeAggregation::WELLS )
|
||||
if ( analyzer )
|
||||
{
|
||||
for ( const auto& wellName : analyzer.wellNames() )
|
||||
if ( axisRangeAggregation == AxisRangeAggregation::WELLS )
|
||||
{
|
||||
addresses.push_back(
|
||||
RifEclipseSummaryAddress::wellAddress( curve->summaryAddressY().vectorName(), wellName ) );
|
||||
for ( const auto& wellName : analyzer->wellNames() )
|
||||
{
|
||||
addresses.push_back(
|
||||
RifEclipseSummaryAddress::wellAddress( curve->summaryAddressY().vectorName(), wellName ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( axisRangeAggregation == AxisRangeAggregation::REGIONS )
|
||||
{
|
||||
for ( auto regionNumber : analyzer.regionNumbers() )
|
||||
if ( axisRangeAggregation == AxisRangeAggregation::REGIONS )
|
||||
{
|
||||
addresses.push_back( RifEclipseSummaryAddress::regionAddress( curve->summaryAddressY().vectorName(),
|
||||
regionNumber ) );
|
||||
for ( auto regionNumber : analyzer->regionNumbers() )
|
||||
{
|
||||
addresses.push_back( RifEclipseSummaryAddress::regionAddress( curve->summaryAddressY().vectorName(),
|
||||
regionNumber ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1005,6 +1001,8 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
|
||||
for ( auto curveSet : plot->curveSets() )
|
||||
{
|
||||
if ( !curveSet->summaryCaseCollection() ) continue;
|
||||
|
||||
if ( curveSet->axisY() == axis->plotAxisType() )
|
||||
{
|
||||
double minimum( std::numeric_limits<double>::infinity() );
|
||||
@@ -1020,7 +1018,7 @@ void RimSummaryMultiPlot::computeAggregatedAxisRange()
|
||||
std::vector<RifEclipseSummaryAddress> addresses =
|
||||
addressesForCurve( curve, m_axisRangeAggregation() );
|
||||
|
||||
for ( auto adr : addresses )
|
||||
for ( const auto& adr : addresses )
|
||||
{
|
||||
auto [min, max] = curveSet->summaryCaseCollection()->minMax( adr );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user