#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

@ -8,6 +8,7 @@ set (SOURCE_GROUP_HEADER_FILES
${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h
@ -17,6 +18,7 @@ set (SOURCE_GROUP_SOURCE_FILES
${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp
${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp ${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp

View File

@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicWellPathImportPerforationIntervalsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimPerforationInterval.h"
#include "RimPerforationCollection.h"
#include "RifPerforationIntervalReader.h"
#include "RiuMainWindow.h"
#include "cafSelectionManager.h"
#include <QAction>
#include <QFileDialog>
CAF_CMD_SOURCE_INIT(RicWellPathImportPerforationIntervalsFeature, "RicWellPathImportPerforationIntervalsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicWellPathImportPerforationIntervalsFeature::isCommandEnabled()
{
if (RicWellPathImportPerforationIntervalsFeature::selectedWellPath() != nullptr)
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathImportPerforationIntervalsFeature::onActionTriggered(bool isChecked)
{
RimWellPathCollection* wellPathCollection = RicWellPathImportPerforationIntervalsFeature::selectedWellPath();
CVF_ASSERT(wellPathCollection);
// Open dialog box to select well path files
RiaApplication* app = RiaApplication::instance();
QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR");
QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Perforation Intervals", defaultDir, "Well Path Perforation Intervals (*.ev);;All Files (*.*)");
if (wellPathFilePaths.size() < 1) return;
// Remember the path to next time
app->setLastUsedDialogDirectory("WELLPATH_DIR", QFileInfo(wellPathFilePaths.last()).absolutePath());
std::map<QString, std::vector<RifPerforationInterval> > perforationIntervals = RifPerforationIntervalReader::readPerforationIntervals(wellPathFilePaths);
for (auto& entry : perforationIntervals)
{
RimWellPath* wellPath = wellPathCollection->wellPathByName(entry.first);
if (wellPath == nullptr)
{
RiaLogging::warning(QString("Import Well Path Perforation Intervals : Imported file contains unknown well path '%1'.").arg(entry.first));
}
else
{
for (auto& interval : entry.second)
{
RimPerforationInterval* perforationInterval = new RimPerforationInterval;
perforationInterval->setStartAndEndMD(interval.startMD, interval.endMD);
perforationInterval->setDiameter(interval.diameter);
perforationInterval->setSkinFactor(interval.skinFactor);
if (interval.startOfHistory)
{
perforationInterval->setStartOfHistory();
}
else
{
perforationInterval->setDate(interval.date);
}
wellPath->perforationIntervalCollection()->appendPerforation(perforationInterval);
}
}
}
if (app->project())
{
app->project()->createDisplayModelAndRedrawAllViews();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicWellPathImportPerforationIntervalsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Import Perforation Intervals");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellPathCollection* RicWellPathImportPerforationIntervalsFeature::selectedWellPath()
{
std::vector<RimWellPathCollection*> objects;
caf::SelectionManager::instance()->objectsByType(&objects);
if (objects.size() == 1)
{
return objects[0];
}
return nullptr;
}

View File

@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafCmdFeature.h"
class RimWellPathCollection;
//==================================================================================================
///
//==================================================================================================
class RicWellPathImportPerforationIntervalsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
// Overrides
virtual bool isCommandEnabled() override;
virtual void onActionTriggered( bool isChecked ) override;
virtual void setupActionLook( QAction* actionToSetup ) override;
private:
static RimWellPathCollection* selectedWellPath();
};

View File

@ -12,6 +12,7 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h ${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h ${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h ${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h ${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.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}RifEclipseRestartFilesetAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp ${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp
${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp ${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.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);
};

View File

@ -400,6 +400,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
commandIds << "RicEditPerforationCollectionFeature"; commandIds << "RicEditPerforationCollectionFeature";
commandIds << "RicExportFishbonesLateralsFeature"; commandIds << "RicExportFishbonesLateralsFeature";
commandIds << "RicExportFishbonesWellSegmentsFeature"; commandIds << "RicExportFishbonesWellSegmentsFeature";
commandIds << "RicWellPathImportPerforationIntervalsFeature";
commandIds << "RicWellPathExportCompletionDataFeature"; commandIds << "RicWellPathExportCompletionDataFeature";
commandIds << "RicWellPathImportCompletionsFileFeature"; commandIds << "RicWellPathImportCompletionsFileFeature";
commandIds << "RicFlyToObjectFeature"; commandIds << "RicFlyToObjectFeature";

View File

@ -26,6 +26,7 @@
#include "cafPdmUiListEditor.h" #include "cafPdmUiListEditor.h"
#include "cafPdmUiTextEditor.h" #include "cafPdmUiTextEditor.h"
#include "cafPdmUiLineEditor.h"
CAF_PDM_SOURCE_INIT(RimPerforationInterval, "Perforation"); CAF_PDM_SOURCE_INIT(RimPerforationInterval, "Perforation");
@ -40,6 +41,9 @@ RimPerforationInterval::RimPerforationInterval()
CAF_PDM_InitField(&m_endMD, "EndMeasuredDepth", 0.0, "End MD [m]", "", "", ""); CAF_PDM_InitField(&m_endMD, "EndMeasuredDepth", 0.0, "End MD [m]", "", "", "");
CAF_PDM_InitField(&m_diameter, "Diameter", 0.0, "Diameter [m]", "", "", ""); CAF_PDM_InitField(&m_diameter, "Diameter", 0.0, "Diameter [m]", "", "", "");
CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0, "Skin Factor", "", "", ""); CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0, "Skin Factor", "", "", "");
CAF_PDM_InitField(&m_startOfHistory, "StartOfHistory", true, "Start of History", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_date, "StartDate", "Start Date", "", "", "");
m_date.uiCapability()->setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName());
m_name.uiCapability()->setUiReadOnly(true); m_name.uiCapability()->setUiReadOnly(true);
} }
@ -60,6 +64,41 @@ void RimPerforationInterval::setStartAndEndMD(double startMD, double endMD)
m_endMD = endMD; m_endMD = endMD;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::setStartOfHistory()
{
m_startOfHistory = true;
m_date.uiCapability()->setUiReadOnly(m_startOfHistory());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::setDate(const QDate& date)
{
m_startOfHistory = false;
m_date = QDateTime(date);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::setDiameter(double diameter)
{
m_diameter = diameter;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPerforationInterval::setSkinFactor(double skinFactor)
{
m_skinFactor = skinFactor;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -88,6 +127,11 @@ void RimPerforationInterval::fieldChangedByUi(const caf::PdmFieldHandle* changed
RimProject* proj; RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted(proj); this->firstAncestorOrThisOfTypeAsserted(proj);
proj->createDisplayModelAndRedrawAllViews(); proj->createDisplayModelAndRedrawAllViews();
if (changedField == &m_startOfHistory)
{
m_date.uiCapability()->setUiReadOnly(m_startOfHistory());
}
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -107,6 +151,8 @@ void RimPerforationInterval::defineUiOrdering(QString uiConfigName, caf::PdmUiOr
uiOrdering.add(&m_endMD); uiOrdering.add(&m_endMD);
uiOrdering.add(&m_diameter); uiOrdering.add(&m_diameter);
uiOrdering.add(&m_skinFactor); uiOrdering.add(&m_skinFactor);
uiOrdering.add(&m_startOfHistory);
uiOrdering.add(&m_date);
uiOrdering.skipRemainingFields(); uiOrdering.skipRemainingFields();
} }

View File

@ -25,9 +25,10 @@
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include <QDate>
//================================================================================================== //==================================================================================================
/// ///
///
//================================================================================================== //==================================================================================================
class RimPerforationInterval : public RimCheckableNamedObject, public Rim3dPropertiesInterface class RimPerforationInterval : public RimCheckableNamedObject, public Rim3dPropertiesInterface
{ {
@ -38,6 +39,10 @@ public:
virtual ~RimPerforationInterval(); virtual ~RimPerforationInterval();
void setStartAndEndMD(double startMD, double endMD); void setStartAndEndMD(double startMD, double endMD);
void setStartOfHistory();
void setDate(const QDate& date);
void setDiameter(double diameter);
void setSkinFactor(double skinFactor);
double startMD() const { return m_startMD(); } double startMD() const { return m_startMD(); }
double endMD() const { return m_endMD(); } double endMD() const { return m_endMD(); }
double diameter() const { return m_diameter(); } double diameter() const { return m_diameter(); }
@ -55,4 +60,6 @@ private:
caf::PdmField< double > m_endMD; caf::PdmField< double > m_endMD;
caf::PdmField< double > m_diameter; caf::PdmField< double > m_diameter;
caf::PdmField< double > m_skinFactor; caf::PdmField< double > m_skinFactor;
caf::PdmField< bool > m_startOfHistory;
caf::PdmField< QDateTime > m_date;
}; };