mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#1452 Fishbones : Export laterals to text file
This commit is contained in:
parent
b0c5ceeab6
commit
342a58a0ae
@ -6,10 +6,12 @@ endif()
|
||||
|
||||
set (SOURCE_GROUP_HEADER_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
@ -0,0 +1,142 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicExportFishbonesLateralsFeature.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimFishbonesMultipleSubs.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
#include "cafUtils.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
CAF_CMD_SOURCE_INIT(RicExportFishbonesLateralsFeature, "RicExportFishbonesLateralsFeature");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportFishbonesLateralsFeature::onActionTriggered(bool isChecked)
|
||||
{
|
||||
RimWellPath* wellPath = selectedWellPath();
|
||||
CVF_ASSERT(wellPath);
|
||||
|
||||
RiaApplication* app = RiaApplication::instance();
|
||||
QString projectFolder = app->currentProjectPath();
|
||||
|
||||
QString defaultDir = app->lastUsedDialogDirectoryWithFallback("WELL_PATH_EXPORT_DIR", projectFolder);
|
||||
|
||||
QString defaultFileName = defaultDir + "/" + caf::Utils::makeValidFileBasename((wellPath->name())) + ".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;
|
||||
|
||||
QFile exportFile(completeFilename);
|
||||
|
||||
RiaLogging::info("Starting export of Fishbones well path laterals to : " + completeFilename);
|
||||
|
||||
if (!exportFile.open(QIODevice::WriteOnly))
|
||||
{
|
||||
RiaLogging::error("Could not open the file :\n" + completeFilename);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// See RifWellPathAsciiFileReader::readAllWellData for reading of dev files
|
||||
// Export format
|
||||
//
|
||||
// wellname : <well name><sub lateral name>_<sub index>_<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 : wellPath->fishbonesSubs())
|
||||
{
|
||||
if (!fishbone->isChecked()) continue;
|
||||
|
||||
for (size_t subIndex = 0; subIndex < fishbone->locationOfSubs().size(); subIndex++)
|
||||
{
|
||||
for (size_t lateralIndex = 0; lateralIndex < fishbone->lateralLengths().size(); lateralIndex++)
|
||||
{
|
||||
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMD = fishbone->coordsAndMDForLateral(subIndex, lateralIndex);
|
||||
|
||||
// Pad with "0" to get a total of two characters defining the sub index text
|
||||
QString subIndexText = QString("%1").arg(subIndex, 2, 10, QChar('0'));
|
||||
|
||||
QString lateralName = QString("%1_%2_%3_%4").arg(wellPath->name()).arg(fishbone->name()).arg(subIndexText).arg(lateralIndex);
|
||||
stream << "wellname : " << lateralName << endl;
|
||||
|
||||
for (auto coordMD : coordsAndMD)
|
||||
{
|
||||
// Export X and Y unchanged, invert sign of Z to get TVD, export MD unchanged
|
||||
stream << coordMD.first.x() << " " << coordMD.first.y() << " " << -coordMD.first.z() << " " << coordMD.second << endl;
|
||||
}
|
||||
stream << -999 << endl << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RiaLogging::info("Completed export of Fishbones well path laterals to : " + completeFilename);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellPath* RicExportFishbonesLateralsFeature::selectedWellPath()
|
||||
{
|
||||
RimWellPath* wellPath = nullptr;
|
||||
|
||||
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
|
||||
|
||||
caf::PdmObjectHandle* objHandle = dynamic_cast<caf::PdmObjectHandle*>(pdmUiItem);
|
||||
if (objHandle)
|
||||
{
|
||||
objHandle->firstAncestorOrThisOfType(wellPath);
|
||||
}
|
||||
|
||||
return wellPath;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportFishbonesLateralsFeature::setupActionLook(QAction* actionToSetup)
|
||||
{
|
||||
//actionToSetup->setIcon(QIcon(":/FractureSymbol16x16.png"));
|
||||
actionToSetup->setText("Export Fishbones Laterals");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicExportFishbonesLateralsFeature::isCommandEnabled()
|
||||
{
|
||||
if (selectedWellPath())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 RimWellPath;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicExportFishbonesLateralsFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
virtual void onActionTriggered(bool isChecked) override;
|
||||
virtual void setupActionLook(QAction* actionToSetup) override;
|
||||
virtual bool isCommandEnabled() override;
|
||||
|
||||
private:
|
||||
static RimWellPath* selectedWellPath();
|
||||
};
|
@ -191,17 +191,25 @@ std::vector<double> RimFishbonesMultipleSubs::lateralLengths() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RimFishbonesMultipleSubs::coordsForLateral(size_t subIndex, size_t lateralIndex) const
|
||||
{
|
||||
std::vector<RigCoordAndMD> coordsAndMD = m_rigFishbonesGeometry->coordsForLateral(subIndex, lateralIndex);
|
||||
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMD = m_rigFishbonesGeometry->coordsForLateral(subIndex, lateralIndex);
|
||||
|
||||
std::vector<cvf::Vec3d> domainCoords;
|
||||
for (auto c :coordsAndMD)
|
||||
for (const auto& coordMD : coordsAndMD)
|
||||
{
|
||||
domainCoords.push_back(c.m_coord);
|
||||
domainCoords.push_back(coordMD.first);
|
||||
}
|
||||
|
||||
return domainCoords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::pair<cvf::Vec3d, double>> RimFishbonesMultipleSubs::coordsAndMDForLateral(size_t subIndex, size_t lateralIndex) const
|
||||
{
|
||||
return m_rigFishbonesGeometry->coordsForLateral(subIndex, lateralIndex);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -64,7 +64,8 @@ public:
|
||||
double lateralCountPerSub() const;
|
||||
std::vector<double> lateralLengths() const;
|
||||
|
||||
std::vector<cvf::Vec3d> coordsForLateral(size_t subIndex, size_t lateralIndex) const;
|
||||
std::vector<cvf::Vec3d> coordsForLateral(size_t subIndex, size_t lateralIndex) const;
|
||||
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMDForLateral(size_t subIndex, size_t lateralIndex) const;
|
||||
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
@ -396,6 +396,7 @@ QStringList RimContextCommandBuilder::commandsFromSelection()
|
||||
commandIds << "RicSummaryCurveSwitchAxisFeature";
|
||||
|
||||
commandIds << "RicNewFishbonesSubsFeature";
|
||||
commandIds << "RicExportFishbonesLateralsFeature";
|
||||
|
||||
// Work in progress -- End
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user