From 028b5303a798464d589386ff2f3700bcfb9628c4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jan 2018 09:08:26 +0100 Subject: [PATCH] #1758 Add support for export of COMPDATL for LGR grid --- .../RicExportFractureCompletionsImpl.cpp | 20 +--- ...RicWellPathExportCompletionDataFeature.cpp | 113 ++++++++++++++---- .../RicWellPathExportCompletionDataFeature.h | 5 +- .../ReservoirDataModel/RigCompletionData.cpp | 8 ++ .../ReservoirDataModel/RigCompletionData.h | 9 +- 5 files changed, 110 insertions(+), 45 deletions(-) diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp index fd1c1df8e2..87bfde9a8f 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp @@ -344,21 +344,14 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat { if (externalCell.m_cellIndexSpace == RigTransmissibilityCondenser::CellAddress::ECLIPSE) { - if (externalCell.m_globalCellIdx > mainGrid->cellCount()) - { - RiaLogging::error(QString("LGR cells (not supported) found in export of COMPDAT values for fracture %1").arg(fracture->name())); - } - else - { - double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); + double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); - eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; + eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); - compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); - compDat.addMetadata(fracture->name(), QString::number(trans)); - fractureCompletions.push_back(compDat); - } + RigCompletionData compDat(wellPathName, IJKCellIndex(externalCell.m_globalCellIdx, caseToApply)); + compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); + compDat.addMetadata(fracture->name(), QString::number(trans)); + fractureCompletions.push_back(compDat); } } @@ -375,4 +368,3 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat return fractureCompletions; } - diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index c2d7302c3c..07d58ceb8a 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -576,9 +576,44 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) { - //TODO: Check that completion is ready for export + std::set gridNames; - QDir exportFolder = QDir(folderName); + for (const auto& c : completions) + { + gridNames.insert(c.cellIndex().lgrName()); + } + + for (const auto& gridName : gridNames) + { + std::vector completionsForGrid; + + for (const auto& c : completions) + { + if (gridName == c.cellIndex().lgrName()) + { + completionsForGrid.push_back(c); + } + } + + QString lgrFileName = fileName; + if (!gridName.isEmpty()) + { + lgrFileName += "_"; + lgrFileName += gridName; + } + + printCompletionsToFileLgr(folderName, lgrFileName, completionsForGrid, exportType); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + if (completions.empty()) return; + + QDir exportFolder(folderName); if (!exportFolder.exists()) { @@ -589,7 +624,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin QString filePath = exportFolder.filePath(fileName); QFile exportFile(filePath); - if (!exportFile.open(QIODevice::WriteOnly)) + if (!exportFile.open(QIODevice::WriteOnly)) { RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); return; @@ -602,8 +637,7 @@ void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QStrin std::sort(completions.begin(), completions.end()); // Print completion data - generateCompdatTable(formatter, completions); - + generateCompdatTable(formatter, completions[0].cellIndex().lgrName(), completions); if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) { @@ -655,26 +689,53 @@ std::map > RicWellPathExportComplet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData) +void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData) { - std::vector header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; + std::vector header; - formatter.keyword("COMPDAT"); + if (lgrName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDAT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn("KH"), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn("Df"), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0") + }; + + formatter.keyword("COMPDATL"); + } formatter.header(header); for (const RigCompletionData& data : completionData) @@ -690,6 +751,12 @@ void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseData formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); } formatter.add(data.wellName()); + + if (!lgrName.isEmpty()) + { + formatter.add(lgrName); + } + formatter.addZeroBasedCellIndex(data.cellIndex().localCellIndexI()).addZeroBasedCellIndex(data.cellIndex().localCellIndexJ()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()).addZeroBasedCellIndex(data.cellIndex().localCellIndexK()); switch (data.connectionState()) { diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 27a83f0d03..39ddf22a6c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -154,11 +154,14 @@ public: private: static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, const RicExportCompletionDataSettingsUi& settings); + static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static void printCompletionsToFileLgr(const QString& folderName, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); + static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); + static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const QString& lgrName, const std::vector& completionData); static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp index 9ed28d6361..821b03631c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp @@ -467,3 +467,11 @@ QString IJKCellIndex::oneBasedLocalCellIndexString() const return text; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString IJKCellIndex::lgrName() const +{ + return m_lgrName; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/RigCompletionData.h index e10657d1bf..fee3505ceb 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/RigCompletionData.h @@ -52,13 +52,6 @@ public: IJKCellIndex(size_t globalCellIndex, const RimEclipseCase* eclipseCase); - IJKCellIndex(const IJKCellIndex& other) - { - m_localCellIndexI = other.m_localCellIndexI; - m_localCellIndexJ = other.m_localCellIndexJ; - m_localCellIndexK = other.m_localCellIndexK; - } - bool operator==(const IJKCellIndex& other) const { return m_localCellIndexI == other.m_localCellIndexI && m_localCellIndexJ == other.m_localCellIndexJ && m_localCellIndexK == other.m_localCellIndexK; @@ -80,6 +73,8 @@ public: QString oneBasedLocalCellIndexString() const; + QString lgrName() const; + private: size_t m_globalCellIndex; QString m_lgrName;