#3527 Split out the valve locations from RimFishbonesMultipleSubs.h

This commit is contained in:
Gaute Lindkvist 2018-10-19 12:20:09 +02:00
parent fc4620985f
commit 43552fde88
5 changed files with 549 additions and 229 deletions

View File

@ -26,6 +26,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimMswCompletionParameters.h
${CMAKE_CURRENT_LIST_DIR}/RimNonDarcyPerforationParameters.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathComponentInterface.h
${CMAKE_CURRENT_LIST_DIR}/RimWellPathValve.h
${CMAKE_CURRENT_LIST_DIR}/RimMultipleValveLocations.h
)
@ -55,6 +56,7 @@ ${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurveCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMswCompletionParameters.cpp
${CMAKE_CURRENT_LIST_DIR}/RimNonDarcyPerforationParameters.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellPathValve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMultipleValveLocations.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -24,6 +24,7 @@
#include "RimProject.h"
#include "RimWellPath.h"
#include "RimFishbonesCollection.h"
#include "RimMultipleValveLocations.h"
#include "cafPdmUiDoubleValueEditor.h"
#include "cafPdmUiListEditor.h"
@ -36,6 +37,7 @@
#include "cvfMath.h"
CAF_PDM_SOURCE_INIT(RimFishbonesMultipleSubs, "FishbonesMultipleSubs");
namespace caf {
@ -92,20 +94,11 @@ RimFishbonesMultipleSubs::RimFishbonesMultipleSubs()
CAF_PDM_InitField(&m_icdOrificeDiameter, "IcdOrificeDiameter", 7.0, "ICD Orifice Diameter [mm]", "", "", "");
CAF_PDM_InitField(&m_icdFlowCoefficient, "IcdFlowCoefficient", 1.5, "ICD Flow Coefficient", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_locationOfSubs, "LocationOfSubs", "Measured Depths [m]", "", "", "");
m_locationOfSubs.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_subsLocationMode, "SubsLocationMode", caf::AppEnum<LocationType>(FB_SUB_COUNT_END), "Location Defined By", "", "", "");
CAF_PDM_InitField(&m_rangeStart, "RangeStart", 100.0, "Start MD [m]", "", "", "");
m_rangeStart.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_rangeEnd, "RangeEnd", 250.0, "End MD [m]", "", "", "");
m_rangeEnd.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_rangeSubSpacing, "RangeSubSpacing", "Spacing [m]", "", "", "");
m_rangeSubSpacing.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_rangeSubCount, "RangeSubCount", 13, "Number of Subs", "", "", "");
initialiseObsoleteFields();
CAF_PDM_InitFieldNoDefault(&m_valveLocations, "ValveLocations", "Valve Locations", "", "", "");
m_valveLocations = new RimMultipleValveLocations();
m_valveLocations.uiCapability()->setUiHidden(true);
m_valveLocations.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_subsOrientationMode, "SubsOrientationMode", caf::AppEnum<LateralsOrientationType>(FB_LATERAL_ORIENTATION_RANDOM), "Orientation", "", "", "");
@ -156,11 +149,7 @@ QString RimFishbonesMultipleSubs::generatedName() const
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::setMeasuredDepthAndCount(double measuredDepth, double spacing, int subCount)
{
m_subsLocationMode = FB_SUB_SPACING_END;
m_rangeStart = measuredDepth;
m_rangeEnd = measuredDepth + spacing * subCount;
m_rangeSubCount = subCount;
m_valveLocations->setMeasuredDepthAndCount(measuredDepth, spacing, subCount);
computeRangesAndLocations();
computeRotationAngles();
@ -171,9 +160,7 @@ void RimFishbonesMultipleSubs::setMeasuredDepthAndCount(double measuredDepth, do
//--------------------------------------------------------------------------------------------------
double RimFishbonesMultipleSubs::measuredDepth(size_t subIndex) const
{
CVF_ASSERT(subIndex < m_locationOfSubs().size());
return m_locationOfSubs()[subIndex];
return m_valveLocations->measuredDepth(subIndex);
}
//--------------------------------------------------------------------------------------------------
@ -338,6 +325,25 @@ std::vector<double> RimFishbonesMultipleSubs::lateralLengths() const
return lengths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::valveLocationsUpdated()
{
RimFishbonesCollection* collection;
this->firstAncestorOrThisOfTypeAsserted(collection);
computeSubLateralIndices();
collection->recalculateStartMD();
computeRotationAngles();
computeSubLateralIndices();
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted(proj);
proj->reloadCompletionTypeResultsInAllViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -440,9 +446,9 @@ cvf::Color3f RimFishbonesMultipleSubs::defaultComponentColor() const
double RimFishbonesMultipleSubs::startMD() const
{
double measuredDepth = 0.0;
if (!m_locationOfSubs().empty())
if (!m_valveLocations->locationOfValves().empty())
{
measuredDepth = m_locationOfSubs().front();
measuredDepth = m_valveLocations->locationOfValves().front();
}
return measuredDepth;
@ -454,9 +460,9 @@ double RimFishbonesMultipleSubs::startMD() const
double RimFishbonesMultipleSubs::endMD() const
{
double measuredDepth = 0.0;
if (!m_locationOfSubs().empty())
if (!m_valveLocations->locationOfValves().empty())
{
measuredDepth = m_locationOfSubs().back();
measuredDepth = m_valveLocations->locationOfValves().back();
}
return measuredDepth;
@ -467,78 +473,18 @@ double RimFishbonesMultipleSubs::endMD() const
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
bool recomputeLocations = false;
if (changedField == &m_subsLocationMode)
{
if (m_subsLocationMode == FB_SUB_COUNT_END || m_subsLocationMode == FB_SUB_SPACING_END)
{
recomputeLocations = true;
}
}
if (changedField == &m_rangeStart ||
changedField == &m_rangeEnd ||
changedField == &m_rangeSubCount ||
changedField == &m_rangeSubSpacing)
{
recomputeLocations = true;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry();
if (rigWellPathGeo && !rigWellPathGeo->m_measuredDepths.empty())
{
double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back();
m_rangeStart = cvf::Math::clamp(m_rangeStart(), 0.0, lastWellPathMD);
m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), m_rangeStart(), lastWellPathMD);
}
}
if (changedField == &m_rangeSubSpacing)
{
// Minimum distance between fishbones is 13.0m
// Use 10.0m to allow for some flexibility
double minimumDistanceMeter = 10.0;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD)
{
double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet(minimumDistanceMeter);
m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceFeet, std::max(m_rangeSubSpacing(), minimumDistanceFeet));
}
else
{
m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceMeter, std::max(m_rangeSubSpacing(), minimumDistanceMeter));
}
}
if (recomputeLocations)
{
computeRangesAndLocations();
}
if (recomputeLocations ||
changedField == &m_locationOfSubs ||
changedField == &m_subsOrientationMode)
if (changedField == &m_subsOrientationMode)
{
computeRotationAngles();
}
if (changedField == &m_locationOfSubs ||
changedField == &m_lateralInstallSuccessFraction ||
if (changedField == &m_lateralInstallSuccessFraction ||
changedField == &m_lateralCountPerSub)
{
computeSubLateralIndices();
}
RimProject* proj;
this->firstAncestorOrThisOfTypeAsserted(proj);
proj->reloadCompletionTypeResultsInAllViews();
valveLocationsUpdated();
}
//--------------------------------------------------------------------------------------------------
@ -562,53 +508,8 @@ caf::PdmFieldHandle* RimFishbonesMultipleSubs::objectToggleField()
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::computeRangesAndLocations()
{
if (m_subsLocationMode == FB_SUB_COUNT_END)
{
int divisor = 1;
if (m_rangeSubCount > 2) divisor = m_rangeSubCount - 1;
m_rangeSubSpacing = fabs(m_rangeStart - m_rangeEnd) / divisor;
}
else if (m_subsLocationMode == FB_SUB_SPACING_END)
{
m_rangeSubCount = (fabs(m_rangeStart - m_rangeEnd) / m_rangeSubSpacing) + 1;
if (m_rangeSubCount < 1)
{
m_rangeSubCount = 1;
}
}
if (m_subsLocationMode == FB_SUB_COUNT_END || m_subsLocationMode == FB_SUB_SPACING_END)
{
std::vector<double> validMeasuredDepths;
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry();
if (rigWellPathGeo && rigWellPathGeo->m_measuredDepths.size() > 1)
{
double firstWellPathMD = rigWellPathGeo->m_measuredDepths.front();
double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back();
for (auto md : locationsFromStartSpacingAndCount(m_rangeStart, m_rangeSubSpacing, m_rangeSubCount))
{
if (md >= firstWellPathMD && md <= lastWellPathMD)
{
validMeasuredDepths.push_back(md);
}
}
}
}
m_locationOfSubs = validMeasuredDepths;
}
RimFishbonesCollection* collection;
this->firstAncestorOrThisOfTypeAsserted(collection);
computeSubLateralIndices();
collection->recalculateStartMD();
m_valveLocations->computeRangesAndLocations();
valveLocationsUpdated();
}
//--------------------------------------------------------------------------------------------------
@ -630,11 +531,6 @@ void RimFishbonesMultipleSubs::defineUiOrdering(QString uiConfigName, caf::PdmUi
m_lateralTubingRoghnessFactor.uiCapability()->setUiName("Tubing Roughness Factor [m]");
m_icdOrificeDiameter.uiCapability()->setUiName("ICD Orifice Diameter [mm]");
m_locationOfSubs.uiCapability()->setUiName("Measured Depths [m]");
m_rangeStart.uiCapability()->setUiName("Start MD [m]");
m_rangeEnd.uiCapability()->setUiName("End MD [m]");
m_rangeSubSpacing.uiCapability()->setUiName("Spacing [m]");
}
else if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD)
{
@ -645,11 +541,6 @@ void RimFishbonesMultipleSubs::defineUiOrdering(QString uiConfigName, caf::PdmUi
m_lateralTubingRoghnessFactor.uiCapability()->setUiName("Tubing Roughness Factor [ft]");
m_icdOrificeDiameter.uiCapability()->setUiName("ICD Orifice Diameter [in]");
m_locationOfSubs.uiCapability()->setUiName("Measured Depths [ft]");
m_rangeStart.uiCapability()->setUiName("Start MD [ft]");
m_rangeEnd.uiCapability()->setUiName("End MD [ft]");
m_rangeSubSpacing.uiCapability()->setUiName("Spacing [ft]");
}
}
}
@ -660,28 +551,9 @@ void RimFishbonesMultipleSubs::defineUiOrdering(QString uiConfigName, caf::PdmUi
group->add(&fishbonesColor);
}
{
{
caf::PdmUiGroup* group = uiOrdering.addNewGroup("Location");
group->add(&m_subsLocationMode);
if (m_subsLocationMode() != FB_SUB_USER_DEFINED)
{
group->add(&m_rangeStart);
group->add(&m_rangeEnd);
if (m_subsLocationMode() == FB_SUB_COUNT_END)
{
group->add(&m_rangeSubCount);
group->add(&m_rangeSubSpacing);
}
else if (m_subsLocationMode() == FB_SUB_SPACING_END)
{
group->add(&m_rangeSubSpacing);
group->add(&m_rangeSubCount);
}
}
group->add(&m_locationOfSubs);
m_valveLocations->uiOrdering(uiConfigName, *group);
}
{
@ -720,38 +592,6 @@ void RimFishbonesMultipleSubs::defineUiOrdering(QString uiConfigName, caf::PdmUi
mswGroup->add(&m_icdFlowCoefficient);
}
// Visibility
if (m_subsLocationMode == FB_SUB_USER_DEFINED)
{
m_locationOfSubs.uiCapability()->setUiReadOnly(false);
m_rangeSubSpacing.uiCapability()->setUiReadOnly(true);
m_rangeSubCount.uiCapability()->setUiReadOnly(true);
m_rangeStart.uiCapability()->setUiReadOnly(true);
m_rangeEnd.uiCapability()->setUiReadOnly(true);
}
else
{
m_locationOfSubs.uiCapability()->setUiReadOnly(true);
m_rangeSubSpacing.uiCapability()->setUiReadOnly(false);
m_rangeSubCount.uiCapability()->setUiReadOnly(false);
m_rangeStart.uiCapability()->setUiReadOnly(false);
m_rangeEnd.uiCapability()->setUiReadOnly(false);
if (m_subsLocationMode == FB_SUB_COUNT_END)
{
m_rangeSubSpacing.uiCapability()->setUiReadOnly(true);
m_rangeSubCount.uiCapability()->setUiReadOnly(false);
}
else
{
m_rangeSubSpacing.uiCapability()->setUiReadOnly(false);
m_rangeSubCount.uiCapability()->setUiReadOnly(true);
}
}
uiOrdering.skipRemainingFields();
}
@ -760,7 +600,9 @@ void RimFishbonesMultipleSubs::defineUiOrdering(QString uiConfigName, caf::PdmUi
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::initAfterRead()
{
if (m_locationOfSubs().size() != m_installationRotationAngles().size())
initValveLocationFromLegacyData();
if (m_valveLocations->locationOfValves().size() != m_installationRotationAngles().size())
{
computeRotationAngles();
}
@ -797,7 +639,7 @@ void RimFishbonesMultipleSubs::computeRotationAngles()
{
std::vector<double> vals;
for (size_t i = 0; i < m_locationOfSubs().size(); i++)
for (size_t i = 0; i < m_valveLocations->locationOfValves().size(); i++)
{
vals.push_back(RimFishbonesMultipleSubs::randomValueFromRange(0, 360));
}
@ -811,7 +653,7 @@ void RimFishbonesMultipleSubs::computeRotationAngles()
void RimFishbonesMultipleSubs::computeSubLateralIndices()
{
m_subLateralIndices.clear();
for (size_t subIndex = 0; subIndex < m_locationOfSubs().size(); ++subIndex)
for (size_t subIndex = 0; subIndex < m_valveLocations->locationOfValves().size(); ++subIndex)
{
SubLateralIndex subLateralIndex;
subLateralIndex.subIndex = subIndex;
@ -822,7 +664,7 @@ void RimFishbonesMultipleSubs::computeSubLateralIndices()
}
m_subLateralIndices.push_back(subLateralIndex);
}
double numLaterals = static_cast<double>(m_locationOfSubs().size() * m_lateralCountPerSub);
double numLaterals = static_cast<double>(m_valveLocations->locationOfValves().size() * m_lateralCountPerSub);
int numToRemove = static_cast<int>(std::round((1 - m_lateralInstallSuccessFraction) * numLaterals));
srand(m_randomSeed());
while (numToRemove > 0)
@ -837,21 +679,6 @@ void RimFishbonesMultipleSubs::computeSubLateralIndices()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimFishbonesMultipleSubs::locationsFromStartSpacingAndCount(double start, double spacing, size_t count)
{
std::vector<double> measuredDepths;
for (size_t i = 0; i < count; i++)
{
measuredDepths.push_back(start + spacing * i);
}
return measuredDepths;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -866,3 +693,54 @@ int RimFishbonesMultipleSubs::randomValueFromRange(int min, int max)
return randomValue;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::initialiseObsoleteFields()
{
CAF_PDM_InitField(&m_subsLocationMode_OBSOLETE, "SubsLocationMode", caf::AppEnum<LocationType>(FB_SUB_UNDEFINED), "Location Defined By", "", "", "");
m_subsLocationMode_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_rangeStart_OBSOLETE, "RangeStart", std::numeric_limits<double>::infinity(), "Start MD [m]", "", "", "");
m_rangeStart_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_rangeEnd_OBSOLETE, "RangeEnd", std::numeric_limits<double>::infinity(), "End MD [m]", "", "", "");
m_rangeEnd_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_rangeSubSpacing_OBSOLETE, "RangeSubSpacing", std::numeric_limits<double>::infinity(), "Spacing [m]", "", "", "");
m_rangeSubSpacing_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitField(&m_rangeSubCount_OBSOLETE, "RangeSubCount", -1, "Number of Subs", "", "", "");
m_rangeSubCount_OBSOLETE.xmlCapability()->setIOWritable(false);
CAF_PDM_InitFieldNoDefault(&m_locationOfSubs_OBSOLETE, "LocationOfSubs", "Measured Depths [m]", "", "", "");
m_locationOfSubs_OBSOLETE.xmlCapability()->setIOWritable(false);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFishbonesMultipleSubs::initValveLocationFromLegacyData()
{
RimMultipleValveLocations::LocationType locationType = RimMultipleValveLocations::VALVE_UNDEFINED;
if (m_subsLocationMode_OBSOLETE() == FB_SUB_COUNT_END)
{
locationType = RimMultipleValveLocations::VALVE_COUNT;
}
else if (m_subsLocationMode_OBSOLETE() == FB_SUB_SPACING_END)
{
locationType = RimMultipleValveLocations::VALVE_SPACING;
}
else if (m_subsLocationMode_OBSOLETE() == FB_SUB_USER_DEFINED)
{
locationType = RimMultipleValveLocations::VALVE_CUSTOM;
}
m_valveLocations->initFieldsFromFishbones(locationType,
m_rangeStart_OBSOLETE(),
m_rangeEnd_OBSOLETE(),
m_rangeSubSpacing_OBSOLETE(),
m_rangeSubCount_OBSOLETE(),
m_locationOfSubs_OBSOLETE());
}

View File

@ -38,6 +38,7 @@
#include <memory>
class RigFisbonesGeometry;
class RimMultipleValveLocations;
//==================================================================================================
///
@ -61,7 +62,8 @@ public:
{
FB_SUB_COUNT_END,
FB_SUB_SPACING_END,
FB_SUB_USER_DEFINED
FB_SUB_USER_DEFINED,
FB_SUB_UNDEFINED
};
enum LateralsOrientationType
@ -95,6 +97,8 @@ public:
size_t icdCount() const { return m_icdCount(); }
std::vector<double> lateralLengths() const;
void valveLocationsUpdated();
const std::vector<SubLateralIndex>& installedLateralIndices() const { return m_subLateralIndices; };
std::vector<cvf::Vec3d> coordsForLateral(size_t subIndex, size_t lateralIndex) const;
std::vector<std::pair<cvf::Vec3d, double>> coordsAndMDForLateral(size_t subIndex, size_t lateralIndex) const;
@ -129,9 +133,10 @@ private:
void computeRotationAngles();
void computeSubLateralIndices();
static std::vector<double> locationsFromStartSpacingAndCount(double start, double spacing, size_t count);
static int randomValueFromRange(int min, int max);
void initialiseObsoleteFields();
void initValveLocationFromLegacyData();
private:
caf::PdmField<bool> m_isActive;
caf::PdmProxyValueField<QString> m_name;
@ -153,16 +158,9 @@ private:
caf::PdmField<double> m_icdOrificeDiameter;
caf::PdmField<double> m_icdFlowCoefficient;
caf::PdmField<caf::AppEnum<LocationType> > m_subsLocationMode;
caf::PdmField<double> m_rangeStart;
caf::PdmField<double> m_rangeEnd;
caf::PdmField<double> m_rangeSubSpacing;
caf::PdmField<int> m_rangeSubCount;
caf::PdmChildField<RimMultipleValveLocations*> m_valveLocations;
caf::PdmField<caf::AppEnum<LateralsOrientationType> > m_subsOrientationMode;
caf::PdmField<std::vector<double>> m_locationOfSubs; // Given in measured depth
caf::PdmField<std::vector<double>> m_installationRotationAngles;
caf::PdmField<double> m_fixedInstallationRotationAngle;
@ -172,4 +170,13 @@ private:
std::unique_ptr<RigFisbonesGeometry> m_rigFishbonesGeometry;
std::vector<SubLateralIndex> m_subLateralIndices;
// Moved to RimMultipleValveLocations
caf::PdmField<caf::AppEnum<LocationType> > m_subsLocationMode_OBSOLETE;
caf::PdmField<double> m_rangeStart_OBSOLETE;
caf::PdmField<double> m_rangeEnd_OBSOLETE;
caf::PdmField<double> m_rangeSubSpacing_OBSOLETE;
caf::PdmField<int> m_rangeSubCount_OBSOLETE;
caf::PdmField<std::vector<double>> m_locationOfSubs_OBSOLETE; // Given in measured depth
};

View File

@ -0,0 +1,361 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimMultipleValveLocations.h"
#include "RigWellPath.h"
#include "RimFishbonesMultipleSubs.h"
#include "RimWellPath.h"
#include "cafPdmUiDoubleValueEditor.h"
#include "cafPdmUiListEditor.h"
CAF_PDM_SOURCE_INIT(RimMultipleValveLocations, "RimMultipleValveLocations");
namespace caf {
template<>
void AppEnum<RimMultipleValveLocations::LocationType>::setUp()
{
addItem(RimMultipleValveLocations::VALVE_COUNT, "VALVE_COUNT", "Start/End/Number of Subs");
addItem(RimMultipleValveLocations::VALVE_SPACING, "VALVE_SPACING", "Start/End/Spacing");
addItem(RimMultipleValveLocations::VALVE_CUSTOM, "VALVE_CUSTOM", "User Specification");
setDefault(RimMultipleValveLocations::VALVE_COUNT);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimMultipleValveLocations::RimMultipleValveLocations()
{
CAF_PDM_InitObject("RimMultipleValveLocations", ":/FishBoneGroup16x16.png", "", "");
CAF_PDM_InitField(&m_locationType, "LocationMode", caf::AppEnum<LocationType>(VALVE_COUNT), "Location Defined By", "", "", "");
CAF_PDM_InitField(&m_rangeStart, "RangeStart", 100.0, "Start MD [m]", "", "", "");
m_rangeStart.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_rangeEnd, "RangeEnd", 250.0, "End MD [m]", "", "", "");
m_rangeEnd.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitFieldNoDefault(&m_rangeValveSpacing, "ValveSpacing", "Spacing [m]", "", "", "");
m_rangeValveSpacing.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName());
CAF_PDM_InitField(&m_rangeValveCount, "RangeValveCount", 13, "Number of Valves", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_locationOfValves, "LocationOfValves", "Measured Depths [m]", "", "", "");
m_locationOfValves.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimMultipleValveLocations::measuredDepth(size_t valveIndex) const
{
CVF_ASSERT(valveIndex < m_locationOfValves().size());
return m_locationOfValves()[valveIndex];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double>& RimMultipleValveLocations::locationOfValves() const
{
return m_locationOfValves();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::setLocationType(LocationType locationType)
{
m_locationType = locationType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::setMeasuredDepthAndCount(double measuredDepth, double spacing, int valveCount)
{
m_locationType = RimMultipleValveLocations::VALVE_SPACING;
m_rangeStart = measuredDepth;
m_rangeEnd = measuredDepth + spacing * valveCount;
m_rangeValveCount = valveCount;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::computeRangesAndLocations()
{
if (m_locationType == VALVE_COUNT)
{
int divisor = 1;
if (m_rangeValveCount > 2) divisor = m_rangeValveCount - 1;
m_rangeValveSpacing = fabs(m_rangeStart - m_rangeEnd) / divisor;
}
else if (m_locationType == VALVE_SPACING)
{
m_rangeValveCount = (fabs(m_rangeStart - m_rangeEnd) / m_rangeValveSpacing) + 1;
if (m_rangeValveCount < 1)
{
m_rangeValveCount = 1;
}
}
if (m_locationType == VALVE_COUNT || m_locationType == VALVE_SPACING)
{
std::vector<double> validMeasuredDepths;
{
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry();
if (rigWellPathGeo && rigWellPathGeo->m_measuredDepths.size() > 1)
{
double firstWellPathMD = rigWellPathGeo->m_measuredDepths.front();
double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back();
for (auto md : locationsFromStartSpacingAndCount(m_rangeStart, m_rangeValveSpacing, m_rangeValveCount))
{
if (md >= firstWellPathMD && md <= lastWellPathMD)
{
validMeasuredDepths.push_back(md);
}
}
}
}
m_locationOfValves = validMeasuredDepths;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::initFieldsFromFishbones(LocationType locationType, double rangeStart, double rangeEnd, double valveSpacing, int valveCount, const std::vector<double>& locationOfValves)
{
if (locationType != VALVE_UNDEFINED)
{
m_locationType = locationType;
}
if (rangeStart != std::numeric_limits<double>::infinity())
{
m_rangeStart = rangeStart;
}
if (rangeEnd!= std::numeric_limits<double>::infinity())
{
m_rangeEnd = rangeEnd;
}
if (valveSpacing != std::numeric_limits<double>::infinity())
{
m_rangeValveSpacing = valveSpacing;
}
if (valveCount != -1)
{
m_rangeValveCount = valveCount;
}
if (!locationOfValves.empty())
{
m_locationOfValves = locationOfValves;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
{
RimWellPath* wellPath;
firstAncestorOrThisOfType(wellPath);
if (wellPath)
{
if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_METRIC)
{
m_locationOfValves.uiCapability()->setUiName("Measured Depths [m]");
m_rangeStart.uiCapability()->setUiName("Start MD [m]");
m_rangeEnd.uiCapability()->setUiName("End MD [m]");
m_rangeValveSpacing.uiCapability()->setUiName("Spacing [m]");
}
else if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD)
{
m_locationOfValves.uiCapability()->setUiName("Measured Depths [ft]");
m_rangeStart.uiCapability()->setUiName("Start MD [ft]");
m_rangeEnd.uiCapability()->setUiName("End MD [ft]");
m_rangeValveSpacing.uiCapability()->setUiName("Spacing [ft]");
}
}
}
{
uiOrdering.add(&m_locationType);
if (m_locationType() != VALVE_CUSTOM)
{
uiOrdering.add(&m_rangeStart);
uiOrdering.add(&m_rangeEnd);
if (m_locationType() == VALVE_COUNT)
{
uiOrdering.add(&m_rangeValveCount);
uiOrdering.add(&m_rangeValveSpacing);
}
else if (m_locationType() == VALVE_SPACING)
{
uiOrdering.add(&m_rangeValveSpacing);
uiOrdering.add(&m_rangeValveCount);
}
}
uiOrdering.add(&m_locationOfValves);
}
if (m_locationType() == VALVE_CUSTOM)
{
m_locationOfValves.uiCapability()->setUiReadOnly(false);
m_rangeValveSpacing.uiCapability()->setUiReadOnly(true);
m_rangeValveCount.uiCapability()->setUiReadOnly(true);
m_rangeStart.uiCapability()->setUiReadOnly(true);
m_rangeEnd.uiCapability()->setUiReadOnly(true);
}
else
{
m_locationOfValves.uiCapability()->setUiReadOnly(true);
m_rangeValveSpacing.uiCapability()->setUiReadOnly(false);
m_rangeValveCount.uiCapability()->setUiReadOnly(false);
m_rangeStart.uiCapability()->setUiReadOnly(false);
m_rangeEnd.uiCapability()->setUiReadOnly(false);
if (m_locationType() == VALVE_COUNT)
{
m_rangeValveSpacing.uiCapability()->setUiReadOnly(true);
m_rangeValveCount.uiCapability()->setUiReadOnly(false);
}
else
{
m_rangeValveSpacing.uiCapability()->setUiReadOnly(false);
m_rangeValveCount.uiCapability()->setUiReadOnly(true);
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimMultipleValveLocations::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
bool recomputeLocations = false;
if (changedField == &m_locationType)
{
if (m_locationType == VALVE_COUNT || m_locationType == VALVE_SPACING)
{
recomputeLocations = true;
}
}
if (changedField == &m_rangeStart ||
changedField == &m_rangeEnd ||
changedField == &m_rangeValveCount ||
changedField == &m_rangeValveSpacing)
{
recomputeLocations = true;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry();
if (rigWellPathGeo && !rigWellPathGeo->m_measuredDepths.empty())
{
double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back();
m_rangeStart = cvf::Math::clamp(m_rangeStart(), 0.0, lastWellPathMD);
m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), m_rangeStart(), lastWellPathMD);
}
}
if (changedField == &m_rangeValveSpacing)
{
// Minimum distance between fishbones is 13.0m
// Use 10.0m to allow for some flexibility
double minimumDistanceMeter = 10.0;
RimWellPath* wellPath = nullptr;
this->firstAncestorOrThisOfTypeAsserted(wellPath);
if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD)
{
double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet(minimumDistanceMeter);
m_rangeValveSpacing = cvf::Math::clamp(m_rangeValveSpacing(), minimumDistanceFeet, std::max(m_rangeValveSpacing(), minimumDistanceFeet));
}
else
{
m_rangeValveSpacing = cvf::Math::clamp(m_rangeValveSpacing(), minimumDistanceMeter, std::max(m_rangeValveSpacing(), minimumDistanceMeter));
}
}
if (recomputeLocations)
{
computeRangesAndLocations();
}
RimWellPathComponentInterface* parentCompletion = nullptr;
this->firstAncestorOrThisOfType(parentCompletion);
caf::PdmObject* pdmParent = dynamic_cast<caf::PdmObject*>(parentCompletion);
if (recomputeLocations || changedField == &m_locationOfValves)
{
if (parentCompletion)
{
RimFishbonesMultipleSubs* fishbones = dynamic_cast<RimFishbonesMultipleSubs*>(parentCompletion);
if (fishbones)
{
fishbones->valveLocationsUpdated();
}
}
}
if (pdmParent)
{
pdmParent->updateConnectedEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<double> RimMultipleValveLocations::locationsFromStartSpacingAndCount(double start, double spacing, size_t count)
{
std::vector<double> measuredDepths;
for (size_t i = 0; i < count; i++)
{
measuredDepths.push_back(start + spacing * i);
}
return measuredDepths;
}

View File

@ -0,0 +1,72 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "cafAppEnum.h"
#include "cafPdmBase.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cvfBase.h"
class RimMultipleValveLocations : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
enum LocationType
{
VALVE_COUNT,
VALVE_SPACING,
VALVE_CUSTOM,
VALVE_UNDEFINED
};
public:
RimMultipleValveLocations();
double measuredDepth(size_t valveIndex) const;
const std::vector<double>& locationOfValves() const;
void setLocationType(LocationType locationType);
void setMeasuredDepthAndCount(double measuredDepth, double spacing, int subCount);
void computeRangesAndLocations();
void initFieldsFromFishbones(LocationType locationType,
double rangeStart,
double rangeEnd,
double valveSpacing,
int valveCount,
const std::vector<double>& locationOfValves);
protected:
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
private:
static std::vector<double> locationsFromStartSpacingAndCount(double start, double spacing, size_t count);
private:
caf::PdmField<caf::AppEnum<LocationType> > m_locationType;
caf::PdmField<double> m_rangeStart;
caf::PdmField<double> m_rangeEnd;
caf::PdmField<double> m_rangeValveSpacing;
caf::PdmField<int> m_rangeValveCount;
caf::PdmField<std::vector<double>> m_locationOfValves; // Given in measured depth
};