From 47bb14eb06c04427f93fadd1a3db22b4ba606951 Mon Sep 17 00:00:00 2001 From: Gaute Lindkvist Date: Fri, 14 Dec 2018 08:44:36 +0100 Subject: [PATCH] #3864 Update and clamp valve positions to perforation interval when perforation interval changes. --- .../RicWellPathExportMswCompletionsImpl.cpp | 41 +++++++++---------- .../Completions/RimMultipleValveLocations.cpp | 23 +++++++++-- .../Completions/RimMultipleValveLocations.h | 5 ++- .../Completions/RimPerforationInterval.cpp | 9 ++++ .../Completions/RimWellPathValve.cpp | 38 +++++++++++++---- .../Completions/RimWellPathValve.h | 1 + 6 files changed, 82 insertions(+), 35 deletions(-) diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp index a74b168ce7..8369481c19 100644 --- a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportMswCompletionsImpl.cpp @@ -1139,12 +1139,12 @@ void RicWellPathExportMswCompletionsImpl::assignSuperValveCompletions( if (isAicd) { - superAICD.reset(new RicMswPerforationAICD(valveLabel)); + superAICD = std::make_shared(valveLabel); superAICD->addSubSegment(subSegment); } else { - superICD.reset(new RicMswPerforationICD(valveLabel)); + superICD = std::make_shared(valveLabel); superICD->addSubSegment(subSegment); } } @@ -1152,14 +1152,14 @@ void RicWellPathExportMswCompletionsImpl::assignSuperValveCompletions( { QString valveLabel = QString("%1 #%2").arg("Combined Valve for segment").arg(nMainSegment + 2); std::shared_ptr subSegment(new RicMswSubSegment(overlapStart, overlapStart + 0.1, 0.0, 0.0)); - superICD.reset(new RicMswPerforationICD(valveLabel)); + superICD = std::make_shared(valveLabel); superICD->addSubSegment(subSegment); } else if (overlap > 0.0 && (isAicd && !superAICD)) { QString valveLabel = QString("%1 #%2").arg("Combined Valve for segment").arg(nMainSegment + 2); std::shared_ptr subSegment(new RicMswSubSegment(overlapStart, overlapStart + 0.1, 0.0, 0.0)); - superAICD.reset(new RicMswPerforationAICD(valveLabel)); + superAICD = std::make_shared(valveLabel); superAICD->addSubSegment(subSegment); } @@ -1216,11 +1216,11 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperValves( std::shared_ptr accumulator; if (std::dynamic_pointer_cast(superValve)) { - accumulator.reset(new RicMswICDAccumulator(unitSystem)); + accumulator = std::make_shared(unitSystem); } else if (std::dynamic_pointer_cast(superValve)) { - accumulator.reset(new RicMswAICDAccumulator(unitSystem)); + accumulator = std::make_shared(unitSystem); } for (const RimPerforationInterval* interval : perforationIntervals) @@ -1260,7 +1260,7 @@ void RicWellPathExportMswCompletionsImpl::assignValveContributionsToSuperValves( for (auto regularValvePair : assignedRegularValves) { - if (regularValvePair.second.size()) + if (!regularValvePair.second.empty()) { QStringList valveLabels; for (std::pair regularValve : regularValvePair.second) @@ -1610,9 +1610,8 @@ std::vector SubSegmentIntersectionInfo::spiltInterse if (!pathGeometry) return out; - for (size_t i = 0; i < intersections.size(); i++) + for (const auto& intersection : intersections) { - const auto& intersection = intersections[i]; double segLen = intersection.endMD - intersection.startMD; int segCount = (int)std::trunc(segLen / maxSegmentLength) + 1; @@ -1621,12 +1620,12 @@ std::vector SubSegmentIntersectionInfo::spiltInterse if (segCount == 1) { - out.push_back(SubSegmentIntersectionInfo(intersection.globCellIndex, - -intersection.startPoint.z(), - -intersection.endPoint.z(), - intersection.startMD, - intersection.endMD, - intersection.intersectionLengthsInCellCS)); + out.emplace_back(intersection.globCellIndex, + -intersection.startPoint.z(), + -intersection.endPoint.z(), + intersection.startMD, + intersection.endMD, + intersection.intersectionLengthsInCellCS); } else { @@ -1640,12 +1639,12 @@ std::vector SubSegmentIntersectionInfo::spiltInterse currEndMd = currStartMd + effectiveMaxSegLen; cvf::Vec3d segEndPoint = pathGeometry->interpolatedPointAlongWellPath(currEndMd); - out.push_back(SubSegmentIntersectionInfo(intersection.globCellIndex, - lastTvd, - lasti ? -intersection.endPoint.z() : -segEndPoint.z(), - currStartMd, - lasti ? intersection.endMD : currEndMd, - intersection.intersectionLengthsInCellCS / segCount)); + out.emplace_back(intersection.globCellIndex, + lastTvd, + lasti ? -intersection.endPoint.z() : -segEndPoint.z(), + currStartMd, + lasti ? intersection.endMD : currEndMd, + intersection.intersectionLengthsInCellCS / segCount); currStartMd = currEndMd; lastTvd = -segEndPoint.z(); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp b/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp index 4f99f00327..987a1d7bd1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.cpp @@ -67,6 +67,21 @@ RimMultipleValveLocations::RimMultipleValveLocations() m_locationOfValves.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMultipleValveLocations::perforationIntervalUpdated() +{ + double existingRangeStart = m_rangeStart(); + double existingRangeEnd = m_rangeEnd(); + m_rangeStart = cvf::Math::clamp(m_rangeStart(), perforationStartMD(), perforationEndMD()); + m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), perforationStartMD(), perforationEndMD()); + if (existingRangeStart != m_rangeStart() || existingRangeEnd != m_rangeEnd()) + { + computeRangesAndLocations(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -295,8 +310,8 @@ void RimMultipleValveLocations::fieldChangedByUi(const caf::PdmFieldHandle* chan changedField == &m_rangeValveSpacing) { recomputeLocations = true; - m_rangeStart = cvf::Math::clamp(m_rangeStart(), rangeMin(), rangeMax()); - m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), rangeMin(), rangeMax()); + m_rangeStart = cvf::Math::clamp(m_rangeStart(), perforationStartMD(), perforationEndMD()); + m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), perforationStartMD(), perforationEndMD()); } if (changedField == &m_rangeValveSpacing) @@ -376,7 +391,7 @@ double RimMultipleValveLocations::minimumSpacingMeters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimMultipleValveLocations::rangeMin() const +double RimMultipleValveLocations::perforationStartMD() const { const RimPerforationInterval* perfInterval = nullptr; this->firstAncestorOrThisOfType(perfInterval); @@ -391,7 +406,7 @@ double RimMultipleValveLocations::rangeMin() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimMultipleValveLocations::rangeMax() const +double RimMultipleValveLocations::perforationEndMD() const { const RimPerforationInterval* perfInterval = nullptr; this->firstAncestorOrThisOfType(perfInterval); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.h b/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.h index 746d56cb23..755015505b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimMultipleValveLocations.h @@ -41,6 +41,7 @@ public: public: RimMultipleValveLocations(); + void perforationIntervalUpdated(); double measuredDepth(size_t valveIndex) const; double rangeStart() const; double rangeEnd() const; @@ -62,8 +63,8 @@ protected: private: int rangeCountFromSpacing() const; double minimumSpacingMeters() const; - double rangeMin() const; - double rangeMax() const; + double perforationStartMD() const; + double perforationEndMD() const; static std::vector locationsFromStartSpacingAndCount(double start, double spacing, size_t count); private: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp index e20775dfc7..5768577771 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp @@ -314,6 +314,15 @@ void RimPerforationInterval::fieldChangedByUi(const caf::PdmFieldHandle* changed const QVariant& oldValue, const QVariant& newValue) { + if (changedField == &m_startMD || + changedField == &m_endMD) + { + for (RimWellPathValve* valve : m_valves()) + { + valve->perforationIntervalUpdated(); + } + } + this->updateAllReferringTracks(); RimProject* proj = nullptr; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp index 3f46398695..79d14be6df 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.cpp @@ -69,6 +69,25 @@ RimWellPathValve::~RimWellPathValve() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPathValve::perforationIntervalUpdated() +{ + if (m_type() == RiaDefines::ICV) + { + const RimPerforationInterval* perfInterval = nullptr; + this->firstAncestorOrThisOfType(perfInterval); + double startMD = perfInterval->startMD(); + double endMD = perfInterval->endMD(); + m_measuredDepth = cvf::Math::clamp(m_measuredDepth(), startMD, endMD); + } + else + { + m_multipleValveLocations->perforationIntervalUpdated(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -436,19 +455,22 @@ void RimWellPathValve::defineEditorAttribute(const caf::PdmFieldHandle* field, Q //-------------------------------------------------------------------------------------------------- void RimWellPathValve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { - QString fullName = componentLabel() + QString(" %1").arg(m_measuredDepth()); - this->setName(fullName); - - if ( m_type() == RiaDefines::ICD ) - { - this->setUiIcon(QIcon(":/ICDValve16x16.png")); - } - else if ( m_type() == RiaDefines::ICV ) + if ( m_type() == RiaDefines::ICV ) { this->setUiIcon(QIcon(":/ICVValve16x16.png")); + QString fullName = QString("%1: %2").arg(componentLabel()).arg(m_measuredDepth()); + this->setName(fullName); + } + else if ( m_type() == RiaDefines::ICD ) + { + this->setUiIcon(QIcon(":/ICDValve16x16.png")); + QString fullName = QString("%1: %2 - %3").arg(componentLabel()).arg(m_multipleValveLocations->rangeStart()).arg(m_multipleValveLocations->rangeEnd()); + this->setName(fullName); } else if ( m_type() == RiaDefines::AICD ) { this->setUiIcon(QIcon(":/AICDValve16x16.png")); + QString fullName = QString("%1: %2 - %3").arg(componentLabel()).arg(m_multipleValveLocations->rangeStart()).arg(m_multipleValveLocations->rangeEnd()); + this->setName(fullName); } } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.h index b5f1a511f8..7978c65d76 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathValve.h @@ -44,6 +44,7 @@ public: RimWellPathValve(); ~RimWellPathValve() override; + void perforationIntervalUpdated(); void setMeasuredDepthAndCount(double startMD, double spacing, int valveCount); void multipleValveGeometryUpdated(); std::vector valveLocations() const;