mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
#12722 Fix grouping of files and detection of realization number
* Detect single ensemble for Everest file grouping * Enhance realization number extraction to support underscore separator
This commit is contained in:
1 parent
4397da9114
commit
a59c8d0a3f
3 files changed
+24
-7
No files matched your search
@@ -122,6 +122,13 @@ std::map<std::pair<std::string, std::string>, std::vector<std::string>>
|
||||
|
||||
auto commonFolder = internal::findLastCommonFolder( normalizedPaths );
|
||||
|
||||
if ( RiaStdStringTools::toUpper( commonFolder ).contains( "BATCH" ) )
|
||||
{
|
||||
// If the common folder is "BATCH", we assume all files are in the same ensemble and group them under the common folder name
|
||||
groupedPaths[{ commonFolder, commonFolder }] = filepaths;
|
||||
return groupedPaths;
|
||||
}
|
||||
|
||||
for ( const auto& filepath : normalizedPaths )
|
||||
{
|
||||
auto rest = filepath.substr( commonPrefix.size() );
|
||||
|
||||
@@ -221,9 +221,10 @@ bool RifOpmSummaryTools::isEsmryConversionRequired( const QString& fileName )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::expected<int, QString> RifOpmSummaryTools::extractRealizationNumber( const QString& path )
|
||||
{
|
||||
QRegularExpression pattern( "realization-(\\d+)", QRegularExpression::CaseInsensitiveOption );
|
||||
QRegularExpressionMatch match = pattern.match( path );
|
||||
// Regular expression to match realization number in the format "realization-<number>" or "realization_<number>"
|
||||
QRegularExpression pattern( "realization[-_](\\d+)", QRegularExpression::CaseInsensitiveOption );
|
||||
|
||||
QRegularExpressionMatch match = pattern.match( path );
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
bool ok;
|
||||
|
||||
@@ -100,10 +100,19 @@ TEST( RifCaseRealizationParametersReaderTest, SuccessfulParsing )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST( RifCaseRealizationParametersReaderTest, FindRealizationNumber )
|
||||
{
|
||||
QString filePath = "d:/gitroot-ceesol/ResInsight-regression-test/ModelData/ensemble_reek_with_params/realization-"
|
||||
"7/iter-0/eclipse/model/3_R001_REEK-7.SMSPEC";
|
||||
{
|
||||
QString filePath = "d:/gitroot-ceesol/ResInsight-regression-test/ModelData/ensemble_reek_with_params/realization-"
|
||||
"7/iter-0/eclipse/model/3_R001_REEK-7.SMSPEC";
|
||||
|
||||
auto realisationNumber = RifOpmSummaryTools::extractRealizationNumber( filePath );
|
||||
EXPECT_TRUE( realisationNumber.has_value() );
|
||||
EXPECT_EQ( 7, realisationNumber.value() );
|
||||
auto realisationNumber = RifOpmSummaryTools::extractRealizationNumber( filePath );
|
||||
EXPECT_TRUE( realisationNumber.has_value() );
|
||||
EXPECT_EQ( 7, realisationNumber.value() );
|
||||
}
|
||||
{
|
||||
QString filePath = "f:/Models/scratch/my_case/batch_1/geo_realization_2/simulation_2/eclipse/model/PROJECT-0.SMSPEC";
|
||||
|
||||
auto realisationNumber = RifOpmSummaryTools::extractRealizationNumber( filePath );
|
||||
EXPECT_TRUE( realisationNumber.has_value() );
|
||||
EXPECT_EQ( 2, realisationNumber.value() );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user