Skip to content

Commit

Permalink
Support loading formation names when importing an ensemble
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Jan 20, 2025
1 parent 7acbc86 commit 4ea46dd
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,25 @@
#include "RiaImportEclipseCaseTools.h"

#include "RicCreateGridCaseGroupFromFilesFeature.h"
#include "RicImportFormationNamesFeature.h"
#include "RicNewViewFeature.h"
#include "RicRecursiveFileSearchDialog.h"

#include "Rim3dView.h"
#include "RimEclipseCaseCollection.h"
#include "RimEclipseCaseEnsemble.h"
#include "RimEclipseResultCase.h"
#include "RimFormationNames.h"
#include "RimOilField.h"
#include "RimProject.h"
#include "RimViewNameConfig.h"

#include "cafProgressInfo.h"
#include "cafSelectionManager.h"
#include "cafUtils.h"

#include <QAction>
#include <QDir>
#include <QFileInfo>

CAF_CMD_SOURCE_INIT( RicCreateGridCaseEnsemblesFromFilesFeature, "RicCreateGridCaseEnsemblesFromFilesFeature" );
Expand Down Expand Up @@ -115,9 +119,16 @@ RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingle

QString caseName = gridFileName.completeBaseName();

auto* rimResultReservoir = new RimEclipseResultCase();
rimResultReservoir->setCaseInfo( caseName, caseFileName );
eclipseCaseEnsemble->addCase( rimResultReservoir );
auto* rimResultCase = new RimEclipseResultCase();
rimResultCase->setCaseInfo( caseName, caseFileName );
eclipseCaseEnsemble->addCase( rimResultCase );

QFileInfo fi( caseFileName );

// look for formation file two levels up from the egrid file
auto formationFolder = QDir( fi.dir().path() + "/../../" );
RimFormationNames* formations = loadFormationsFromEnsembleFolder( formationFolder.absolutePath() );
if ( formations != nullptr ) rimResultCase->setFormationNames( formations );
}

oilfield->analysisModels()->caseEnsembles.push_back( eclipseCaseEnsemble );
Expand Down Expand Up @@ -154,3 +165,17 @@ std::pair<QStringList, RiaEnsembleNameTools::EnsembleGroupingMode>

return std::make_pair( result.files, result.groupingMode );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFormationNames* RicCreateGridCaseEnsemblesFromFilesFeature::loadFormationsFromEnsembleFolder( const QString folderName )
{
QStringList filters;
filters << "*.lyr";

QStringList fileList = caf::Utils::getFilesInDirectory( folderName, filters, true /*absolute filename*/ );
if ( fileList.isEmpty() ) return nullptr;

return RicImportFormationNamesFeature::importFormationFiles( fileList );
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <vector>

class RimEclipseCaseEnsemble;
class RimFormationNames;

//==================================================================================================
///
Expand All @@ -40,6 +41,8 @@ class RicCreateGridCaseEnsemblesFromFilesFeature : public caf::CmdFeature
{
}

static RimFormationNames* loadFormationsFromEnsembleFolder( const QString folderName );

protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
Expand Down
29 changes: 29 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@
#include "RigMainGrid.h"

#include "RimDialogData.h"
#include "RimEclipseCaseEnsemble.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseView.h"
#include "RimFlowDiagSolution.h"
#include "RimFormationNames.h"
#include "RimMockModelSettings.h"
#include "RimProject.h"
#include "RimReservoirCellResultsStorage.h"
Expand Down Expand Up @@ -695,3 +697,30 @@ void RimEclipseResultCase::defineEditorAttribute( const caf::PdmFieldHandle* fie
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimEclipseResultCase::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
// if this is part of an ensemble, use lyr file set during ensemble creating
if ( fieldNeedingOptions == &m_activeFormationNames )
{
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
if ( ensemble != nullptr )
{
QList<caf::PdmOptionItemInfo> options;
if ( m_activeFormationNames() )
{
options.push_back( caf::PdmOptionItemInfo( m_activeFormationNames->fileNameWoPath(), m_activeFormationNames(), false ) );
}
else
{
options.push_back( caf::PdmOptionItemInfo( "None", nullptr ) );
}
return options;
}
}

return RimEclipseCase::calculateValueOptions( fieldNeedingOptions );
}
1 change: 1 addition & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseResultCase.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class RimEclipseResultCase : public RimEclipseCase
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;

private:
void loadAndUpdateSourSimData();
Expand Down

0 comments on commit 4ea46dd

Please sign in to comment.