#14667 Completions: Simplify segment interval properties

This commit is contained in:
Kristian Bendiksen committed 2026-09-16 11:35:13 +02:00
1 parent 63bcc22485
commit 52e212e24f
13 files changed
+313 -120

No files matched your search

@@ -150,6 +150,22 @@ void RimDiameterRoughnessInterval::setRoughnessFactor( double roughness )
m_roughnessFactor = roughness;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimDiameterRoughnessInterval::useCustomStartDate() const
{
return m_useCustomStartDate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RimDiameterRoughnessInterval::customStartDate() const
{
return m_startDate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -57,9 +57,11 @@ public:
void setRoughnessFactor( double roughness );
// Date tracking
void enableCustomStartDate( bool enable );
void setCustomStartDate( const QDate& date );
bool isActiveOnDate( const QDateTime& date ) const;
bool useCustomStartDate() const;
QDateTime customStartDate() const;
void enableCustomStartDate( bool enable );
void setCustomStartDate( const QDate& date );
bool isActiveOnDate( const QDateTime& date ) const;
// Validation
bool isValidInterval() const;
@@ -100,7 +100,7 @@ RimMswCompletionParameters::RimMswCompletionParameters()
"Roughness Factor" );
// New interval-based fields
CAF_PDM_InitScriptableFieldNoDefault( &m_diameterRoughnessMode, "DiameterRoughnessMode", "Diameter Roughness Mode" );
CAF_PDM_InitFieldNoDefault( &m_diameterRoughnessMode, "DiameterRoughnessMode", "Diameter Roughness Mode" );
CAF_PDM_InitFieldNoDefault( &m_diameterRoughnessIntervals, "DiameterRoughnessIntervals", "Diameter Roughness Intervals" );
m_diameterRoughnessIntervals = new RimDiameterRoughnessIntervalCollection();
m_diameterRoughnessIntervals->intervalsField().uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
@@ -375,6 +375,38 @@ double RimMswCompletionParameters::maxSegmentLength() const
return m_enforceMaxSegmentLength ? m_maxSegmentLength : std::numeric_limits<double>::infinity();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimMswCompletionParameters::storedReferenceMD() const
{
return m_refMD();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMswCompletionParameters::customValuesForLateral() const
{
return m_customValuesForLateral();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimMswCompletionParameters::enforceMaxSegmentLength() const
{
return m_enforceMaxSegmentLength();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimMswCompletionParameters::storedMaxSegmentLength() const
{
return m_maxSegmentLength();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -79,6 +79,12 @@ public:
LengthAndDepthEnum lengthAndDepth() const;
double maxSegmentLength() const;
// Stored values for legacy migration, including settings currently disabled in the UI.
double storedReferenceMD() const;
bool customValuesForLateral() const;
bool enforceMaxSegmentLength() const;
double storedMaxSegmentLength() const;
void setReferenceMDType( ReferenceMDType refType );
void setManualReferenceMD( double manualRefMD );
void setLinerDiameter( double diameter );
@@ -73,13 +73,6 @@ void RimSegmentCollection::LengthAndDepthEnum::setUp()
setDefault( RimSegmentCollection::LengthAndDepthType::ABS );
}
template <>
void RimSegmentCollection::DiameterRoughnessModeEnum::setUp()
{
addItem( RimSegmentCollection::DiameterRoughnessMode::UNIFORM, "Uniform", "Uniform" );
addItem( RimSegmentCollection::DiameterRoughnessMode::INTERVALS, "Intervals", "Intervals" );
setDefault( RimSegmentCollection::DiameterRoughnessMode::UNIFORM );
}
} // namespace caf
CAF_PDM_SOURCE_INIT( RimSegmentCollection, "SegmentCollection" );
@@ -98,7 +91,6 @@ RimSegmentCollection::RimSegmentCollection()
const auto unitSystem = RiaDefines::EclipseUnitSystem::UNITS_METRIC;
CAF_PDM_InitScriptableField( &m_linerDiameter, "LinerDiameter", defaultLinerDiameter( unitSystem ), "Liner Inner Diameter" );
CAF_PDM_InitScriptableField( &m_roughnessFactor, "RoughnessFactor", defaultRoughnessFactor( unitSystem ), "Roughness Factor" );
CAF_PDM_InitScriptableFieldNoDefault( &m_diameterRoughnessMode, "DiameterRoughnessMode", "Diameter Roughness Mode" );
CAF_PDM_InitScriptableFieldNoDefault( &m_segmentIntervals, "Intervals", "Segment Intervals" );
CAF_PDM_InitScriptableFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" );
@@ -257,21 +249,6 @@ void RimSegmentCollection::setLengthAndDepth( LengthAndDepthType lengthAndDepthT
m_lengthAndDepth = lengthAndDepthType;
}
RimSegmentCollection::DiameterRoughnessMode RimSegmentCollection::diameterRoughnessMode() const
{
return m_diameterRoughnessMode();
}
void RimSegmentCollection::setDiameterRoughnessMode( DiameterRoughnessMode mode )
{
m_diameterRoughnessMode = mode;
}
bool RimSegmentCollection::isUsingIntervalSpecificValues() const
{
return m_diameterRoughnessMode() == DiameterRoughnessMode::INTERVALS;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -290,11 +267,7 @@ RimSegmentInterval* RimSegmentCollection::findIntervalAtMD( double md, const std
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::getDiameterAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem ) const
{
if ( isUsingIntervalSpecificValues() )
{
if ( auto* interval = findIntervalAtMD( md, std::nullopt ) ) return interval->diameter( unitSystem );
return defaultLinerDiameter( unitSystem );
}
if ( auto* interval = findIntervalAtMD( md, std::nullopt ) ) return interval->diameter( unitSystem );
return linerDiameter( unitSystem );
}
@@ -303,11 +276,7 @@ double RimSegmentCollection::getDiameterAtMD( double md, RiaDefines::EclipseUnit
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::getRoughnessAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem ) const
{
if ( isUsingIntervalSpecificValues() )
{
if ( auto* interval = findIntervalAtMD( md, std::nullopt ) ) return interval->roughnessFactor( unitSystem );
return defaultRoughnessFactor( unitSystem );
}
if ( auto* interval = findIntervalAtMD( md, std::nullopt ) ) return interval->roughnessFactor( unitSystem );
return roughnessFactor( unitSystem );
}
@@ -316,11 +285,7 @@ double RimSegmentCollection::getRoughnessAtMD( double md, RiaDefines::EclipseUni
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::getDiameterAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem, const QDateTime& exportDate ) const
{
if ( isUsingIntervalSpecificValues() )
{
if ( auto* interval = findIntervalAtMD( md, exportDate ) ) return interval->diameter( unitSystem );
return defaultLinerDiameter( unitSystem );
}
if ( auto* interval = findIntervalAtMD( md, exportDate ) ) return interval->diameter( unitSystem );
return linerDiameter( unitSystem );
}
@@ -329,11 +294,7 @@ double RimSegmentCollection::getDiameterAtMD( double md, RiaDefines::EclipseUnit
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::getRoughnessAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem, const QDateTime& exportDate ) const
{
if ( isUsingIntervalSpecificValues() )
{
if ( auto* interval = findIntervalAtMD( md, exportDate ) ) return interval->roughnessFactor( unitSystem );
return defaultRoughnessFactor( unitSystem );
}
if ( auto* interval = findIntervalAtMD( md, exportDate ) ) return interval->roughnessFactor( unitSystem );
return roughnessFactor( unitSystem );
}
@@ -478,32 +439,32 @@ void RimSegmentCollection::importLegacyData( const RimMswCompletionParameters* l
!legacyParameters->customSegmentIntervals()->intervals().empty();
if ( !hasLegacyData ) return;
m_refMDType = static_cast<ReferenceMDType>(
static_cast<int>( static_cast<RimMswCompletionParameters::ReferenceMDType>( legacyParameters->m_refMDType() ) ) );
m_refMD = legacyParameters->m_refMD();
m_customValuesForLateral = legacyParameters->m_customValuesForLateral();
m_linerDiameter = legacyParameters->m_linerDiameter();
m_roughnessFactor = legacyParameters->m_roughnessFactor();
m_diameterRoughnessMode = static_cast<DiameterRoughnessMode>(
static_cast<int>( static_cast<RimMswCompletionParameters::DiameterRoughnessMode>( legacyParameters->m_diameterRoughnessMode() ) ) );
m_pressureDrop = static_cast<PressureDropType>(
static_cast<int>( static_cast<RimMswCompletionParameters::PressureDropType>( legacyParameters->m_pressureDrop() ) ) );
m_refMDType = static_cast<ReferenceMDType>( static_cast<int>( legacyParameters->referenceMDType() ) );
m_refMD = legacyParameters->storedReferenceMD();
m_customValuesForLateral = legacyParameters->customValuesForLateral();
m_linerDiameter = legacyParameters->linerDiameter();
m_roughnessFactor = legacyParameters->roughnessFactor();
m_pressureDrop = static_cast<PressureDropType>(
static_cast<int>( static_cast<RimMswCompletionParameters::PressureDropType>( legacyParameters->pressureDrop() ) ) );
m_lengthAndDepth = static_cast<LengthAndDepthType>(
static_cast<int>( static_cast<RimMswCompletionParameters::LengthAndDepthType>( legacyParameters->lengthAndDepth() ) ) );
m_enforceMaxSegmentLength = legacyParameters->enforceMaxSegmentLength();
m_maxSegmentLength = legacyParameters->storedMaxSegmentLength();
m_maxSegmentLength = legacyParameters->m_maxSegmentLength();
removeAllIntervals();
for ( auto* oldInterval : legacyParameters->m_diameterRoughnessIntervals->intervals() )
if ( legacyParameters->diameterRoughnessMode() == RimMswCompletionParameters::DiameterRoughnessMode::INTERVALS )
{
auto* interval =
createInterval( oldInterval->startMD(), oldInterval->endMD(), oldInterval->diameter(), oldInterval->roughnessFactor() );
interval->m_useCustomStartDate = oldInterval->m_useCustomStartDate();
interval->m_startDate = oldInterval->m_startDate();
for ( auto* oldInterval : legacyParameters->diameterRoughnessIntervals()->intervals() )
{
auto* interval =
createInterval( oldInterval->startMD(), oldInterval->endMD(), oldInterval->diameter(), oldInterval->roughnessFactor() );
interval->enableCustomStartDate( oldInterval->useCustomStartDate() );
interval->setCustomStartDate( oldInterval->customStartDate() );
}
}
constexpr double boundTolerance = 1.0e-6;
for ( auto* oldInterval : legacyParameters->customSegmentIntervals()->intervals() )
for ( auto* oldInterval : legacyParameters->m_customSegmentIntervals->intervals() )
{
const auto currentIntervals = intervals();
const auto matchingInterval =
@@ -514,53 +475,53 @@ void RimSegmentCollection::importLegacyData( const RimMswCompletionParameters* l
std::abs( interval->endMD() - oldInterval->endMD() ) <= boundTolerance;
} );
if ( matchingInterval == currentIntervals.end() )
{
createInterval( oldInterval->startMD(), oldInterval->endMD(), legacyParameters->linerDiameter(), legacyParameters->roughnessFactor() );
legacyParameters->m_roughnessFactor() );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::defaultLinerDiameter( RiaDefines::EclipseUnitSystem unitSystem )
{
return unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ? 0.152 : 0.5;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimSegmentCollection::defaultRoughnessFactor( RiaDefines::EclipseUnitSystem unitSystem )
{
return unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC ? 1.0e-5 : 3.28e-5;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentCollection::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_refMDType || changedField == &m_diameterRoughnessMode ) updateAllRequiredEditors();
if ( changedField == &m_refMDType ) updateAllRequiredEditors();
if ( changedField == &m_enforceMaxSegmentLength )
{
m_maxSegmentLength.uiCapability()->setUiHidden( !m_enforceMaxSegmentLength() );
caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentCollection::appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const
{
menuBuilder << "RicNewSegmentIntervalFeature";
if ( hasIntervals() ) menuBuilder << "RicDeleteSegmentIntervalFeature";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto* wellPath = firstAncestorOrThisOfTypeAsserted<RimWellPath>();
@@ -580,12 +541,8 @@ void RimSegmentCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd
}
auto* diameterGroup = uiOrdering.addNewGroup( "Diameter and Roughness" );
diameterGroup->add( &m_diameterRoughnessMode );
if ( m_diameterRoughnessMode() == DiameterRoughnessMode::UNIFORM )
{
diameterGroup->add( &m_linerDiameter );
diameterGroup->add( &m_roughnessFactor );
}
diameterGroup->add( &m_linerDiameter );
diameterGroup->add( &m_roughnessFactor );
if ( wellPath->isTopLevelWellPath() )
{
@@ -598,24 +555,23 @@ void RimSegmentCollection::defineUiOrdering( QString uiConfigName, caf::PdmUiOrd
const bool readOnly = !wellPath->isTopLevelWellPath() && !m_customValuesForLateral();
m_linerDiameter.uiCapability()->setUiReadOnly( readOnly );
m_roughnessFactor.uiCapability()->setUiReadOnly( readOnly );
m_diameterRoughnessMode.uiCapability()->setUiReadOnly( readOnly );
m_segmentIntervals.uiCapability()->setUiReadOnly( readOnly );
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
for ( auto* interval : intervals() )
uiTreeOrdering.add( interval );
uiTreeOrdering.skipRemainingChildren( true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentCollection::initAfterRead()
{
if ( m_linerDiameter() == std::numeric_limits<double>::infinity() && m_roughnessFactor() == std::numeric_limits<double>::infinity() )
@@ -60,16 +60,9 @@ public:
INC
};
enum class DiameterRoughnessMode
{
UNIFORM,
INTERVALS
};
using ReferenceMDEnum = caf::AppEnum<ReferenceMDType>;
using PressureDropEnum = caf::AppEnum<PressureDropType>;
using LengthAndDepthEnum = caf::AppEnum<LengthAndDepthType>;
using DiameterRoughnessModeEnum = caf::AppEnum<DiameterRoughnessMode>;
using ReferenceMDEnum = caf::AppEnum<ReferenceMDType>;
using PressureDropEnum = caf::AppEnum<PressureDropType>;
using LengthAndDepthEnum = caf::AppEnum<LengthAndDepthType>;
RimSegmentCollection();
@@ -90,10 +83,6 @@ public:
void setPressureDrop( PressureDropType pressureDropType );
void setLengthAndDepth( LengthAndDepthType lengthAndDepthType );
DiameterRoughnessMode diameterRoughnessMode() const;
void setDiameterRoughnessMode( DiameterRoughnessMode mode );
bool isUsingIntervalSpecificValues() const;
double getDiameterAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem ) const;
double getRoughnessAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem ) const;
double getDiameterAtMD( double md, RiaDefines::EclipseUnitSystem unitSystem, const QDateTime& exportDate ) const;
@@ -137,7 +126,6 @@ private:
caf::PdmField<double> m_linerDiameter;
caf::PdmField<double> m_roughnessFactor;
caf::PdmField<DiameterRoughnessModeEnum> m_diameterRoughnessMode;
caf::PdmChildArrayField<RimSegmentInterval*> m_segmentIntervals;
caf::PdmField<PressureDropEnum> m_pressureDrop;
@@ -23,12 +23,14 @@
#include "RiaLogging.h"
#include "RiaQDateTimeTools.h"
#include "RimSegmentCollection.h"
#include "RimWellPath.h"
#include "cafCmdFeatureMenuBuilder.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiDoubleValueEditor.h"
#include "cafPdmUiTreeOrdering.h"
#include <cmath>
@@ -91,11 +93,14 @@ double RimSegmentInterval::diameter() const
//--------------------------------------------------------------------------------------------------
double RimSegmentInterval::diameter( RiaDefines::EclipseUnitSystem unitSystem ) const
{
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
return RiaEclipseUnitTools::meterToInch( m_diameter );
}
return m_diameter; // METRIC units - already in meters
auto* wellPath = firstAncestorOrThisOfType<RimWellPath>();
auto sourceUnitSystem = wellPath ? wellPath->unitSystem() : RiaDefines::EclipseUnitSystem::UNITS_METRIC;
if ( sourceUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
return RiaEclipseUnitTools::feetToMeter( m_diameter );
if ( sourceUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
return RiaEclipseUnitTools::meterToFeet( m_diameter );
return m_diameter;
}
//--------------------------------------------------------------------------------------------------
@@ -111,11 +116,14 @@ double RimSegmentInterval::roughnessFactor() const
//--------------------------------------------------------------------------------------------------
double RimSegmentInterval::roughnessFactor( RiaDefines::EclipseUnitSystem unitSystem ) const
{
if ( unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
{
auto* wellPath = firstAncestorOrThisOfType<RimWellPath>();
auto sourceUnitSystem = wellPath ? wellPath->unitSystem() : RiaDefines::EclipseUnitSystem::UNITS_METRIC;
if ( sourceUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC )
return RiaEclipseUnitTools::feetToMeter( m_roughnessFactor );
if ( sourceUnitSystem == RiaDefines::EclipseUnitSystem::UNITS_METRIC && unitSystem == RiaDefines::EclipseUnitSystem::UNITS_FIELD )
return RiaEclipseUnitTools::meterToFeet( m_roughnessFactor );
}
return m_roughnessFactor; // METRIC units - already in meters
return m_roughnessFactor;
}
//--------------------------------------------------------------------------------------------------
@@ -299,6 +307,8 @@ void RimSegmentInterval::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
{
if ( changedField == &m_startMD || changedField == &m_endMD )
{
uiCapability()->setUiName( QString( "%1 - %2" ).arg( m_startMD() ).arg( m_endMD() ) );
// Validate interval
if ( m_startMD >= m_endMD )
{
@@ -321,12 +331,30 @@ void RimSegmentInterval::fieldChangedByUi( const caf::PdmFieldHandle* changedFie
//--------------------------------------------------------------------------------------------------
void RimSegmentInterval::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
auto* wellPath = firstAncestorOrThisOfType<RimWellPath>();
if ( wellPath )
{
const bool isMetric = wellPath->unitSystem() == RiaDefines::EclipseUnitSystem::UNITS_METRIC;
m_startMD.uiCapability()->setUiName( isMetric ? "Start MD [m]" : "Start MD [ft]" );
m_endMD.uiCapability()->setUiName( isMetric ? "End MD [m]" : "End MD [ft]" );
m_diameter.uiCapability()->setUiName( isMetric ? "Diameter [m]" : "Diameter [ft]" );
m_roughnessFactor.uiCapability()->setUiName( isMetric ? "Roughness Factor [m]" : "Roughness Factor [ft]" );
}
uiOrdering.add( &m_startMD );
uiOrdering.add( &m_endMD );
uiOrdering.add( &m_diameter );
uiOrdering.add( &m_roughnessFactor );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimSegmentInterval::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName )
{
uiCapability()->setUiName( QString( "%1 - %2" ).arg( m_startMD() ).arg( m_endMD() ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -32,7 +32,8 @@ class RimWellPath;
namespace caf
{
class CmdFeatureMenuBuilder;
}
class PdmUiTreeOrdering;
} // namespace caf
//==================================================================================================
///
@@ -98,6 +99,7 @@ public:
protected:
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) override;
private:
void updateConnectedEditors();
@@ -533,9 +533,6 @@ bool RimWellEventTimeline::applyTubingEvent( const RimWellEventTubing& event, Ri
return false;
}
// Set the diameter roughness mode to intervals
mswParams->setDiameterRoughnessMode( RimSegmentCollection::DiameterRoughnessMode::INTERVALS );
RimSegmentInterval* interval = nullptr;
for ( auto* existingInterval : segmentCollection->intervals() )
{