mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Merge pull request #4989 from OPM/import-ascii-data-to-simulation-case
Import ascii data to simulation case
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include "RimEclipseInputCase.h"
|
#include "RimEclipseInputCase.h"
|
||||||
#include "RimEclipseInputPropertyCollection.h"
|
#include "RimEclipseInputPropertyCollection.h"
|
||||||
|
#include "RimEclipseResultCase.h"
|
||||||
|
|
||||||
#include "RiaApplication.h"
|
#include "RiaApplication.h"
|
||||||
#include "Riu3DMainWindowTools.h"
|
#include "Riu3DMainWindowTools.h"
|
||||||
@@ -39,7 +40,9 @@ CAF_CMD_SOURCE_INIT( RicAddEclipseInputPropertyFeature, "RicAddEclipseInputPrope
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
|
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 )
|
void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
||||||
{
|
{
|
||||||
RimEclipseInputPropertyCollection* inputPropertyCollection = selectedInputPropertyCollection();
|
RimEclipseCase* eclipseCase = nullptr;
|
||||||
if ( !inputPropertyCollection ) return;
|
|
||||||
|
|
||||||
QString casePath;
|
RimEclipseInputPropertyCollection* inputPropertyCollection =
|
||||||
|
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputPropertyCollection>();
|
||||||
|
if ( !inputPropertyCollection )
|
||||||
{
|
{
|
||||||
RimEclipseInputCase* inputReservoir = nullptr;
|
// No property collection selected: triggered from RimEclipseInputCase/RimEclipseResultCase.
|
||||||
inputPropertyCollection->firstAncestorOrThisOfTypeAsserted( inputReservoir );
|
eclipseCase = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCase>();
|
||||||
|
if ( eclipseCase )
|
||||||
QFileInfo fi( inputReservoir->gridFileName() );
|
{
|
||||||
casePath = fi.absolutePath();
|
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();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "INPUT_FILES", casePath );
|
QString defaultDir = app->lastUsedDialogDirectoryWithFallback( "INPUT_FILES", casePath );
|
||||||
@@ -71,8 +86,9 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
|||||||
// Remember the directory to next time
|
// Remember the directory to next time
|
||||||
defaultDir = QFileInfo( fileNames.last() ).absolutePath();
|
defaultDir = QFileInfo( fileNames.last() ).absolutePath();
|
||||||
app->setLastUsedDialogDirectory( "INPUT_FILES", defaultDir );
|
app->setLastUsedDialogDirectory( "INPUT_FILES", defaultDir );
|
||||||
|
eclipseCase->importAsciiInputProperties( fileNames );
|
||||||
addEclipseInputProperty( fileNames, inputPropertyCollection );
|
inputPropertyCollection->updateConnectedEditors();
|
||||||
|
eclipseCase->updateConnectedEditors();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -81,27 +97,5 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
|||||||
void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup )
|
void RicAddEclipseInputPropertyFeature::setupActionLook( QAction* actionToSetup )
|
||||||
{
|
{
|
||||||
actionToSetup->setText( "Add Input Property" );
|
actionToSetup->setText( "Add Input Property" );
|
||||||
}
|
actionToSetup->setIcon( QIcon( ":/EclipseInput48x48.png" ) );
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "RicEclipseCellResultToFileImpl.h"
|
#include "RicEclipseCellResultToFileImpl.h"
|
||||||
#include "RicExportFeatureImpl.h"
|
#include "RicExportFeatureImpl.h"
|
||||||
|
|
||||||
#include "RimEclipseInputCase.h"
|
#include "RimEclipseCase.h"
|
||||||
#include "RimEclipseInputProperty.h"
|
#include "RimEclipseInputProperty.h"
|
||||||
#include "RimEclipseInputPropertyCollection.h"
|
#include "RimEclipseInputPropertyCollection.h"
|
||||||
#include "RimExportInputPropertySettings.h"
|
#include "RimExportInputPropertySettings.h"
|
||||||
@@ -81,23 +81,23 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
|||||||
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
|
exportSettings.eclipseKeyword = inputProperty->eclipseKeyword;
|
||||||
|
|
||||||
// Find input reservoir for this property
|
// Find input reservoir for this property
|
||||||
RimEclipseInputCase* inputReservoir = nullptr;
|
RimEclipseCase* eclipseCase = nullptr;
|
||||||
{
|
{
|
||||||
RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimEclipseInputPropertyCollection*>(
|
RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast<RimEclipseInputPropertyCollection*>(
|
||||||
inputProperty->parentField()->ownerObject() );
|
inputProperty->parentField()->ownerObject() );
|
||||||
if ( !inputPropertyCollection ) return;
|
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();
|
RiaApplication* app = RiaApplication::instance();
|
||||||
QString projectFolder = app->currentProjectPath();
|
QString projectFolder = app->currentProjectPath();
|
||||||
if ( projectFolder.isEmpty() )
|
if ( projectFolder.isEmpty() )
|
||||||
{
|
{
|
||||||
projectFolder = inputReservoir->locationOnDisc();
|
projectFolder = eclipseCase->locationOnDisc();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
|
QString outputFileName = projectFolder + "/" + inputProperty->eclipseKeyword;
|
||||||
@@ -117,7 +117,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered( bool isChecked )
|
|||||||
|
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile( exportSettings.fileName,
|
bool isOk = RicEclipseCellResultToFileImpl::writePropertyToTextFile( exportSettings.fileName,
|
||||||
inputReservoir->eclipseCaseData(),
|
eclipseCase->eclipseCaseData(),
|
||||||
0,
|
0,
|
||||||
inputProperty->resultName,
|
inputProperty->resultName,
|
||||||
exportSettings.eclipseKeyword,
|
exportSettings.eclipseKeyword,
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.h
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/RifDerivedEnsembleReader.h
|
${CMAKE_CURRENT_LIST_DIR}/RifDerivedEnsembleReader.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader.h
|
${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader.h
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.h
|
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.h
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.h
|
||||||
|
|
||||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h
|
#${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}/RifActiveCellsReader.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.cpp
|
${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.cpp
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.cpp
|
||||||
|
|
||||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||||
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp
|
#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ bool RifEclipseInputFileTools::exportGrid( const QString& fileName,
|
|||||||
cvf::Vec2f origin( mapAxes[2] - minPoint2f.x(), mapAxes[3] - minPoint2f.y() );
|
cvf::Vec2f origin( mapAxes[2] - minPoint2f.x(), mapAxes[3] - minPoint2f.y() );
|
||||||
cvf::Vec2f xPoint = cvf::Vec2f( mapAxes[4], mapAxes[5] ) - minPoint2f;
|
cvf::Vec2f xPoint = cvf::Vec2f( mapAxes[4], mapAxes[5] ) - minPoint2f;
|
||||||
cvf::Vec2f yPoint = cvf::Vec2f( mapAxes[0], mapAxes[1] ) - 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 );
|
mapAxisTrans.setTranslation( mapAxisTrans.translation() - minPoint3d );
|
||||||
}
|
}
|
||||||
@@ -875,25 +875,31 @@ bool RifEclipseInputFileTools::readDataFromKeyword( ecl_kw_type* eclipseK
|
|||||||
CVF_ASSERT( eclipseKeywordData );
|
CVF_ASSERT( eclipseKeywordData );
|
||||||
CVF_ASSERT( errMsg );
|
CVF_ASSERT( errMsg );
|
||||||
|
|
||||||
bool mathingItemCount = false;
|
// Number of values to allocate in the result data structure. Must either be number of active cells or
|
||||||
size_t keywordItemCount = 0u;
|
// 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() )
|
if ( keywordItemCount == caseData->mainGrid()->cellCount() )
|
||||||
{
|
{
|
||||||
mathingItemCount = true;
|
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;
|
mathingItemCount = true;
|
||||||
|
scalarValueCount = caseData->activeCellInfo( RiaDefines::MATRIX_MODEL )->reservoirActiveCellCount();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ( !mathingItemCount )
|
if ( !mathingItemCount )
|
||||||
{
|
{
|
||||||
QString errFormat( "Size mismatch: Main Grid has %1 cells, keyword %2 has %3 cells" );
|
QString errFormat( "Size mismatch: Main Grid has %1 cells, keyword %2 has %3 cells" );
|
||||||
*errMsg = errFormat.arg( caseData->mainGrid()->cellCount() ).arg( resultName ).arg( keywordItemCount );
|
*errMsg = errFormat.arg( caseData->mainGrid()->cellCount() ).arg( resultName ).arg( keywordItemCount );
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RigEclipseResultAddress resAddr( RiaDefines::INPUT_PROPERTY, resultName );
|
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 );
|
auto newPropertyData = caseData->results( RiaDefines::MATRIX_MODEL )->modifiableCellScalarResultTimesteps( resAddr );
|
||||||
|
|
||||||
newPropertyData->push_back( std::vector<double>() );
|
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() );
|
ecl_kw_get_data_as_double( eclipseKeywordData, newPropertyData->at( 0 ).data() );
|
||||||
|
|
||||||
|
|||||||
227
ApplicationCode/FileInterface/RifEclipseInputPropertyLoader.cpp
Normal file
227
ApplicationCode/FileInterface/RifEclipseInputPropertyLoader.cpp
Normal 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 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 );
|
||||||
|
};
|
||||||
@@ -886,6 +886,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
|||||||
}
|
}
|
||||||
else if ( dynamic_cast<RimEclipseCase*>( uiItem ) )
|
else if ( dynamic_cast<RimEclipseCase*>( uiItem ) )
|
||||||
{
|
{
|
||||||
|
menuBuilder << "RicAddEclipseInputPropertyFeature";
|
||||||
menuBuilder << "RicReloadCaseFeature";
|
menuBuilder << "RicReloadCaseFeature";
|
||||||
createExecuteScriptForCasesFeatureMenu( menuBuilder );
|
createExecuteScriptForCasesFeatureMenu( menuBuilder );
|
||||||
menuBuilder << "RicCloseSourSimDataFeature";
|
menuBuilder << "RicCloseSourSimDataFeature";
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
#include "RimEclipseContourMapView.h"
|
#include "RimEclipseContourMapView.h"
|
||||||
#include "RimEclipseContourMapViewCollection.h"
|
#include "RimEclipseContourMapViewCollection.h"
|
||||||
|
#include "RimEclipseInputPropertyCollection.h"
|
||||||
#include "RimEclipsePropertyFilter.h"
|
#include "RimEclipsePropertyFilter.h"
|
||||||
#include "RimEclipsePropertyFilterCollection.h"
|
#include "RimEclipsePropertyFilterCollection.h"
|
||||||
#include "RimEclipseStatisticsCase.h"
|
#include "RimEclipseStatisticsCase.h"
|
||||||
@@ -95,6 +96,10 @@ RimEclipseCase::RimEclipseCase()
|
|||||||
m_contourMapCollection = new RimEclipseContourMapViewCollection;
|
m_contourMapCollection = new RimEclipseContourMapViewCollection;
|
||||||
m_contourMapCollection.uiCapability()->setUiTreeHidden( true );
|
m_contourMapCollection.uiCapability()->setUiTreeHidden( true );
|
||||||
|
|
||||||
|
CAF_PDM_InitFieldNoDefault( &m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "" );
|
||||||
|
m_inputPropertyCollection = new RimEclipseInputPropertyCollection;
|
||||||
|
m_inputPropertyCollection->parentField()->uiCapability()->setUiHidden( true );
|
||||||
|
|
||||||
// Obsolete fields
|
// Obsolete fields
|
||||||
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "FilesContainingFaults", "", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_filesContainingFaults_OBSOLETE, "FilesContainingFaults", "", "", "", "" );
|
||||||
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_filesContainingFaults_OBSOLETE );
|
RiaFieldhandleTools::disableWriteAndSetFieldHidden( &m_filesContainingFaults_OBSOLETE );
|
||||||
@@ -124,6 +129,7 @@ RimEclipseCase::~RimEclipseCase()
|
|||||||
|
|
||||||
delete m_matrixModelResults();
|
delete m_matrixModelResults();
|
||||||
delete m_fractureModelResults();
|
delete m_fractureModelResults();
|
||||||
|
delete m_inputPropertyCollection;
|
||||||
|
|
||||||
RimProject* project = RiaApplication::instance()->project();
|
RimProject* project = RiaApplication::instance()->project();
|
||||||
if ( project )
|
if ( project )
|
||||||
@@ -544,6 +550,11 @@ void RimEclipseCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrderin
|
|||||||
uiTreeOrdering.add( &m_contourMapCollection );
|
uiTreeOrdering.add( &m_contourMapCollection );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !m_inputPropertyCollection->inputProperties.empty() )
|
||||||
|
{
|
||||||
|
uiTreeOrdering.add( &m_inputPropertyCollection );
|
||||||
|
}
|
||||||
|
|
||||||
uiTreeOrdering.skipRemainingChildren( true );
|
uiTreeOrdering.skipRemainingChildren( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -602,6 +613,14 @@ RimEclipseContourMapViewCollection* RimEclipseCase::contourMapCollection()
|
|||||||
return m_contourMapCollection;
|
return m_contourMapCollection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RimEclipseInputPropertyCollection* RimEclipseCase::inputPropertyCollection()
|
||||||
|
{
|
||||||
|
return m_inputPropertyCollection();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -983,3 +1002,11 @@ std::vector<QDateTime> RimEclipseCase::timeStepDates() const
|
|||||||
}
|
}
|
||||||
return std::vector<QDateTime>();
|
return std::vector<QDateTime>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimEclipseCase::importAsciiInputProperties( const QStringList& fileNames )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -37,17 +37,18 @@
|
|||||||
|
|
||||||
class QString;
|
class QString;
|
||||||
|
|
||||||
class RigEclipseCaseData;
|
|
||||||
class RigCaseCellResultsData;
|
class RigCaseCellResultsData;
|
||||||
|
class RigEclipseCaseData;
|
||||||
class RigGridBase;
|
class RigGridBase;
|
||||||
class RigMainGrid;
|
class RigMainGrid;
|
||||||
|
class RigVirtualPerforationTransmissibilities;
|
||||||
class RimCaseCollection;
|
class RimCaseCollection;
|
||||||
class RimIdenticalGridCaseGroup;
|
|
||||||
class RimReservoirCellResultsStorage;
|
|
||||||
class RimEclipseContourMapView;
|
class RimEclipseContourMapView;
|
||||||
class RimEclipseContourMapViewCollection;
|
class RimEclipseContourMapViewCollection;
|
||||||
|
class RimEclipseInputPropertyCollection;
|
||||||
class RimEclipseView;
|
class RimEclipseView;
|
||||||
class RigVirtualPerforationTransmissibilities;
|
class RimIdenticalGridCaseGroup;
|
||||||
|
class RimReservoirCellResultsStorage;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
@@ -71,6 +72,7 @@ public:
|
|||||||
bool ensureReservoirCaseIsOpen();
|
bool ensureReservoirCaseIsOpen();
|
||||||
bool openReserviorCase();
|
bool openReserviorCase();
|
||||||
virtual bool openEclipseGridFile() = 0;
|
virtual bool openEclipseGridFile() = 0;
|
||||||
|
virtual bool importAsciiInputProperties( const QStringList& fileNames );
|
||||||
|
|
||||||
RigEclipseCaseData* eclipseCaseData();
|
RigEclipseCaseData* eclipseCaseData();
|
||||||
const RigEclipseCaseData* eclipseCaseData() const;
|
const RigEclipseCaseData* eclipseCaseData() const;
|
||||||
@@ -101,6 +103,7 @@ public:
|
|||||||
|
|
||||||
RimCaseCollection* parentCaseCollection();
|
RimCaseCollection* parentCaseCollection();
|
||||||
RimEclipseContourMapViewCollection* contourMapCollection();
|
RimEclipseContourMapViewCollection* contourMapCollection();
|
||||||
|
RimEclipseInputPropertyCollection* inputPropertyCollection();
|
||||||
|
|
||||||
QStringList timeStepStrings() const override;
|
QStringList timeStepStrings() const override;
|
||||||
QString timeStepName( int frameIdx ) const override;
|
QString timeStepName( int frameIdx ) const override;
|
||||||
@@ -137,8 +140,9 @@ private:
|
|||||||
std::vector<Rim3dView*> allSpecialViews() const override;
|
std::vector<Rim3dView*> allSpecialViews() const override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
caf::PdmField<bool> m_flipXAxis;
|
caf::PdmField<bool> m_flipXAxis;
|
||||||
caf::PdmField<bool> m_flipYAxis;
|
caf::PdmField<bool> m_flipYAxis;
|
||||||
|
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
caf::PdmField<QString> m_filesContainingFaultsSemColSeparated;
|
caf::PdmField<QString> m_filesContainingFaultsSemColSeparated;
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "RiaPreferences.h"
|
#include "RiaPreferences.h"
|
||||||
|
|
||||||
#include "RifEclipseInputFileTools.h"
|
#include "RifEclipseInputFileTools.h"
|
||||||
|
#include "RifEclipseInputPropertyLoader.h"
|
||||||
#include "RifReaderEclipseInput.h"
|
#include "RifReaderEclipseInput.h"
|
||||||
#include "RifReaderInterface.h"
|
#include "RifReaderInterface.h"
|
||||||
#include "RifReaderMockModel.h"
|
#include "RifReaderMockModel.h"
|
||||||
@@ -41,7 +42,6 @@
|
|||||||
#include "RimReservoirCellResultsStorage.h"
|
#include "RimReservoirCellResultsStorage.h"
|
||||||
#include "RimTools.h"
|
#include "RimTools.h"
|
||||||
|
|
||||||
#include "cafPdmUiTreeOrdering.h"
|
|
||||||
#include "cafProgressInfo.h"
|
#include "cafProgressInfo.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
@@ -58,10 +58,6 @@ RimEclipseInputCase::RimEclipseInputCase()
|
|||||||
CAF_PDM_InitField( &m_gridFileName, "GridFileName", QString(), "Case File Name", "", "", "" );
|
CAF_PDM_InitField( &m_gridFileName, "GridFileName", QString(), "Case File Name", "", "", "" );
|
||||||
m_gridFileName.uiCapability()->setUiReadOnly( true );
|
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", "", "", "" );
|
CAF_PDM_InitFieldNoDefault( &m_additionalFiles, "AdditionalFileNamesProxy", "Additional Files", "", "", "" );
|
||||||
m_additionalFiles.registerGetMethod( this, &RimEclipseInputCase::additionalFiles );
|
m_additionalFiles.registerGetMethod( this, &RimEclipseInputCase::additionalFiles );
|
||||||
m_additionalFiles.uiCapability()->setUiReadOnly( true );
|
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 )
|
RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( m_inputPropertyCollection,
|
||||||
{
|
this->eclipseCaseData(),
|
||||||
std::map<QString, QString> readProperties = RifEclipseInputFileTools::readProperties( propertyFileName,
|
importFaults,
|
||||||
this->eclipseCaseData() );
|
filesToRead );
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +240,6 @@ void RimEclipseInputCase::reloadEclipseGridFile()
|
|||||||
openReserviorCase();
|
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
|
/// Loads input property data from the gridFile and additional files
|
||||||
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
|
/// Creates new InputProperties if necessary, and flags the unused ones as obsolete
|
||||||
@@ -282,101 +260,9 @@ void RimEclipseInputCase::loadAndSyncronizeInputProperties()
|
|||||||
}
|
}
|
||||||
filenames.push_back( m_gridFileName );
|
filenames.push_back( m_gridFileName );
|
||||||
|
|
||||||
size_t inputPropCount = this->m_inputPropertyCollection()->inputProperties.size();
|
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(),
|
||||||
|
eclipseCaseData(),
|
||||||
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() * inputPropCount ), "Reading Input properties" );
|
filenames );
|
||||||
|
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -441,16 +327,6 @@ void RimEclipseInputCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrde
|
|||||||
group->add( &m_flipYAxis );
|
group->add( &m_flipYAxis );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
///
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
|
||||||
void RimEclipseInputCase::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/ )
|
|
||||||
{
|
|
||||||
uiTreeOrdering.add( &m_inputPropertyCollection );
|
|
||||||
|
|
||||||
RimEclipseCase::defineUiTreeOrdering( uiTreeOrdering, uiConfigName );
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -46,10 +46,9 @@ public:
|
|||||||
|
|
||||||
// File open methods
|
// File open methods
|
||||||
bool openDataFileSet( const QStringList& fileNames );
|
bool openDataFileSet( const QStringList& fileNames );
|
||||||
|
bool importAsciiInputProperties( const QStringList& fileNames ) override;
|
||||||
void loadAndSyncronizeInputProperties();
|
void loadAndSyncronizeInputProperties();
|
||||||
|
|
||||||
RimEclipseInputPropertyCollection* inputPropertyCollection();
|
|
||||||
|
|
||||||
// RimCase overrides
|
// RimCase overrides
|
||||||
bool openEclipseGridFile() override;
|
bool openEclipseGridFile() override;
|
||||||
void reloadEclipseGridFile() override;
|
void reloadEclipseGridFile() override;
|
||||||
@@ -70,16 +69,14 @@ private:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cvf::ref<RifReaderInterface> createMockModel( QString modelName );
|
cvf::ref<RifReaderInterface> createMockModel( QString modelName );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Fields
|
// Fields
|
||||||
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
|
caf::PdmField<QString> m_gridFileName;
|
||||||
caf::PdmField<QString> m_gridFileName;
|
caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles;
|
||||||
caf::PdmProxyValueField<std::vector<QString>> m_additionalFiles;
|
|
||||||
|
|
||||||
// Obsolete fields
|
// Obsolete fields
|
||||||
caf::PdmField<std::vector<QString>> m_additionalFilenames_OBSOLETE;
|
caf::PdmField<std::vector<QString>> m_additionalFilenames_OBSOLETE;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "RicfCommandObject.h"
|
#include "RicfCommandObject.h"
|
||||||
|
|
||||||
|
#include "RifEclipseInputPropertyLoader.h"
|
||||||
#include "RifEclipseOutputFileTools.h"
|
#include "RifEclipseOutputFileTools.h"
|
||||||
#include "RifReaderEclipseOutput.h"
|
#include "RifReaderEclipseOutput.h"
|
||||||
#include "RifReaderEclipseRft.h"
|
#include "RifReaderEclipseRft.h"
|
||||||
@@ -41,6 +42,8 @@
|
|||||||
|
|
||||||
#include "RimDialogData.h"
|
#include "RimDialogData.h"
|
||||||
#include "RimEclipseCellColors.h"
|
#include "RimEclipseCellColors.h"
|
||||||
|
#include "RimEclipseInputProperty.h"
|
||||||
|
#include "RimEclipseInputPropertyCollection.h"
|
||||||
#include "RimEclipseView.h"
|
#include "RimEclipseView.h"
|
||||||
#include "RimFlowDiagSolution.h"
|
#include "RimFlowDiagSolution.h"
|
||||||
#include "RimMockModelSettings.h"
|
#include "RimMockModelSettings.h"
|
||||||
@@ -239,6 +242,18 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
bool RimEclipseResultCase::importAsciiInputProperties( const QStringList& fileNames )
|
||||||
|
{
|
||||||
|
bool importFaults = false;
|
||||||
|
return RifEclipseInputPropertyLoader::readInputPropertiesFromFiles( m_inputPropertyCollection,
|
||||||
|
this->eclipseCaseData(),
|
||||||
|
importFaults,
|
||||||
|
fileNames.toVector().toStdVector() );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -26,11 +26,13 @@
|
|||||||
|
|
||||||
#include <cafPdmProxyValueField.h>
|
#include <cafPdmProxyValueField.h>
|
||||||
|
|
||||||
class RifReaderInterface;
|
|
||||||
class RigMainGrid;
|
|
||||||
class RimFlowDiagSolution;
|
|
||||||
class RigFlowDiagSolverInterface;
|
|
||||||
class RifReaderEclipseRft;
|
class RifReaderEclipseRft;
|
||||||
|
class RifReaderInterface;
|
||||||
|
class RigFlowDiagSolverInterface;
|
||||||
|
class RigMainGrid;
|
||||||
|
class RimEclipseInputProperty;
|
||||||
|
class RimEclipseInputPropertyCollection;
|
||||||
|
class RimFlowDiagSolution;
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
//
|
//
|
||||||
@@ -53,6 +55,7 @@ public:
|
|||||||
bool openEclipseGridFile() override;
|
bool openEclipseGridFile() override;
|
||||||
|
|
||||||
bool importGridAndResultMetaData( bool showTimeStepFilter );
|
bool importGridAndResultMetaData( bool showTimeStepFilter );
|
||||||
|
bool importAsciiInputProperties( const QStringList& fileNames );
|
||||||
|
|
||||||
void reloadEclipseGridFile() override;
|
void reloadEclipseGridFile() override;
|
||||||
bool openAndReadActiveCellData( RigEclipseCaseData* mainEclipseCase );
|
bool openAndReadActiveCellData( RigEclipseCaseData* mainEclipseCase );
|
||||||
|
|||||||
Reference in New Issue
Block a user