mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2610 Import case realization parameters and store those in summary case
This commit is contained in:
parent
70f99d8da4
commit
f7f09c0719
@ -40,6 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.h
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
@ -85,6 +86,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.cpp
|
||||
|
||||
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
|
||||
|
@ -0,0 +1,200 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 "RifCaseRealizationParametersReader.h"
|
||||
#include "RifFileParseTools.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define PARAMETERS_FILE_NAME "parameters.txt"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QString& fileName)
|
||||
{
|
||||
m_parameters = new RigCaseRealizationParameters();
|
||||
m_fileName = fileName;
|
||||
m_file = nullptr;
|
||||
m_textStream = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationParametersReader::~RifCaseRealizationParametersReader()
|
||||
{
|
||||
if (m_textStream)
|
||||
{
|
||||
delete m_textStream;
|
||||
}
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::parse()
|
||||
{
|
||||
int lineNo = 0;
|
||||
QTextStream* dataStream = openDataStream();
|
||||
|
||||
try
|
||||
{
|
||||
while (!dataStream->atEnd())
|
||||
{
|
||||
QString line = dataStream->readLine();
|
||||
|
||||
lineNo++;
|
||||
QStringList cols = RifFileParseTools::splitLineAndTrim(line, " ");
|
||||
|
||||
if (cols.size() != 2)
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
QString& name = cols[0];
|
||||
QString& strValue = cols[1];
|
||||
|
||||
if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii()))
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble(strValue, &parseOk);
|
||||
if (!parseOk)
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
m_parameters->addParameter(name, value);
|
||||
}
|
||||
|
||||
closeDataStream();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
closeDataStream();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QTextStream* RifCaseRealizationParametersReader::openDataStream()
|
||||
{
|
||||
openFile();
|
||||
|
||||
m_textStream = new QTextStream(m_file);
|
||||
return m_textStream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::closeDataStream()
|
||||
{
|
||||
if (m_textStream)
|
||||
{
|
||||
delete m_textStream;
|
||||
m_textStream = nullptr;
|
||||
}
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::openFile()
|
||||
{
|
||||
if (!m_file)
|
||||
{
|
||||
m_file = new QFile(m_fileName);
|
||||
if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
closeFile();
|
||||
//delete m_file;
|
||||
//m_file = nullptr;
|
||||
throw FileParseException(QString("Failed to open %1").arg(m_fileName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::closeFile()
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
m_file->close();
|
||||
delete m_file;
|
||||
m_file = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const cvf::ref<RigCaseRealizationParameters> RifCaseRealizationParametersReader::parameters() const
|
||||
{
|
||||
return m_parameters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifCaseRealizationParametersFileLocator::locate(const QString& modelPath)
|
||||
{
|
||||
int MAX_LEVELS_UP = 2;
|
||||
int dirLevel = 0;
|
||||
|
||||
QDir qdir(modelPath);
|
||||
|
||||
const QFileInfo dir(modelPath);
|
||||
if (dir.isFile()) qdir.cdUp();
|
||||
else if (!dir.isDir()) return "";
|
||||
|
||||
do
|
||||
{
|
||||
QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (const QString& file : files)
|
||||
{
|
||||
if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return qdir.absoluteFilePath(file);
|
||||
}
|
||||
}
|
||||
qdir.cdUp();
|
||||
|
||||
} while (dirLevel++ < MAX_LEVELS_UP);
|
||||
|
||||
return "";
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 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 "RiaPreferences.h"
|
||||
|
||||
#include "RifSummaryCaseRestartSelector.h"
|
||||
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class QStringList;
|
||||
class QTextStream;
|
||||
class QFile;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifCaseRealizationParametersReader
|
||||
{
|
||||
public:
|
||||
RifCaseRealizationParametersReader(const QString& fileName);
|
||||
~RifCaseRealizationParametersReader();
|
||||
|
||||
void parse();
|
||||
const cvf::ref<RigCaseRealizationParameters> parameters() const;
|
||||
|
||||
private:
|
||||
QTextStream* openDataStream();
|
||||
void closeDataStream();
|
||||
void openFile();
|
||||
void closeFile();
|
||||
private:
|
||||
cvf::ref<RigCaseRealizationParameters> m_parameters;
|
||||
|
||||
QString m_fileName;
|
||||
QFile* m_file;
|
||||
QTextStream* m_textStream;
|
||||
};
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifCaseRealizationParametersFileLocator
|
||||
{
|
||||
public:
|
||||
static QString locate(const QString& modelPath);
|
||||
};
|
@ -17,6 +17,7 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RifEnsambleParametersReader.h"
|
||||
#include "RifCaseRealizationParametersReader.h"
|
||||
#include "RifFileParseTools.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
@ -27,20 +28,12 @@
|
||||
#include <QDir>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define PARAMETERS_FILE_NAME "parameters.txt"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& fileName)
|
||||
RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& modelDirectory)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
m_file = nullptr;
|
||||
m_textStream = nullptr;
|
||||
m_modelDirectory = modelDirectory;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -48,165 +41,16 @@ RifEnsambleParametersReader::RifEnsambleParametersReader(const QString& fileName
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEnsambleParametersReader::~RifEnsambleParametersReader()
|
||||
{
|
||||
if (m_textStream)
|
||||
{
|
||||
delete m_textStream;
|
||||
}
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEnsambleParametersReader::parse()
|
||||
RifEnsambleParametersPtr RifEnsambleParametersReader::import()
|
||||
{
|
||||
bool errors = false;
|
||||
QTextStream* dataStream = openDataStream();
|
||||
int lineNo = 0;
|
||||
RifEnsambleParametersPtr parameters;
|
||||
|
||||
try
|
||||
{
|
||||
while (!dataStream->atEnd() && !errors)
|
||||
{
|
||||
QString line = dataStream->readLine();
|
||||
|
||||
lineNo++;
|
||||
QStringList cols = RifFileParseTools::splitLineAndTrim(line, " ");
|
||||
|
||||
if (cols.size() != 2)
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid file format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
QString& name = cols[0];
|
||||
QString& strValue = cols[1];
|
||||
|
||||
if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii()))
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble(strValue, &parseOk);
|
||||
if (!parseOk)
|
||||
{
|
||||
throw FileParseException(QString("RifEnsambleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
}
|
||||
|
||||
m_parameters.addParameter(name, value);
|
||||
}
|
||||
|
||||
closeDataStream();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
closeDataStream();
|
||||
throw;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QTextStream* RifEnsambleParametersReader::openDataStream()
|
||||
{
|
||||
if (!openFile()) return nullptr;
|
||||
|
||||
m_textStream = new QTextStream(m_file);
|
||||
return m_textStream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEnsambleParametersReader::closeDataStream()
|
||||
{
|
||||
if (m_textStream)
|
||||
{
|
||||
delete m_textStream;
|
||||
m_textStream = nullptr;
|
||||
}
|
||||
closeFile();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifEnsambleParametersReader::openFile()
|
||||
{
|
||||
if (!m_file)
|
||||
{
|
||||
m_file = new QFile(m_fileName);
|
||||
if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
{
|
||||
RiaLogging::error(QString("Failed to open %1").arg(m_fileName));
|
||||
|
||||
delete m_file;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEnsambleParametersReader::closeFile()
|
||||
{
|
||||
if (m_file)
|
||||
{
|
||||
m_file->close();
|
||||
delete m_file;
|
||||
m_file = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RifEnsambleParameters& RifEnsambleParametersReader::parameters() const
|
||||
{
|
||||
return m_parameters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifEnsambleParameters::addParameter(const QString& name, double value)
|
||||
{
|
||||
m_parameters[name] = value;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString, double> RifEnsambleParameters::parameters() const
|
||||
{
|
||||
return m_parameters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifEnsambleParametersFileLocator::locate(const QString& modelPath)
|
||||
{
|
||||
int MAX_LEVELS_UP = 2;
|
||||
|
||||
int dirLevel = 0;
|
||||
QDir qdir(modelPath);
|
||||
|
||||
do
|
||||
{
|
||||
QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (const QString& file : files)
|
||||
{
|
||||
if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0)
|
||||
{
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
} while (dirLevel++ == MAX_LEVELS_UP);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
@ -18,67 +18,29 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
#include "RifSummaryCaseRestartSelector.h"
|
||||
#include "RifEnsambleParameters.h"
|
||||
|
||||
#include <QString>
|
||||
#include <QTextStream>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class QStringList;
|
||||
class QTextStream;
|
||||
class QFile;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifEnsambleParameters
|
||||
{
|
||||
public:
|
||||
void addParameter(const QString& name, double value);
|
||||
std::map<QString, double> parameters() const;
|
||||
|
||||
private:
|
||||
std::map<QString, double> m_parameters;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
// UNDER CONSTRUCTION
|
||||
//==================================================================================================
|
||||
class RifEnsambleParametersReader
|
||||
{
|
||||
public:
|
||||
RifEnsambleParametersReader(const QString& fileName);
|
||||
RifEnsambleParametersReader(const QString& modelDirectory);
|
||||
~RifEnsambleParametersReader();
|
||||
|
||||
void parse();
|
||||
const RifEnsambleParameters& parameters() const;
|
||||
RifEnsambleParametersPtr import();
|
||||
|
||||
private:
|
||||
QTextStream* openDataStream();
|
||||
void closeDataStream();
|
||||
bool openFile();
|
||||
void closeFile();
|
||||
private:
|
||||
RifEnsambleParameters m_parameters;
|
||||
|
||||
QString m_fileName;
|
||||
QFile* m_file;
|
||||
QTextStream* m_textStream;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RifEnsambleParametersFileLocator
|
||||
{
|
||||
public:
|
||||
static QString locate(const QString& modelPath);
|
||||
QString m_modelDirectory;
|
||||
};
|
||||
|
@ -83,6 +83,22 @@ bool RimSummaryCase::isObservedData()
|
||||
return m_isObservedData;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryCase::setCaseRealizationParameters(cvf::ref<RigCaseRealizationParameters> crlParameters)
|
||||
{
|
||||
m_crlParameters = crlParameters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<RigCaseRealizationParameters> RimSummaryCase::caseRealizationParameters() const
|
||||
{
|
||||
return m_crlParameters;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -17,6 +17,8 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include "RigCaseRealizationParameters.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
@ -52,6 +54,9 @@ public:
|
||||
|
||||
bool isObservedData();
|
||||
|
||||
void setCaseRealizationParameters(cvf::ref<RigCaseRealizationParameters> crlParameters);
|
||||
cvf::ref<RigCaseRealizationParameters> caseRealizationParameters() const;
|
||||
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue);
|
||||
void updateTreeItemName();
|
||||
@ -60,6 +65,8 @@ protected:
|
||||
caf::PdmField<bool> m_useAutoShortName;
|
||||
caf::PdmField<QString> m_summaryHeaderFilename;
|
||||
bool m_isObservedData;
|
||||
|
||||
cvf::ref<RigCaseRealizationParameters> m_crlParameters;
|
||||
|
||||
private:
|
||||
virtual void initAfterRead() override;
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "RifEclipseSummaryTools.h"
|
||||
#include "RifSummaryCaseRestartSelector.h"
|
||||
#include "RifCaseRealizationParametersReader.h"
|
||||
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimFileSummaryCase.h"
|
||||
@ -33,6 +34,27 @@
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimSummaryCaseMainCollection,"SummaryCaseCollection");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Internal function
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void addCaseRealizationParametersIfFound(RimSummaryCase& sumCase, const QString modelFolderOrFile)
|
||||
{
|
||||
QString parametersFile = RifCaseRealizationParametersFileLocator::locate(modelFolderOrFile);
|
||||
if (!parametersFile.isEmpty())
|
||||
{
|
||||
RifCaseRealizationParametersReader reader(parametersFile);
|
||||
|
||||
// Try parse case realization parameters
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
sumCase.setCaseRealizationParameters(reader.parameters());
|
||||
}
|
||||
catch (...) {}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -288,6 +310,7 @@ std::vector<RimSummaryCase*> RimSummaryCaseMainCollection::createAndAddSummaryCa
|
||||
newSumCase->setAssociatedEclipseCase(eclResCase);
|
||||
newSumCase->createSummaryReaderInterface();
|
||||
newSumCase->updateOptionSensitivity();
|
||||
addCaseRealizationParametersIfFound(*newSumCase, importFileInfos.front().fileName);
|
||||
sumCases.push_back(newSumCase);
|
||||
|
||||
// Remove the processed element and add 'orphan' summary cases
|
||||
@ -302,7 +325,7 @@ std::vector<RimSummaryCase*> RimSummaryCaseMainCollection::createAndAddSummaryCa
|
||||
newSumCase->setSummaryHeaderFileName(fileInfo.fileName);
|
||||
newSumCase->createSummaryReaderInterface();
|
||||
newSumCase->updateOptionSensitivity();
|
||||
|
||||
addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName);
|
||||
sumCases.push_back(newSumCase);
|
||||
}
|
||||
}
|
||||
@ -329,7 +352,7 @@ std::vector<RimSummaryCase*> RimSummaryCaseMainCollection::createAndAddSummaryCa
|
||||
newSumCase->setSummaryHeaderFileName(fileInfo.fileName);
|
||||
newSumCase->createSummaryReaderInterface();
|
||||
newSumCase->updateOptionSensitivity();
|
||||
|
||||
addCaseRealizationParametersIfFound(*newSumCase, fileInfo.fileName);
|
||||
sumCases.push_back(newSumCase);
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.h
|
||||
)
|
||||
|
||||
|
||||
@ -129,6 +130,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,36 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RigCaseRealizationParameters.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigCaseRealizationParameters::addParameter(const QString& name, double value)
|
||||
{
|
||||
m_parameters[name] = value;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<QString, double> RigCaseRealizationParameters::parameters() const
|
||||
{
|
||||
return m_parameters;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cvfObject.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RigCaseRealizationParameters : public cvf::Object
|
||||
{
|
||||
public:
|
||||
void addParameter(const QString& name, double value);
|
||||
std::map<QString, double> parameters() const;
|
||||
|
||||
private:
|
||||
std::map<QString, double> m_parameters;
|
||||
};
|
@ -40,7 +40,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifEnsambleParametersReader-Test.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader-Test.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,106 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiaTestDataDirectory.h"
|
||||
|
||||
#include "RifCaseRealizationParametersReader.h"
|
||||
#include "RifFileParseTools.h"
|
||||
|
||||
#include <QString>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
static const QString TEST_DATA_DIRECTORY = QString("%1/RifCaseRealizationParametersReader/").arg(TEST_DATA_DIR);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifCaseRealizationParametersReaderTest, LocatorTestSuccess)
|
||||
{
|
||||
QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2");
|
||||
QString expected = TEST_DATA_DIRECTORY + "parameters.txt";
|
||||
EXPECT_EQ(expected.toStdString(), file.toStdString());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifCaseRealizationParametersReaderTest, LocatorTestFailure)
|
||||
{
|
||||
QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2/1");
|
||||
QString expected = "";
|
||||
EXPECT_EQ(expected.toStdString(), file.toStdString());
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifCaseRealizationParametersReaderTest, SuccessfulParsing)
|
||||
{
|
||||
RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
const cvf::ref<RigCaseRealizationParameters> parameters = reader.parameters();
|
||||
std::map<QString, double> params = parameters->parameters();
|
||||
|
||||
EXPECT_EQ(1, params.count("LETSWOF:L_1OW"));
|
||||
EXPECT_EQ(1, params.count("LETSGOF:KRG1"));
|
||||
EXPECT_EQ(1, params.count("LOG10_MULTFLT:MULTFLT_F1"));
|
||||
|
||||
EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"]);
|
||||
EXPECT_EQ(0.97, params["LETSGOF:KRG1"]);
|
||||
EXPECT_EQ(-0.168356, params["LOG10_MULTFLT:MULTFLT_F1"]);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidFormat)
|
||||
{
|
||||
RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
catch (FileParseException e)
|
||||
{
|
||||
EXPECT_TRUE(e.message.contains("Invalid file format in line 10"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidNumberFormat)
|
||||
{
|
||||
RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
catch (FileParseException e)
|
||||
{
|
||||
EXPECT_TRUE(e.message.contains("Invalid number format in line 10"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include "RiaTestDataDirectory.h"
|
||||
|
||||
#include "RifEnsambleParametersReader.h"
|
||||
#include "RifFileParseTools.h"
|
||||
|
||||
#include <QString>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
static const QString TEST_DATA_DIRECTORY = QString("%1/RifEnsambleParametersReader/").arg(TEST_DATA_DIR);
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEnsambleParametersReaderTest, SuccessfulParsing)
|
||||
{
|
||||
RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
const RifEnsambleParameters& parameters = reader.parameters();
|
||||
std::map<QString, double> params = parameters.parameters();
|
||||
|
||||
EXPECT_TRUE(params.count("LETSWOF:L_1OW"));
|
||||
EXPECT_TRUE(params.count("LETSGOF:KRG1"));
|
||||
EXPECT_TRUE(params.count("LOG10_MULTFLT:MULTFLT_F1"));
|
||||
|
||||
EXPECT_EQ(params["LETSWOF:L_1OW"], 1.83555);
|
||||
EXPECT_EQ(params["LETSGOF:KRG1"], 0.97);
|
||||
EXPECT_EQ(params["LOG10_MULTFLT:MULTFLT_F1"], -0.168356);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidFormat)
|
||||
{
|
||||
RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
catch (FileParseException e)
|
||||
{
|
||||
EXPECT_TRUE(e.message.contains("Invalid file format in line 10"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RifEnsambleParametersReaderTest, ParseFailed_InvalidNumberFormat)
|
||||
{
|
||||
RifEnsambleParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt");
|
||||
|
||||
try
|
||||
{
|
||||
reader.parse();
|
||||
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
catch (FileParseException e)
|
||||
{
|
||||
EXPECT_TRUE(e.message.contains("Invalid number format in line 10"));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
EXPECT_TRUE(false);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user