Merge branch 'dev' into hdf-prototype

This commit is contained in:
Magne Sjaastad
2017-08-14 10:47:44 +02:00
443 changed files with 20467 additions and 3429 deletions

View File

@@ -5,12 +5,14 @@ if (${CMAKE_VERSION} VERSION_GREATER "2.8.2")
endif()
set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.h
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h
@@ -19,6 +21,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}RifWellPathImporter.h
${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h
# HDF5 file reader is directly included in ResInsight main CmakeList.txt
@@ -26,12 +29,14 @@ ${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp
@@ -40,6 +45,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}RifWellPathImporter.cpp
${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.cpp
# HDF5 file reader is directly included in ResInsight main CmakeList.txt

View File

@@ -0,0 +1,289 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 "RifEclipseDataTableFormatter.h"
#include "cvfAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out) : m_out(out)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter::~RifEclipseDataTableFormatter()
{
CVF_ASSERT(m_buffer.empty());
CVF_ASSERT(m_columns.empty());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseDataTableFormatter::outputBuffer()
{
if (m_columns.size() > 0)
{
m_out << "-- ";
for (RifEclipseOutputTableColumn& column : m_columns)
{
m_out << formatColumn(column.title, column);
}
m_out << "\n";
}
for (auto line : m_buffer)
{
if (line.lineType == COMMENT)
{
outputComment(line);
}
else if (line.lineType == CONTENTS)
{
m_out << " ";
for (size_t i = 0; i < line.data.size(); ++i)
{
m_out << formatColumn(line.data[i], m_columns[i]);
}
m_out << " /" << "\n";
}
}
m_columns.clear();
m_buffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseDataTableFormatter::outputComment(RifEclipseOutputTableLine& comment)
{
m_out << "-- " << comment.data[0] << "\n";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseDataTableFormatter::tableCompleted()
{
outputBuffer();
// Output an "empty" line after a finished table
m_out << "/\n";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::keyword(const QString keyword)
{
CVF_ASSERT(m_buffer.empty());
CVF_ASSERT(m_columns.empty());
m_out << keyword << "\n";
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::header(const std::vector<RifEclipseOutputTableColumn> header)
{
outputBuffer();
m_columns = header;
for (RifEclipseOutputTableColumn& column : m_columns)
{
column.width = measure(column.title);
}
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::comment(const QString comment)
{
RifEclipseOutputTableLine line;
line.data.push_back(comment);
line.lineType = COMMENT;
if (m_columns.empty())
{
outputComment(line);
}
else
{
m_buffer.push_back(line);
}
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::add(const QString str)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(str), m_columns[column].width);
m_lineBuffer.push_back(str);
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::add(double num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num, m_columns[column].doubleFormat), m_columns[column].width);
m_lineBuffer.push_back(format(num, m_columns[column].doubleFormat));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::add(int num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num), m_columns[column].width);
m_lineBuffer.push_back(format(num));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::add(size_t num)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
m_columns[column].width = std::max(measure(num), m_columns[column].width);
m_lineBuffer.push_back(format(num));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::addZeroBasedCellIndex(size_t index)
{
size_t column = m_lineBuffer.size();
CVF_ASSERT(column < m_columns.size());
// Increase index by 1 to use Eclipse 1-based cell index instead of ResInsight 0-based
index++;
m_columns[column].width = std::max(measure(index), m_columns[column].width);
m_lineBuffer.push_back(format(index));
return *this;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifEclipseDataTableFormatter::rowCompleted()
{
RifEclipseOutputTableLine line;
line.data = m_lineBuffer;
line.lineType = CONTENTS;
m_buffer.push_back(line);
m_lineBuffer.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseDataTableFormatter::measure(const QString str)
{
return str.length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseDataTableFormatter::measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat)
{
return format(num, doubleFormat).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseDataTableFormatter::measure(int num)
{
return format(num).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifEclipseDataTableFormatter::measure(size_t num)
{
return format(num).length();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat)
{
switch (doubleFormat.format)
{
case RifEclipseOutputTableDoubleFormat::RIF_FLOAT:
return QString("%1").arg(num, 0, 'f', doubleFormat.width);
case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC:
return QString("%1").arg(num, 0, 'E');
default:
return QString("%1");
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseDataTableFormatter::format(int num)
{
return QString("%1").arg(num);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseDataTableFormatter::format(size_t num)
{
return QString("%1").arg(num);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RifEclipseDataTableFormatter::formatColumn(const QString str, RifEclipseOutputTableColumn column)
{
if (column.alignment == LEFT)
{
return str.leftJustified(column.width + m_colSpacing, ' ');
}
else
{
return str.rightJustified(column.width, ' ').leftJustified(m_colSpacing, ' ');
}
}

View File

@@ -0,0 +1,140 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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 <QString>
#include <QTextStream>
#include <vector>
//==================================================================================================
//
//==================================================================================================
enum RifEclipseOutputTableLineType
{
COMMENT,
CONTENTS
};
//==================================================================================================
//
//==================================================================================================
enum RifEclipseOutputTableAlignment
{
LEFT,
RIGHT
};
//==================================================================================================
//
//==================================================================================================
enum RifEclipseOutputTableDoubleFormat
{
RIF_SCIENTIFIC,
RIF_FLOAT,
};
//==================================================================================================
//
//==================================================================================================
struct RifEclipseOutputTableLine
{
RifEclipseOutputTableLineType lineType;
std::vector< QString > data;
};
//==================================================================================================
//
//==================================================================================================
struct RifEclipseOutputTableDoubleFormatting
{
RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat format = RIF_FLOAT, int width = 5)
: format(format),
width(width)
{}
RifEclipseOutputTableDoubleFormat format;
int width;
};
//==================================================================================================
//
//==================================================================================================
struct RifEclipseOutputTableColumn
{
RifEclipseOutputTableColumn(const QString& title,
RifEclipseOutputTableDoubleFormatting doubleFormat = RifEclipseOutputTableDoubleFormatting(),
RifEclipseOutputTableAlignment alignment = LEFT,
int width = -1)
: title(title),
doubleFormat(doubleFormat),
alignment(alignment),
width(width)
{
}
QString title;
RifEclipseOutputTableDoubleFormatting doubleFormat;
RifEclipseOutputTableAlignment alignment;
int width;
};
//==================================================================================================
//
//==================================================================================================
class RifEclipseDataTableFormatter
{
public:
RifEclipseDataTableFormatter(QTextStream& out);
virtual ~RifEclipseDataTableFormatter();
RifEclipseDataTableFormatter& keyword(const QString keyword);
RifEclipseDataTableFormatter& header(std::vector<RifEclipseOutputTableColumn> tableHeader);
RifEclipseDataTableFormatter& add(const QString str);
RifEclipseDataTableFormatter& add(double num);
RifEclipseDataTableFormatter& add(int num);
RifEclipseDataTableFormatter& add(size_t num);
RifEclipseDataTableFormatter& addZeroBasedCellIndex(size_t index);
RifEclipseDataTableFormatter& comment(const QString str);
void rowCompleted();
void tableCompleted();
private:
int measure(const QString str);
int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
int measure(int num);
int measure(size_t num);
QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat);
QString format(int num);
QString format(size_t num);
QString formatColumn(const QString str, RifEclipseOutputTableColumn column);
void outputBuffer();
void outputComment(RifEclipseOutputTableLine& comment);
private:
std::vector<RifEclipseOutputTableColumn> m_columns;
std::vector<RifEclipseOutputTableLine> m_buffer;
std::vector<QString> m_lineBuffer;
QTextStream& m_out;
int m_colSpacing = 5;
};

View File

@@ -231,7 +231,7 @@ std::map<QString, QString> RifEclipseInputFileTools::readProperties(const QStrin
ecl_kw_type* eclipseKeywordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false, ecl_type_create_from_type(ECL_FLOAT_TYPE));
if (eclipseKeywordData)
{
QString newResultName = caseData->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword);
QString newResultName = caseData->results(RiaDefines::MATRIX_MODEL)->makeResultNameUnique(fileKeywords[i].keyword);
if (readDataFromKeyword(eclipseKeywordData, caseData, newResultName))
{
newResults[newResultName] = fileKeywords[i].keyword;
@@ -290,7 +290,7 @@ bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordDa
{
mathingItemCount = true;
}
if (itemCount == caseData->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->reservoirActiveCellCount())
if (itemCount == caseData->activeCellInfo(RiaDefines::MATRIX_MODEL)->reservoirActiveCellCount())
{
mathingItemCount = true;
}
@@ -301,7 +301,7 @@ bool RifEclipseInputFileTools::readDataFromKeyword(ecl_kw_type* eclipseKeywordDa
size_t resultIndex = RifEclipseInputFileTools::findOrCreateResult(resultName, caseData);
if (resultIndex == cvf::UNDEFINED_SIZE_T) return false;
std::vector< std::vector<double> >& newPropertyData = caseData->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& newPropertyData = caseData->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(resultIndex);
newPropertyData.push_back(std::vector<double>());
newPropertyData[0].resize(ecl_kw_get_size(eclipseKeywordData), HUGE_VAL);
ecl_kw_get_data_as_double(eclipseKeywordData, newPropertyData[0].data());
@@ -446,7 +446,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
{
CVF_ASSERT(eclipseCase);
size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName);
size_t resultIndex = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(resultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
return false;
@@ -458,7 +458,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName,
return false;
}
std::vector< std::vector<double> >& resultData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex);
std::vector< std::vector<double> >& resultData = eclipseCase->results(RiaDefines::MATRIX_MODEL)->cellScalarResults(resultIndex);
if (resultData.size() == 0)
{
return false;
@@ -717,10 +717,10 @@ qint64 RifEclipseInputFileTools::findKeyword(const QString& keyword, QFile& file
//--------------------------------------------------------------------------------------------------
size_t RifEclipseInputFileTools::findOrCreateResult(const QString& newResultName, RigEclipseCaseData* reservoir)
{
size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName);
size_t resultIndex = reservoir->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(newResultName);
if (resultIndex == cvf::UNDEFINED_SIZE_T)
{
resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false);
resultIndex = reservoir->results(RiaDefines::MATRIX_MODEL)->addEmptyScalarResult(RiaDefines::INPUT_PROPERTY, newResultName, false);
}
return resultIndex;

View File

@@ -0,0 +1,125 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RifPerforationIntervalReader.h"
#include <QFile>
#include <QDate>
const QString PERFORATION_KEY("perforation");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, std::vector<RifPerforationInterval> > RifPerforationIntervalReader::readPerforationIntervals(const QStringList& filePaths)
{
std::map<QString, std::vector<RifPerforationInterval>> perforationIntervals;
foreach (QString filePath, filePaths)
{
readFileIntoMap(filePath, &perforationIntervals);
}
return perforationIntervals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<QString, std::vector<RifPerforationInterval> > RifPerforationIntervalReader::readPerforationIntervals(const QString& filePath)
{
std::map<QString, std::vector<RifPerforationInterval> > perforationIntervals;
readFileIntoMap(filePath, &perforationIntervals);
return perforationIntervals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifPerforationIntervalReader::readFileIntoMap(const QString& filePath, std::map<QString, std::vector<RifPerforationInterval>>* perforations)
{
QFile data(filePath);
if (!data.open(QFile::ReadOnly))
{
return;
}
QString wellName;
do {
QString line = data.readLine();
if (line.startsWith("--"))
{
// Skip comment
continue;
}
// Replace any tabs with spaces to enable splitting on spaces
line.replace("\t", " ");
QStringList parts = line.split(" ", QString::SkipEmptyParts);
if (line.startsWith("WELLNAME"))
{
// Save current well name
if (parts.size() == 2)
{
wellName = parts[1].trimmed();
}
}
else if (parts.size() >= 6)
{
RifPerforationInterval interval;
int mdStartIndex;
if (parts[3] == PERFORATION_KEY)
{
interval.date = QDate::fromString(QString("%1 %2 %3").arg(parts[0]).arg(parts[1]).arg(parts[2]), "dd MMM yyyy");
interval.startOfHistory = false;
mdStartIndex = 4;
}
else if (parts[1] == PERFORATION_KEY)
{
interval.startOfHistory = true;
mdStartIndex = 2;
}
else
{
continue;
}
interval.startMD = parts[mdStartIndex].toDouble();
interval.endMD = parts[mdStartIndex + 1].toDouble();
interval.diameter = parts[mdStartIndex + 2].toDouble();
interval.skinFactor = parts[mdStartIndex + 3].toDouble();
auto match = perforations->find(wellName);
if (match == perforations->end())
{
(*perforations)[wellName] = std::vector<RifPerforationInterval>();
}
(*perforations)[wellName].push_back(interval);
}
} while (!data.atEnd());
}

View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- 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 "RimPerforationInterval.h"
#include <map>
#include <QString>
struct RifPerforationInterval
{
double startMD;
double endMD;
double diameter;
double skinFactor;
bool startOfHistory;
QDate date;
};
//==================================================================================================
///
//==================================================================================================
class RifPerforationIntervalReader
{
public:
static std::map<QString, std::vector<RifPerforationInterval> > readPerforationIntervals(const QStringList& filePaths);
static std::map<QString, std::vector<RifPerforationInterval> > readPerforationIntervals(const QString& filePath);
private:
static void readFileIntoMap(const QString& filePath, std::map<QString, std::vector<RifPerforationInterval> >* perforations);
};

View File

@@ -38,6 +38,6 @@ public:
virtual void close() {}
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values ) { return false; }
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values ) { return false; }
virtual bool staticResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values ) { return false; }
virtual bool dynamicResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values ) { return false; }
};

View File

@@ -37,6 +37,7 @@
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigSingleWellResultsData.h"
#include "RigEclipseResultInfo.h"
#include "cafProgressInfo.h"
@@ -203,8 +204,6 @@ RifReaderEclipseOutput::RifReaderEclipseOutput()
m_fileName.clear();
m_filesWithSameBaseName.clear();
m_timeSteps.clear();
m_eclipseCase = NULL;
m_ecl_init_file = NULL;
@@ -252,8 +251,8 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid,
return false;
}
RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL);
RigActiveCellInfo* fractureActiveCellInfo = eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL);
CVF_ASSERT(activeCellInfo && fractureActiveCellInfo);
@@ -455,7 +454,7 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
{
CVF_ASSERT(m_eclipseCase);
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RiaDefines::MATRIX_MODEL);
CVF_ASSERT(matrixModelResults);
if (fileName.isEmpty())
@@ -471,9 +470,11 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
RiaLogging::info("HDF: Removing all existing Sour Sim data ...");
matrixModelResults->eraseAllSourSimData();
if (m_dynamicResultsAccess.isNull())
std::vector<QDateTime> dateTimes;
std::vector<double> daysSinceSimulationStart;
if (m_dynamicResultsAccess.notNull())
{
m_timeSteps.clear();
m_dynamicResultsAccess->timeSteps(&dateTimes, &daysSinceSimulationStart);
}
std::unique_ptr<RifHdf5ReaderInterface> myReader;
@@ -489,27 +490,27 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
}
std::vector<QDateTime> hdfTimeSteps = myReader->timeSteps();
if (m_timeSteps.size() > 0)
if (dateTimes.size() > 0)
{
if (hdfTimeSteps.size() != m_timeSteps.size())
if (hdfTimeSteps.size() != dateTimes.size())
{
RiaLogging::error("HDF: Time step count does not match");
RiaLogging::error(QString("HDF: Eclipse count %1").arg(m_timeSteps.size()));
RiaLogging::error(QString("HDF: Eclipse count %1").arg(dateTimes.size()));
RiaLogging::error(QString("HDF: HDF count %1").arg(hdfTimeSteps.size()));
return;
}
bool isTimeStampsEqual = true;
for (size_t i = 0; i < m_timeSteps.size(); i++)
for (size_t i = 0; i < dateTimes.size(); i++)
{
if (hdfTimeSteps[i].date() != m_timeSteps[i].date())
if (hdfTimeSteps[i].date() != dateTimes[i].date())
{
RiaLogging::error("HDF: Time steps does not match");
QString dateStr("yyyy.MMM.ddd hh:mm");
RiaLogging::error(QString("HDF: Eclipse date %1").arg(m_timeSteps[i].toString(dateStr)));
RiaLogging::error(QString("HDF: Eclipse date %1").arg(dateTimes[i].toString(dateStr)));
RiaLogging::error(QString("HDF: HDF date %1").arg(hdfTimeSteps[i].toString(dateStr)));
isTimeStampsEqual = false;
@@ -521,28 +522,40 @@ void RifReaderEclipseOutput::setHdf5FileName(const QString& fileName)
else
{
// Use time steps from HDF to define the time steps
m_timeSteps = hdfTimeSteps;
dateTimes = hdfTimeSteps;
QDateTime firstDate = hdfTimeSteps[0];
for (auto d : hdfTimeSteps)
{
daysSinceSimulationStart.push_back(firstDate.daysTo(d));
}
}
std::vector<int> reportNumbers;
if (m_dynamicResultsAccess.notNull())
std::vector<RigEclipseTimeStepInfo> timeStepInfos;
{
reportNumbers = m_dynamicResultsAccess->reportNumbers();
}
else
{
for (size_t i = 0; i < m_timeSteps.size(); i++)
std::vector<int> reportNumbers;
if (m_dynamicResultsAccess.notNull())
{
reportNumbers.push_back(static_cast<int>(i));
reportNumbers = m_dynamicResultsAccess->reportNumbers();
}
else
{
for (size_t i = 0; i < dateTimes.size(); i++)
{
reportNumbers.push_back(static_cast<int>(i));
}
}
timeStepInfos = RigEclipseTimeStepInfo::createTimeStepInfos(dateTimes, reportNumbers, daysSinceSimulationStart);
}
QStringList resultNames = myReader->propertyNames();
for (int i = 0; i < resultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::SOURSIMRL, resultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RiaDefines::SOURSIMRL, resultNames[i], false);
matrixModelResults->setTimeStepInfos(resIndex, timeStepInfos);
}
m_hdfReaderInterface = std::move(myReader);
@@ -718,8 +731,8 @@ bool RifReaderEclipseOutput::readActiveCellInfo()
return false;
}
RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* fractureActiveCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL);
RigActiveCellInfo* fractureActiveCellInfo = m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL);
activeCellInfo->setReservoirCellCount(reservoirCellCount);
fractureActiveCellInfo->setReservoirCellCount(reservoirCellCount);
@@ -782,8 +795,10 @@ void RifReaderEclipseOutput::buildMetaData()
progInfo.setNextProgressIncrement(m_filesWithSameBaseName.size());
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* fractureModelResults = m_eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS);
RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RiaDefines::MATRIX_MODEL);
RigCaseCellResultsData* fractureModelResults = m_eclipseCase->results(RiaDefines::FRACTURE_MODEL);
std::vector<RigEclipseTimeStepInfo> timeStepInfos;
// Create access object for dynamic results
m_dynamicResultsAccess = createDynamicResultsAccess();
@@ -793,9 +808,7 @@ void RifReaderEclipseOutput::buildMetaData()
progInfo.incrementProgress();
// Get time steps
m_dynamicResultsAccess->timeSteps(&m_timeSteps, &m_daysSinceSimulationStart);
std::vector<int> reportNumbers = m_dynamicResultsAccess->reportNumbers();
timeStepInfos = createFilteredTimeStepInfos();
QStringList resultNames;
std::vector<size_t> resultNamesDataItemCounts;
@@ -803,41 +816,41 @@ void RifReaderEclipseOutput::buildMetaData()
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount());
m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL),
m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL),
RiaDefines::MATRIX_MODEL, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RiaDefines::DYNAMIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepInfos(resIndex, timeStepInfos);
}
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount());
m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL),
m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL),
RiaDefines::FRACTURE_MODEL, m_dynamicResultsAccess->timeStepCount());
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, m_timeSteps, m_daysSinceSimulationStart, reportNumbers);
size_t resIndex = fractureModelResults->addEmptyScalarResult(RiaDefines::DYNAMIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepInfos(resIndex, timeStepInfos);
}
}
// Default units type is METRIC
RigEclipseCaseData::UnitsType unitsType = RigEclipseCaseData::UNITS_METRIC;
RiaEclipseUnitTools::UnitSystem unitsType = RiaEclipseUnitTools::UNITS_METRIC;
{
int unitsTypeValue = m_dynamicResultsAccess->readUnitsType();
if (unitsTypeValue == 2)
{
unitsType = RigEclipseCaseData::UNITS_FIELD;
unitsType = RiaEclipseUnitTools::UNITS_FIELD;
}
else if (unitsTypeValue == 3)
{
unitsType = RigEclipseCaseData::UNITS_LAB;
unitsType = RiaEclipseUnitTools::UNITS_LAB;
}
}
@@ -859,59 +872,40 @@ void RifReaderEclipseOutput::buildMetaData()
RifEclipseOutputFileTools::findKeywordsAndItemCount(filesUsedToFindAvailableKeywords, &resultNames, &resultNamesDataItemCounts);
std::vector<QDateTime> staticDate;
std::vector<double> staticDay;
std::vector<int> staticReportNumber;
std::vector<RigEclipseTimeStepInfo> staticTimeStepInfo;
if (!timeStepInfos.empty())
{
if ( m_timeSteps.size() > 0 )
{
staticDate.push_back(m_timeSteps.front());
}
if (m_daysSinceSimulationStart.size() > 0)
{
staticDay.push_back(m_daysSinceSimulationStart.front());
}
std::vector<int> reportNumbers;
if (m_dynamicResultsAccess.notNull())
{
reportNumbers = m_dynamicResultsAccess->reportNumbers();
}
if ( reportNumbers.size() > 0 )
{
staticReportNumber.push_back(reportNumbers.front());
}
staticTimeStepInfo.push_back(timeStepInfos.front());
}
{
QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::MATRIX_RESULTS, 1);
m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL),
m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL),
RiaDefines::MATRIX_MODEL, 1);
// Add ACTNUM
matrixResultNames += "ACTNUM";
for (int i = 0; i < matrixResultNames.size(); ++i)
{
size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepDates(resIndex, staticDate, staticDay, staticReportNumber);
size_t resIndex = matrixModelResults->addEmptyScalarResult(RiaDefines::STATIC_NATIVE, matrixResultNames[i], false);
matrixModelResults->setTimeStepInfos(resIndex, staticTimeStepInfo);
}
}
{
QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts,
m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS),
m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS),
RifReaderInterface::FRACTURE_RESULTS, 1);
m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL),
m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL),
RiaDefines::FRACTURE_MODEL, 1);
// Add ACTNUM
fractureResultNames += "ACTNUM";
for (int i = 0; i < fractureResultNames.size(); ++i)
{
size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepDates(resIndex, staticDate, staticDay, staticReportNumber);
size_t resIndex = fractureModelResults->addEmptyScalarResult(RiaDefines::STATIC_NATIVE, fractureResultNames[i], false);
fractureModelResults->setTimeStepInfos(resIndex, staticTimeStepInfo);
}
}
}
@@ -948,7 +942,7 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::createDynamicResultsAccess(
//--------------------------------------------------------------------------------------------------
/// Get all values of a given static result as doubles
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values)
bool RifReaderEclipseOutput::staticResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values)
{
CVF_ASSERT(values);
@@ -999,7 +993,7 @@ void RifReaderEclipseOutput::sourSimRlResult(const QString& result, size_t stepI
size_t activeCellCount = cvf::UNDEFINED_SIZE_T;
{
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL);
fracActCellInfo->gridActiveCellCounts(0, activeCellCount);
}
@@ -1017,10 +1011,7 @@ void RifReaderEclipseOutput::sourSimRlResult(const QString& result, size_t stepI
//--------------------------------------------------------------------------------------------------
/// Get dynamic result at given step index. Will concatenate values for the main grid and all sub grids.
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseOutput::dynamicResult(const QString& result,
PorosityModelResultType matrixOrFracture,
size_t stepIndex,
std::vector<double>* values)
bool RifReaderEclipseOutput::dynamicResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
@@ -1031,8 +1022,10 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result,
if (m_dynamicResultsAccess.notNull())
{
size_t indexOnFile = timeStepIndexOnFile(stepIndex);
std::vector<double> fileValues;
if (!m_dynamicResultsAccess->results(result, stepIndex, m_eclipseCase->mainGrid()->gridCount(), &fileValues))
if (!m_dynamicResultsAccess->results(result, indexOnFile, m_eclipseCase->mainGrid()->gridCount(), &fileValues))
{
return false;
}
@@ -1160,8 +1153,8 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa
double fieldGasToOilEquivalent = 1.0e6/5800; // Mega ft^3 to BOE
double metricGasToOilEquivalent = 1.0/1.0e3; // Sm^3 Gas to Sm^3 oe
if (m_eclipseCase->unitsType() == RigEclipseCaseData::UNITS_FIELD) gasRate = fieldGasToOilEquivalent * gasRate;
if (m_eclipseCase->unitsType() == RigEclipseCaseData::UNITS_METRIC) gasRate = metricGasToOilEquivalent * gasRate;
if (m_eclipseCase->unitsType() == RiaEclipseUnitTools::UNITS_FIELD) gasRate = fieldGasToOilEquivalent * gasRate;
if (m_eclipseCase->unitsType() == RiaEclipseUnitTools::UNITS_METRIC) gasRate = metricGasToOilEquivalent * gasRate;
resultPoint.m_gasRate = gasRate;
}
@@ -1830,7 +1823,16 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo
}
wellResults->computeMappingFromResultTimeIndicesToWellTimeIndices(m_timeSteps);
std::vector<QDateTime> filteredTimeSteps;
{
std::vector<RigEclipseTimeStepInfo> filteredTimeStepInfos = createFilteredTimeStepInfos();
for (auto a : filteredTimeStepInfos)
{
filteredTimeSteps.push_back(a.m_date);
}
}
wellResults->computeMappingFromResultTimeIndicesToWellTimeIndices(filteredTimeSteps);
wells.push_back(wellResults.p());
@@ -1850,7 +1852,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
const std::vector<size_t>& keywordDataItemCounts,
const RigActiveCellInfo* matrixActiveCellInfo,
const RigActiveCellInfo* fractureActiveCellInfo,
PorosityModelResultType porosityModel,
RiaDefines::PorosityModelType porosityModel,
size_t timeStepCount) const
{
CVF_ASSERT(matrixActiveCellInfo);
@@ -1860,7 +1862,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
return QStringList();
}
if (porosityModel == RifReaderInterface::FRACTURE_RESULTS)
if (porosityModel == RiaDefines::FRACTURE_MODEL)
{
if (fractureActiveCellInfo->reservoirActiveCellCount() == 0)
{
@@ -1896,14 +1898,14 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
size_t sumFractureMatrixActiveCellCount = matrixActiveCellInfo->reservoirActiveCellCount() + fractureActiveCellInfo->reservoirActiveCellCount();
size_t timeStepsMatrixAndFractureRest = keywordDataItemCount % sumFractureMatrixActiveCellCount;
if (porosityModel == RifReaderInterface::MATRIX_RESULTS && timeStepsMatrixRest == 0)
if (porosityModel == RiaDefines::MATRIX_MODEL && timeStepsMatrixRest == 0)
{
if (keywordDataItemCount <= timeStepCount * std::max(matrixActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount))
{
validKeyword = true;
}
}
else if (porosityModel == RifReaderInterface::FRACTURE_RESULTS && fractureActiveCellInfo->reservoirActiveCellCount() > 0 && timeStepsFractureRest == 0)
else if (porosityModel == RiaDefines::FRACTURE_MODEL && fractureActiveCellInfo->reservoirActiveCellCount() > 0 && timeStepsFractureRest == 0)
{
if (keywordDataItemCount <= timeStepCount * std::max(fractureActiveCellInfo->reservoirActiveCellCount(), sumFractureMatrixActiveCellCount))
{
@@ -1949,19 +1951,47 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* destinationResultValues, const std::vector<double>& sourceResultValues)
std::vector<RigEclipseTimeStepInfo> RifReaderEclipseOutput::createFilteredTimeStepInfos()
{
std::vector<RigEclipseTimeStepInfo> timeStepInfos;
if (m_dynamicResultsAccess.notNull())
{
std::vector<QDateTime> timeStepsOnFile;
std::vector<double> daysSinceSimulationStartOnFile;
std::vector<int> reportNumbersOnFile;
m_dynamicResultsAccess->timeSteps(&timeStepsOnFile, &daysSinceSimulationStartOnFile);
reportNumbersOnFile = m_dynamicResultsAccess->reportNumbers();
for (size_t i = 0; i < timeStepsOnFile.size(); i++)
{
if (this->isTimeStepIncludedByFilter(i))
{
timeStepInfos.push_back(RigEclipseTimeStepInfo(timeStepsOnFile[i], reportNumbersOnFile[i], daysSinceSimulationStartOnFile[i]));
}
}
}
return timeStepInfos;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* destinationResultValues, const std::vector<double>& sourceResultValues)
{
if (sourceResultValues.size() == 0) return;
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS);
RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RiaDefines::FRACTURE_MODEL);
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS && fracActCellInfo->reservoirActiveCellCount() == 0)
if (matrixOrFracture == RiaDefines::MATRIX_MODEL && fracActCellInfo->reservoirActiveCellCount() == 0)
{
destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end());
}
else
{
RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS);
RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(RiaDefines::MATRIX_MODEL);
size_t sourceStartPosition = 0;
@@ -1973,7 +2003,7 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod
actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount);
fracActCellInfo->gridActiveCellCounts(i, fractureActiveCellCount);
if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS)
if (matrixOrFracture == RiaDefines::MATRIX_MODEL)
{
destinationResultValues->insert(destinationResultValues->end(),
sourceResultValues.begin() + sourceStartPosition,
@@ -2008,14 +2038,6 @@ void RifReaderEclipseOutput::openInitFile()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifReaderEclipseOutput::timeSteps()
{
return m_timeSteps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@@ -24,9 +24,6 @@
#include "cvfCollection.h"
#include <QList>
#include <QDateTime>
#include <memory>
class RifEclipseOutputFileTools;
@@ -34,6 +31,7 @@ class RifEclipseRestartDataAccess;
class RifHdf5ReaderInterface;
class RigActiveCellInfo;
class RigFault;
class RigEclipseTimeStepInfo;
class RigGridBase;
class RigMainGrid;
@@ -60,8 +58,8 @@ public:
virtual bool openAndReadActiveCellData(const QString& fileName, const std::vector<QDateTime>& mainCaseTimeSteps, RigEclipseCaseData* eclipseCase);
void close();
bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values);
bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
bool staticResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values);
bool dynamicResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values);
void sourSimRlResult(const QString& result, size_t stepIndex, std::vector<double>* values);
static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCaseData* eclipseCase);
@@ -78,30 +76,26 @@ private:
void importFaults(const QStringList& fileSet, cvf::Collection<RigFault>* faults);
void openInitFile();
bool openDynamicAccess();
void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector<double>* values, const std::vector<double>& fileValues);
void extractResultValuesBasedOnPorosityModel(RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values, const std::vector<double>& fileValues);
void transferStaticNNCData(const ecl_grid_type* mainEclGrid , ecl_file_type* init_file, RigMainGrid* mainGrid);
void transferDynamicNNCData(const ecl_grid_type* mainEclGrid, RigMainGrid* mainGrid);
RifEclipseRestartDataAccess* createDynamicResultsAccess();
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const;
QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector<size_t>& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, RiaDefines::PorosityModelType matrixOrFracture, size_t timeStepCount) const;
std::vector<RigEclipseTimeStepInfo> createFilteredTimeStepInfos();
virtual std::vector<QDateTime> timeSteps();
private:
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_filesWithSameBaseName; // Set of files in filename's path with same base name as filename
QString m_fileName; // Name of file used to start accessing Eclipse output files
QStringList m_filesWithSameBaseName; // Set of files in filename's path with same base name as filename
RigEclipseCaseData* m_eclipseCase;
RigEclipseCaseData* m_eclipseCase;
std::vector<QDateTime> m_timeSteps;
std::vector<double> m_daysSinceSimulationStart;
ecl_file_type* m_ecl_init_file; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
ecl_file_type* m_ecl_init_file; // File access to static results
cvf::ref<RifEclipseRestartDataAccess> m_dynamicResultsAccess; // File access to dynamic results
std::unique_ptr<RifHdf5ReaderInterface> m_hdfReaderInterface;
};

View File

@@ -68,6 +68,9 @@ bool RifReaderInterface::isNNCsEnabled()
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const QString RifReaderInterface::faultIncludeFileAbsolutePathPrefix()
{
if (m_settings.notNull())
@@ -77,3 +80,43 @@ const QString RifReaderInterface::faultIncludeFileAbsolutePathPrefix()
return QString();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderInterface::setTimeStepFilter(const std::vector<size_t>& fileTimeStepIndices)
{
m_fileTimeStepIndices = fileTimeStepIndices;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderInterface::isTimeStepIncludedByFilter(size_t timeStepIndex) const
{
if (m_fileTimeStepIndices.empty()) return true;
for (auto i : m_fileTimeStepIndices)
{
if (i == timeStepIndex)
{
return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifReaderInterface::timeStepIndexOnFile(size_t timeStepIndex) const
{
if (timeStepIndex < m_fileTimeStepIndices.size())
{
return m_fileTimeStepIndices[timeStepIndex];
}
return timeStepIndex;
}

View File

@@ -20,6 +20,8 @@
#pragma once
#include "RiaPorosityModel.h"
#include "cvfBase.h"
#include "cvfObject.h"
@@ -43,13 +45,6 @@ class RifReaderSettings;
//==================================================================================================
class RifReaderInterface : public cvf::Object
{
public:
enum PorosityModelResultType
{
MATRIX_RESULTS,
FRACTURE_RESULTS
};
public:
RifReaderInterface() { }
virtual ~RifReaderInterface() { }
@@ -64,16 +59,21 @@ public:
virtual bool open(const QString& fileName, RigEclipseCaseData* eclipseCase) = 0;
virtual void close() = 0;
virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0;
virtual std::vector<QDateTime> timeSteps() { std::vector<QDateTime> timeSteps; return timeSteps; }
virtual bool staticResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values) = 0;
virtual bool dynamicResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values) = 0;
void setFilenamesWithFaults(const std::vector<QString>& filenames) { m_filenamesWithFaults = filenames; }
std::vector<QString> filenamesWithFaults() { return m_filenamesWithFaults; }
void setTimeStepFilter(const std::vector<size_t>& fileTimeStepIndices);
protected:
bool isTimeStepIncludedByFilter(size_t timeStepIndex) const;
size_t timeStepIndexOnFile(size_t timeStepIndex) const;
private:
std::vector<QString> m_filenamesWithFaults;
caf::PdmPointer<RifReaderSettings> m_settings;
std::vector<size_t> m_fileTimeStepIndices;
};

View File

@@ -20,10 +20,9 @@
#include "RifReaderMockModel.h"
#include "RifReaderInterface.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultInfo.h"
//--------------------------------------------------------------------------------------------------
///
@@ -34,34 +33,34 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
m_reservoir = eclipseCase;
RigCaseCellResultsData* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS);
RigCaseCellResultsData* cellResults = eclipseCase->results(RiaDefines::MATRIX_MODEL);
std::vector<QDateTime> dates;
std::vector<double> days;
std::vector<int> repNumbers;
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.timeStepCount()); i++)
std::vector<RigEclipseTimeStepInfo> timeStepInfos;
{
dates.push_back(QDateTime(QDate(2012+i, 6, 1)));
days.push_back(i);
repNumbers.push_back(i);
std::vector<QDateTime> dates;
std::vector<double> days;
std::vector<int> repNumbers;
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.timeStepCount()); i++)
{
dates.push_back(QDateTime(QDate(2012+i, 6, 1)));
days.push_back(i);
repNumbers.push_back(i);
}
timeStepInfos = RigEclipseTimeStepInfo::createTimeStepInfos(dates, repNumbers, days);
}
for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++)
{
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false);
cellResults->setTimeStepDates(resIdx, dates, days, repNumbers);
size_t resIdx = cellResults->addEmptyScalarResult(RiaDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false);
cellResults->setTimeStepInfos(resIdx, timeStepInfos);
}
if (m_reservoirBuilder.timeStepCount() == 0) return true;
std::vector<QDateTime> staticDates;
staticDates.push_back(dates[0]);
std::vector<double> staticDays;
staticDays.push_back(days[0]);
std::vector<int> staticRepNumbers;
staticRepNumbers.push_back(0);
std::vector<RigEclipseTimeStepInfo> staticResultTimeStepInfos;
staticResultTimeStepInfos.push_back(timeStepInfos[0]);
for (int i = 0; i < static_cast<int>(m_reservoirBuilder.resultCount()); i++)
{
@@ -71,8 +70,8 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
int resIndex = 0;
if (i > 1) resIndex = i;
size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false);
cellResults->setTimeStepDates(resIdx, staticDates, staticDays, staticRepNumbers);
size_t resIdx = cellResults->addEmptyScalarResult(RiaDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false);
cellResults->setTimeStepInfos(resIdx, staticResultTimeStepInfos);
}
@@ -80,8 +79,8 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCaseData* eclip
{ \
size_t resIdx; \
QString resultName(Name); \
resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName, false); \
cellResults->setTimeStepDates(resIdx, staticDates, staticDays, staticRepNumbers); \
resIdx = cellResults->addEmptyScalarResult(RiaDefines::INPUT_PROPERTY, resultName, false); \
cellResults->setTimeStepInfos(resIdx, staticResultTimeStepInfos); \
cellResults->cellScalarResults(resIdx).resize(1); \
std::vector<double>& values = cellResults->cellScalarResults(resIdx)[0]; \
this->inputProperty(resultName, &values); \
@@ -114,7 +113,7 @@ bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector<
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values)
bool RifReaderMockModel::staticResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values)
{
m_reservoirBuilder.staticResult(m_reservoir, result, values);
@@ -124,7 +123,7 @@ bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
bool RifReaderMockModel::dynamicResult(const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values)
{
m_reservoirBuilder.dynamicResult(m_reservoir, result, stepIndex, values);

View File

@@ -39,8 +39,8 @@ public:
virtual bool open( const QString& fileName, RigEclipseCaseData* eclipseCase );
virtual void close();
virtual bool staticResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector<double>* values );
virtual bool staticResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, std::vector<double>* values );
virtual bool dynamicResult( const QString& result, RiaDefines::PorosityModelType matrixOrFracture, size_t stepIndex, std::vector<double>* values );
private:
void populateReservoir(RigEclipseCaseData* eclipseCase);

View File

@@ -0,0 +1,378 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RifWellPathImporter.h"
#include "RifJsonEncodeDecode.h"
#include <fstream>
#include "cafUtils.h"
#include <QFileInfo>
#include <cmath>
#include <algorithm>
#define ASCII_FILE_DEFAULT_START_INDEX 0
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readWellData(const QString& filePath, size_t indexInFile)
{
CVF_ASSERT(caf::Utils::fileExists(filePath));
if (isJsonFile(filePath))
{
return readJsonWellData(filePath);
}
else
{
return readAsciiWellData(filePath, indexInFile);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readWellData(const QString& filePath)
{
return readWellData(filePath, ASCII_FILE_DEFAULT_START_INDEX);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readWellMetaData(const QString& filePath, size_t indexInFile)
{
CVF_ASSERT(caf::Utils::fileExists(filePath));
if (isJsonFile(filePath))
{
return readJsonWellMetaData(filePath);
}
else
{
return readAsciiWellMetaData(filePath, indexInFile);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readWellMetaData(const QString& filePath)
{
return readWellMetaData(filePath, ASCII_FILE_DEFAULT_START_INDEX);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RifWellPathImporter::wellDataCount(const QString& filePath)
{
if (isJsonFile(filePath))
{
// Only support JSON files with single well data currently
return 1;
}
else
{
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
// If we have the file in the map, assume it is already read.
if (it != m_fileNameToWellDataGroupMap.end())
{
return it->second.size();
}
readAllAsciiWellData(filePath);
it = m_fileNameToWellDataGroupMap.find(filePath);
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
return it->second.size();;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifWellPathImporter::isJsonFile(const QString & filePath)
{
QFileInfo fileInfo(filePath);
if (fileInfo.suffix().compare("json") == 0)
{
return true;
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readJsonWellMetaData(const QString & filePath)
{
ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filePath);
WellMetaData metadata;
metadata.m_id = jsonMap["id"].toString();
metadata.m_name = jsonMap["name"].toString();
metadata.m_sourceSystem = jsonMap["sourceSystem"].toString();
metadata.m_utmZone = jsonMap["utmZone"].toString();
metadata.m_updateUser = jsonMap["updateUser"].toString();
metadata.m_surveyType = jsonMap["surveyType"].toString();
// Convert updateDate from the following format:
// "Number of milliseconds elapsed since midnight Coordinated Universal Time (UTC)
// of January 1, 1970, not counting leap seconds"
QString updateDateStr = jsonMap["updateDate"].toString().trimmed();
uint updateDateUint = updateDateStr.toULongLong() / 1000; // Should be within 32 bit, maximum number is 4294967295 which corresponds to year 2106
metadata.m_updateDate.setTime_t(updateDateUint);
return metadata;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readJsonWellData(const QString& filePath)
{
ResInsightInternalJson::JsonReader jsonReader;
QMap<QString, QVariant> jsonMap = jsonReader.decodeFile(filePath);
double datumElevation = jsonMap["datumElevation"].toDouble();
QList<QVariant> pathList = jsonMap["path"].toList();
WellData wellData;
wellData.m_wellPathGeometry->setDatumElevation(datumElevation);
wellData.m_name = jsonMap["name"].toString();
foreach(QVariant point, pathList)
{
QMap<QString, QVariant> coordinateMap = point.toMap();
cvf::Vec3d vec3d(coordinateMap["east"].toDouble(), coordinateMap["north"].toDouble(), -(coordinateMap["tvd"].toDouble() - datumElevation));
wellData.m_wellPathGeometry->m_wellPathPoints.push_back(vec3d);
double measuredDepth = coordinateMap["md"].toDouble();
wellData.m_wellPathGeometry->m_measuredDepths.push_back(measuredDepth);
}
return wellData;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::readAllAsciiWellData(const QString& filePath)
{
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
// If we have the file in the map, assume it is already read.
if (it != m_fileNameToWellDataGroupMap.end())
{
return;
}
// Create the data container
std::vector<RifWellPathImporter::WellData>& fileWellDataArray = m_fileNameToWellDataGroupMap[filePath];
std::ifstream stream(filePath.toLatin1().data());
double x(HUGE_VAL), y(HUGE_VAL), tvd(HUGE_VAL), md(HUGE_VAL);
bool hasReadWellPointInCurrentWell = false;
while (stream.good())
{
// First check if we can read a number
stream >> x;
if (stream.good()) // If we can, assume this line is a well point entry
{
stream >> y >> tvd >> md;
if (!stream.good())
{
// -999 or otherwise to few numbers before some word
if (x != -999)
{
// Error in file: missing numbers at this line
}
stream.clear();
}
else
{
if (!fileWellDataArray.size())
{
fileWellDataArray.push_back(RifWellPathImporter::WellData());
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
}
cvf::Vec3d wellPoint(x, y, -tvd);
fileWellDataArray.back().m_wellPathGeometry->m_wellPathPoints.push_back(wellPoint);
fileWellDataArray.back().m_wellPathGeometry->m_measuredDepths.push_back(md);
x = HUGE_VAL;
y = HUGE_VAL;
tvd = HUGE_VAL;
md = HUGE_VAL;
hasReadWellPointInCurrentWell = true;
}
}
else
{
// Could not read one double.
// we assume there is a comment line or a well path description
stream.clear();
std::string line;
std::getline(stream, line, '\n');
// Skip possible comment lines (-- is used in eclipse, so Haakon H<>gst<73>l considered it smart to skip these here as well)
// The first "-" is eaten by the stream >> x above
if (line.find("-") == 0 || line.find("#") == 0)
{
// Comment line, just ignore
}
else
{
// Find the first and the last position of any quotes (and do not care to match quotes)
size_t quoteStartIdx = line.find_first_of("'`<60><><EFBFBD>");
size_t quoteEndIdx = line.find_last_of("'`<60><><EFBFBD>");
std::string wellName;
bool haveAPossibleWellStart = false;
if (quoteStartIdx < line.size() -1)
{
// Extract the text between the quotes
wellName = line.substr(quoteStartIdx + 1, quoteEndIdx - 1 - quoteStartIdx);
haveAPossibleWellStart = true;
}
else if (quoteStartIdx > line.length())
{
// We did not find any quotes
// Supported alternatives are
// name <WellNameA>
// wellname: <WellNameA>
std::string lineLowerCase = line;
transform(lineLowerCase.begin(), lineLowerCase.end(), lineLowerCase.begin(), ::tolower);
std::string tokenName = "name";
std::size_t foundNameIdx = lineLowerCase.find(tokenName);
if (foundNameIdx != std::string::npos)
{
std::string tokenColon = ":";
std::size_t foundColonIdx = lineLowerCase.find(tokenColon, foundNameIdx);
if (foundColonIdx != std::string::npos)
{
wellName = line.substr(foundColonIdx + tokenColon.length());
}
else
{
wellName = line.substr(foundNameIdx + tokenName.length());
}
haveAPossibleWellStart = true;
}
else
{
// Interpret the whole line as the well name.
QString name = line.c_str();
if (!name.trimmed().isEmpty())
{
wellName = name.trimmed().toStdString();
haveAPossibleWellStart = true;
}
}
}
if (haveAPossibleWellStart)
{
// Create a new Well data if we have read some data into the previous one.
// if not, just overwrite the name
if (hasReadWellPointInCurrentWell || fileWellDataArray.size() == 0)
{
fileWellDataArray.push_back(RifWellPathImporter::WellData());
fileWellDataArray.back().m_wellPathGeometry = new RigWellPath();
}
QString name = wellName.c_str();
if (!name.trimmed().isEmpty())
{
// Do not overwrite the name aquired from a line above, if this line is empty
fileWellDataArray.back().m_name = name.trimmed();
}
hasReadWellPointInCurrentWell = false;
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellData RifWellPathImporter::readAsciiWellData(const QString& filePath, size_t indexInFile)
{
readAllAsciiWellData(filePath);
std::map<QString, std::vector<RifWellPathImporter::WellData> >::iterator it = m_fileNameToWellDataGroupMap.find(filePath);
CVF_ASSERT(it != m_fileNameToWellDataGroupMap.end());
if (indexInFile < it->second.size())
{
return it->second[indexInFile];
}
else
{
// Error : The ascii well path file does not contain that many well paths
return RifWellPathImporter::WellData();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifWellPathImporter::WellMetaData RifWellPathImporter::readAsciiWellMetaData(const QString & filePath, size_t indexInFile)
{
// No metadata in ASCII files
return WellMetaData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::clear()
{
m_fileNameToWellDataGroupMap.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifWellPathImporter::removeFilePath(const QString& filePath)
{
m_fileNameToWellDataGroupMap.erase(filePath);
}

View File

@@ -0,0 +1,75 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
//
// 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 "RigWellPath.h"
#include "cvfObject.h"
#include <map>
#include <vector>
#include <QString>
#include <QDateTime>
//==================================================================================================
///
///
//==================================================================================================
class RifWellPathImporter
{
public:
struct WellData
{
QString m_name;
cvf::ref<RigWellPath> m_wellPathGeometry;
};
struct WellMetaData
{
QString m_name;
QString m_id;
QString m_sourceSystem;
QString m_utmZone;
QString m_updateUser;
QString m_surveyType;
QDateTime m_updateDate;
};
WellData readWellData(const QString& filePath, size_t indexInFile);
WellData readWellData(const QString& filePath);
WellMetaData readWellMetaData(const QString& filePath, size_t indexInFile);
WellMetaData readWellMetaData(const QString& filePath);
size_t wellDataCount(const QString& filePath);
void clear();
void removeFilePath(const QString& filePath);
private:
WellData readJsonWellData(const QString& filePath);
WellMetaData readJsonWellMetaData(const QString& filePath);
WellData readAsciiWellData(const QString& filePath, size_t indexInFile);
WellMetaData readAsciiWellMetaData(const QString& filePath, size_t indexInFile);
void readAllAsciiWellData(const QString& filePath);
inline bool isJsonFile(const QString& filePath);
std::map<QString, std::vector<RifWellPathImporter::WellData> > m_fileNameToWellDataGroupMap;
};