#1523 Completions : Import perforation intervals from file

This commit is contained in:
Bjørnar Grip Fjær
2017-05-30 11:56:18 +02:00
parent f25701ba98
commit 5cafccdc80
9 changed files with 403 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ ${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
@@ -31,6 +32,7 @@ ${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

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);
};