#82 Import ascii grdecl input properties into simulation case.

This allows data from text files to be imported into a binary Eclipse case
imported based on *.EGRID.
This commit is contained in:
Kristian Bendiksen 2019-10-30 16:52:25 +01:00
parent 357b07506f
commit 22a5a1fe0f
8 changed files with 64 additions and 38 deletions

View File

@ -21,6 +21,7 @@
#include "RimEclipseInputCase.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseResultCase.h"
#include "RiaApplication.h"
#include "Riu3DMainWindowTools.h"
@ -39,7 +40,8 @@ CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPrope
//--------------------------------------------------------------------------------------------------
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
{
return selectedInputPropertyCollection() != nullptr;
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>();
}
//--------------------------------------------------------------------------------------------------
@ -47,17 +49,29 @@ bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
{
RimEclipseInputPropertyCollection* inputPropertyCollection = selectedInputPropertyCollection();
if ( !inputPropertyCollection ) return;
RimEclipseCase* eclipseCase = nullptr;
QString casePath;
RimEclipseInputPropertyCollection* inputPropertyCollection =
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>();
if ( !inputPropertyCollection )
{
RimEclipseInputCase* inputReservoir = nullptr;
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( inputReservoir );
QFileInfo fi( inputReservoir->gridFileName() );
casePath = fi.absolutePath();
// No property collection selected: triggered from RimEclipseResultCase.
eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
if ( eclipseCase )
{
inputPropertyCollection = eclipseCase->inputPropertyCollection();
}
}
else
{
// Triggered from collection: get eclipse case ancestor
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( eclipseCase );
}
if ( !inputPropertyCollection || !eclipseCase ) return;
QFileInfo fi( eclipseCase->gridFileName() );
QString casePath = fi.absolutePath();
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "INPUT_FILES", casePath );
@ -71,8 +85,8 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
// Remember the directory to next time
defaultDir = QFileInfo( fileNames.last() ).absolutePath();
app->setLastUsedDialogDirectory( "INPUT_FILES", defaultDir );
addEclipseInputProperty( fileNames, inputPropertyCollection );
eclipseCase->importAsciiInputProperties( fileNames );
inputPropertyCollection->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@ -82,26 +96,3 @@ void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup
{
actionToSetup->setText( "Add Input Property" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseInputPropertyCollection* RicAddEclipseInputPropertyFeature::selectedInputPropertyCollection() const
{
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAddEclipseInputPropertyFeature::addEclipseInputProperty( const QStringList& fileNames,
RimEclipseInputPropertyCollection* inputPropertyCollection )
{
CVF_ASSERT( inputPropertyCollection );
RimEclipseInputCase* inputReservoir = nullptr;
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( inputReservoir );
inputReservoir->openDataFileSet( fileNames );
inputPropertyCollection->updateConnectedEditors();
}

View File

@ -223,6 +223,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewContourMapViewFeature";
menuBuilder << "RicShowFlowCharacteristicsPlotFeature";
menuBuilder << "RicEclipseCaseNewGroupFeature";
menuBuilder << "RicAddEclipseInputPropertyFeature";
menuBuilder << "Separator";
menuBuilder << "RicCopyReferencesToClipboardFeature";
menuBuilder << "Separator";

View File

@ -999,3 +999,8 @@ std::vector<QDateTime> RimEclipseCase::timeStepDates() const
}
return std::vector<QDateTime>();
}
bool RimEclipseCase::importAsciiInputProperties( const QStringList& fileNames )
{
return false;
}

View File

@ -72,6 +72,7 @@ public:
bool ensureReservoirCaseIsOpen();
bool openReserviorCase();
virtual bool openEclipseGridFile() = 0;
virtual bool importAsciiInputProperties( const QStringList& fileNames );
RigEclipseCaseData* eclipseCaseData();
const RigEclipseCaseData* eclipseCaseData() const;

View File

@ -73,6 +73,15 @@ RimEclipseInputCase::RimEclipseInputCase()
//--------------------------------------------------------------------------------------------------
RimEclipseInputCase::~RimEclipseInputCase() {}
//--------------------------------------------------------------------------------------------------
/// Import ascii properties. If no grid data has been read, it will first find the possible
/// grid data among the files then read all supported properties from the files matching the grid
//--------------------------------------------------------------------------------------------------
bool RimEclipseInputCase::importAsciiInputProperties( const QStringList& fileNames )
{
return openDataFileSet( fileNames );
}
//--------------------------------------------------------------------------------------------------
/// Open the supplied file set. If no grid data has been read, it will first find the possible
/// grid data among the files then read all supported properties from the files matching the grid

View File

@ -46,6 +46,7 @@ public:
// File open methods
bool openDataFileSet( const QStringList& fileNames );
bool importAsciiInputProperties( const QStringList& fileNames ) override;
void loadAndSyncronizeInputProperties();
// RimCase overrides

View File

@ -28,6 +28,7 @@
#include "RicfCommandObject.h"
#include "RifEclipseInputPropertyLoader.h"
#include "RifEclipseOutputFileTools.h"
#include "RifReaderEclipseOutput.h"
#include "RifReaderEclipseRft.h"
@ -41,6 +42,8 @@
#include "RimDialogData.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipseView.h"
#include "RimFlowDiagSolution.h"
#include "RimMockModelSettings.h"
@ -239,6 +242,18 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseResultCase::importAsciiInputProperties( const QStringList& fileNames )
{
bool importFaults = false;
return RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( m_inputPropertyCollection,
this->eclipseCaseData(),
importFaults,
fileNames.toVector().toStdVector() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -26,11 +26,13 @@
#include <cafPdmProxyValueField.h>
class RifReaderInterface;
class RigMainGrid;
class RimFlowDiagSolution;
class RigFlowDiagSolverInterface;
class RifReaderEclipseRft;
class RifReaderInterface;
class RigFlowDiagSolverInterface;
class RigMainGrid;
class RimEclipseInputProperty;
class RimEclipseInputPropertyCollection;
class RimFlowDiagSolution;
//==================================================================================================
//
@ -53,6 +55,7 @@ public:
bool openEclipseGridFile() override;
bool importGridAndResultMetaData( bool showTimeStepFilter );
bool importAsciiInputProperties( const QStringList& fileNames );
void reloadEclipseGridFile() override;
bool openAndReadActiveCellData( RigEclipseCaseData* mainEclipseCase );