From 6c51938000895e86b7d0ecca5ab070d551a9b447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 11 Oct 2017 15:23:14 +0200 Subject: [PATCH] #1976 RFT/PLT Plot. Associate well path and sim well when loading models and files --- .../ProjectDataModel/RimEclipseCase.cpp | 15 +++++++++++ .../ProjectDataModel/RimWellPath.cpp | 27 ++++++++++++------- .../ProjectDataModel/RimWellPath.h | 3 ++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 217588ddfc..504c111a9c 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -49,6 +49,9 @@ #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" +#include "RimOilField.h" +#include "RimWellPathCollection.h" +#include "RimWellPath.h" #include "cafPdmDocument.h" #include "cafProgressInfo.h" @@ -616,6 +619,18 @@ bool RimEclipseCase::openReserviorCase() createTimeStepFormatString(); + // Associate existing well paths with simulation wells + RimProject* proj = RiaApplication::instance()->project(); + for (const auto& oilField : proj->oilFields()) + { + for (const auto& wellPath : oilField->wellPathCollection()->wellPaths()) + { + if (!wellPath->isAssociatedWithSimulationWell()) + { + wellPath->tryAssociateWithSimulationWell(); + } + } + } return true; } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 4eacb50036..b6505dcf9a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -40,6 +40,8 @@ #include "RivWellPathPartMgr.h" +#include "RiaApplication.h" + #include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" @@ -47,7 +49,6 @@ #include #include #include -#include "RiaApplication.h" CAF_PDM_SOURCE_INIT(RimWellPath, "WellPath"); @@ -345,6 +346,7 @@ void RimWellPath::setName(const QString& name) { m_name = name; m_completions->setWellNameForExport(name); + tryAssociateWithSimulationWell(); } //-------------------------------------------------------------------------------------------------- @@ -408,11 +410,7 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO if (m_simWellName().isEmpty()) { // Try to set default simulation well name - auto simWellName = tryFindSimulationWellFromWellPathName(m_name); - if (!simWellName.isEmpty()) - { - m_simWellName = simWellName; - } + tryAssociateWithSimulationWell(); } caf::PdmUiGroup* appGroup = uiOrdering.addNewGroup("Appearance"); @@ -641,15 +639,24 @@ int RimWellPath::relatedSimulationWellBranch() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString RimWellPath::tryFindSimulationWellFromWellPathName(const QString& wellPathName) +bool RimWellPath::tryAssociateWithSimulationWell() { RimProject* proj = RiaApplication::instance()->project(); for (const auto& simWellName : proj->simulationWellNames()) { - if (QString::compare(simWellName, wellPathName) == 0) + if (QString::compare(simWellName, m_name) == 0) { - return simWellName; + m_simWellName = simWellName; + return true; } } - return ""; + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellPath::isAssociatedWithSimulationWell() const +{ + return !m_simWellName().isEmpty() && QString::compare(m_simWellName, SIM_WELL_NONE_NAME) != 0; } diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index bf3b1213e2..4784b0aff0 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -116,7 +116,8 @@ public: const QString relatedSimulationWell() const; int relatedSimulationWellBranch() const; - static const QString tryFindSimulationWellFromWellPathName(const QString& wellPathName); + bool tryAssociateWithSimulationWell(); + bool isAssociatedWithSimulationWell() const; private: