Merge pull request #4989 from OPM/import-ascii-data-to-simulation-case

Import ascii data to simulation case
This commit is contained in:
Magne Sjaastad 2019-11-06 11:35:35 +01:00 committed by GitHub
commit 25d2ee0e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 434 additions and 209 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,9 @@ CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPrope
//--------------------------------------------------------------------------------------------------
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
{
return selectedInputPropertyCollection() != nullptr;
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputCase>() ||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>();
}
//--------------------------------------------------------------------------------------------------
@ -47,17 +50,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 RimEclipseInputCase/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 +86,9 @@ 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();
eclipseCase->updateConnectedEditors();
}
//--------------------------------------------------------------------------------------------------
@ -81,27 +97,5 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
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();
actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) );
}

View File

@ -25,7 +25,7 @@
#include "RicEclipseCellResultToFileImpl.h"
#include "RicExportFeatureImpl.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseCase.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimExportInputPropertySettings.h"
@ -81,23 +81,23 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
// Find input reservoir for this property
RimEclipseInputCase* inputReservoir = nullptr;
RimEclipseCase* eclipseCase = nullptr;
{
RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimEclipseInputPropertyCollection*>(
inputProperty->parentField()->ownerObject() );
if ( !inputPropertyCollection ) return;
inputReservoir = dynamic_cast<RimEclipseInputCase*>( inputPropertyCollection->parentField()->ownerObject() );
eclipseCase = dynamic_cast<RimEclipseCase*>( inputPropertyCollection->parentField()->ownerObject() );
}
if ( !inputReservoir ) return;
if ( !eclipseCase ) return;
{
RiaApplication* app = RiaApplication::instance();
QString projectFolder = app->currentProjectPath();
if ( projectFolder.isEmpty() )
{
projectFolder = inputReservoir->locationOnDisc();
projectFolder = eclipseCase->locationOnDisc();
}
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
@ -117,7 +117,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
QString errorMsg;
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile( exportSettings.fileName,
inputReservoir->eclipseCaseData(),
eclipseCase->eclipseCaseData(),
0,
inputProperty->resultName,
exportSettings.eclipseKeyword,

View File

@ -48,7 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.h
${CMAKE_CURRENT_LIST_DIR}/RifDerivedEnsembleReader.h
${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader.h
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.h
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.h
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h
@ -101,6 +101,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifDerivedEnsembleReader.cpp
${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader.cpp
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.cpp
${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.cpp
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.cpp
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp

View File

@ -306,7 +306,7 @@ bool RifEclipseInputFileTools::exportGrid( const QString& fileName,
cvf::Vec2f origin( mapAxes[2] - minPoint2f.x(), mapAxes[3] - minPoint2f.y() );
cvf::Vec2f xPoint = cvf::Vec2f( mapAxes[4], mapAxes[5] ) - minPoint2f;
cvf::Vec2f yPoint = cvf::Vec2f( mapAxes[0], mapAxes[1] ) - minPoint2f;
mapAxes = {yPoint.x(), yPoint.y(), origin.x(), origin.y(), xPoint.x(), xPoint.y()};
mapAxes = { yPoint.x(), yPoint.y(), origin.x(), origin.y(), xPoint.x(), xPoint.y() };
mapAxisTrans.setTranslation( mapAxisTrans.translation() - minPoint3d );
}
@ -875,25 +875,31 @@ bool RifEclipseInputFileTools::readDataFromKeyword( ecl_kw_type* eclipseK
CVF_ASSERT( eclipseKeywordData );
CVF_ASSERT( errMsg );
bool mathingItemCount = false;
size_t keywordItemCount = 0u;
// Number of values to allocate in the result data structure. Must either be number of active cells or
// number of total cells in case to match the criteria in RigCaseCellResultsData::isUsingGlobalActiveIndex
size_t scalarValueCount = 0u;
{
keywordItemCount = static_cast<size_t>( ecl_kw_get_size( eclipseKeywordData ) );
bool mathingItemCount = false;
size_t keywordItemCount = static_cast<size_t>( ecl_kw_get_size( eclipseKeywordData ) );
if ( keywordItemCount == caseData->mainGrid()->cellCount() )
{
mathingItemCount = true;
scalarValueCount = caseData->mainGrid()->globalCellArray().size();
}
if ( keywordItemCount == caseData->activeCellInfo( RiaDefines::MATRIX_MODEL )->reservoirActiveCellCount() )
else if ( keywordItemCount == caseData->activeCellInfo( RiaDefines::MATRIX_MODEL )->reservoirActiveCellCount() )
{
mathingItemCount = true;
scalarValueCount = caseData->activeCellInfo( RiaDefines::MATRIX_MODEL )->reservoirActiveCellCount();
}
}
if ( !mathingItemCount )
{
QString errFormat( "Size mismatch: Main Grid has %1 cells, keyword %2 has %3 cells" );
*errMsg = errFormat.arg( caseData->mainGrid()->cellCount() ).arg( resultName ).arg( keywordItemCount );
return false;
if ( !mathingItemCount )
{
QString errFormat( "Size mismatch: Main Grid has %1 cells, keyword %2 has %3 cells" );
*errMsg = errFormat.arg( caseData->mainGrid()->cellCount() ).arg( resultName ).arg( keywordItemCount );
return false;
}
}
RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName );
@ -902,7 +908,7 @@ bool RifEclipseInputFileTools::readDataFromKeyword( ecl_kw_type* eclipseK
auto newPropertyData = caseData->results( RiaDefines::MATRIX_MODEL )->modifiableCellScalarResultTimesteps( resAddr );
newPropertyData->push_back( std::vector<double>() );
newPropertyData->at( 0 ).resize( ecl_kw_get_size( eclipseKeywordData ), HUGE_VAL );
newPropertyData->at( 0 ).resize( scalarValueCount, HUGE_VAL );
ecl_kw_get_data_as_double( eclipseKeywordData, newPropertyData->at( 0 ).data() );

View File

@ -0,0 +1,227 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifEclipseInputPropertyLoader.h"
#include "RifEclipseInputFileTools.h"
#include "RifReaderEclipseInput.h"
#include "RigActiveCellInfo.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RimEclipseInputProperty.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimTools.h"
#include "cafProgressInfo.h"
#include <QFileInfo>
//--------------------------------------------------------------------------------------------------
/// Loads input property data from the gridFile and additional files
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
//--------------------------------------------------------------------------------------------------
void RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties(
RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const std::vector<QString>& filenames )
{
CVF_ASSERT( inputPropertyCollection );
CVF_ASSERT( eclipseCaseData );
CVF_ASSERT( eclipseCaseData->mainGrid()->gridPointDimensions() != cvf::Vec3st( 0, 0, 0 ) );
size_t inputPropCount = inputPropertyCollection->inputProperties.size();
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() * inputPropCount ), "Reading Input properties" );
int i = 0;
for ( const QString& filename : filenames )
{
int progress = static_cast<int>( i * inputPropCount );
progInfo.setProgressDescription( filename );
QFileInfo fileNameInfo( filename );
bool isExistingFile = fileNameInfo.exists();
// Find all the keywords present on the file
std::set<QString> fileKeywordSet = extractKeywordsOnFile( filenames[i], isExistingFile );
readDataForEachInputProperty( inputPropertyCollection,
eclipseCaseData,
filename,
isExistingFile,
&fileKeywordSet,
&progInfo,
progress );
progInfo.setProgress( static_cast<int>( progress + inputPropCount ) );
// Check if there are more known property keywords left on file.
// If it is, read them and create inputProperty objects
readInputPropertiesForRemainingKeywords( inputPropertyCollection, eclipseCaseData, filename, &fileKeywordSet );
i++;
}
// All input properties still unknown at this stage is missing a file
setResolvedState( inputPropertyCollection, RimEclipseInputProperty::UNKNOWN, RimEclipseInputProperty::FILE_MISSING );
}
//--------------------------------------------------------------------------------------------------
/// Loads input property data from additional files.
//--------------------------------------------------------------------------------------------------
bool RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
bool importFaults,
const std::vector<QString>& filenames )
{
for ( const QString& propertyFileName : filenames )
{
std::map<QString, QString> readProperties = RifEclipseInputFileTools::readProperties( propertyFileName,
eclipseCaseData );
std::map<QString, QString>::iterator it;
for ( it = readProperties.begin(); it != readProperties.end(); ++it )
{
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = it->first;
inputProperty->eclipseKeyword = it->second;
inputProperty->fileName = propertyFileName;
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
inputPropertyCollection->inputProperties.push_back( inputProperty );
}
// Avoid importing faults from the input property files when faults already exists in
// the eclipse case. Faults can theoretically appear in any of the files, but reading
// and appending them to the existing fault collection is not currently supported.
if ( importFaults && eclipseCaseData->mainGrid()->faults().empty() )
{
cvf::Collection<RigFault> faultCollection;
RifEclipseInputFileTools::parseAndReadFaults( propertyFileName, &faultCollection );
if ( !faultCollection.empty() )
{
eclipseCaseData->mainGrid()->setFaults( faultCollection );
}
}
}
// TODO: seems a bit optimistic?
return true;
}
//--------------------------------------------------------------------------------------------------
/// Extract keywords from a input property file.
//--------------------------------------------------------------------------------------------------
std::set<QString> RifEclipseInputPropertyLoader::extractKeywordsOnFile( const QString& filename, bool isExistingFile )
{
std::set<QString> fileKeywordSet;
if ( isExistingFile )
{
std::vector<RifKeywordAndFilePos> fileKeywords;
RifEclipseInputFileTools::findKeywordsOnFile( filename, &fileKeywords );
for ( const RifKeywordAndFilePos& fileKeyword : fileKeywords )
{
fileKeywordSet.insert( fileKeyword.keyword );
}
}
return fileKeywordSet;
}
//--------------------------------------------------------------------------------------------------
/// Change the resolved state of all matching input properties in a collection.
//--------------------------------------------------------------------------------------------------
void RifEclipseInputPropertyLoader::setResolvedState( RimEclipseInputPropertyCollection* inputPropertyCollection,
RimEclipseInputProperty::ResolveState currentState,
RimEclipseInputProperty::ResolveState newState )
{
for ( RimEclipseInputProperty* inputProperty : inputPropertyCollection->inputProperties )
{
if ( inputProperty->resolvedState() == currentState )
{
inputProperty->resolvedState = newState;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseInputPropertyLoader::readDataForEachInputProperty( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const QString& filename,
bool isExistingFile,
std::set<QString>* fileKeywordSet,
caf::ProgressInfo* progressInfo,
int progressOffset )
{
// Find the input property objects referring to the file
std::vector<RimEclipseInputProperty*> ipsUsingThisFile = inputPropertyCollection->findInputProperties( filename );
// Read property data for each inputProperty
int progress = 0;
for ( RimEclipseInputProperty* inputProperty : ipsUsingThisFile )
{
if ( !isExistingFile )
{
inputProperty->resolvedState = RimEclipseInputProperty::FILE_MISSING;
}
else
{
inputProperty->resolvedState = RimEclipseInputProperty::KEYWORD_NOT_IN_FILE;
QString kw = inputProperty->eclipseKeyword();
if ( fileKeywordSet->count( kw ) )
{
if ( RifEclipseInputFileTools::readProperty( filename, eclipseCaseData, kw, inputProperty->resultName ) )
{
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
}
}
fileKeywordSet->erase( kw );
}
progressInfo->setProgress( static_cast<int>( progressOffset + progress ) );
progress++;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseInputPropertyLoader::readInputPropertiesForRemainingKeywords(
RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const QString& filename,
std::set<QString>* fileKeywordSet )
{
for ( const QString& fileKeyword : *fileKeywordSet )
{
QString resultName = eclipseCaseData->results( RiaDefines::MATRIX_MODEL )->makeResultNameUnique( fileKeyword );
if ( RifEclipseInputFileTools::readProperty( filename, eclipseCaseData, fileKeyword, resultName ) )
{
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = resultName;
inputProperty->eclipseKeyword = fileKeyword;
inputProperty->fileName = filename;
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
inputPropertyCollection->inputProperties.push_back( inputProperty );
}
}
}

View File

@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2019- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RimEclipseInputProperty.h"
#include <set>
#include <vector>
#include <QString>
class RimEclipseInputPropertyCollection;
class RigEclipseCaseData;
namespace caf
{
class ProgressInfo;
}
//==================================================================================================
//
//
//
//==================================================================================================
class RifEclipseInputPropertyLoader
{
public:
static void loadAndSyncronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const std::vector<QString>& filenames );
static bool readInputPropertiesFromFiles( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
bool importFaults,
const std::vector<QString>& filenames );
private:
// Hide constructor to prevent instantiation
RifEclipseInputPropertyLoader();
static std::set<QString> extractKeywordsOnFile( const QString& filename, bool isExistingFile );
static void setResolvedState( RimEclipseInputPropertyCollection* inputPropertyCollection,
RimEclipseInputProperty::ResolveState currentState,
RimEclipseInputProperty::ResolveState newState );
static void readDataForEachInputProperty( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const QString& filename,
bool isExistingFile,
std::set<QString>* fileKeywordSet,
caf::ProgressInfo* progressInfo,
int progressOffset );
static void readInputPropertiesForRemainingKeywords( RimEclipseInputPropertyCollection* inputPropertyCollection,
RigEclipseCaseData* eclipseCaseData,
const QString& filename,
std::set<QString>* fileKeywordSet );
};

View File

@ -886,6 +886,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
}
else if ( dynamic_cast<RimEclipseCase*>( uiItem ) )
{
menuBuilder << "RicAddEclipseInputPropertyFeature";
menuBuilder << "RicReloadCaseFeature";
createExecuteScriptForCasesFeatureMenu( menuBuilder );
menuBuilder << "RicCloseSourSimDataFeature";

View File

@ -43,6 +43,7 @@
#include "RimEclipseCellColors.h"
#include "RimEclipseContourMapView.h"
#include "RimEclipseContourMapViewCollection.h"
#include "RimEclipseInputPropertyCollection.h"
#include "RimEclipsePropertyFilter.h"
#include "RimEclipsePropertyFilterCollection.h"
#include "RimEclipseStatisticsCase.h"
@ -95,6 +96,10 @@ RimEclipseCase::RimEclipseCase()
m_contourMapCollection = new RimEclipseContourMapViewCollection;
m_contourMapCollection.uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "" );
m_inputPropertyCollection = new RimEclipseInputPropertyCollection;
m_inputPropertyCollection->parentField()->uiCapability()->setUiHidden( true );
// Obsolete fields
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "FilesContainingFaults", "", "", "", "" );
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_filesContainingFaults_OBSOLETE );
@ -124,6 +129,7 @@ RimEclipseCase::~RimEclipseCase()
delete m_matrixModelResults();
delete m_fractureModelResults();
delete m_inputPropertyCollection;
RimProject* project = RiaApplication::instance()->project();
if ( project )
@ -544,6 +550,11 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
uiTreeOrdering.add( &m_contourMapCollection );
}
if ( !m_inputPropertyCollection->inputProperties.empty() )
{
uiTreeOrdering.add( &m_inputPropertyCollection );
}
uiTreeOrdering.skipRemainingChildren( true );
}
@ -602,6 +613,14 @@ RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection()
return m_contourMapCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseInputPropertyCollection* RimEclipseCase::inputPropertyCollection()
{
return m_inputPropertyCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -983,3 +1002,11 @@ std::vector<QDateTime> RimEclipseCase::timeStepDates() const
}
return std::vector<QDateTime>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimEclipseCase::importAsciiInputProperties( const QStringList& fileNames )
{
return false;
}

View File

@ -37,17 +37,18 @@
class QString;
class RigEclipseCaseData;
class RigCaseCellResultsData;
class RigEclipseCaseData;
class RigGridBase;
class RigMainGrid;
class RigVirtualPerforationTransmissibilities;
class RimCaseCollection;
class RimIdenticalGridCaseGroup;
class RimReservoirCellResultsStorage;
class RimEclipseContourMapView;
class RimEclipseContourMapViewCollection;
class RimEclipseInputPropertyCollection;
class RimEclipseView;
class RigVirtualPerforationTransmissibilities;
class RimIdenticalGridCaseGroup;
class RimReservoirCellResultsStorage;
//==================================================================================================
//
@ -71,6 +72,7 @@ public:
bool ensureReservoirCaseIsOpen();
bool openReserviorCase();
virtual bool openEclipseGridFile() = 0;
virtual bool importAsciiInputProperties( const QStringList& fileNames );
RigEclipseCaseData* eclipseCaseData();
const RigEclipseCaseData* eclipseCaseData() const;
@ -101,6 +103,7 @@ public:
RimCaseCollection* parentCaseCollection();
RimEclipseContourMapViewCollection* contourMapCollection();
RimEclipseInputPropertyCollection* inputPropertyCollection();
QStringList timeStepStrings() const override;
QString timeStepName( int frameIdx ) const override;
@ -137,8 +140,9 @@ private:
std::vector<Rim3dView*> allSpecialViews() const override;
protected:
caf::PdmField<bool> m_flipXAxis;
caf::PdmField<bool> m_flipYAxis;
caf::PdmField<bool> m_flipXAxis;
caf::PdmField<bool> m_flipYAxis;
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
private:
caf::PdmField<QString> m_filesContainingFaultsSemColSeparated;

View File

@ -25,6 +25,7 @@
#include "RiaPreferences.h"
#include "RifEclipseInputFileTools.h"
#include "RifEclipseInputPropertyLoader.h"
#include "RifReaderEclipseInput.h"
#include "RifReaderInterface.h"
#include "RifReaderMockModel.h"
@ -41,7 +42,6 @@
#include "RimReservoirCellResultsStorage.h"
#include "RimTools.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafProgressInfo.h"
#include <QDir>
@ -58,10 +58,6 @@ RimEclipseInputCase::RimEclipseInputCase()
CAF_PDM_InitField( &m_gridFileName, "GridFileName", QString(), "Case File Name", "", "", "" );
m_gridFileName.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "" );
m_inputPropertyCollection = new RimEclipseInputPropertyCollection;
m_inputPropertyCollection->parentField()->uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" );
m_additionalFiles.registerGetMethod( this, &RimEclipseInputCase::additionalFiles );
m_additionalFiles.uiCapability()->setUiReadOnly( true );
@ -75,9 +71,15 @@ RimEclipseInputCase::RimEclipseInputCase()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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 )
{
delete m_inputPropertyCollection;
return openDataFileSet( fileNames );
}
//--------------------------------------------------------------------------------------------------
@ -171,33 +173,10 @@ bool RimEclipseInputCase::openDataFileSet( const QStringList& fileNames )
}
}
for ( const QString& propertyFileName : filesToRead )
{
std::map<QString, QString> readProperties = RifEclipseInputFileTools::readProperties( propertyFileName,
this->eclipseCaseData() );
std::map<QString, QString>::iterator it;
for ( it = readProperties.begin(); it != readProperties.end(); ++it )
{
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = it->first;
inputProperty->eclipseKeyword = it->second;
inputProperty->fileName = propertyFileName;
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
m_inputPropertyCollection->inputProperties.push_back( inputProperty );
}
if ( importFaults )
{
cvf::Collection<RigFault> faultCollection;
RifEclipseInputFileTools::parseAndReadFaults( propertyFileName, &faultCollection );
if ( !faultCollection.empty() )
{
this->eclipseCaseData()->mainGrid()->setFaults( faultCollection );
}
}
}
RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( m_inputPropertyCollection,
this->eclipseCaseData(),
importFaults,
filesToRead );
return true;
}
@ -261,7 +240,6 @@ void RimEclipseInputCase::reloadEclipseGridFile()
openReserviorCase();
}
#define for_all( stdVector, indexName ) for ( size_t indexName = 0; indexName < stdVector.size(); ++indexName )
//--------------------------------------------------------------------------------------------------
/// Loads input property data from the gridFile and additional files
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
@ -282,101 +260,9 @@ void RimEclipseInputCase::loadAndSyncronizeInputProperties()
}
filenames.push_back( m_gridFileName );
size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size();
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() * inputPropCount ), "Reading Input properties" );
for_all( filenames, i )
{
int progress = static_cast<int>( i * inputPropCount );
// Find all the keywords present on the file
progInfo.setProgressDescription( filenames[i] );
QFileInfo fileNameInfo( filenames[i] );
bool isExistingFile = fileNameInfo.exists();
std::set<QString> fileKeywordSet;
if ( isExistingFile )
{
std::vector<RifKeywordAndFilePos> fileKeywords;
RifEclipseInputFileTools::findKeywordsOnFile( filenames[i], &fileKeywords );
for_all( fileKeywords, fkIt ) fileKeywordSet.insert( fileKeywords[fkIt].keyword );
}
// Find the input property objects referring to the file
std::vector<RimEclipseInputProperty*> ipsUsingThisFile = this->m_inputPropertyCollection()->findInputProperties(
filenames[i] );
// Read property data for each inputProperty
for_all( ipsUsingThisFile, ipIdx )
{
if ( !isExistingFile )
{
ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::FILE_MISSING;
}
else
{
QString kw = ipsUsingThisFile[ipIdx]->eclipseKeyword();
ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::KEYWORD_NOT_IN_FILE;
if ( fileKeywordSet.count( kw ) )
{
if ( RifEclipseInputFileTools::readProperty( filenames[i],
this->eclipseCaseData(),
kw,
ipsUsingThisFile[ipIdx]->resultName ) )
{
ipsUsingThisFile[ipIdx]->resolvedState = RimEclipseInputProperty::RESOLVED;
}
}
fileKeywordSet.erase( kw );
}
progInfo.setProgress( static_cast<int>( progress + ipIdx ) );
}
progInfo.setProgress( static_cast<int>( progress + inputPropCount ) );
// Check if there are more known property keywords left on file. If it is, read them and create inputProperty objects
for ( const QString& fileKeyword : fileKeywordSet )
{
{
QString resultName =
this->eclipseCaseData()->results( RiaDefines::MATRIX_MODEL )->makeResultNameUnique( fileKeyword );
if ( RifEclipseInputFileTools::readProperty( filenames[i], this->eclipseCaseData(), fileKeyword, resultName ) )
{
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
inputProperty->resultName = resultName;
inputProperty->eclipseKeyword = fileKeyword;
inputProperty->fileName = filenames[i];
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
m_inputPropertyCollection->inputProperties.push_back( inputProperty );
}
}
progInfo.setProgress( static_cast<int>( progress + inputPropCount ) );
}
}
for_all( m_inputPropertyCollection->inputProperties, i )
{
if ( m_inputPropertyCollection->inputProperties[i]->resolvedState() == RimEclipseInputProperty::UNKNOWN )
{
m_inputPropertyCollection->inputProperties[i]->resolvedState = RimEclipseInputProperty::FILE_MISSING;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimEclipseInputPropertyCollection* RimEclipseInputCase::inputPropertyCollection()
{
return m_inputPropertyCollection();
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(),
eclipseCaseData(),
filenames );
}
//--------------------------------------------------------------------------------------------------
@ -441,16 +327,6 @@ void RimEclipseInputCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
group->add( &m_flipYAxis );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseInputCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
{
uiTreeOrdering.add( &m_inputPropertyCollection );
RimEclipseCase::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -46,10 +46,9 @@ public:
// File open methods
bool openDataFileSet( const QStringList& fileNames );
bool importAsciiInputProperties( const QStringList& fileNames ) override;
void loadAndSyncronizeInputProperties();
RimEclipseInputPropertyCollection* inputPropertyCollection();
// RimCase overrides
bool openEclipseGridFile() override;
void reloadEclipseGridFile() override;
@ -70,16 +69,14 @@ private:
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
private:
cvf::ref<RifReaderInterface> createMockModel( QString modelName );
private:
// Fields
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
caf::PdmField<QString> m_gridFileName;
caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles;
caf::PdmField<QString> m_gridFileName;
caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles;
// Obsolete fields
caf::PdmField<std::vector<QString>> m_additionalFilenames_OBSOLETE;

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 );