#3325 Well Path export. Command file command for exporting well paths

This commit is contained in:
Bjørn Erik Jensen 2018-09-25 09:09:13 +02:00
parent f61b82dd35
commit c422ffc6ed
10 changed files with 142 additions and 26 deletions

View File

@ -21,6 +21,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h
${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.h
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.h
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -45,6 +46,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfCreateMultipleFractures.cpp
${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -34,6 +34,7 @@ namespace caf {
addItem(RicfCommandFileExecutor::PROPERTIES, "PROPERTIES", "Properties");
addItem(RicfCommandFileExecutor::SNAPSHOTS, "SNAPSHOTS", "Snapshots");
addItem(RicfCommandFileExecutor::STATISTICS, "STATISTICS", "Statistics");
addItem(RicfCommandFileExecutor::WELLPATHS, "WELLPATHS", "Well Path");
setDefault(RicfCommandFileExecutor::COMPLETIONS);
}
}

View File

@ -39,7 +39,8 @@ public:
COMPLETIONS,
SNAPSHOTS,
PROPERTIES,
STATISTICS
STATISTICS,
WELLPATHS
};
typedef caf::AppEnum<ExportType> ExportTypeEnum;

View File

@ -81,7 +81,7 @@ void RicfCreateMultipleFractures::execute()
// Get case and fracture template
auto gridCase = caseFromId(m_caseId);
auto fractureTemplate = fractureTemplateFromId(m_templateId);
auto wellPaths = this->wellPaths();
auto wellPaths = this->wellPaths(m_wellPathNames);
if (gridCase && fractureTemplate && !wellPaths.empty() && validateArguments())
{
@ -166,18 +166,18 @@ RimFractureTemplate* RicfCreateMultipleFractures::fractureTemplateFromId(int tem
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RicfCreateMultipleFractures::wellPaths() const
std::vector<RimWellPath*> RicfCreateMultipleFractures::wellPaths(const std::vector<QString>& wellPathNames)
{
std::vector<RimWellPath*> wellPaths;
auto allWellPaths = RiaApplication::instance()->project()->allWellPaths();
if (!m_wellPathNames.v().empty())
if (!wellPathNames.empty())
{
std::set<QString> wellPathNameSet(m_wellPathNames.v().begin(), m_wellPathNames.v().end());
std::set<QString> wellPathNameSet(wellPathNames.begin(), wellPathNames.end());
for (auto wellPath : allWellPaths)
{
if (!RiaWellNameComparer::tryMatchNameInList(wellPath->name(), m_wellPathNames.v()).isEmpty())
if (!RiaWellNameComparer::tryMatchNameInList(wellPath->name(), wellPathNames).isEmpty())
wellPaths.push_back(wellPath);
}
}
@ -186,7 +186,7 @@ std::vector<RimWellPath*> RicfCreateMultipleFractures::wellPaths() const
wellPaths = allWellPaths;
}
if (wellPaths.empty() || wellPaths.size() < m_wellPathNames.v().size())
if (wellPaths.empty() || wellPaths.size() < wellPathNames.size())
{
RiaLogging::error(QString("createMultipleFractures: One or more well paths was not found"));
std::this_thread::sleep_for(std::chrono::seconds(2));

View File

@ -50,12 +50,12 @@ public:
RicfCreateMultipleFractures();
virtual void execute() override;
static std::vector<RimWellPath*> wellPaths(const std::vector<QString>& wellPathNames);
private:
bool validateArguments() const;
RimEclipseCase* caseFromId(int caseId)const ;
RimFractureTemplate* fractureTemplateFromId(int templateId) const;
std::vector<RimWellPath*> wellPaths() const;
caf::PdmField<int> m_caseId;
caf::PdmField<std::vector<QString>> m_wellPathNames;

View File

@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfExportWellPaths.h"
#include "RicfCommandFileExecutor.h"
#include "RicfCreateMultipleFractures.h"
#include "ExportCommands/RicExportSelectedWellPathsFeature.h"
#include "RimProject.h"
#include "RimDialogData.h"
#include "RimFractureTemplate.h"
#include "RimOilField.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseCollection.h"
#include "RimWellPath.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RiaWellNameComparer.h"
#include "cafCmdFeatureManager.h"
CAF_PDM_SOURCE_INIT(RicfExportWellPaths, "exportWellPaths");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportWellPaths::RicfExportWellPaths()
{
RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names", "", "", "");
RICF_InitField(&m_mdStepSize, "mdStepSize", 5.0, "MD Step Size", "", "", "");
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicfExportWellPaths::execute()
{
const auto wellPaths = RicfCreateMultipleFractures::wellPaths(m_wellPathNames);
if (!wellPaths.empty())
{
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath(RicfCommandFileExecutor::WELLPATHS);
if (exportFolder.isNull())
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("wellpaths");
}
caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance();
auto feature = dynamic_cast<RicExportSelectedWellPathsFeature*>(commandManager->getCommandFeature("RicExportSelectedWellPathsFeature"));
for (const auto wellPath : wellPaths)
{
if (wellPath)
{
feature->exportWellPath(wellPath, m_mdStepSize, exportFolder);
}
}
}
}

View File

@ -0,0 +1,45 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicfCommandObject.h"
#include "cafPdmField.h"
#include "cafAppEnum.h"
class RimWellPath;
//==================================================================================================
//
//
//
//==================================================================================================
class RicfExportWellPaths : public RicfCommandObject
{
CAF_PDM_HEADER_INIT;
public:
RicfExportWellPaths();
virtual void execute() override;
private:
caf::PdmField<std::vector<QString>> m_wellPathNames;
caf::PdmField<double> m_mdStepSize;
};

View File

@ -83,6 +83,13 @@ void RicExportSelectedWellPathsFeature::exportWellPath(const RimWellPath* wellPa
QFilePtr RicExportSelectedWellPathsFeature::openFileForExport(const QString& folderName, const QString& fileName)
{
QDir exportFolder = QDir(folderName);
if (!exportFolder.exists())
{
bool createdPath = exportFolder.mkpath(".");
if (createdPath)
RiaLogging::info("Created export folder " + folderName);
}
QString filePath = exportFolder.filePath(fileName);
QFilePtr exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly))

View File

@ -55,7 +55,7 @@ void RicExportVisibleWellPathsFeature::exportWellPath(const RimWellPath* wellPat
double endMd = geom->measureDepths().back();
auto fileName = wellPath->name() + ".dev";
auto filePtr = openFileForExport(folder, fileName);
auto filePtr = RicExportSelectedWellPathsFeature::openFileForExport(folder, fileName);
QTextStream stream(filePtr.get());
stream.setRealNumberNotation(QTextStream::FixedNotation);
@ -76,22 +76,6 @@ void RicExportVisibleWellPathsFeature::exportWellPath(const RimWellPath* wellPat
filePtr->close();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QFilePtr RicExportVisibleWellPathsFeature::openFileForExport(const QString& folderName, const QString& fileName)
{
QDir exportFolder = QDir(folderName);
QString filePath = exportFolder.filePath(fileName);
QFilePtr exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly))
{
auto errorMessage = QString("Export Well Path: Could not open the file: %1").arg(filePath);
RiaLogging::error(errorMessage);
}
return exportFile;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -40,7 +40,6 @@ class RicExportVisibleWellPathsFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
void exportWellPath(const RimWellPath* wellPath, double mdStepSize, const QString& folder);
QFilePtr openFileForExport(const QString& folderName, const QString& fileName);
private:
bool isCommandEnabled() override;