mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#3427 Export fishbones laterals. Use export well paths impl
This commit is contained in:
parent
2b1c6e9706
commit
0c0ecc7d56
@ -21,6 +21,11 @@
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "ExportCommands/RicExportSelectedWellPathsFeature.h"
|
||||
#include "ExportCommands/RicExportWellPathsUi.h"
|
||||
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimFishbonesCollection.h"
|
||||
#include "RimFishbonesMultipleSubs.h"
|
||||
#include "RimWellPath.h"
|
||||
@ -31,7 +36,6 @@
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLateralsFeature");
|
||||
|
||||
@ -40,6 +44,8 @@ CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLatera
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
using EXP = RicExportSelectedWellPathsFeature;
|
||||
|
||||
RimFishbonesCollection* fishbonesCollection = selectedFishbonesCollection();
|
||||
CVF_ASSERT(fishbonesCollection);
|
||||
|
||||
@ -51,68 +57,60 @@ void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
|
||||
QString projectFolder = app->currentProjectPath();
|
||||
|
||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallback("WELL_PATH_EXPORT_DIR", projectFolder);
|
||||
auto fileName = caf::Utils::makeValidFileBasename(wellPath->name()) + "_laterals.dev";
|
||||
|
||||
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename((wellPath->name())) + "_laterals.dev";
|
||||
QString completeFilename = QFileDialog::getSaveFileName(nullptr, "Select File for Well Path Data Export", defaultFileName, "Well Path Text File(*.dev);;All files(*.*)");
|
||||
if (completeFilename.isEmpty()) return;
|
||||
|
||||
RiaLogging::info("Starting export of Fishbones well path laterals to : " + completeFilename);
|
||||
|
||||
QFile exportFile(completeFilename);
|
||||
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
auto dialogData = EXP::openDialog();
|
||||
if (dialogData)
|
||||
{
|
||||
RiaLogging::error("Could not open the file :\n" + completeFilename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// See RifWellPathAsciiFileReader::readAllWellData for reading of dev files
|
||||
//
|
||||
// http://resinsight.org/docs/wellpaths/
|
||||
// Export format
|
||||
//
|
||||
// WELLNAME: <well name>_<fishbone name>_Sub<sub index>_Lat<lateral index>
|
||||
//
|
||||
// for each coordinate along lateral, export
|
||||
// x y TVD MD
|
||||
// separate laterals using -999 on a single line
|
||||
|
||||
QTextStream stream(&exportFile);
|
||||
for (RimFishbonesMultipleSubs* fishbone : fishbonesCollection->activeFishbonesSubs())
|
||||
{
|
||||
const QString fishboneName = fishbone->generatedName();
|
||||
|
||||
for (auto& sub : fishbone->installedLateralIndices())
|
||||
auto folder = dialogData->exportFolder();
|
||||
auto mdStepSize = dialogData->mdStepSize();
|
||||
if (folder.isEmpty())
|
||||
{
|
||||
for (size_t lateralIndex : sub.lateralIndices)
|
||||
return;
|
||||
}
|
||||
|
||||
auto exportFile = EXP::openFileForExport(folder, fileName);
|
||||
auto stream = EXP::createOutputFileStream(*exportFile);
|
||||
|
||||
for (RimFishbonesMultipleSubs* fishbone : wellPath->fishbonesCollection()->activeFishbonesSubs())
|
||||
{
|
||||
const QString fishboneName = fishbone->generatedName();
|
||||
|
||||
for (auto& sub : fishbone->installedLateralIndices())
|
||||
{
|
||||
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMD = fishbone->coordsAndMDForLateral(sub.subIndex, lateralIndex);
|
||||
|
||||
// Pad with "0" to get a total of two characters defining the sub index text
|
||||
QString subIndexText = QString("%1").arg(sub.subIndex, 2, 10, QChar('0'));
|
||||
|
||||
QString lateralNameCandidate = QString("%1_%2_Sub%3_Lat%4").arg(wellPath->name()).arg(fishboneName).arg(subIndexText).arg(lateralIndex);
|
||||
QString lateralName = caf::Utils::makeValidFileBasename(lateralNameCandidate);
|
||||
|
||||
stream << "WELLNAME: " << lateralName << endl;
|
||||
|
||||
for (auto coordMD : coordsAndMD)
|
||||
for (size_t lateralIndex : sub.lateralIndices)
|
||||
{
|
||||
int numberOfDecimals = 2;
|
||||
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMD = fishbone->coordsAndMDForLateral(sub.subIndex, lateralIndex);
|
||||
|
||||
std::vector<cvf::Vec3d> lateralCoords;
|
||||
std::vector<double> lateralMDs;
|
||||
|
||||
// Export X and Y unchanged, invert sign of Z to get TVD, export MD unchanged
|
||||
stream << formatNumber(coordMD.first.x(), numberOfDecimals);
|
||||
stream << " " << formatNumber(coordMD.first.y(), numberOfDecimals);
|
||||
stream << " " << formatNumber(-coordMD.first.z(), numberOfDecimals);
|
||||
stream << " " << formatNumber(coordMD.second, numberOfDecimals) << endl;
|
||||
lateralCoords.reserve(coordsAndMD.size());
|
||||
lateralMDs.reserve(coordsAndMD.size());
|
||||
|
||||
for (auto& coordMD : coordsAndMD)
|
||||
{
|
||||
lateralCoords.push_back(coordMD.first);
|
||||
lateralMDs.push_back(coordMD.second);
|
||||
}
|
||||
|
||||
RigWellPath geometry;
|
||||
geometry.m_wellPathPoints = lateralCoords;
|
||||
geometry.m_measuredDepths = lateralMDs;
|
||||
|
||||
// Pad with "0" to get a total of two characters defining the sub index text
|
||||
QString subIndexText = QString("%1").arg(sub.subIndex, 2, 10, QChar('0'));
|
||||
QString lateralName = QString("%1_%2_Sub%3_Lat%4").arg(wellPath->name()).arg(fishboneName).arg(subIndexText).arg(lateralIndex);
|
||||
|
||||
EXP::writeWellPathGeometryToStream(*stream, &geometry, lateralName, mdStepSize);
|
||||
}
|
||||
stream << -999 << endl << endl;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
exportFile->close();
|
||||
}
|
||||
|
||||
RiaLogging::info("Completed export of Fishbones well path laterals to : " + completeFilename);
|
||||
RiaLogging::info("Completed export of Fishbones well path laterals to : " + fileName);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -18,9 +18,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFile>
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RimFishbonesCollection;
|
||||
class RimWellPath;
|
||||
class QTextStream;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
#ifndef DOUBLE_INF
|
||||
#define DOUBLE_INF std::numeric_limits<double>::infinity()
|
||||
#endif
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -29,6 +42,8 @@ class RicExportFishbonesLateralsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
//static void exportFishboneLaterals(const RimWellPath* wellPath, QTextStream& stream, double mdStepSize);
|
||||
|
||||
protected:
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
|
@ -27,18 +27,15 @@
|
||||
|
||||
#include "RimWellPath.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimDialogData.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileInfo>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include <cafUtils.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -51,30 +48,39 @@ CAF_CMD_SOURCE_INIT(RicExportSelectedWellPathsFeature, "RicExportSelectedWellPat
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder)
|
||||
{
|
||||
auto geom = wellPath->wellPathGeometry();
|
||||
double currMd = geom->measureDepths().front() - mdStepSize;
|
||||
double endMd = geom->measureDepths().back();
|
||||
|
||||
auto fileName = wellPath->name() + ".dev";
|
||||
auto filePtr = openFileForExport(folder, fileName);
|
||||
QTextStream stream(filePtr.get());
|
||||
stream.setRealNumberNotation(QTextStream::FixedNotation);
|
||||
auto stream = createOutputFileStream(*filePtr);
|
||||
|
||||
stream << "WELLNAME: '" << wellPath->name() << "'" << endl;
|
||||
writeWellPathGeometryToStream(*stream, wellPath->wellPathGeometry(), wellPath->name(), mdStepSize);
|
||||
filePtr->close();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportSelectedWellPathsFeature::writeWellPathGeometryToStream(QTextStream& stream,
|
||||
const RigWellPath* geometry,
|
||||
const QString& wellName,
|
||||
double mdStepSize)
|
||||
{
|
||||
double currMd = geometry->measureDepths().front() - mdStepSize;
|
||||
double endMd = geometry->measureDepths().back();
|
||||
|
||||
stream << "WELLNAME: '" << caf::Utils::makeValidFileBasename(wellName) << "'" << endl;
|
||||
|
||||
while (currMd < endMd)
|
||||
{
|
||||
currMd += mdStepSize;
|
||||
if (currMd > endMd) currMd = endMd;
|
||||
|
||||
auto pt = geom->interpolatedPointAlongWellPath(currMd);
|
||||
auto pt = geometry->interpolatedPointAlongWellPath(currMd);
|
||||
double tvd = -pt.z();
|
||||
|
||||
// Write to file
|
||||
stream << pt.x() << " " << pt.y() << " " << tvd << " " << currMd << endl;
|
||||
}
|
||||
|
||||
filePtr->close();
|
||||
stream << -999 << endl << endl;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -100,6 +106,17 @@ QFilePtr RicExportSelectedWellPathsFeature::openFileForExport(const QString& fol
|
||||
return exportFile;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QTextStreamPtr RicExportSelectedWellPathsFeature::createOutputFileStream(QFile& file)
|
||||
{
|
||||
auto stream = QTextStreamPtr(new QTextStream(&file));
|
||||
stream->setRealNumberNotation(QTextStream::FixedNotation);
|
||||
stream->setRealNumberPrecision(2);
|
||||
return stream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -164,7 +181,7 @@ RicExportWellPathsUi* RicExportSelectedWellPathsFeature::openDialog()
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
RimProject* proj = app->project();
|
||||
|
||||
QString startPath = app->lastUsedDialogDirectory("WELL_LOGS_DIR");
|
||||
QString startPath = app->lastUsedDialogDirectory("WELL_PATH_EXPORT_DIR");
|
||||
if (startPath.isEmpty())
|
||||
{
|
||||
QFileInfo fi(proj->fileName());
|
||||
@ -172,7 +189,10 @@ RicExportWellPathsUi* RicExportSelectedWellPathsFeature::openDialog()
|
||||
}
|
||||
|
||||
RicExportWellPathsUi* featureUi = app->project()->dialogData()->wellPathsExportData();
|
||||
featureUi->setExportFolder(startPath);
|
||||
if (featureUi->exportFolder().isEmpty())
|
||||
{
|
||||
featureUi->setExportFolder(startPath);
|
||||
}
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog(nullptr, featureUi, "Export Well Paths", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||
propertyDialog.resize(QSize(600, 60));
|
||||
@ -180,7 +200,7 @@ RicExportWellPathsUi* RicExportSelectedWellPathsFeature::openDialog()
|
||||
if (propertyDialog.exec() == QDialog::Accepted && !featureUi->exportFolder().isEmpty())
|
||||
{
|
||||
auto dialogData = app->project()->dialogData()->wellPathsExportData();
|
||||
app->setLastUsedDialogDirectory("WELL_LOGS_DIR", dialogData->exportFolder());
|
||||
app->setLastUsedDialogDirectory("WELL_PATH_EXPORT_DIR", dialogData->exportFolder());
|
||||
return dialogData;
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -24,13 +24,16 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
class RigWellPath;
|
||||
class RimWellPath;
|
||||
class RicExportWellPathsUi;
|
||||
class QTextStream;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
typedef std::shared_ptr<QFile> QFilePtr;
|
||||
typedef std::shared_ptr<QTextStream> QTextStreamPtr;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -39,14 +42,16 @@ class RicExportSelectedWellPathsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
static void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
|
||||
static QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
|
||||
static void handleAction(const std::vector<RimWellPath*>& wellPaths);
|
||||
static void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
|
||||
|
||||
static RicExportWellPathsUi* openDialog();
|
||||
static QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
|
||||
static QTextStreamPtr createOutputFileStream(QFile& file);
|
||||
static void writeWellPathGeometryToStream(QTextStream& stream, const RigWellPath* geometry, const QString& wellName, double mdStepSize);
|
||||
|
||||
private:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook(QAction* actionToSetup) override;
|
||||
|
||||
static RicExportWellPathsUi* openDialog();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user