mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Roff: allow roff files in input property import
This commit is contained in:
parent
264ad01e9e
commit
fc4294a6ad
@ -24,6 +24,7 @@
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimRoffCase.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
@ -44,6 +45,7 @@ bool RicAddEclipseInputPropertyFeature::isCommandEnabled()
|
||||
{
|
||||
return caf::SelectionManager::instance()->selectedItemOfType<RimEclipseInputCase>() ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultCase>() ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimRoffCase>() ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseCellColors>() ||
|
||||
caf::SelectionManager::instance()->selectedItemOfType<RimEclipseView>();
|
||||
}
|
||||
|
@ -51,6 +51,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifActiveCellsReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifInputPropertyLoader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceImporter.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.h
|
||||
@ -127,6 +128,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCsvDataTableFormatter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifReaderEnsembleStatisticsRft.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputPropertyLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifInputPropertyLoader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSurfaceImporter.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifRoffReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifColorLegendData.cpp
|
||||
|
@ -31,65 +31,6 @@
|
||||
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||
RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<QString>& filenames,
|
||||
bool allowImportOfFaults )
|
||||
{
|
||||
std::vector<RimEclipseInputProperty*> existingProperties = inputPropertyCollection->inputProperties.children();
|
||||
|
||||
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() ), "Reading Input properties" );
|
||||
|
||||
for ( const auto& filename : filenames )
|
||||
{
|
||||
progInfo.setProgressDescription( filename );
|
||||
|
||||
auto resultNamesEclipseKeywords = RifEclipseInputPropertyLoader::readProperties( filename, eclipseCaseData );
|
||||
|
||||
for ( const auto& [resultName, eclipseKeyword] : resultNamesEclipseKeywords )
|
||||
{
|
||||
bool isProperyPresent = false;
|
||||
bool isFaultKeywordPresent = false;
|
||||
for ( const auto* propertyObj : existingProperties )
|
||||
{
|
||||
if ( propertyObj->resultName() == resultName )
|
||||
{
|
||||
isProperyPresent = true;
|
||||
}
|
||||
else if ( propertyObj->resultName() == "FAULTS" )
|
||||
{
|
||||
isFaultKeywordPresent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isProperyPresent )
|
||||
{
|
||||
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
|
||||
inputProperty->resultName = resultName;
|
||||
inputProperty->eclipseKeyword = eclipseKeyword;
|
||||
inputProperty->fileName = filename;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
inputPropertyCollection->inputProperties.push_back( inputProperty );
|
||||
}
|
||||
|
||||
if ( allowImportOfFaults && isFaultKeywordPresent )
|
||||
{
|
||||
RifEclipseInputFileTools::importFaultsFromFile( eclipseCaseData, filename );
|
||||
}
|
||||
}
|
||||
|
||||
progInfo.incrementProgress();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
|
@ -41,21 +41,16 @@ class ProgressInfo;
|
||||
class RifEclipseInputPropertyLoader
|
||||
{
|
||||
public:
|
||||
static void loadAndSyncronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||
RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<QString>& filenames,
|
||||
bool allowImportOfFaults );
|
||||
|
||||
static void createInputPropertiesFromKeywords( RigEclipseCaseData* eclipseCase,
|
||||
const std::vector<RifEclipseKeywordContent>& keywordContent );
|
||||
|
||||
// Returns map of assigned resultName and Eclipse Keyword.
|
||||
static std::map<QString, QString> readProperties( const QString& fileName, RigEclipseCaseData* eclipseCase );
|
||||
|
||||
private:
|
||||
// Hide constructor to prevent instantiation
|
||||
RifEclipseInputPropertyLoader();
|
||||
|
||||
// Returns map of assigned resultName and Eclipse Keyword.
|
||||
static std::map<QString, QString> readProperties( const QString& fileName, RigEclipseCaseData* eclipseCase );
|
||||
|
||||
static const std::vector<QString>& invalidPropertyDataKeywords();
|
||||
static bool isValidDataKeyword( const QString& keyword );
|
||||
|
||||
|
102
ApplicationLibCode/FileInterface/RifInputPropertyLoader.cpp
Normal file
102
ApplicationLibCode/FileInterface/RifInputPropertyLoader.cpp
Normal file
@ -0,0 +1,102 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022- 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 "RifInputPropertyLoader.h"
|
||||
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "RifEclipseInputPropertyLoader.h"
|
||||
#include "RifRoffFileTools.h"
|
||||
|
||||
#include "RigEclipseCaseData.h"
|
||||
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifInputPropertyLoader::loadAndSyncronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||
RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<QString>& filenames,
|
||||
bool allowImportOfFaults )
|
||||
{
|
||||
std::vector<RimEclipseInputProperty*> existingProperties = inputPropertyCollection->inputProperties.children();
|
||||
|
||||
caf::ProgressInfo progInfo( static_cast<int>( filenames.size() ), "Reading Input properties" );
|
||||
|
||||
for ( const auto& filename : filenames )
|
||||
{
|
||||
progInfo.setProgressDescription( filename );
|
||||
|
||||
auto resultNamesEclipseKeywords = RifInputPropertyLoader::readProperties( filename, eclipseCaseData );
|
||||
|
||||
for ( const auto& [resultName, eclipseKeyword] : resultNamesEclipseKeywords )
|
||||
{
|
||||
bool isProperyPresent = false;
|
||||
bool isFaultKeywordPresent = false;
|
||||
for ( const auto* propertyObj : existingProperties )
|
||||
{
|
||||
if ( propertyObj->resultName() == resultName )
|
||||
{
|
||||
isProperyPresent = true;
|
||||
}
|
||||
else if ( propertyObj->resultName() == "FAULTS" )
|
||||
{
|
||||
isFaultKeywordPresent = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !isProperyPresent )
|
||||
{
|
||||
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
|
||||
inputProperty->resultName = resultName;
|
||||
inputProperty->eclipseKeyword = eclipseKeyword;
|
||||
inputProperty->fileName = filename;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
inputPropertyCollection->inputProperties.push_back( inputProperty );
|
||||
}
|
||||
|
||||
if ( allowImportOfFaults && isFaultKeywordPresent )
|
||||
{
|
||||
RifEclipseInputFileTools::importFaultsFromFile( eclipseCaseData, filename );
|
||||
}
|
||||
}
|
||||
|
||||
progInfo.incrementProgress();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString, QString> RifInputPropertyLoader::readProperties( const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCaseData )
|
||||
{
|
||||
RiaDefines::ImportFileType fileType = RiaDefines::obtainFileTypeFromFileName( fileName );
|
||||
if ( fileType == RiaDefines::ImportFileType::ROFF_FILE )
|
||||
{
|
||||
auto [isOk, keywordMapping] = RifRoffFileTools::createInputProperties( fileName, eclipseCaseData );
|
||||
return keywordMapping;
|
||||
}
|
||||
|
||||
return RifEclipseInputPropertyLoader::readProperties( fileName, eclipseCaseData );
|
||||
}
|
44
ApplicationLibCode/FileInterface/RifInputPropertyLoader.h
Normal file
44
ApplicationLibCode/FileInterface/RifInputPropertyLoader.h
Normal file
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2022- 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 <QString>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class RimEclipseInputPropertyCollection;
|
||||
class RigEclipseCaseData;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifInputPropertyLoader
|
||||
{
|
||||
public:
|
||||
static void loadAndSyncronizeInputProperties( RimEclipseInputPropertyCollection* inputPropertyCollection,
|
||||
RigEclipseCaseData* eclipseCaseData,
|
||||
const std::vector<QString>& filenames,
|
||||
bool allowImportOfFaults );
|
||||
|
||||
private:
|
||||
static std::map<QString, QString> readProperties( const QString& fileName, RigEclipseCaseData* eclipseCaseData );
|
||||
};
|
@ -592,17 +592,20 @@ size_t RifRoffFileTools::computeActiveCellMatrixIndex( std::vector<int>& activeC
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifRoffFileTools::createInputProperties( const QString& fileName, RigEclipseCaseData* eclipseCaseData )
|
||||
std::pair<bool, std::map<QString, QString>>
|
||||
RifRoffFileTools::createInputProperties( const QString& fileName, RigEclipseCaseData* eclipseCaseData )
|
||||
{
|
||||
RiaLogging::info( QString( "Opening roff file: %1" ).arg( fileName ) );
|
||||
|
||||
std::string filename = fileName.toStdString();
|
||||
|
||||
std::map<QString, QString> keywordMapping;
|
||||
|
||||
std::ifstream stream( filename, std::ios::binary );
|
||||
if ( !stream.good() )
|
||||
{
|
||||
RiaLogging::error( "Unable to open roff file" );
|
||||
return false;
|
||||
return std::make_pair( false, keywordMapping );
|
||||
}
|
||||
|
||||
try
|
||||
@ -634,18 +637,20 @@ bool RifRoffFileTools::createInputProperties( const QString& fileName, RigEclips
|
||||
RiaLogging::error( QString( "Unable to import result '%1' from %2" )
|
||||
.arg( QString::fromStdString( keyword ) )
|
||||
.arg( fileName ) );
|
||||
return false;
|
||||
return std::make_pair( false, keywordMapping );
|
||||
}
|
||||
|
||||
keywordMapping[QString::fromStdString( keyword )] = newResultName;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch ( std::runtime_error& err )
|
||||
{
|
||||
RiaLogging::error( QString( "Roff property file import failed: %1" ).arg( err.what() ) );
|
||||
return false;
|
||||
return std::make_pair( false, keywordMapping );
|
||||
}
|
||||
|
||||
return true;
|
||||
return std::make_pair( true, keywordMapping );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "Token.hpp"
|
||||
@ -44,7 +45,8 @@ public:
|
||||
|
||||
static bool openGridFile( const QString& fileName, RigEclipseCaseData* eclipseCase, QString* errorMessages );
|
||||
|
||||
static bool createInputProperties( const QString& fileName, RigEclipseCaseData* eclipseCase );
|
||||
static std::pair<bool, std::map<QString, QString>> createInputProperties( const QString& fileName,
|
||||
RigEclipseCaseData* eclipseCase );
|
||||
|
||||
private:
|
||||
static void interpretSplitenzData( int nz,
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
#include "RifEclipseInputPropertyLoader.h"
|
||||
#include "RifInputPropertyLoader.h"
|
||||
#include "RifReaderSettings.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
@ -739,10 +739,10 @@ void RimEclipseCase::loadAndSyncronizeInputProperties( bool importGridOrFaultDat
|
||||
filenames.push_back( fileName );
|
||||
}
|
||||
|
||||
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(),
|
||||
eclipseCaseData(),
|
||||
filenames,
|
||||
importGridOrFaultData );
|
||||
RifInputPropertyLoader::loadAndSyncronizeInputProperties( inputPropertyCollection(),
|
||||
eclipseCaseData(),
|
||||
filenames,
|
||||
importGridOrFaultData );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "RifEclipseInputPropertyLoader.h"
|
||||
#include "RifInputPropertyLoader.h"
|
||||
#include "RifReaderEclipseInput.h"
|
||||
#include "RifReaderInterface.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
@ -174,10 +174,10 @@ bool RimEclipseInputCase::openDataFileSet( const QStringList& fileNames )
|
||||
}
|
||||
}
|
||||
|
||||
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( m_inputPropertyCollection,
|
||||
this->eclipseCaseData(),
|
||||
filesToRead,
|
||||
importFaults );
|
||||
RifInputPropertyLoader::loadAndSyncronizeInputProperties( m_inputPropertyCollection,
|
||||
this->eclipseCaseData(),
|
||||
filesToRead,
|
||||
importFaults );
|
||||
|
||||
if ( importFaults )
|
||||
{
|
||||
|
@ -28,8 +28,8 @@
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
|
||||
#include "RifEclipseInputPropertyLoader.h"
|
||||
#include "RifEclipseOutputFileTools.h"
|
||||
#include "RifInputPropertyLoader.h"
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RifReaderEclipseRft.h"
|
||||
#include "RifReaderMockModel.h"
|
||||
@ -236,11 +236,10 @@ bool RimEclipseResultCase::importGridAndResultMetaData( bool showTimeStepFilter
|
||||
bool RimEclipseResultCase::importAsciiInputProperties( const QStringList& fileNames )
|
||||
{
|
||||
bool importFaults = false;
|
||||
RifEclipseInputPropertyLoader::loadAndSyncronizeInputProperties( m_inputPropertyCollection,
|
||||
this->eclipseCaseData(),
|
||||
std::vector<QString>( fileNames.begin(),
|
||||
fileNames.end() ),
|
||||
importFaults );
|
||||
RifInputPropertyLoader::loadAndSyncronizeInputProperties( m_inputPropertyCollection,
|
||||
this->eclipseCaseData(),
|
||||
std::vector<QString>( fileNames.begin(), fileNames.end() ),
|
||||
importFaults );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifInputPropertyLoader.h"
|
||||
#include "RifRoffFileTools.h"
|
||||
|
||||
#include "RigActiveCellInfo.h"
|
||||
@ -100,8 +101,12 @@ bool RimRoffCase::openEclipseGridFile()
|
||||
|
||||
results( RiaDefines::PorosityModelType::MATRIX_MODEL )->computeCellVolumes();
|
||||
|
||||
// Read properties from grid file
|
||||
RifRoffFileTools::createInputProperties( fileName, eclipseCaseData() );
|
||||
|
||||
// Read properties from input property collection
|
||||
loadAndSyncronizeInputProperties( false );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -140,3 +145,17 @@ QString RimRoffCase::locationOnDisc() const
|
||||
QFileInfo fi( gridFileName() );
|
||||
return fi.absolutePath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimRoffCase::importAsciiInputProperties( const QStringList& fileNames )
|
||||
{
|
||||
bool importFaults = false;
|
||||
RifInputPropertyLoader::loadAndSyncronizeInputProperties( m_inputPropertyCollection,
|
||||
this->eclipseCaseData(),
|
||||
std::vector<QString>( fileNames.begin(), fileNames.end() ),
|
||||
importFaults );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -37,11 +37,10 @@ public:
|
||||
RimRoffCase();
|
||||
~RimRoffCase() override;
|
||||
|
||||
// RimCase overrides
|
||||
bool openEclipseGridFile() override;
|
||||
void reloadEclipseGridFile() override;
|
||||
bool importAsciiInputProperties( const QStringList& fileNames ) override;
|
||||
|
||||
// Overrides from RimCase
|
||||
QString locationOnDisc() const override;
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user