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:
@@ -727,6 +727,10 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
std::string token1;
|
||||
std::string token2;
|
||||
|
||||
int intValue0 = 0;
|
||||
int intValue1 = 0;
|
||||
int intValue2 = 0;
|
||||
|
||||
vectorName = tokens[0];
|
||||
|
||||
if ( tokens.size() > 1 ) token1 = tokens[1];
|
||||
@@ -740,7 +744,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
return fieldAddress( vectorName );
|
||||
|
||||
case SUMMARY_AQUIFER:
|
||||
if ( !token1.empty() ) return aquiferAddress( vectorName, RiaStdStringTools::toInt( token1 ) );
|
||||
if ( !token1.empty() )
|
||||
{
|
||||
RiaStdStringTools::toInt( token1, intValue0 );
|
||||
return aquiferAddress( vectorName, intValue0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case SUMMARY_NETWORK:
|
||||
@@ -752,7 +760,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
break;
|
||||
|
||||
case SUMMARY_REGION:
|
||||
if ( !token1.empty() ) return regionAddress( vectorName, RiaStdStringTools::toInt( token1 ) );
|
||||
if ( !token1.empty() )
|
||||
{
|
||||
RiaStdStringTools::toInt( token1, intValue0 );
|
||||
return regionAddress( vectorName, intValue0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case SUMMARY_REGION_2_REGION:
|
||||
@@ -761,9 +773,10 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
auto regions = RiaStdStringTools::splitString( token1, '-' );
|
||||
if ( regions.size() == 2 )
|
||||
{
|
||||
return regionToRegionAddress( vectorName,
|
||||
RiaStdStringTools::toInt( regions[0] ),
|
||||
RiaStdStringTools::toInt( regions[1] ) );
|
||||
RiaStdStringTools::toInt( regions[0], intValue0 );
|
||||
RiaStdStringTools::toInt( regions[1], intValue1 );
|
||||
|
||||
return regionToRegionAddress( vectorName, intValue0, intValue1 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -782,11 +795,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
auto ijk = RiaStdStringTools::splitString( token2, ',' );
|
||||
if ( ijk.size() == 3 )
|
||||
{
|
||||
return wellCompletionAddress( vectorName,
|
||||
token1,
|
||||
RiaStdStringTools::toInt( ijk[0] ),
|
||||
RiaStdStringTools::toInt( ijk[1] ),
|
||||
RiaStdStringTools::toInt( ijk[2] ) );
|
||||
RiaStdStringTools::toInt( ijk[0], intValue0 );
|
||||
RiaStdStringTools::toInt( ijk[1], intValue1 );
|
||||
RiaStdStringTools::toInt( ijk[2], intValue2 );
|
||||
|
||||
return wellCompletionAddress( vectorName, token1, intValue0, intValue1, intValue2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -802,18 +815,23 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
auto ijk = RiaStdStringTools::splitString( token3, ',' );
|
||||
if ( ijk.size() == 3 )
|
||||
{
|
||||
return wellCompletionLgrAddress( vectorName,
|
||||
token1,
|
||||
token2,
|
||||
RiaStdStringTools::toInt( ijk[0] ),
|
||||
RiaStdStringTools::toInt( ijk[1] ),
|
||||
RiaStdStringTools::toInt( ijk[2] ) );
|
||||
RiaStdStringTools::toInt( ijk[0], intValue0 );
|
||||
RiaStdStringTools::toInt( ijk[1], intValue1 );
|
||||
RiaStdStringTools::toInt( ijk[2], intValue2 );
|
||||
|
||||
return wellCompletionLgrAddress( vectorName, token1, token2, intValue0, intValue1, intValue2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SUMMARY_WELL_SEGMENT:
|
||||
if ( !token2.empty() ) return wellSegmentAddress( vectorName, token1, RiaStdStringTools::toInt( token2 ) );
|
||||
|
||||
if ( !token2.empty() )
|
||||
{
|
||||
RiaStdStringTools::toInt( token2, intValue0 );
|
||||
|
||||
return wellSegmentAddress( vectorName, token1, intValue0 );
|
||||
}
|
||||
break;
|
||||
|
||||
case SUMMARY_BLOCK:
|
||||
@@ -822,10 +840,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
auto ijk = RiaStdStringTools::splitString( token1, ',' );
|
||||
if ( ijk.size() == 3 )
|
||||
{
|
||||
return blockAddress( vectorName,
|
||||
RiaStdStringTools::toInt( ijk[0] ),
|
||||
RiaStdStringTools::toInt( ijk[1] ),
|
||||
RiaStdStringTools::toInt( ijk[2] ) );
|
||||
RiaStdStringTools::toInt( ijk[0], intValue0 );
|
||||
RiaStdStringTools::toInt( ijk[1], intValue1 );
|
||||
RiaStdStringTools::toInt( ijk[2], intValue2 );
|
||||
|
||||
return blockAddress( vectorName, intValue0, intValue1, intValue2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -836,11 +855,11 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
|
||||
auto ijk = RiaStdStringTools::splitString( token2, ',' );
|
||||
if ( ijk.size() == 3 )
|
||||
{
|
||||
return blockLgrAddress( vectorName,
|
||||
token1,
|
||||
RiaStdStringTools::toInt( ijk[0] ),
|
||||
RiaStdStringTools::toInt( ijk[1] ),
|
||||
RiaStdStringTools::toInt( ijk[2] ) );
|
||||
RiaStdStringTools::toInt( ijk[0], intValue0 );
|
||||
RiaStdStringTools::toInt( ijk[1], intValue1 );
|
||||
RiaStdStringTools::toInt( ijk[2], intValue2 );
|
||||
|
||||
return blockLgrAddress( vectorName, token1, intValue0, intValue1, intValue2 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -395,32 +395,49 @@ std::pair<std::set<RifEclipseSummaryAddress>, std::map<RifEclipseSummaryAddress,
|
||||
|
||||
std::vector<std::string> invalidKeywords;
|
||||
|
||||
for ( const auto& keyword : keywords )
|
||||
#pragma omp parallel
|
||||
{
|
||||
auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword );
|
||||
if ( !eclAdr.isValid() )
|
||||
{
|
||||
invalidKeywords.push_back( keyword );
|
||||
std::set<RifEclipseSummaryAddress> threadAddresses;
|
||||
std::map<RifEclipseSummaryAddress, std::string> threadAddressToNodeIndexMap;
|
||||
std::vector<std::string> threadInvalidKeywords;
|
||||
|
||||
// If a category is not found, use the MISC category
|
||||
eclAdr = RifEclipseSummaryAddress::miscAddress( keyword );
|
||||
#pragma omp for
|
||||
for ( int index = 0; index < (int)keywords.size(); index++ )
|
||||
{
|
||||
auto keyword = keywords[index];
|
||||
|
||||
auto eclAdr = RifEclipseSummaryAddress::fromEclipseTextAddress( keyword );
|
||||
if ( !eclAdr.isValid() )
|
||||
{
|
||||
threadInvalidKeywords.push_back( keyword );
|
||||
|
||||
// If a category is not found, use the MISC category
|
||||
eclAdr = RifEclipseSummaryAddress::miscAddress( keyword );
|
||||
}
|
||||
|
||||
if ( eclAdr.isValid() )
|
||||
{
|
||||
threadAddresses.insert( eclAdr );
|
||||
threadAddressToNodeIndexMap[eclAdr] = keyword;
|
||||
}
|
||||
}
|
||||
|
||||
if ( eclAdr.isValid() )
|
||||
#pragma omp critical
|
||||
{
|
||||
addresses.insert( eclAdr );
|
||||
addressToNodeIndexMap[eclAdr] = keyword;
|
||||
addresses.insert( threadAddresses.begin(), threadAddresses.end() );
|
||||
addressToNodeIndexMap.insert( threadAddressToNodeIndexMap.begin(), threadAddressToNodeIndexMap.end() );
|
||||
invalidKeywords.insert( invalidKeywords.end(), threadInvalidKeywords.begin(), threadInvalidKeywords.end() );
|
||||
}
|
||||
|
||||
// DEBUG code
|
||||
// Used to print keywords not being categorized correctly
|
||||
/*
|
||||
for ( const auto& kw : invalidKeywords )
|
||||
{
|
||||
RiaLogging::warning( QString::fromStdString( kw ) );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
// DEBUG code
|
||||
// Used to print keywords not being categorized correctly
|
||||
/*
|
||||
for ( const auto& kw : invalidKeywords )
|
||||
{
|
||||
RiaLogging::warning( QString::fromStdString( kw ) );
|
||||
}
|
||||
*/
|
||||
|
||||
return { addresses, addressToNodeIndexMap };
|
||||
}
|
||||
|
||||
@@ -57,13 +57,5 @@ bool RifSummaryReaderInterface::hasAddress( const RifEclipseSummaryAddress& resu
|
||||
static const RifEclipseSummaryAddress defaultAdr = RifEclipseSummaryAddress();
|
||||
if ( resultAddress == defaultAdr ) return true;
|
||||
|
||||
for ( const RifEclipseSummaryAddress& summaryAddress : m_allResultAddresses )
|
||||
{
|
||||
if ( summaryAddress == resultAddress )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return ( m_allResultAddresses.count( resultAddress ) > 0 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user