mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#743) Added import of Input Case using opm-parser
This commit is contained in:
parent
eb6d3e0e8f
commit
830db2c6ec
ApplicationCode
ThirdParty/custom-opm-parser/opm-parser/opm/parser/eclipse/EclipseState
@ -380,6 +380,7 @@ if(RESINSIGHT_ENABLE_COTIRE)
|
||||
# using namespace cvf
|
||||
set_source_files_properties (GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
|
||||
set_source_files_properties (UnitTests/cvfGeometryTools-Test.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
|
||||
set_source_files_properties (UnitTests/opm-parser-Performance-Test.cpp PROPERTIES COTIRE_EXCLUDED TRUE)
|
||||
|
||||
set_target_properties(ResInsight PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE)
|
||||
|
||||
|
@ -44,6 +44,7 @@ ${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.h
|
||||
|
||||
# General delete of any object in a child array field
|
||||
${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h
|
||||
@ -90,6 +91,7 @@ ${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseOpmFeature.cpp
|
||||
|
||||
|
||||
# General delete of any object in a child array field
|
||||
|
100
ApplicationCode/Commands/RicImportInputEclipseCaseOpmFeature.cpp
Normal file
100
ApplicationCode/Commands/RicImportInputEclipseCaseOpmFeature.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 "RicImportInputEclipseCaseOpmFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
|
||||
#include "RimDefines.h"
|
||||
#include "RimEclipseCaseCollection.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseInputCaseOpm.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RiuMainWindow.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicImportInputEclipseCaseOpmFeature, "RicImportInputEclipseCaseOpmFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicImportInputEclipseCaseOpmFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportInputEclipseCaseOpmFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES");
|
||||
QString fileName = QFileDialog::getOpenFileName(RiuMainWindow::instance(), "Import Eclipse DATA file", defaultDir, "Eclipse Input Files and Input Properties (*.DATA *)");
|
||||
|
||||
if (fileName.isEmpty()) return;
|
||||
|
||||
// Remember the path to next time
|
||||
app->setDefaultFileDialogDirectory("INPUT_FILES", QFileInfo(fileName).absolutePath());
|
||||
|
||||
RimProject* proj = app->project();
|
||||
RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL;
|
||||
if (analysisModels)
|
||||
{
|
||||
// This code originates from RiaApplication::openInputEclipseCaseFromFileNames
|
||||
|
||||
RimEclipseInputCaseOpm* rimInputReservoir = new RimEclipseInputCaseOpm();
|
||||
proj->assignCaseIdToCase(rimInputReservoir);
|
||||
|
||||
rimInputReservoir->importNewEclipseGridAndProperties(fileName);
|
||||
|
||||
analysisModels->cases.push_back(rimInputReservoir);
|
||||
|
||||
RimEclipseView* riv = rimInputReservoir->createAndAddReservoirView();
|
||||
|
||||
riv->cellResult()->setResultType(RimDefines::INPUT_PROPERTY);
|
||||
riv->hasUserRequestedAnimation = true;
|
||||
|
||||
riv->loadDataAndUpdate();
|
||||
|
||||
if (!riv->cellResult()->hasResult())
|
||||
{
|
||||
riv->cellResult()->setResultVariable(RimDefines::undefinedResultName());
|
||||
}
|
||||
|
||||
analysisModels->updateConnectedEditors();
|
||||
|
||||
RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicImportInputEclipseCaseOpmFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
actionToSetup->setIcon(QIcon(":/EclipseInput48x48.png"));
|
||||
actionToSetup->setText("Import Input Eclipse Case (opm-parser) - BETA");
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 "cafCmdFeature.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicImportInputEclipseCaseOpmFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
virtual bool isCommandEnabled();
|
||||
virtual void onActionTriggered( bool isChecked );
|
||||
virtual void setupActionLook( QAction* actionToSetup );
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderSettings.h
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderOpmParserInput.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -36,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RifReaderOpmParserInput.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
617
ApplicationCode/FileInterface/RifReaderOpmParserInput.cpp
Normal file
617
ApplicationCode/FileInterface/RifReaderOpmParserInput.cpp
Normal file
@ -0,0 +1,617 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 "RifReaderOpmParserInput.h"
|
||||
|
||||
#include "RifReaderEclipseOutput.h"
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RimEclipseInputCaseOpm.h"
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
#include "RiuMainWindow.h"
|
||||
#include "RiuProcessMonitor.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include "opm/parser/eclipse/Deck/DeckItem.hpp"
|
||||
#include "opm/parser/eclipse/Parser/MessageContainer.hpp"
|
||||
#include "opm/parser/eclipse/Parser/ParseContext.hpp"
|
||||
#include "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmParserInput::importGridAndProperties(const QString& fileName, RigCaseData* caseData, std::map<QString, QString>* mapFromResultNameToKeyword)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Started reading of grid and properties from file : " + fileName + "\n"));
|
||||
|
||||
{
|
||||
std::shared_ptr<const Opm::EclipseGrid> eclipseGrid;
|
||||
std::string errorMessage;
|
||||
|
||||
std::shared_ptr<const Opm::Deck> deck;
|
||||
|
||||
try
|
||||
{
|
||||
Opm::Parser parser;
|
||||
|
||||
// A default ParseContext will set up all parsing errors to throw exceptions
|
||||
Opm::ParseContext parseContext;
|
||||
|
||||
for (auto state : allParserConfigKeys())
|
||||
{
|
||||
parseContext.addKey(state);
|
||||
}
|
||||
|
||||
// Treat all parsing errors as warnings
|
||||
parseContext.update(Opm::InputError::WARN);
|
||||
|
||||
deck = parser.parseFile(fileName.toStdString(), parseContext);
|
||||
|
||||
if (deck)
|
||||
{
|
||||
eclipseGrid = Opm::Parser::parseGrid(*deck, parseContext);
|
||||
|
||||
if (eclipseGrid && eclipseGrid->hasCellInfo())
|
||||
{
|
||||
if (eclipseGrid->c_ptr())
|
||||
{
|
||||
RifReaderEclipseOutput::transferGeometry(eclipseGrid->c_ptr(), caseData);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw std::invalid_argument("No valid 3D grid detected");
|
||||
}
|
||||
|
||||
Opm::TableManager tableManager(*deck);
|
||||
|
||||
Opm::Eclipse3DProperties properties(*deck, tableManager, *eclipseGrid);
|
||||
|
||||
std::vector<std::string> predefKeywords = RifReaderOpmParserInput::knownPropertyKeywords();
|
||||
for (auto keyword : predefKeywords)
|
||||
{
|
||||
if (properties.supportsGridProperty(keyword))
|
||||
{
|
||||
if (properties.hasDeckDoubleGridProperty(keyword))
|
||||
{
|
||||
auto allValues = properties.getDoubleGridProperty(keyword).getData();
|
||||
|
||||
QString newResultName = caseData->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(QString::fromStdString(keyword));
|
||||
size_t resultIndex = RifReaderOpmParserPropertyReader::findOrCreateResult(newResultName, caseData);
|
||||
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
std::vector< std::vector<double> >& newPropertyData = caseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
|
||||
newPropertyData.push_back(allValues);
|
||||
|
||||
mapFromResultNameToKeyword->insert(std::make_pair(newResultName, QString::fromStdString(keyword)));
|
||||
}
|
||||
}
|
||||
else if (properties.hasDeckIntGridProperty(keyword))
|
||||
{
|
||||
auto intValues = properties.getIntGridProperty(keyword).getData();
|
||||
|
||||
QString newResultName = caseData->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(QString::fromStdString(keyword));
|
||||
size_t resultIndex = RifReaderOpmParserPropertyReader::findOrCreateResult(newResultName, caseData);
|
||||
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
std::vector< std::vector<double> >& newPropertyData = caseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
|
||||
|
||||
std::vector<double> doubleValues;
|
||||
|
||||
doubleValues.insert(std::end(doubleValues), std::begin(intValues), std::end(intValues));
|
||||
|
||||
newPropertyData.push_back(doubleValues);
|
||||
|
||||
mapFromResultNameToKeyword->insert(std::make_pair(newResultName, QString::fromStdString(keyword)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
errorMessage = e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMessage = "Unknown exception throwm from Opm::Parser";
|
||||
}
|
||||
|
||||
if (deck)
|
||||
{
|
||||
const Opm::MessageContainer& messages = deck->getMessageContainer();
|
||||
if (messages.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog("\n\n Error messages from Deck : \n");
|
||||
}
|
||||
for (auto m : messages)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" : " + QString::fromStdString(m.message) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (eclipseGrid)
|
||||
{
|
||||
const Opm::MessageContainer& messages = eclipseGrid->getMessageContainer();
|
||||
if (messages.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog("\n\n Error messages from EclipseGrid : \n");
|
||||
}
|
||||
for (auto m : messages)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" EclipseG" + QString::fromStdString(m.message) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(errorMessage) + "\n");
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Failed reading of grid and properties from file : " + fileName + "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Completed reading of grid and properties from file : " + fileName + "\n"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderOpmParserInput::knownPropertyKeywords()
|
||||
{
|
||||
std::vector<std::string> knownKeywords;
|
||||
knownKeywords.push_back("AQUIFERA");
|
||||
knownKeywords.push_back("ACTNUM");
|
||||
knownKeywords.push_back("EQLNUM");
|
||||
knownKeywords.push_back("FIPNUM");
|
||||
knownKeywords.push_back("KRG");
|
||||
knownKeywords.push_back("KRGR");
|
||||
knownKeywords.push_back("KRO");
|
||||
knownKeywords.push_back("KRORG");
|
||||
knownKeywords.push_back("KRORW");
|
||||
knownKeywords.push_back("KRW");
|
||||
knownKeywords.push_back("KRWR");
|
||||
knownKeywords.push_back("MINPVV");
|
||||
knownKeywords.push_back("MULTPV");
|
||||
knownKeywords.push_back("MULTX");
|
||||
knownKeywords.push_back("MULTX-");
|
||||
knownKeywords.push_back("MULTY");
|
||||
knownKeywords.push_back("MULTY-");
|
||||
knownKeywords.push_back("MULTZ");
|
||||
knownKeywords.push_back("NTG");
|
||||
knownKeywords.push_back("PCG");
|
||||
knownKeywords.push_back("PCW");
|
||||
knownKeywords.push_back("PERMX");
|
||||
knownKeywords.push_back("PERMY");
|
||||
knownKeywords.push_back("PERMZ");
|
||||
knownKeywords.push_back("PORO");
|
||||
knownKeywords.push_back("PVTNUM");
|
||||
knownKeywords.push_back("SATNUM");
|
||||
knownKeywords.push_back("SGCR");
|
||||
knownKeywords.push_back("SGL");
|
||||
knownKeywords.push_back("SGLPC");
|
||||
knownKeywords.push_back("SGU");
|
||||
knownKeywords.push_back("SGWCR");
|
||||
knownKeywords.push_back("SWATINIT");
|
||||
knownKeywords.push_back("SWCR");
|
||||
knownKeywords.push_back("SWGCR");
|
||||
knownKeywords.push_back("SWL");
|
||||
knownKeywords.push_back("SWLPC");
|
||||
knownKeywords.push_back("TRANX");
|
||||
knownKeywords.push_back("TRANY");
|
||||
knownKeywords.push_back("TRANZ");
|
||||
|
||||
return knownKeywords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifReaderOpmParserInput::allParserConfigKeys()
|
||||
{
|
||||
std::vector<std::string> configKeys;
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_UNKNOWN_KEYWORD);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_RANDOM_TEXT);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_RANDOM_SLASH);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_MISSING_DIMS_KEYWORD);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_EXTRA_DATA);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_MISSING_INCLUDE);
|
||||
configKeys.push_back(Opm::ParseContext::UNSUPPORTED_SCHEDULE_GEO_MODIFIER);
|
||||
configKeys.push_back(Opm::ParseContext::UNSUPPORTED_COMPORD_TYPE);
|
||||
configKeys.push_back(Opm::ParseContext::UNSUPPORTED_INITIAL_THPRES);
|
||||
configKeys.push_back(Opm::ParseContext::INTERNAL_ERROR_UNINITIALIZED_THPRES);
|
||||
configKeys.push_back(Opm::ParseContext::PARSE_MISSING_SECTIONS);
|
||||
|
||||
return configKeys;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/*
|
||||
bool RifReaderOpmParserInput::openGridFile(const QString& fileName, bool importProperties, RigCaseData* caseData, RimEclipseInputCaseOpm* rimInputCase)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Started grid reading from file : " + fileName + "\n"));
|
||||
|
||||
{
|
||||
std::shared_ptr<const Opm::EclipseGrid> eclipseGrid;
|
||||
std::string errorMessage;
|
||||
|
||||
try
|
||||
{
|
||||
Opm::Parser parser;
|
||||
|
||||
// A default ParseContext will set up all parsing errors to throw exceptions
|
||||
Opm::ParseContext parseContext;
|
||||
parseContext.addKey("PARSE_MISSING_SECTIONS");
|
||||
|
||||
// Treat all parsing errors as warnings
|
||||
parseContext.update(Opm::InputError::WARN);
|
||||
|
||||
auto deck = parser.parseFile(fileName.toStdString(), parseContext);
|
||||
|
||||
eclipseGrid = parser.parseGrid(*deck, parseContext);
|
||||
if (eclipseGrid && eclipseGrid->c_ptr())
|
||||
{
|
||||
RifReaderEclipseOutput::transferGeometry(eclipseGrid->c_ptr(), caseData);
|
||||
|
||||
if (importProperties)
|
||||
{
|
||||
std::map<QString, QString> allPropertiesOnFile;
|
||||
RifReaderOpmParserPropertyReader::readAllProperties(deck, caseData, &allPropertiesOnFile);
|
||||
for (auto it = allPropertiesOnFile.begin(); it != allPropertiesOnFile.end(); ++it)
|
||||
{
|
||||
RimEclipseInputProperty* inputProperty = new RimEclipseInputProperty;
|
||||
inputProperty->resultName = it->first;
|
||||
inputProperty->eclipseKeyword = it->second;
|
||||
inputProperty->fileName = fileName;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
rimInputCase->m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
errorMessage = e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMessage = "Unknown exception throwm from Opm::Parser";
|
||||
}
|
||||
|
||||
if (eclipseGrid)
|
||||
{
|
||||
const Opm::MessageContainer& messages = eclipseGrid->getMessageContainer();
|
||||
for (auto m : messages)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(m.message) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(errorMessage) + "\n");
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Failed grid reading from file : " + fileName + "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Completed grid reading from file : " + fileName + "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RifReaderOpmParserPropertyReader::findOrCreateResult(const QString& newResultName, RigCaseData* reservoir)
|
||||
{
|
||||
size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
|
||||
if (resultIndex == cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false);
|
||||
}
|
||||
|
||||
return resultIndex;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString, QString> RifReaderOpmParserInput::copyPropertiesToCaseData(const QString& fileName, RigCaseData* caseData)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Started reading of properties from file : " + fileName + "\n"));
|
||||
|
||||
std::map<QString, QString> newResults;
|
||||
|
||||
{
|
||||
std::shared_ptr<const Opm::EclipseGrid> eclipseGrid;
|
||||
std::string errorMessage;
|
||||
|
||||
try
|
||||
{
|
||||
Opm::Parser parser;
|
||||
|
||||
// A default ParseContext will set up all parsing errors to throw exceptions
|
||||
Opm::ParseContext parseContext;
|
||||
|
||||
// Treat all parsing errors as warnings
|
||||
parseContext.update(Opm::InputError::WARN);
|
||||
|
||||
auto deck = parser.parseFile(fileName.toStdString(), parseContext);
|
||||
|
||||
RifReaderOpmParserPropertyReader::readAllProperties(deck, caseData, &newResults);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
errorMessage = e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMessage = "Unknown exception throwm from Opm::Parser";
|
||||
}
|
||||
|
||||
if (eclipseGrid)
|
||||
{
|
||||
const Opm::MessageContainer& messages = eclipseGrid->getMessageContainer();
|
||||
for (auto m : messages)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(m.message) + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
if (errorMessage.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(errorMessage) + "\n");
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Failed reading of properties from file : " + fileName + "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Completed reading of properties from file : " + fileName + "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
return newResults;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmParserPropertyReader::readAllProperties(std::shared_ptr< Opm::Deck > deck, RigCaseData* caseData, std::map<QString, QString>* newResults)
|
||||
{
|
||||
std::set<std::string> uniqueKeywords;
|
||||
for (auto it = deck->begin(); it != deck->end(); it++)
|
||||
{
|
||||
uniqueKeywords.insert(it->name());
|
||||
}
|
||||
|
||||
for (auto keyword : uniqueKeywords)
|
||||
{
|
||||
bool isItemCountEqual = RifReaderOpmParserPropertyReader::isDataItemCountIdenticalToMainGridCellCount(deck, keyword, caseData);
|
||||
|
||||
if (isItemCountEqual)
|
||||
{
|
||||
std::vector<double> allValues;
|
||||
|
||||
RifReaderOpmParserPropertyReader::getAllValuesForKeyword(deck, keyword, allValues);
|
||||
|
||||
QString keywordName = QString::fromStdString(keyword);
|
||||
QString newResultName = caseData->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(keywordName);
|
||||
size_t resultIndex = findOrCreateResult(newResultName, caseData);
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
std::vector< std::vector<double> >& newPropertyData = caseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
|
||||
newPropertyData.push_back(allValues);
|
||||
}
|
||||
|
||||
newResults->insert(std::make_pair(newResultName, keywordName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderOpmParserPropertyReader::RifReaderOpmParserPropertyReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderOpmParserPropertyReader::~RifReaderOpmParserPropertyReader()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderOpmParserPropertyReader::open(const QString& fileName)
|
||||
{
|
||||
{
|
||||
std::string errorMessage;
|
||||
|
||||
try
|
||||
{
|
||||
Opm::Parser parser;
|
||||
|
||||
// A default ParseContext will set up all parsing errors to throw exceptions
|
||||
Opm::ParseContext parseContext;
|
||||
|
||||
// Treat all parsing errors as warnings
|
||||
parseContext.update(Opm::InputError::WARN);
|
||||
|
||||
m_deck = parser.parseFile(fileName.toStdString(), parseContext);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
errorMessage = e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMessage = "Unknown exception throwm from Opm::Parser";
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<QString> RifReaderOpmParserPropertyReader::keywords() const
|
||||
{
|
||||
std::set<QString> ids;
|
||||
|
||||
if (m_deck)
|
||||
{
|
||||
for (auto it = m_deck->begin(); it != m_deck->end(); it++)
|
||||
{
|
||||
ids.insert(QString::fromStdString(it->name()));
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderOpmParserPropertyReader::copyPropertyToCaseData(const QString& keywordName, RigCaseData* caseData, const QString& resultName)
|
||||
{
|
||||
{
|
||||
std::string errorMessage;
|
||||
|
||||
try
|
||||
{
|
||||
std::string stdKeywordName = keywordName.toStdString();
|
||||
|
||||
if (m_deck->hasKeyword(stdKeywordName))
|
||||
{
|
||||
bool isItemCountEqual = isDataItemCountIdenticalToMainGridCellCount(m_deck, stdKeywordName, caseData);
|
||||
if (isItemCountEqual)
|
||||
{
|
||||
std::vector<double> allValues;
|
||||
|
||||
getAllValuesForKeyword(m_deck, stdKeywordName, allValues);
|
||||
|
||||
size_t resultIndex = RifReaderOpmParserPropertyReader::findOrCreateResult(resultName, caseData);
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
std::vector< std::vector<double> >& newPropertyData = caseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
|
||||
newPropertyData.push_back(allValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
errorMessage = e.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
errorMessage = "Unknown exception throwm from Opm::Parser";
|
||||
}
|
||||
|
||||
QString fileName = QString::fromStdString(m_deck->getDataFile());
|
||||
|
||||
if (errorMessage.size() > 0)
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(" " + QString::fromStdString(errorMessage) + "\n");
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Error detected while reading property %1 from file : %2\n").arg(keywordName).arg(fileName));
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuMainWindow::instance()->processMonitor()->addStringToLog(QString("Completed reading of property %1 from file : %2\n").arg(keywordName).arg(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderOpmParserPropertyReader::getAllValuesForKeyword(std::shared_ptr< Opm::Deck > deck, const std::string& keyword, std::vector<double>& allValues)
|
||||
{
|
||||
for (auto deckKeyword : deck->getKeywordList(keyword))
|
||||
{
|
||||
if (deckKeyword->isDataKeyword() && deckKeyword->size() == 1)
|
||||
{
|
||||
auto deckRecord = deckKeyword->getDataRecord();
|
||||
if (deckRecord.size() == 1)
|
||||
{
|
||||
if (deckRecord.getDataItem().typeof() == Opm::DeckItem::integer)
|
||||
{
|
||||
auto opmData = deckKeyword->getIntData();
|
||||
allValues.insert(std::end(allValues), std::begin(opmData), std::end(opmData));
|
||||
}
|
||||
else if (deckRecord.getDataItem().typeof() == Opm::DeckItem::fdouble)
|
||||
{
|
||||
auto opmData = deckKeyword->getRawDoubleData();
|
||||
allValues.insert(std::end(allValues), std::begin(opmData), std::end(opmData));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifReaderOpmParserPropertyReader::isDataItemCountIdenticalToMainGridCellCount(std::shared_ptr< Opm::Deck > deck, const std::string& keyword, RigCaseData* caseData)
|
||||
{
|
||||
bool isEqual = false;
|
||||
{
|
||||
size_t valueCount = 0;
|
||||
for (auto deckKeyword : deck->getKeywordList(keyword))
|
||||
{
|
||||
if (deckKeyword->isDataKeyword())
|
||||
{
|
||||
valueCount += deckKeyword->getDataSize();
|
||||
}
|
||||
}
|
||||
|
||||
if (valueCount == caseData->mainGrid()->cellCount())
|
||||
{
|
||||
isEqual = true;
|
||||
}
|
||||
}
|
||||
|
||||
return isEqual;
|
||||
}
|
||||
|
77
ApplicationCode/FileInterface/RifReaderOpmParserInput.h
Normal file
77
ApplicationCode/FileInterface/RifReaderOpmParserInput.h
Normal file
@ -0,0 +1,77 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include <QString>
|
||||
|
||||
class RigCaseData;
|
||||
|
||||
namespace Opm {
|
||||
class Deck;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifReaderOpmParserInput
|
||||
{
|
||||
public:
|
||||
|
||||
static void importGridAndProperties(const QString& fileName, RigCaseData* eclipseCase, std::map<QString, QString>* mapFromResultNameToKeyword);
|
||||
|
||||
/*
|
||||
static bool openGridFile(const QString& fileName, bool importProperties, RigCaseData* eclipseCase, RimEclipseInputCaseOpm* RimInputCase);
|
||||
static std::map<QString, QString> copyPropertiesToCaseData(const QString& fileName, RigCaseData* eclipseCase);
|
||||
*/
|
||||
|
||||
private:
|
||||
static std::vector<std::string> knownPropertyKeywords();
|
||||
static std::vector<std::string> allParserConfigKeys();
|
||||
};
|
||||
|
||||
|
||||
|
||||
// This class is intended to be used for reading additional properties from standalone files
|
||||
// Not yet in use
|
||||
class RifReaderOpmParserPropertyReader
|
||||
{
|
||||
public:
|
||||
RifReaderOpmParserPropertyReader();
|
||||
virtual ~RifReaderOpmParserPropertyReader();
|
||||
|
||||
bool open(const QString& fileName);
|
||||
std::set<QString> keywords() const;
|
||||
|
||||
bool copyPropertyToCaseData(const QString& keywordName, RigCaseData* eclipseCase, const QString& resultName);
|
||||
|
||||
static size_t findOrCreateResult(const QString& newResultName, RigCaseData* reservoir);
|
||||
static void readAllProperties(std::shared_ptr< Opm::Deck > deck, RigCaseData* caseData, std::map<QString, QString>* newResults);
|
||||
static void getAllValuesForKeyword(std::shared_ptr< Opm::Deck > deck, const std::string& keyword, std::vector<double>& allValues);
|
||||
static bool isDataItemCountIdenticalToMainGridCellCount(std::shared_ptr< Opm::Deck > deck, const std::string& keyword, RigCaseData* caseData);
|
||||
private:
|
||||
std::shared_ptr< Opm::Deck > m_deck;
|
||||
};
|
@ -87,7 +87,7 @@ ${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.h
|
||||
${CEE_CURRENT_LIST_DIR}RimPlotCurve.h
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@ -173,7 +173,7 @@ ${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RimEclipseInputCaseOpm.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
171
ApplicationCode/ProjectDataModel/RimEclipseInputCaseOpm.cpp
Normal file
171
ApplicationCode/ProjectDataModel/RimEclipseInputCaseOpm.cpp
Normal file
@ -0,0 +1,171 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 "RimEclipseInputCaseOpm.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifReaderOpmParserInput.h"
|
||||
#include "RifReaderSettings.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipseInputPropertyCollection.h"
|
||||
#include "RimReservoirCellResultsStorage.h"
|
||||
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <QFileInfo>
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimEclipseInputCaseOpm, "EclipseInputCaseOpm");
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseInputCaseOpm::RimEclipseInputCaseOpm()
|
||||
: RimEclipseCase()
|
||||
{
|
||||
CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", "");
|
||||
|
||||
CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,"");
|
||||
m_gridFileName.uiCapability()->setUiReadOnly(true);
|
||||
|
||||
CAF_PDM_InitFieldNoDefault(&m_inputPropertyCollection, "InputPropertyCollection", "", "", "", "");
|
||||
m_inputPropertyCollection = new RimEclipseInputPropertyCollection;
|
||||
m_inputPropertyCollection->parentField()->uiCapability()->setUiHidden(true);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseInputCaseOpm::~RimEclipseInputCaseOpm()
|
||||
{
|
||||
delete m_inputPropertyCollection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseInputCaseOpm::importNewEclipseGridAndProperties(const QString& fileName)
|
||||
{
|
||||
m_gridFileName = fileName;
|
||||
|
||||
QFileInfo gridFileName(m_gridFileName);
|
||||
QString caseName = gridFileName.completeBaseName();
|
||||
this->caseUserDescription = caseName + " (opm-parser)";
|
||||
|
||||
importEclipseGridAndProperties(m_gridFileName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseInputCaseOpm::openEclipseGridFile()
|
||||
{
|
||||
importEclipseGridAndProperties(m_gridFileName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimEclipseInputCaseOpm::locationOnDisc() const
|
||||
{
|
||||
if (m_gridFileName().isEmpty()) return QString();
|
||||
|
||||
QFileInfo fi(m_gridFileName);
|
||||
return fi.absolutePath();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseInputCaseOpm::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
bool foundFile = false;
|
||||
std::vector<QString> searchedPaths;
|
||||
|
||||
m_gridFileName = relocateFile(m_gridFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseInputCaseOpm::importEclipseGridAndProperties(const QString& fileName)
|
||||
{
|
||||
if (this->reservoirData() == NULL)
|
||||
{
|
||||
this->setReservoirData(new RigCaseData);
|
||||
|
||||
std::map<QString, QString> mapUiNameToKeyword;
|
||||
|
||||
RifReaderOpmParserInput::importGridAndProperties(fileName, reservoirData(), &mapUiNameToKeyword);
|
||||
|
||||
if (this->reservoirData()->mainGrid() == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto inputProperty : m_inputPropertyCollection->inputProperties)
|
||||
{
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::KEYWORD_NOT_IN_FILE;
|
||||
}
|
||||
|
||||
for (auto it = mapUiNameToKeyword.begin(); it != mapUiNameToKeyword.end(); ++it)
|
||||
{
|
||||
RimEclipseInputProperty* inputProperty = m_inputPropertyCollection->findInputProperty(it->first);
|
||||
|
||||
if (!inputProperty)
|
||||
{
|
||||
inputProperty = new RimEclipseInputProperty;
|
||||
|
||||
inputProperty->resultName = it->first;
|
||||
inputProperty->eclipseKeyword = it->second;
|
||||
inputProperty->fileName = fileName;
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
|
||||
m_inputPropertyCollection->inputProperties.push_back(inputProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
inputProperty->resolvedState = RimEclipseInputProperty::RESOLVED;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this->reservoirData()->mainGrid()->setFlipAxis(flipXAxis, flipYAxis);
|
||||
|
||||
computeCachedData();
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
if (app->preferences()->autocomputeDepthRelatedProperties)
|
||||
{
|
||||
RimReservoirCellResultsStorage* matrixResults = results(RifReaderInterface::MATRIX_RESULTS);
|
||||
RimReservoirCellResultsStorage* fractureResults = results(RifReaderInterface::FRACTURE_RESULTS);
|
||||
|
||||
matrixResults->computeDepthRelatedResults();
|
||||
fractureResults->computeDepthRelatedResults();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
65
ApplicationCode/ProjectDataModel/RimEclipseInputCaseOpm.h
Normal file
65
ApplicationCode/ProjectDataModel/RimEclipseInputCaseOpm.h
Normal file
@ -0,0 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016 Statoil 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 "RimEclipseCase.h"
|
||||
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfObject.h"
|
||||
|
||||
class RimEclipseInputProperty;
|
||||
class RimEclipseInputPropertyCollection;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// This class is intended to replace RimEclipseInputCase when the opm-parser is considered stable
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimEclipseInputCaseOpm : public RimEclipseCase
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimEclipseInputCaseOpm();
|
||||
virtual ~RimEclipseInputCaseOpm();
|
||||
|
||||
// Fields
|
||||
caf::PdmChildField<RimEclipseInputPropertyCollection*> m_inputPropertyCollection;
|
||||
|
||||
void importNewEclipseGridAndProperties(const QString& fileName);
|
||||
|
||||
// RimCase overrides
|
||||
virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets.
|
||||
|
||||
// Overrides from RimCase
|
||||
virtual QString locationOnDisc() const;
|
||||
virtual QString gridFileName() const { return m_gridFileName();}
|
||||
|
||||
virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath);
|
||||
|
||||
private:
|
||||
void importEclipseGridAndProperties(const QString& fileName);
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_gridFileName;
|
||||
};
|
@ -22,6 +22,7 @@ ${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}ScalarMapper-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}WellPathAsciiFileReader-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}opm-parser-Test.cpp
|
||||
${CEE_CURRENT_LIST_DIR}opm-parser-Performance-Test.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
60
ApplicationCode/UnitTests/opm-parser-Performance-Test.cpp
Normal file
60
ApplicationCode/UnitTests/opm-parser-Performance-Test.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
#include "opm/parser/eclipse/Parser/Parser.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RigCaseData.h"
|
||||
#include "RifEclipseInputFileTools.h"
|
||||
#include "RifReaderOpmParserInput.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTime>
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
using namespace Opm;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(opm_parser_test, smallCase)
|
||||
{
|
||||
/*
|
||||
// QString filename = "d:/Models/Statoil/small_ascii/10K_BOX_MSW.GRDECL";
|
||||
QString filename = "d:/Models/Statoil/testcase_juli_2011/data/grid_local.grdecl";
|
||||
|
||||
|
||||
|
||||
size_t iterationCount = 5;
|
||||
|
||||
qDebug() << "ERT reading\n";
|
||||
|
||||
for (size_t i = 0; i < iterationCount; i++)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
|
||||
RigCaseData caseData;
|
||||
|
||||
RifEclipseInputFileTools::openGridFile(filename, &caseData, false);
|
||||
|
||||
qDebug() << time.elapsed();
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "OPM reading\n";
|
||||
|
||||
for (size_t i = 0; i < iterationCount; i++)
|
||||
{
|
||||
QTime time;
|
||||
time.start();
|
||||
|
||||
RigCaseData caseData;
|
||||
|
||||
RifReaderOpmParserInput::openGridFile(filename, false, &caseData, false);
|
||||
|
||||
qDebug() << time.elapsed();
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
@ -427,6 +427,7 @@ void RiuMainWindow::createMenus()
|
||||
QMenu* importMenu = fileMenu->addMenu("&Import");
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseOpmFeature"));
|
||||
importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature"));
|
||||
importMenu->addSeparator();
|
||||
#ifdef USE_ODB_API
|
||||
|
@ -430,16 +430,18 @@ namespace Opm {
|
||||
|
||||
bool Eclipse3DProperties::hasDeckIntGridProperty(const std::string& keyword) const {
|
||||
auto kw = uppercase(keyword);
|
||||
if (!m_intGridProperties.supportsKeyword( kw ))
|
||||
throw std::logic_error("Integer grid property " + kw + " is unsupported!");
|
||||
if (!m_intGridProperties.supportsKeyword(kw))
|
||||
return false;
|
||||
//throw std::logic_error("Integer grid property " + kw + " is unsupported!");
|
||||
|
||||
return m_intGridProperties.hasKeyword( kw );
|
||||
}
|
||||
|
||||
bool Eclipse3DProperties::hasDeckDoubleGridProperty(const std::string& keyword) const {
|
||||
auto kw = uppercase(keyword);
|
||||
if (!m_doubleGridProperties.supportsKeyword( kw ))
|
||||
throw std::logic_error("Double grid property " + kw + " is unsupported!");
|
||||
if (!m_doubleGridProperties.supportsKeyword(kw))
|
||||
return false;
|
||||
//throw std::logic_error("Double grid property " + kw + " is unsupported!");
|
||||
|
||||
return m_doubleGridProperties.hasKeyword( kw );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user