#3828 Refactor Completion export code by splitting out MSW export into separate files

* Plus fill in some incomplete functionality regarding MSW export
This commit is contained in:
Gaute Lindkvist 2018-12-06 13:29:34 +01:00
parent b4482d20b0
commit e677778ddd
17 changed files with 1897 additions and 1859 deletions

View File

@ -33,7 +33,8 @@
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h"
#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h"
#include "CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h"
CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw");
@ -44,6 +45,10 @@ RicfExportMsw::RicfExportMsw()
{
RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", "");
RICF_InitField(&m_wellPathName, "wellPath", QString(), "Well Path Name", "", "", "");
RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", "");
RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", "");
RICF_InitField(&m_includeFractures, "includeFractures", true, "Include Fractures", "", "", "");
}
//--------------------------------------------------------------------------------------------------
@ -53,7 +58,7 @@ void RicfExportMsw::execute()
{
using TOOLS = RicfApplicationTools;
RicCaseAndFileExportSettingsUi exportSettings;
RicExportCompletionDataSettingsUi exportSettings;
auto eclipseCase = TOOLS::caseFromId(m_caseId());
if (!eclipseCase)
@ -67,7 +72,11 @@ void RicfExportMsw::execute()
{
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath("completions");
}
exportSettings.caseToApply = eclipseCase;
exportSettings.folder = exportFolder;
exportSettings.includePerforations = m_includePerforations;
exportSettings.includeFishbones = m_includeFishbones;
exportSettings.includeFractures = m_includeFractures;
RimWellPath* wellPath = RiaApplication::instance()->project()->wellPathByName(m_wellPathName);
if (!wellPath)
@ -76,8 +85,5 @@ void RicfExportMsw::execute()
return;
}
if (!wellPath->fishbonesCollection()->activeFishbonesSubs().empty())
{
RicExportFishbonesWellSegmentsFeature::exportWellSegments(wellPath, wellPath->fishbonesCollection()->activeFishbonesSubs(), exportSettings);
}
RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(exportSettings, { wellPath });
}

View File

@ -39,4 +39,7 @@ public:
private:
caf::PdmField<int> m_caseId;
caf::PdmField<QString> m_wellPathName;
caf::PdmField<bool> m_includePerforations;
caf::PdmField<bool> m_includeFishbones;
caf::PdmField<bool> m_includeFractures;
};

View File

@ -3,9 +3,10 @@ set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportMswCompletionsImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionsFileTools.h
${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h
${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportFracturesWellSegmentsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsWellSegmentsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h
${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.h
@ -24,9 +25,10 @@ set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportMswCompletionsImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionsFileTools.cpp
${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportFracturesWellSegmentsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsWellSegmentsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp
${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.cpp

View File

@ -16,7 +16,7 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicExportFishbonesWellSegmentsFeature.h"
#include "RicExportCompletionsWellSegmentsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
@ -26,12 +26,16 @@
#include "RicExportFeatureImpl.h"
#include "RicMswExportInfo.h"
#include "RicWellPathExportCompletionDataFeatureImpl.h"
#include "RicWellPathExportMswCompletionsImpl.h"
#include "RicWellPathExportCompletionsFileTools.h"
#include "RimProject.h"
#include "RimFishboneWellPathCollection.h"
#include "RimFishbonesCollection.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimPerforationCollection.h"
#include "RimWellPath.h"
#include "RimWellPathFractureCollection.h"
#include "RimEclipseCase.h"
#include "RigMainGrid.h"
@ -50,18 +54,25 @@
#include <QDir>
CAF_CMD_SOURCE_INIT(RicExportFishbonesWellSegmentsFeature, "RicExportFishbonesWellSegmentsFeature");
CAF_CMD_SOURCE_INIT(RicExportCompletionsWellSegmentsFeature, "RicExportCompletionsWellSegmentsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked)
void RicExportCompletionsWellSegmentsFeature::onActionTriggered(bool isChecked)
{
RimFishbonesCollection* fishbonesCollection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFishbonesCollection>();
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
CVF_ASSERT(fishbonesCollection);
CVF_ASSERT(wellPath);
RimFishbonesCollection* fishbonesCollection =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFishbonesCollection>();
RimWellPathFractureCollection* fractureCollection =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>();
RimPerforationCollection* perforationCollection =
caf::SelectionManager::instance()->selectedItemAncestorOfType<RimPerforationCollection>();
CVF_ASSERT(fishbonesCollection || fractureCollection || perforationCollection);
RiaApplication* app = RiaApplication::instance();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder("COMPLETIONS");
@ -87,18 +98,22 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked)
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
RicExportCompletionDataSettingsUi completionExportSettings;
completionExportSettings.caseToApply.setValue(exportSettings.caseToApply);
completionExportSettings.folder.setValue(exportSettings.folder);
if (!fishbonesCollection->activeFishbonesSubs().empty())
{
exportWellSegments(wellPath, fishbonesCollection->activeFishbonesSubs(), exportSettings);
}
completionExportSettings.includeFishbones = fishbonesCollection != nullptr && !fishbonesCollection->activeFishbonesSubs().empty();
completionExportSettings.includeFractures = fractureCollection != nullptr && !fractureCollection->activeFractures().empty();
completionExportSettings.includePerforations = perforationCollection != nullptr && !perforationCollection->activePerforations().empty();
RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions(completionExportSettings, { wellPath });
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::setupActionLook(QAction* actionToSetup)
void RicExportCompletionsWellSegmentsFeature::setupActionLook(QAction* actionToSetup)
{
actionToSetup->setText("Export Well Segments");
}
@ -106,55 +121,20 @@ void RicExportFishbonesWellSegmentsFeature::setupActionLook(QAction* actionToSet
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportFishbonesWellSegmentsFeature::isCommandEnabled()
bool RicExportCompletionsWellSegmentsFeature::isCommandEnabled()
{
if (caf::SelectionManager::instance()->selectedItemAncestorOfType<RimFishbonesCollection>())
{
return true;
}
else if (caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>())
{
return true;
}
else if (caf::SelectionManager::instance()->selectedItemAncestorOfType<RimPerforationCollection>())
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath* wellPath, const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs, const RicCaseAndFileExportSettingsUi& settings)
{
if (fishbonesSubs.empty()) return;
if (settings.caseToApply() == nullptr)
{
RiaLogging::error("Export Well Segments: Cannot export completions data without specified eclipse case");
return;
}
QString fileName = QString("%1-Welsegs").arg(settings.caseToApply()->caseUserDescription());
fileName = caf::Utils::makeValidFileBasename(fileName);
QDir exportFolder(settings.folder());
if (!exportFolder.exists())
{
bool createdPath = exportFolder.mkpath(".");
if (createdPath)
RiaLogging::info("Created export folder " + settings.folder());
else
RiaLogging::error("Selected output folder does not exist, and could not be created.");
}
QString filePath = exportFolder.filePath(fileName);
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
RiaLogging::error(QString("Export Well Segments: Could not open the file: %1").arg(filePath));
return;
}
RicMswExportInfo exportInfo = RicWellPathExportCompletionDataFeatureImpl::generateFishbonesMswExportInfo(settings.caseToApply, wellPath, fishbonesSubs, true);
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
RicWellPathExportCompletionDataFeatureImpl::generateWelsegsTable (formatter, exportInfo);
RicWellPathExportCompletionDataFeatureImpl::generateCompsegTables(formatter, exportInfo);
RicWellPathExportCompletionDataFeatureImpl::generateWsegvalvTable(formatter, exportInfo);
}

View File

@ -22,22 +22,22 @@
#include "cafCmdFeature.h"
class RimFishbonesCollection;
class RimFishbonesMultipleSubs;
class RimWellPath;
class RimWellPathFracture;
class RimWellPathFractureCollection;
//==================================================================================================
///
//==================================================================================================
class RicExportFracturesWellSegmentsFeature : public caf::CmdFeature
class RicExportCompletionsWellSegmentsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static void exportWellSegments(const RimWellPath* wellPath, const std::vector<RimWellPathFracture*>& fractures, const RicCaseAndFileExportSettingsUi& settings);
protected:
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
bool isCommandEnabled() override;
};

View File

@ -1,47 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicCaseAndFileExportSettingsUi.h"
#include "cafCmdFeature.h"
class RimFishbonesCollection;
class RimFishbonesMultipleSubs;
class RimWellPath;
//==================================================================================================
///
//==================================================================================================
class RicExportFishbonesWellSegmentsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
bool isCommandEnabled() override;
public:
static void exportWellSegments(const RimWellPath* wellPath,
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs,
const RicCaseAndFileExportSettingsUi& settings);
};

View File

@ -1,168 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicExportFracturesWellSegmentsFeature.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
#include "RicCaseAndFileExportSettingsUi.h"
#include "RicExportFeatureImpl.h"
#include "RicMswExportInfo.h"
#include "RicWellPathExportCompletionDataFeatureImpl.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathFracture.h"
#include "RimWellPathFractureCollection.h"
#include "RifEclipseDataTableFormatter.h"
#include "Riu3DMainWindowTools.h"
#include "cafSelectionManager.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafUtils.h"
#include <QAction>
#include <QDir>
CAF_CMD_SOURCE_INIT(RicExportFracturesWellSegmentsFeature, "RicExportFracturesWellSegmentsFeature");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFracturesWellSegmentsFeature::exportWellSegments(const RimWellPath* wellPath, const std::vector<RimWellPathFracture*>& fractures, const RicCaseAndFileExportSettingsUi& settings)
{
if (settings.caseToApply() == nullptr)
{
RiaLogging::error("Export Fracture Well Segments: Cannot export completions data without specified eclipse case");
return;
}
QString fileName = QString("%1-Fracture-Welsegs").arg(settings.caseToApply()->caseUserDescription());
fileName = caf::Utils::makeValidFileBasename(fileName);
QDir exportFolder(settings.folder());
if (!exportFolder.exists())
{
bool createdPath = exportFolder.mkpath(".");
if (createdPath)
RiaLogging::info("Export Fracture Well Segments: Created export folder " + settings.folder());
else
RiaLogging::error("Export Fracture Well Segments: Selected output folder does not exist, and could not be created.");
}
QString filePath = exportFolder.filePath(fileName);
QFile exportFile(filePath);
if (!exportFile.open(QIODevice::WriteOnly | QIODevice::Text))
{
RiaLogging::error(QString("Export Fracture Well Segments: Could not open the file: %1").arg(filePath));
return;
}
RicMswExportInfo exportInfo = RicWellPathExportCompletionDataFeatureImpl::generateFracturesMswExportInfo(settings.caseToApply, wellPath, fractures);
QTextStream stream(&exportFile);
RifEclipseDataTableFormatter formatter(stream);
RicWellPathExportCompletionDataFeatureImpl::generateWelsegsTable(formatter, exportInfo);
RicWellPathExportCompletionDataFeatureImpl::generateCompsegTables(formatter, exportInfo);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFracturesWellSegmentsFeature::onActionTriggered(bool isChecked)
{
RimWellPath* wellPath = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPath>();
RimWellPathFracture* fracture = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFracture>();
RimWellPathFractureCollection* collection = caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>();
CVF_ASSERT(wellPath);
CVF_ASSERT(collection);
RiaApplication* app = RiaApplication::instance();
QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder("COMPLETIONS");
RicCaseAndFileExportSettingsUi exportSettings;
std::vector<RimCase*> cases;
app->project()->allCases(cases);
for (auto c : cases)
{
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(c);
if (eclipseCase != nullptr)
{
exportSettings.caseToApply = eclipseCase;
break;
}
}
exportSettings.folder = defaultDir;
caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Fractures as Multi Segment Wells", "");
RicExportFeatureImpl::configureForExport(&propertyDialog);
if (propertyDialog.exec() == QDialog::Accepted)
{
RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", QFileInfo(exportSettings.folder).absolutePath());
std::vector<RimWellPathFracture*> fractures;
if (fracture)
{
fractures.push_back(fracture);
}
else
{
for (RimWellPathFracture* activeFracture : collection->activeFractures())
{
fractures.push_back(activeFracture);
}
}
exportWellSegments(wellPath, fractures, exportSettings);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicExportFracturesWellSegmentsFeature::setupActionLook(QAction* actionToSetup)
{
if (caf::SelectionManager::instance()->selectedItemOfType<RimWellPathFracture>())
{
actionToSetup->setText("Export Fracture as Multi Segment Well");
}
else
{
actionToSetup->setText("Export Fractures as Multi Segment Well");
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicExportFracturesWellSegmentsFeature::isCommandEnabled()
{
if (RiaApplication::enableDevelopmentFeatures() && caf::SelectionManager::instance()->selectedItemAncestorOfType<RimWellPathFractureCollection>())
{
return true;
}
return false;
}

View File

@ -19,7 +19,9 @@
#include "RicFishbonesTransmissibilityCalculationFeatureImp.h"
#include "RicExportCompletionDataSettingsUi.h"
#include "RicMswExportInfo.h"
#include "RicWellPathExportCompletionDataFeatureImpl.h"
#include "RicWellPathExportMswCompletionsImpl.h"
#include "RigActiveCellInfo.h"
#include "RigCompletionData.h"
@ -187,7 +189,7 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell
// Generate data
const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData();
RicMswExportInfo exportInfo =
RicWellPathExportCompletionDataFeatureImpl::generateFishbonesMswExportInfo(settings.caseToApply(), wellPath, false);
RicWellPathExportMswCompletionsImpl::generateFishbonesMswExportInfo(settings.caseToApply(), wellPath, false);
RiaEclipseUnitTools::UnitSystem unitSystem = caseData->unitsType();
bool isMainBore = false;

View File

@ -21,7 +21,6 @@
#include "RigCompletionData.h"
#include "RicExportCompletionDataSettingsUi.h"
#include "RicMswExportInfo.h"
#include "RicWellPathFractureReportItem.h"
#include <QFile>
@ -114,25 +113,6 @@ class RicWellPathExportCompletionDataFeatureImpl
{
public:
static RicMswExportInfo generateFishbonesMswExportInfo(const RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
bool enableSegmentSplitting);
static RicMswExportInfo generateFishbonesMswExportInfo(const RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs,
bool enableSegmentSplitting);
static RicMswExportInfo generateFracturesMswExportInfo(RimEclipseCase* caseToApply,
const RimWellPath* wellPath);
static RicMswExportInfo generateFracturesMswExportInfo(RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
const std::vector<RimWellPathFracture*>& fractures);
static RicMswExportInfo generatePerforationsMswExportInfo(const RicExportCompletionDataSettingsUi& exportSettings,
const RimWellPath* wellPath,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static CellDirection calculateCellMainDirection(RimEclipseCase* eclipseCase,
size_t globalCellIndex,
@ -166,45 +146,11 @@ public:
RimEclipseCase* eclipseCase,
size_t timeStepIndex);
static void generateWelsegsTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
static void generateWelsegsSegments(RifEclipseDataTableFormatter &formatter,
const RicMswExportInfo &exportInfo,
const std::set<RigCompletionData::CompletionType>& exportCompletionTypes);
static void generateWelsegsCompletionCommentHeader(RifEclipseDataTableFormatter &formatter,
RigCompletionData::CompletionType completionType);
static void generateCompsegTables(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
static void generateCompsegTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo,
bool exportSubGridIntersections,
const std::set<RigCompletionData::CompletionType>& exportCompletionTypes);
static void generateCompsegHeader(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo,
RigCompletionData::CompletionType completionType,
bool exportSubGridIntersections);
static void generateWsegvalvTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
static std::vector<RigCompletionData> generatePerforationsCompdatValues(const RimWellPath* wellPath,
const std::vector<const RimPerforationInterval*>& intervals,
const RicExportCompletionDataSettingsUi& settings);
private:
typedef std::vector<std::shared_ptr<RicMswSegment>> MainBoreSegments;
typedef std::map <std::shared_ptr<RicMswCompletion>, std::set<std::pair<const RimWellPathValve*, size_t>>> ValveContributionMap;
static MainBoreSegments createMainBoreSegments(const std::vector<SubSegmentIntersectionInfo>& subSegIntersections,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
const RimWellPath* wellPath,
const RicExportCompletionDataSettingsUi& exportSettings,
bool* foundSubGridIntersections);
static void assignSuperValveCompletions(std::vector<std::shared_ptr<RicMswSegment>>& mainBoreSegments,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static void assignValveContributionsToSuperValves(const std::vector<std::shared_ptr<RicMswSegment>>& mainBoreSegments,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
RiaEclipseUnitTools::UnitSystem unitSystem);
static void moveIntersectionsToSuperValves(MainBoreSegments mainBoreSegments);
static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase,
double skinFactor,
@ -215,11 +161,6 @@ private:
static RigCompletionData combineEclipseCellCompletions(const std::vector<RigCompletionData>& completions,
const RicExportCompletionDataSettingsUi& settings);
static QFilePtr openFileForExport(const QString& fullFileName);
static QFilePtr openFileForExport(const QString& folderName,
const QString& fileName);
static std::vector<RigCompletionData> mainGridCompletions(std::vector<RigCompletionData>& allCompletions);
static std::map<QString, std::vector<RigCompletionData>> subGridsCompletions(std::vector<RigCompletionData>& allCompletions);
@ -256,34 +197,6 @@ private:
const QString& gridName,
const std::vector<RigCompletionData>& completionData);
static std::vector<RigCompletionData> generatePerforationsCompdatValues(const RimWellPath* wellPath,
const std::vector<const RimPerforationInterval*>& intervals,
const RicExportCompletionDataSettingsUi& settings);
static void assignFishbonesLateralIntersections(const RimEclipseCase* caseToApply,
const RimFishbonesMultipleSubs* fishbonesSubs,
std::shared_ptr<RicMswSegment> location,
bool* foundSubGridIntersections,
double maxSegmentLength);
static void assignFractureIntersections(const RimEclipseCase* caseToApply,
const RimWellPathFracture* fracture,
const std::vector<RigCompletionData>& completionData,
std::shared_ptr<RicMswSegment> location,
bool* foundSubGridIntersections);
static void assignPerforationIntervalIntersections(const std::vector<RigCompletionData>& completionData,
std::shared_ptr<RicMswCompletion> perforationCompletion,
const SubSegmentIntersectionInfo& cellIntInfo,
bool* foundSubGridIntersections);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply,
std::shared_ptr<RicMswSegment> location,
int* branchNum,
int* segmentNum);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply,
RicMswExportInfo* exportInfo);
static void appendCompletionData(std::map<size_t, std::vector<RigCompletionData>>* completionData,
const std::vector<RigCompletionData>& data);
@ -291,21 +204,6 @@ private:
const RimWellPath* wellPath,
const QString& gridName = "");
static void exportWellSegments(RimEclipseCase* eclipseCase,
QFilePtr exportFile,
const RimWellPath* wellPath,
const std::vector<RimWellPathFracture*>& fractures);
static void exportWellSegments(RimEclipseCase* eclipseCase,
QFilePtr exportFile,
const RimWellPath* wellPath,
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs);
static void exportWellSegments(const RicExportCompletionDataSettingsUi& exportSettings,
QFilePtr exportFile,
const RimWellPath* wellPath,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static void exportCarfinForTemporaryLgrs(const RimEclipseCase* sourceCase, const QString& folder);
static bool isCompletionWellPathEqual(const RigCompletionData& completion, const RimWellPath* wellPath);

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Equinor 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 "RicWellPathExportCompletionsFileTools.h"
#include "RiaApplication.h"
#include "RiaFilePathTools.h"
#include "RiaLogging.h"
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimWellPathCompletions.h"
#include "cafUtils.h"
#include <QDir>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicWellPathExportCompletionsFileTools::OpenFileException::OpenFileException(const QString& message)
: message(message)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport(const QString& fullFileName)
{
std::pair<QString, QString> folderAndFileName = RiaFilePathTools::toFolderAndFileName(fullFileName);
return openFileForExport(folderAndFileName.first, folderAndFileName.second);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::shared_ptr<QFile> RicWellPathExportCompletionsFileTools::openFileForExport(const QString& folderName, const QString& fileName)
{
QString validFileName = caf::Utils::makeValidFileBasename(fileName);
QDir exportFolder = QDir(folderName);
if (!exportFolder.exists())
{
bool createdPath = exportFolder.mkpath(".");
if (createdPath)
RiaLogging::info("Created export folder " + folderName);
else
{
auto errorMessage = QString("Selected output folder does not exist, and could not be created.");
RiaLogging::error(errorMessage);
throw OpenFileException(errorMessage);
}
}
QString filePath = exportFolder.filePath(validFileName);
std::shared_ptr<QFile> exportFile(new QFile(filePath));
if (!exportFile->open(QIODevice::WriteOnly | QIODevice::Text))
{
auto errorMessage = QString("Export Completions Data: Could not open the file: %1").arg(filePath);
RiaLogging::error(errorMessage);
throw OpenFileException(errorMessage);
}
return exportFile;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimWellPath* RicWellPathExportCompletionsFileTools::findWellPathFromExportName(const QString& wellNameForExport)
{
auto allWellPaths = RiaApplication::instance()->project()->allWellPaths();
for (const auto wellPath : allWellPaths)
{
if (wellPath->completions()->wellNameForExport() == wellNameForExport) return wellPath;
}
return nullptr;
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Equinor 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 <QFile>
#include <QString>
#include <memory>
class RimWellPath;
class RicWellPathExportCompletionsFileTools
{
public:
class OpenFileException
{
public:
OpenFileException(const QString& message);
QString message;
};
static std::shared_ptr<QFile> openFileForExport(const QString& folderName, const QString& fileName);
static std::shared_ptr<QFile> openFileForExport(const QString& fullFileName);
static const RimWellPath* findWellPathFromExportName(const QString& wellNameForExport);
};

View File

@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018 Equinor 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 "RicMswExportInfo.h"
#include "RigCompletionData.h"
class RicExportCompletionDataSettingsUi;
class RifEclipseDataTableFormatter;
class RimEclipseCase;
class RimFishbonesMultipleSubs;
class RimPerforationInterval;
class RimWellPath;
class RimWellPathValve;
class RimWellPathFracture;
class SubSegmentIntersectionInfo;
class QFile;
class RicWellPathExportMswCompletionsImpl
{
public:
static void exportWellSegmentsForAllCompletions(const RicExportCompletionDataSettingsUi& exportSettings,
const std::vector<RimWellPath*>& wellPaths);
static void exportWellSegmentsForFractures(RimEclipseCase* eclipseCase,
std::shared_ptr<QFile> exportFile,
const RimWellPath* wellPath,
const std::vector<RimWellPathFracture*>& fractures);
static void exportWellSegmentsForFishbones(RimEclipseCase* eclipseCase,
std::shared_ptr<QFile> exportFile,
const RimWellPath* wellPath,
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs);
static void exportWellSegmentsForPerforations(RimEclipseCase* eclipseCase,
std::shared_ptr<QFile> exportFile,
const RimWellPath* wellPath,
int timeStep,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static RicMswExportInfo generateFishbonesMswExportInfo(const RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
bool enableSegmentSplitting);
private:
static RicMswExportInfo generateFishbonesMswExportInfo(const RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
const std::vector<RimFishbonesMultipleSubs*>& fishbonesSubs,
bool enableSegmentSplitting);
static RicMswExportInfo generateFracturesMswExportInfo(RimEclipseCase* caseToApply,
const RimWellPath* wellPath);
static RicMswExportInfo generateFracturesMswExportInfo(RimEclipseCase* caseToApply,
const RimWellPath* wellPath,
const std::vector<RimWellPathFracture*>& fractures);
static RicMswExportInfo generatePerforationsMswExportInfo(RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
int timeStep,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static void generateWelsegsTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
static void generateWelsegsSegments(RifEclipseDataTableFormatter &formatter,
const RicMswExportInfo &exportInfo,
const std::set<RigCompletionData::CompletionType>& exportCompletionTypes);
static void generateWelsegsCompletionCommentHeader(RifEclipseDataTableFormatter &formatter,
RigCompletionData::CompletionType completionType);
static void generateCompsegTables(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
static void generateCompsegTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo,
bool exportSubGridIntersections,
const std::set<RigCompletionData::CompletionType>& exportCompletionTypes);
static void generateCompsegHeader(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo,
RigCompletionData::CompletionType completionType,
bool exportSubGridIntersections);
static void generateWsegvalvTable(RifEclipseDataTableFormatter& formatter,
const RicMswExportInfo& exportInfo);
private:
typedef std::vector<std::shared_ptr<RicMswSegment>> MainBoreSegments;
typedef std::map<std::shared_ptr<RicMswCompletion>, std::set<std::pair<const RimWellPathValve*, size_t>>>
ValveContributionMap;
static MainBoreSegments createMainBoreSegmentsForPerforations(const std::vector<SubSegmentIntersectionInfo>& subSegIntersections,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
const RimWellPath* wellPath,
int timeStep,
RimEclipseCase* eclipseCase,
bool* foundSubGridIntersections);
static void assignSuperValveCompletions(std::vector<std::shared_ptr<RicMswSegment>>& mainBoreSegments,
const std::vector<const RimPerforationInterval*>& perforationIntervals);
static void assignValveContributionsToSuperValves(const std::vector<std::shared_ptr<RicMswSegment>>& mainBoreSegments,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
RiaEclipseUnitTools::UnitSystem unitSystem);
static void moveIntersectionsToSuperValves(MainBoreSegments mainBoreSegments);
static void assignFishbonesLateralIntersections(const RimEclipseCase* caseToApply,
const RimFishbonesMultipleSubs* fishbonesSubs,
std::shared_ptr<RicMswSegment> location,
bool* foundSubGridIntersections,
double maxSegmentLength);
static void assignFractureIntersections(const RimEclipseCase* caseToApply,
const RimWellPathFracture* fracture,
const std::vector<RigCompletionData>& completionData,
std::shared_ptr<RicMswSegment> location,
bool* foundSubGridIntersections);
static std::vector<RigCompletionData> generatePerforationIntersections(const RimWellPath* wellPath,
const RimPerforationInterval* perforationInterval,
int timeStep,
RimEclipseCase* eclipseCase);
static void assignPerforationIntersections(const std::vector<RigCompletionData>& completionData,
std::shared_ptr<RicMswCompletion> perforationCompletion,
const SubSegmentIntersectionInfo& cellIntInfo,
bool* foundSubGridIntersections);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply,
std::shared_ptr<RicMswSegment> location,
int* branchNum,
int* segmentNum);
static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, RicMswExportInfo* exportInfo);
};

View File

@ -185,3 +185,21 @@ std::vector<const RimPerforationInterval*> RimPerforationCollection::perforation
return myPerforations;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RimPerforationInterval*> RimPerforationCollection::activePerforations() const
{
std::vector<const RimPerforationInterval*> myActivePerforations;
for (const auto& perforation : m_perforations)
{
if (perforation->isChecked())
{
myActivePerforations.push_back(perforation);
}
}
return myActivePerforations;
}

View File

@ -48,6 +48,7 @@ public:
void setUnitSystemSpecificDefaults();
void appendPerforation(RimPerforationInterval* perforation);
std::vector<const RimPerforationInterval*> perforations() const;
std::vector<const RimPerforationInterval*> activePerforations() const;
private:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;

View File

@ -747,8 +747,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicEditPerforationCollectionFeature";
menuBuilder << "RicExportFishbonesLateralsFeature";
menuBuilder << "RicExportFishbonesWellSegmentsFeature";
menuBuilder << "RicExportFracturesWellSegmentsFeature";
menuBuilder << "RicExportCompletionsWellSegmentsFeature";
{
QStringList candidates;