#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

@@ -32,7 +32,6 @@ void RicNewSegmentIntervalFeature::onActionTriggered( bool isChecked )
auto* collection = caf::SelectionManager::instance()->selectedItemOfType<RimSegmentCollection>();
if ( !collection ) return;
collection->setDiameterRoughnessMode( RimSegmentCollection::DiameterRoughnessMode::INTERVALS );
auto* interval = collection->createInterval( 0.0, 2000.0, collection->linerDiameter(), collection->roughnessFactor() );
collection->updateConnectedEditors();
Riu3DMainWindowTools::selectAsCurrentItem( interval );
@@ -83,10 +83,11 @@ std::vector<RigMswBranch> buildLateralBranches( RimEclipseCase*
auto mswParameters = wellPath->segmentCollection();
if ( !mswParameters ) return result;
const std::string infoType = mswParameters->lengthAndDepth().text().toStdString();
const double tieInMD = wellPath->wellPathTieIn()->tieInMeasuredDepth();
const double tieInTVD = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( tieInMD ).z();
const std::string wellNameForExport = wellPath->completionSettings()->wellNameForExport().toStdString();
const std::string infoType = mswParameters->lengthAndDepth().text().toStdString();
const std::vector<std::pair<double, double>> segmentIntervals = mswParameters->getSegmentIntervals();
const double tieInMD = wellPath->wellPathTieIn()->tieInMeasuredDepth();
const double tieInTVD = -wellPath->wellPathGeometry()->interpolatedPointAlongWellPath( tieInMD ).z();
const std::string wellNameForExport = wellPath->completionSettings()->wellNameForExport().toStdString();
const int lateralBranchNum = ++lateralBranchNumber;
int childOutletSeg = outletSegNum;
@@ -188,7 +189,7 @@ std::vector<RigMswBranch> buildLateralBranches( RimEclipseCase*
segmentNumber,
childOutletSeg,
mswParameters->maxSegmentLength(),
{},
segmentIntervals,
exportDate,
unitSystem,
&childCellSegMap,
@@ -236,7 +237,7 @@ std::vector<RigMswBranch> buildLateralBranches( RimEclipseCase*
segmentNumber,
completionBranchNumber,
mswParameters->maxSegmentLength(),
{},
segmentIntervals,
exportDate,
unitSystem );
result.insert( result.end(), std::make_move_iterator( valveBranches.begin() ), std::make_move_iterator( valveBranches.end() ) );
@@ -265,7 +266,7 @@ std::vector<RigMswBranch> buildLateralBranches( RimEclipseCase*
segmentNumber,
completionBranchNumber,
mswParameters->maxSegmentLength(),
{},
segmentIntervals,
unitSystem,
fishbonesContext );
result.insert( result.end(), std::make_move_iterator( fishBranches.begin() ), std::make_move_iterator( fishBranches.end() ) );
@@ -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() )
{
@@ -41,7 +41,6 @@ std::expected<caf::PdmObjectHandle*, QString> RimcSegmentCollection_addSegmentIn
if ( !segmentCollection ) return std::unexpected( "Segment collection is null. Cannot add segment interval." );
if ( m_endMD() <= m_startMD() ) return std::unexpected( "End MD must be greater than Start MD." );
segmentCollection->setDiameterRoughnessMode( RimSegmentCollection::DiameterRoughnessMode::INTERVALS );
auto* interval = segmentCollection->createInterval( m_startMD(), m_endMD(), m_diameter(), m_roughnessFactor() );
segmentCollection->updateAllRequiredEditors();
return interval;
@@ -6,14 +6,23 @@
#include "RimMswCompletionParameters.h"
#include "RimSegmentCollection.h"
#include "RimSegmentInterval.h"
#include "RimWellPath.h"
#include "RimWellPathCompletions.h"
#include "cafPdmUiFieldHandle.h"
#include "cafPdmUiObjectHandle.h"
#include "cafPdmUiOrdering.h"
#include "cafPdmUiTreeOrdering.h"
#include <memory>
TEST( RimWellPathCompletions, SegmentIntervalsDefineCustomSegmentation )
{
RimWellPathCompletions completions;
auto* segments = completions.segmentCollection();
RimWellPath wellPath;
auto* segments = wellPath.segmentCollection();
segments->setDiameterRoughnessMode( RimSegmentCollection::DiameterRoughnessMode::INTERVALS );
segments->setLinerDiameter( 0.18 );
segments->setRoughnessFactor( 3.0e-5 );
auto* interval = segments->createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
ASSERT_NE( nullptr, interval );
@@ -21,6 +30,47 @@ TEST( RimWellPathCompletions, SegmentIntervalsDefineCustomSegmentation )
EXPECT_EQ( ( std::vector<std::pair<double, double>>{ { 100.0, 200.0 } } ), segments->getSegmentIntervals() );
EXPECT_DOUBLE_EQ( 0.12, segments->getDiameterAtMD( 150.0, RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
EXPECT_DOUBLE_EQ( 2.0e-5, segments->getRoughnessAtMD( 150.0, RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
EXPECT_DOUBLE_EQ( 0.18, segments->getDiameterAtMD( 250.0, RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
EXPECT_DOUBLE_EQ( 3.0e-5, segments->getRoughnessAtMD( 250.0, RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
}
TEST( RimWellPathCompletions, SegmentIntervalUiUsesMeasuredDepthNameAndMetricUnits )
{
RimWellPath wellPath;
auto* interval = wellPath.segmentCollection()->createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
std::unique_ptr<caf::PdmUiTreeOrdering> treeOrdering( interval->uiCapability()->uiTreeOrdering() );
ASSERT_NE( nullptr, treeOrdering );
EXPECT_EQ( "100 - 200", interval->uiCapability()->uiName() );
caf::PdmUiOrdering uiOrdering;
interval->uiCapability()->uiOrdering( "", uiOrdering );
ASSERT_NE( nullptr, interval->findField( "StartMd" ) );
ASSERT_NE( nullptr, interval->findField( "EndMd" ) );
ASSERT_NE( nullptr, interval->findField( "Diameter" ) );
ASSERT_NE( nullptr, interval->findField( "RoughnessFactor" ) );
EXPECT_EQ( "Start MD [m]", interval->findField( "StartMd" )->uiCapability()->uiName() );
EXPECT_EQ( "End MD [m]", interval->findField( "EndMd" )->uiCapability()->uiName() );
EXPECT_EQ( "Diameter [m]", interval->findField( "Diameter" )->uiCapability()->uiName() );
EXPECT_EQ( "Roughness Factor [m]", interval->findField( "RoughnessFactor" )->uiCapability()->uiName() );
}
TEST( RimWellPathCompletions, SegmentIntervalUiUsesFieldUnits )
{
RimWellPath wellPath;
wellPath.setUnitSystem( RiaDefines::EclipseUnitSystem::UNITS_FIELD );
auto* interval = wellPath.segmentCollection()->createInterval( 100.0, 200.0, 0.5, 3.28e-5 );
caf::PdmUiOrdering uiOrdering;
interval->uiCapability()->uiOrdering( "", uiOrdering );
EXPECT_EQ( "Start MD [ft]", interval->findField( "StartMd" )->uiCapability()->uiName() );
EXPECT_EQ( "End MD [ft]", interval->findField( "EndMd" )->uiCapability()->uiName() );
EXPECT_EQ( "Diameter [ft]", interval->findField( "Diameter" )->uiCapability()->uiName() );
EXPECT_EQ( "Roughness Factor [ft]", interval->findField( "RoughnessFactor" )->uiCapability()->uiName() );
EXPECT_DOUBLE_EQ( 0.5, interval->diameter( RiaDefines::EclipseUnitSystem::UNITS_FIELD ) );
EXPECT_DOUBLE_EQ( 0.1524, interval->diameter( RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
}
TEST( RimWellPathCompletions, LegacySegmentIntervalsAreMergedByBounds )
@@ -28,6 +78,7 @@ TEST( RimWellPathCompletions, LegacySegmentIntervalsAreMergedByBounds )
RimMswCompletionParameters legacyParameters;
legacyParameters.setLinerDiameter( 0.2 );
legacyParameters.setRoughnessFactor( 3.0e-5 );
legacyParameters.setDiameterRoughnessMode( RimMswCompletionParameters::DiameterRoughnessMode::INTERVALS );
legacyParameters.diameterRoughnessIntervals()->createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
legacyParameters.customSegmentIntervals()->createInterval( 100.0 + 0.5e-6, 200.0 - 0.5e-6 );
legacyParameters.customSegmentIntervals()->createInterval( 300.0, 400.0 );
@@ -45,6 +96,122 @@ TEST( RimWellPathCompletions, LegacySegmentIntervalsAreMergedByBounds )
EXPECT_DOUBLE_EQ( 3.0e-5, intervals[1]->roughnessFactor() );
}
TEST( RimWellPathCompletions, LegacyUniformDiameterIntervalsRemainInactive )
{
RimMswCompletionParameters legacyParameters;
legacyParameters.diameterRoughnessIntervals()->createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
RimSegmentCollection segments;
segments.importLegacyData( &legacyParameters );
EXPECT_TRUE( segments.intervals().empty() );
}
TEST( RimWellPathCompletions, LegacyMigrationPreservesDisabledSettings )
{
RimMswCompletionParameters legacyParameters;
legacyParameters.setManualReferenceMD( 123.0 );
auto* maxLength = dynamic_cast<caf::PdmField<double>*>( legacyParameters.findField( "MaxSegmentLength" ) );
auto* customValues = dynamic_cast<caf::PdmField<bool>*>( legacyParameters.findField( "CustomValuesForLateral" ) );
ASSERT_NE( nullptr, maxLength );
ASSERT_NE( nullptr, customValues );
maxLength->setValue( 345.0 );
customValues->setValue( true );
legacyParameters.setPressureDrop( RimMswCompletionParameters::PressureDropType::HYDROSTATIC_FRICTION_ACCELERATION );
legacyParameters.setLengthAndDepth( RimMswCompletionParameters::LengthAndDepthType::INC );
RimSegmentCollection segments;
segments.importLegacyData( &legacyParameters );
EXPECT_EQ( RimSegmentCollection::ReferenceMDType::AUTO_REFERENCE_MD, segments.referenceMDType() );
auto* migratedMaxLength = dynamic_cast<caf::PdmField<double>*>( segments.findField( "MaxSegmentLength" ) );
auto* migratedCustomValues = dynamic_cast<caf::PdmField<bool>*>( segments.findField( "CustomValuesForLateral" ) );
auto* enforceMaxLength = dynamic_cast<caf::PdmField<bool>*>( segments.findField( "EnforceMaxSegmentLength" ) );
ASSERT_NE( nullptr, migratedMaxLength );
ASSERT_NE( nullptr, migratedCustomValues );
ASSERT_NE( nullptr, enforceMaxLength );
EXPECT_DOUBLE_EQ( 345.0, migratedMaxLength->value() );
EXPECT_TRUE( migratedCustomValues->value() );
EXPECT_FALSE( enforceMaxLength->value() );
EXPECT_EQ( RimSegmentCollection::PressureDropType::HYDROSTATIC_FRICTION_ACCELERATION, segments.pressureDrop() );
EXPECT_EQ( RimSegmentCollection::LengthAndDepthType::INC, segments.lengthAndDepth() );
segments.setReferenceMDType( RimSegmentCollection::ReferenceMDType::MANUAL_REFERENCE_MD );
EXPECT_DOUBLE_EQ( 123.0, segments.manualReferenceMD() );
enforceMaxLength->setValue( true );
EXPECT_DOUBLE_EQ( 345.0, segments.maxSegmentLength() );
}
TEST( RimWellPathCompletions, DefaultLegacySettingsDoNotOverwriteSegments )
{
RimMswCompletionParameters legacyParameters;
RimSegmentCollection segments;
segments.setLinerDiameter( 0.3 );
segments.createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
segments.importLegacyData( &legacyParameters );
EXPECT_DOUBLE_EQ( 0.3, segments.linerDiameter() );
EXPECT_EQ( 1u, segments.intervals().size() );
}
TEST( RimWellPathCompletions, LegacyMigrationPreservesIntervalDateTime )
{
const auto startDate = QDateTime::fromString( "2026-09-14T13:45:12.123+02:00", Qt::ISODateWithMs );
ASSERT_TRUE( startDate.isValid() );
for ( bool useCustomDate : { false, true } )
{
RimMswCompletionParameters legacyParameters;
legacyParameters.setDiameterRoughnessMode( RimMswCompletionParameters::DiameterRoughnessMode::INTERVALS );
auto* oldInterval = legacyParameters.diameterRoughnessIntervals()->createInterval( 100.0, 200.0, 0.12, 2.0e-5 );
oldInterval->enableCustomStartDate( useCustomDate );
auto* dateField = dynamic_cast<caf::PdmField<QDateTime>*>( oldInterval->findField( "StartDate" ) );
ASSERT_NE( nullptr, dateField );
dateField->setValue( startDate );
RimSegmentCollection segments;
segments.importLegacyData( &legacyParameters );
ASSERT_EQ( 1u, segments.intervals().size() );
auto* interval = segments.intervals().front();
auto* migratedDate = dynamic_cast<caf::PdmField<QDateTime>*>( interval->findField( "StartDate" ) );
ASSERT_NE( nullptr, migratedDate );
EXPECT_EQ( startDate, migratedDate->value() );
EXPECT_EQ( startDate.offsetFromUtc(), migratedDate->value().offsetFromUtc() );
EXPECT_EQ( !useCustomDate, interval->isActiveOnDate( startDate.addMSecs( -1 ) ) );
EXPECT_TRUE( interval->isActiveOnDate( startDate ) );
}
}
TEST( RimWellPathCompletions, LateralSegmentsInheritTopLevelSettings )
{
auto topLevelWell = std::make_unique<RimWellPath>();
RimWellPath lateral;
auto* localSegments = lateral.segmentCollection();
localSegments->setLinerDiameter( 0.1 );
localSegments->setRoughnessFactor( 1.0e-5 );
topLevelWell->segmentCollection()->setReferenceMDType( RimSegmentCollection::ReferenceMDType::MANUAL_REFERENCE_MD );
topLevelWell->segmentCollection()->setManualReferenceMD( 123.0 );
topLevelWell->segmentCollection()->setLinerDiameter( 0.2 );
topLevelWell->segmentCollection()->setRoughnessFactor( 3.0e-5 );
lateral.connectWellPaths( topLevelWell.get(), 100.0 );
EXPECT_EQ( localSegments, lateral.segmentCollection() );
EXPECT_DOUBLE_EQ( 123.0, localSegments->manualReferenceMD() );
EXPECT_DOUBLE_EQ( 0.2, localSegments->linerDiameter( RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
EXPECT_DOUBLE_EQ( 3.0e-5, localSegments->roughnessFactor( RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
topLevelWell->segmentCollection()->setManualReferenceMD( 456.0 );
const RimWellPath& constLateral = lateral;
EXPECT_DOUBLE_EQ( 456.0, constLateral.segmentCollection()->manualReferenceMD() );
topLevelWell.reset();
EXPECT_EQ( localSegments, lateral.segmentCollection() );
EXPECT_EQ( localSegments, constLateral.segmentCollection() );
EXPECT_DOUBLE_EQ( 0.1, localSegments->linerDiameter( RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
EXPECT_DOUBLE_EQ( 1.0e-5, localSegments->roughnessFactor( RiaDefines::EclipseUnitSystem::UNITS_METRIC ) );
}
/*
#include <QRegExpValidator>
//--------------------------------------------------------------------------------------------------