From 7d9c858f13e6be28d95754b002290ad2d0112a17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 7 Nov 2018 07:00:12 +0100 Subject: [PATCH] #3566 Temp LGR. Command file command createLgrForCompletions --- .../CMakeLists_files.cmake | 2 + .../RicfCreateLgrForCompletions.cpp | 116 ++++++++++++++++ .../RicfCreateLgrForCompletions.h | 52 ++++++++ .../RicfExportLgrForCompletions.cpp | 1 - .../RicfExportLgrForCompletions.h | 2 +- .../Commands/RicCreateTemporaryLgrFeature.cpp | 125 +++++++++++------- .../Commands/RicCreateTemporaryLgrFeature.h | 21 ++- 7 files changed, 262 insertions(+), 57 deletions(-) create mode 100644 ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp create mode 100644 ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.h diff --git a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake index 86c927ff66..6cb47f7621 100644 --- a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake @@ -25,6 +25,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RicfCreateLgrForCompletions.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -53,6 +54,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPaths.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportVisibleCells.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportPropertyInViews.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportLgrForCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfCreateLgrForCompletions.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp new file mode 100644 index 0000000000..2a03afc01f --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.cpp @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicfCreateLgrForCompletions.h" + +#include "RicfCommandFileExecutor.h" +#include "RicfCreateMultipleFractures.h" + +#include "RicCreateTemporaryLgrFeature.h" +#include "ExportCommands/RicExportLgrFeature.h" + +#include "RimDialogData.h" +#include "RimEclipseCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimFractureTemplate.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaWellNameComparer.h" + +#include "cafCmdFeatureManager.h" +#include + +CAF_PDM_SOURCE_INIT(RicfCreateLgrForCompletions, "createLgrForCompletions"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicfCreateLgrForCompletions::RicfCreateLgrForCompletions() +{ + RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); + RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); + RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", ""); + RICF_InitField(&m_refinementI, "refinementI", -1, "RefinementI", "", "", ""); + RICF_InitField(&m_refinementJ, "refinementJ", -1, "RefinementJ", "", "", ""); + RICF_InitField(&m_refinementK, "refinementK", -1, "RefinementK", "", "", ""); + RICF_InitField(&m_splitType, "splitType", Lgr::SplitTypeEnum(), "SplitType", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfCreateLgrForCompletions::execute() +{ + const auto wellPaths = RicfCreateMultipleFractures::wellPaths(m_wellPathNames); + if (!wellPaths.empty()) + { + caf::CmdFeatureManager* commandManager = caf::CmdFeatureManager::instance(); + auto feature = dynamic_cast(commandManager->getCommandFeature("RicCreateTemporaryLgrFeature")); + + RimEclipseCase* eclipseCase = nullptr; + { + for (RimEclipseCase* c : RiaApplication::instance()->project()->activeOilField()->analysisModels->cases()) + { + if (c->caseId() == m_caseId()) + { + eclipseCase = c; + break; + } + } + if (!eclipseCase) + { + RiaLogging::error(QString("createLgrForCompletions: Could not find case with ID %1").arg(m_caseId())); + return; + } + } + + caf::VecIjk lgrCellCounts(m_refinementI, m_refinementJ, m_refinementK); + QStringList wellsWithIntersectingLgrs; + for (const auto wellPath : wellPaths) + { + if (wellPath) + { + bool intersectingLgrs = false; + feature->createLgrsForWellPath( + wellPath, + eclipseCase, + m_timeStep, + lgrCellCounts, + m_splitType(), + {RigCompletionData::PERFORATION, RigCompletionData::FRACTURE, RigCompletionData::FISHBONES}, + &intersectingLgrs); + + if (intersectingLgrs) wellsWithIntersectingLgrs.push_back(wellPath->name()); + } + } + + feature->updateViews(eclipseCase); + + if (!wellsWithIntersectingLgrs.empty()) + { + auto wellsList = wellsWithIntersectingLgrs.join(", "); + RiaLogging::error( + "createLgrForCompletions: No LGRs created for some wells due to existing intersecting LGR(s).Affected wells : " + + wellsList); + } + } +} diff --git a/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.h b/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.h new file mode 100644 index 0000000000..f2cb8938af --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfCreateLgrForCompletions.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "ExportCommands/RicLgrSplitType.h" + +#include "cafPdmField.h" +#include "cafAppEnum.h" + +class RimWellPath; + +//================================================================================================== +// +// +// +//================================================================================================== +class RicfCreateLgrForCompletions : public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicfCreateLgrForCompletions(); + + void execute() override; + +private: + caf::PdmField m_caseId; + caf::PdmField m_timeStep; + caf::PdmField> m_wellPathNames; + caf::PdmField m_refinementI; + caf::PdmField m_refinementJ; + caf::PdmField m_refinementK; + caf::PdmField m_splitType; +}; diff --git a/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.cpp index 075237d077..2e962a6439 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.cpp @@ -22,7 +22,6 @@ #include "RicfCreateMultipleFractures.h" #include "ExportCommands/RicExportLgrFeature.h" -#include "ExportCommands/RicExportLgrUi.h" #include "RimProject.h" #include "RimDialogData.h" diff --git a/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.h index 529820f4cc..b747cc16f8 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportLgrForCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "ExportCommands/RicExportLgrUi.h" +#include "ExportCommands/RicLgrSplitType.h" #include "cafAppEnum.h" #include "cafPdmField.h" diff --git a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp index 025a877f4b..a9cb647f88 100644 --- a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp +++ b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.cpp @@ -67,9 +67,71 @@ #include #include +#include CAF_CMD_SOURCE_INIT(RicCreateTemporaryLgrFeature, "RicCreateTemporaryLgrFeature"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateTemporaryLgrFeature::createLgrsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStep, + caf::VecIjk lgrCellCounts, + Lgr::SplitType splitType, + const std::set& completionTypes, + bool* intersectingOtherLgrs) +{ + auto eclipseCaseData = eclipseCase->eclipseCaseData(); + RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL); + bool intersectingLgrs = false; + + auto lgrs = RicExportLgrFeature::buildLgrsForWellPath( + wellPath, eclipseCase, timeStep, lgrCellCounts, splitType, completionTypes, &intersectingLgrs); + + if (intersectingLgrs) *intersectingOtherLgrs = true; + + for (const auto& lgr : lgrs) + { + createLgr(lgr, eclipseCase->eclipseCaseData()->mainGrid()); + + size_t lgrCellCount = lgr.cellCount(); + + activeCellInfo->addLgr(lgrCellCount); + if (fractureActiveCellInfo->reservoirActiveCellCount() > 0) + { + fractureActiveCellInfo->addLgr(lgrCellCount); + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateTemporaryLgrFeature::updateViews(RimEclipseCase* eclipseCase) +{ + RiaApplication::clearAllSelections(); + + deleteAllCachedData(eclipseCase); + RiaApplication::instance()->project()->mainPlotCollection()->deleteAllCachedData(); + computeCachedData(eclipseCase); + + RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots(); + + for (const auto& v : eclipseCase->views()) + { + RimEclipseView* eclipseView = dynamic_cast(v); + if (eclipseView) + { + eclipseView->scheduleReservoirGridGeometryRegen(); + } + + v->loadDataAndUpdate(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -107,65 +169,26 @@ void RicCreateTemporaryLgrFeature::onActionTriggered(bool isChecked) auto lgrCellCounts = dialogData->lgrCellCount(); size_t timeStep = dialogData->timeStep(); auto splitType = dialogData->splitType(); - auto completionTypes = dialogData->completionTypes(); + const auto completionTypes = dialogData->completionTypes(); - auto eclipseCaseData = eclipseCase->eclipseCaseData(); - RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::MATRIX_MODEL); - RigActiveCellInfo* fractureActiveCellInfo = eclipseCaseData->activeCellInfo(RiaDefines::FRACTURE_MODEL); - - bool intersectingOtherLgr = false; + bool intersectingOtherLgrs = false; for (const auto& wellPath : wellPaths) { bool intersectingLgrs = false; + createLgrsForWellPath(wellPath, + eclipseCase, + timeStep, + lgrCellCounts, + splitType, + completionTypes, + &intersectingLgrs); - auto lgrs = RicExportLgrFeature::buildLgrsForWellPath(wellPath, - eclipseCase, - timeStep, - lgrCellCounts, - splitType, - completionTypes, - &intersectingLgrs); - - if (intersectingLgrs) intersectingOtherLgr = true; - - auto mainGrid = eclipseCase->eclipseCaseData()->mainGrid(); - - for (auto lgr : lgrs) - { - createLgr(lgr, eclipseCase->eclipseCaseData()->mainGrid()); - - size_t lgrCellCount = lgr.cellCount(); - - activeCellInfo->addLgr(lgrCellCount); - if (fractureActiveCellInfo->reservoirActiveCellCount() > 0) - { - fractureActiveCellInfo->addLgr(lgrCellCount); - } - } - - mainGrid->calculateFaults(activeCellInfo); + if (intersectingLgrs) intersectingOtherLgrs = true; } - RiaApplication::clearAllSelections(); + updateViews(eclipseCase); - deleteAllCachedData(eclipseCase); - RiaApplication::instance()->project()->mainPlotCollection()->deleteAllCachedData(); - computeCachedData(eclipseCase); - - RiaApplication::instance()->project()->mainPlotCollection()->wellLogPlotCollection()->reloadAllPlots(); - - for (const auto& v : eclipseCase->views()) - { - RimEclipseView* eclipseView = dynamic_cast(v); - if (eclipseView) - { - eclipseView->scheduleReservoirGridGeometryRegen(); - } - - v->loadDataAndUpdate(); - } - - if (intersectingOtherLgr) + if (intersectingOtherLgrs) { QMessageBox::warning(nullptr, "LGR cells intersected", diff --git a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.h b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.h index 57a214995a..0c6e77d586 100644 --- a/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.h +++ b/ApplicationCode/Commands/RicCreateTemporaryLgrFeature.h @@ -18,7 +18,9 @@ #pragma once +#include "ExportCommands/RicLgrSplitType.h" #include "RigCompletionDataGridCell.h" +#include "RigCompletionData.h" #include "cafCmdFeature.h" #include "cafVecIjk.h" @@ -43,14 +45,25 @@ class RicCreateTemporaryLgrFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; +public: + void createLgrsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStep, + caf::VecIjk lgrCellCounts, + Lgr::SplitType splitType, + const std::set& completionTypes, + bool* intersectingOtherLgrs); + + void updateViews(RimEclipseCase* eclipseCase); + protected: bool isCommandEnabled() override; void onActionTriggered(bool isChecked) override; void setupActionLook(QAction* actionToSetup) override; private: - static void createLgr(const LgrInfo& lgrInfo, RigMainGrid* mainGrid); - static void computeCachedData(RimEclipseCase* eclipseCase); - static void deleteAllCachedData(RimEclipseCase* eclipseCase); - static bool containsAnyNonMainGridCells(const std::vector& cells); + void createLgr(const LgrInfo& lgrInfo, RigMainGrid* mainGrid); + void computeCachedData(RimEclipseCase* eclipseCase); + void deleteAllCachedData(RimEclipseCase* eclipseCase); + bool containsAnyNonMainGridCells(const std::vector& cells); };