Improve summary category detection for opm-common reader (#9018)

* Move code to quantitynameinforprovider
* Use some region-to-region helper function from opm-common
* Add more fallbacks
This commit is contained in:
Magne Sjaastad
2022-06-03 13:54:15 +02:00
committed by GitHub
parent 95e9ef8bf1
commit 2472f4697c
6 changed files with 101 additions and 42 deletions

View File

@@ -152,36 +152,6 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromEclipseTextAddress( const
return fromTokens( tokens );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress::SummaryVarCategory RifEclipseSummaryAddress::identifyCategory( const std::string& vectorName )
{
// Try to an exact match on the vector name first in the vector table.
bool exactMatch = true;
auto exactCategory = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromVectorName( vectorName, exactMatch );
if ( exactCategory != SUMMARY_INVALID ) return exactCategory;
if ( vectorName.size() < 3 || vectorName.size() > 8 ) return SUMMARY_INVALID;
// Try to match the base vector name with more heuristics
auto strippedQuantityName = baseVectorName( vectorName );
// First, try to lookup vector in vector table
auto category = RiuSummaryQuantityNameInfoProvider::instance()->categoryFromVectorName( strippedQuantityName );
if ( category != SUMMARY_INVALID ) return category;
// Then check LGR categories
std::string firstTwoLetters = strippedQuantityName.substr( 0, 2 );
if ( firstTwoLetters == "LB" ) return SUMMARY_BLOCK_LGR;
if ( firstTwoLetters == "LC" ) return SUMMARY_WELL_COMPLETION_LGR;
if ( firstTwoLetters == "LW" ) return SUMMARY_WELL_LGR;
if ( strippedQuantityName[0] == 'N' ) return SUMMARY_NETWORK;
return SUMMARY_INVALID;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -762,7 +732,7 @@ RifEclipseSummaryAddress RifEclipseSummaryAddress::fromTokens( const std::vector
if ( tokens.size() > 1 ) token1 = tokens[1];
if ( tokens.size() > 2 ) token2 = tokens[2];
SummaryVarCategory category = identifyCategory( vectorName );
SummaryVarCategory category = RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( vectorName );
switch ( category )
{

View File

@@ -127,8 +127,6 @@ public:
static RifEclipseSummaryAddress fromEclipseTextAddress( const std::string& textAddress );
static RifEclipseSummaryAddress fromEclipseTextAddressParseErrorTokens( const std::string& textAddress );
static SummaryVarCategory identifyCategory( const std::string& vectorName );
static RifEclipseSummaryAddress fieldAddress( const std::string& vectorName );
static RifEclipseSummaryAddress aquiferAddress( const std::string& vectorName, int aquiferNumber );
static RifEclipseSummaryAddress networkAddress( const std::string& vectorName );

View File

@@ -23,6 +23,8 @@
#include "RifEclipseUserDataParserTools.h"
#include "RiuSummaryQuantityNameInfoProvider.h"
#include <QStringList>
//--------------------------------------------------------------------------------------------------
@@ -164,7 +166,8 @@ bool RifEclipseUserDataKeywordTools::isYearX( const std::string& identifier )
RifEclipseSummaryAddress RifEclipseUserDataKeywordTools::makeAndFillAddress( const std::string quantityName,
const std::vector<std::string>& columnHeaderText )
{
RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::identifyCategory( quantityName );
RifEclipseSummaryAddress::SummaryVarCategory category =
RiuSummaryQuantityNameInfoProvider::instance()->identifyCategory( quantityName );
if ( category == RifEclipseSummaryAddress::SUMMARY_INVALID )
{