#10128 Reveal Summary: add ensemble import.

This commit is contained in:
Kristian Bendiksen 2023-04-24 16:04:36 +02:00
parent 33b19a8bb3
commit 26f13012b4
4 changed files with 50 additions and 40 deletions

View File

@ -19,6 +19,7 @@
#include "RiaEnsembleNameTools.h"
#include "RiaFilePathTools.h"
#include "RiaSummaryDefines.h"
#include "RiaTextStringTools.h"
#include "RimCaseDisplayNameTools.h"
@ -136,7 +137,7 @@ std::vector<QStringList> RiaEnsembleNameTools::groupFilesByEnsemble( const QStri
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, QStringList> RiaEnsembleNameTools::groupFilesByStimPlanEnsemble( const QStringList& fileNames )
std::map<QString, QStringList> RiaEnsembleNameTools::groupFilesByCustomEnsemble( const QStringList& fileNames, RiaDefines::FileType fileType )
{
std::vector<QStringList> componentsForAllFilePaths;
for ( const auto& filePath : fileNames )
@ -145,7 +146,7 @@ std::map<QString, QStringList> RiaEnsembleNameTools::groupFilesByStimPlanEnsembl
componentsForAllFilePaths.push_back( components );
}
auto mapping = findUniqueStimPlanEnsembleNames( fileNames, componentsForAllFilePaths );
auto mapping = findUniqueCustomEnsembleNames( fileType, fileNames, componentsForAllFilePaths );
std::set<QString> iterations;
for ( const auto& [name, iterFileNamePair] : mapping )
@ -179,52 +180,56 @@ std::map<QString, QStringList> RiaEnsembleNameTools::groupFilesByStimPlanEnsembl
///
//--------------------------------------------------------------------------------------------------
std::map<QString, std::pair<QString, QString>>
RiaEnsembleNameTools::findUniqueStimPlanEnsembleNames( const QStringList& fileNames, const std::vector<QStringList>& fileNameComponents )
RiaEnsembleNameTools::findUniqueCustomEnsembleNames( RiaDefines::FileType fileType,
const QStringList& fileNames,
const std::vector<QStringList>& fileNameComponents )
{
CAF_ASSERT( fileNames.size() == static_cast<int>( fileNameComponents.size() ) );
struct StimPlanComponents
{
QString realization;
QString iteration;
QString well;
QString fracture;
QString job;
QString fileName;
};
std::vector<StimPlanComponents> comps;
std::map<QString, std::pair<QString, QString>> mapping;
int i = 0;
for ( const auto& fileComponents : fileNameComponents )
{
int numComponents = fileComponents.size();
if ( numComponents >= 8 )
if ( fileType == RiaDefines::FileType::STIMPLAN_SUMMARY )
{
// Expected path: realization/iteration/stimplan/output/well/job/fracture/data.csv
// Example: realization-1/iteration-1/stimplan/output/H-B33/job-01/mainfrac/data.csv
StimPlanComponents c;
c.fileName = fileNames[i];
c.fracture = fileComponents[numComponents - 2];
c.job = fileComponents[numComponents - 3];
c.well = fileComponents[numComponents - 4];
c.iteration = fileComponents[numComponents - 7];
c.realization = fileComponents[numComponents - 8];
if ( numComponents >= 8 && fileComponents[numComponents - 6] == "stimplan" )
{
// Expected path: realization/iteration/stimplan/output/well/job/fracture/data.csv
// Example: realization-1/iteration-1/stimplan/output/H-B33/job-01/mainfrac/data.csv
QString fileName = fileNames[i];
QString fracture = fileComponents[numComponents - 2];
QString job = fileComponents[numComponents - 3];
QString well = fileComponents[numComponents - 4];
QString iteration = fileComponents[numComponents - 7];
QString realization = fileComponents[numComponents - 8];
comps.push_back( c );
QString key = QString( "%1, %2, %3, %4, %5" ).arg( iteration, realization, well, fracture, job );
QString displayName = QString( "%1, %2, %3, %4" ).arg( iteration, well, fracture, job );
mapping[key] = std::make_pair( displayName, fileName );
}
}
else if ( fileType == RiaDefines::FileType::REVEAL_SUMMARY )
{
if ( numComponents >= 6 && fileComponents[numComponents - 4] == "reveal" )
{
// Expected path: realization/iteration/reveal/output/well/data.csv
// Example: realization-1/iteration-1/reveal/output/H-B33/data.csv
QString fileName = fileNames[i];
QString well = fileComponents[numComponents - 2];
QString iteration = fileComponents[numComponents - 5];
QString realization = fileComponents[numComponents - 6];
QString key = QString( "%1, %2, %3" ).arg( iteration, realization, well );
QString displayName = QString( "%1, %2" ).arg( iteration, well );
mapping[key] = std::make_pair( displayName, fileName );
}
}
i++;
}
std::map<QString, std::pair<QString, QString>> mapping;
for ( const StimPlanComponents& c : comps )
{
QString key = QString( "%1, %2, %3, %4, %5" ).arg( c.iteration, c.realization, c.well, c.fracture, c.job );
QString iteration = QString( "%1, %2, %3, %4" ).arg( c.iteration, c.well, c.fracture, c.job );
mapping[key] = std::make_pair( iteration, c.fileName );
}
return mapping;
}

View File

@ -23,6 +23,8 @@
#include <map>
#include <vector>
#include "RiaSummaryDefines.h"
class RimSummaryCase;
//==================================================================================================
@ -50,10 +52,11 @@ public:
const QString& ensembleCaseName );
static std::vector<QStringList> groupFilesByEnsemble( const QStringList& fileNames, EnsembleGroupingMode groupingMode );
static std::map<QString, QStringList> groupFilesByStimPlanEnsemble( const QStringList& fileNames );
static std::map<QString, QStringList> groupFilesByCustomEnsemble( const QStringList& fileNames, RiaDefines::FileType fileType );
static std::map<QString, std::pair<QString, QString>>
findUniqueStimPlanEnsembleNames( const QStringList& fileNames, const std::vector<QStringList>& fileNameComponents );
static std::map<QString, std::pair<QString, QString>> findUniqueCustomEnsembleNames( RiaDefines::FileType fileType,
const QStringList& fileNames,
const std::vector<QStringList>& fileNameComponents );
static QString uniqueShortNameForEnsembleCase( RimSummaryCase* summaryCase );
static QString uniqueShortNameForSummaryCase( RimSummaryCase* summaryCase );

View File

@ -85,9 +85,9 @@ void RicImportEnsembleFeature::onActionTriggered( bool isChecked )
}
else
{
if ( fileType == RiaDefines::FileType::STIMPLAN_SUMMARY )
if ( fileType == RiaDefines::FileType::STIMPLAN_SUMMARY || fileType == RiaDefines::FileType::REVEAL_SUMMARY )
{
std::map<QString, QStringList> groupedByEnsemble = RiaEnsembleNameTools::groupFilesByStimPlanEnsemble( fileNames );
std::map<QString, QStringList> groupedByEnsemble = RiaEnsembleNameTools::groupFilesByCustomEnsemble( fileNames, fileType );
for ( const auto& [ensembleName, groupedFileNames] : groupedByEnsemble )
{
bool useEnsembleNameDialog = false;

View File

@ -432,9 +432,11 @@ void RicRecursiveFileSearchDialog::updateFileListWidget()
if ( ensembleGroupingMode() != RiaEnsembleNameTools::EnsembleGroupingMode::NONE )
{
if ( m_fileType == RicRecursiveFileSearchDialog::FileType::STIMPLAN_SUMMARY )
if ( m_fileType == RicRecursiveFileSearchDialog::FileType::STIMPLAN_SUMMARY ||
m_fileType == RicRecursiveFileSearchDialog::FileType::REVEAL_SUMMARY )
{
std::map<QString, QStringList> groupedByEnsemble = RiaEnsembleNameTools::groupFilesByStimPlanEnsemble( m_foundFiles );
auto fileType = RicRecursiveFileSearchDialog::mapSummaryFileType( m_fileType );
std::map<QString, QStringList> groupedByEnsemble = RiaEnsembleNameTools::groupFilesByCustomEnsemble( m_foundFiles, fileType );
for ( auto [ensembleName, groupedFileNames] : groupedByEnsemble )
{
new QListWidgetItem( QDir::toNativeSeparators( ensembleName ), m_fileListWidget );