Tie-in valve improvements (#13661)

Support (bool, something) pairs as tuples on python side.
Support custom outlet valve md
Add python test for custom outlet valve md
Use tie-in depth as default for custom valve md
Standalone valve creation and display updates
Update MSW valve export
Add valve open/shut flag.
Add python examples
This commit is contained in:
JJ authored and GitHub committed 2026-03-06 12:01:14 +01:00
1 parent f47de8457c
commit 24be78f105
34 files changed
+1139 -157

No files matched your search

@@ -45,6 +45,7 @@
#include "RimProject.h"
#include "RimStimPlanModelCollection.h"
#include "RimTools.h"
#include "RimValveCollection.h"
#include "RimWellEventTimeline.h"
#include "RimWellIASettingsCollection.h"
#include "RimWellLogChannel.h"
@@ -61,6 +62,7 @@
#include "RiuMainWindow.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiTreeAttributes.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafPdmUiTreeViewEditor.h"
@@ -148,7 +150,7 @@ RimWellPath::RimWellPath()
m_wellPathAttributes = new RimWellPathAttributeCollection;
m_wellPathAttributes->uiCapability()->setUiTreeHidden( true );
CAF_PDM_InitFieldNoDefault( &m_wellPathTieIn, "WellPathTieIn", "well Path Tie-In" );
CAF_PDM_InitFieldNoDefault( &m_wellPathTieIn, "WellPathTieIn", "Well Path Tie-In" );
m_wellPathTieIn = new RimWellPathTieIn;
m_wellPathTieIn->connectWellPaths( nullptr, this, 0.0 );
@@ -282,6 +284,16 @@ RimPerforationCollection* RimWellPath::perforationIntervalCollection()
return m_completions->perforationCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimValveCollection* RimWellPath::valveCollection() const
{
CVF_ASSERT( m_completions );
return m_completions->valveCollection();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -415,7 +427,7 @@ const RigWellPath* RimWellPath::wellPathGeometry() const
//--------------------------------------------------------------------------------------------------
double RimWellPath::startMD() const
{
if ( wellPathGeometry() )
if ( wellPathGeometry() && wellPathGeometry()->measuredDepths().size() > 0 )
{
return wellPathGeometry()->measuredDepths().front();
}
@@ -427,7 +439,7 @@ double RimWellPath::startMD() const
//--------------------------------------------------------------------------------------------------
double RimWellPath::endMD() const
{
if ( wellPathGeometry() )
if ( wellPathGeometry() && wellPathGeometry()->measuredDepths().size() > 0 )
{
return wellPathGeometry()->measuredDepths().back();
}
@@ -773,7 +785,10 @@ void RimWellPath::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering,
{
uiTreeOrdering.add( m_completionSettings() );
}
if ( m_completions->valveCollection()->hasValves() )
{
uiTreeOrdering.add( m_completions->valveCollection() );
}
if ( m_completions->fishbonesCollection()->hasFishbones() )
{
uiTreeOrdering.add( m_completions->fishbonesCollection() );
@@ -51,6 +51,7 @@ class RimFractureTemplateCollection;
class RimStimPlanModelCollection;
class RimFishbonesCollection;
class RimPerforationCollection;
class RimValveCollection;
class RimWellPathAttributeCollection;
class RimWellPathCompletions;
class RimWellPathCompletionSettings;
@@ -141,6 +142,7 @@ public:
RimWellPathAttributeCollection* attributeCollection();
const RimWellPathAttributeCollection* attributeCollection() const;
RimWellIASettingsCollection* wellIASettingsCollection();
RimValveCollection* valveCollection() const;
bool showWellPathLabel() const;
bool showWellPath() const;
@@ -30,6 +30,8 @@
#include "RiuMainWindow.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiDoubleSliderEditor.h"
#include "cafPdmUiLabelEditor.h"
@@ -40,7 +42,12 @@ CAF_PDM_SOURCE_INIT( RimWellPathTieIn, "RimWellPathTieIn" );
//--------------------------------------------------------------------------------------------------
RimWellPathTieIn::RimWellPathTieIn()
{
CAF_PDM_InitObject( "Well Path Tie In", ":/NotDefined.png", "", "Well Path Tie In description" );
CAF_PDM_InitScriptableObjectWithNameAndComment( "Well Path Tie In",
":/NotDefined.png",
"",
"Well Path Tie In description",
"WellPathTimeIn",
"A ResInsight Well Tie-in" );
CAF_PDM_InitFieldNoDefault( &m_infoLabel, "InfoLabel", "Use right-click menu of well to set parent well." );
m_infoLabel.uiCapability()->setUiEditorTypeName( caf::PdmUiLabelEditor::uiEditorTypeName() );
@@ -51,14 +58,15 @@ RimWellPathTieIn::RimWellPathTieIn()
m_parentWell.uiCapability()->setUiReadOnly( true );
CAF_PDM_InitFieldNoDefault( &m_childWell, "ChildWellPath", "ChildWellPath" );
CAF_PDM_InitFieldNoDefault( &m_tieInMeasuredDepth, "TieInMeasuredDepth", "Tie In Measured Depth" );
CAF_PDM_InitScriptableFieldNoDefault( &m_tieInMeasuredDepth, "TieInMeasuredDepth", "Tie In Measured Depth" );
m_tieInMeasuredDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitField( &m_addValveAtConnection, "AddValveAtConnection", false, "Add Outlet Valve for Branches" );
CAF_PDM_InitScriptableField( &m_addValveAtConnection, "AddValveAtConnection", false, "Add Outlet Valve for Branch" );
CAF_PDM_InitFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve" );
CAF_PDM_InitScriptableFieldNoDefault( &m_valve, "Valve", "Branch Outlet Valve" );
CAF_PDM_InitScriptableField( &m_customOutletValveMD, "CustomOutletValveMd", std::make_pair( false, 0.0 ), "Outlet Valve Custom MD" );
m_valve = new RimWellPathValve;
m_valve = new RimWellPathValve();
}
//--------------------------------------------------------------------------------------------------
@@ -95,6 +103,53 @@ void RimWellPathTieIn::setTieInMeasuredDepth( double measuredDepth )
m_tieInMeasuredDepth = measuredDepth;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RimWellPathTieIn::branchValveMeasuredDepth() const
{
if ( m_customOutletValveMD().first )
{
return m_customOutletValveMD().second;
}
return m_tieInMeasuredDepth();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathTieIn::setBranchValveMeasuredDepth( double measuredDepth )
{
m_customOutletValveMD = std::make_pair( true, measuredDepth );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathTieIn::useDefaultBranchValveMeasuredDepth()
{
m_customOutletValveMD = std::make_pair( false, m_tieInMeasuredDepth() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathTieIn::setBranchValveTemplate( RimValveTemplate* valveTemplate )
{
if ( m_valve() )
{
m_valve()->setValveTemplate( valveTemplate );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellPathTieIn::setEnableBranchValveAtConnection( bool enable )
{
m_addValveAtConnection = enable;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -157,9 +212,16 @@ void RimWellPathTieIn::updateFirstTargetFromParentWell()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RimWellPathValve* RimWellPathTieIn::outletValve() const
RimWellPathValve* RimWellPathTieIn::outletValve() const
{
return m_addValveAtConnection() && m_valve() && m_valve->valveTemplate() ? m_valve() : nullptr;
auto retVal = m_addValveAtConnection() && m_valve() && m_valve->valveTemplate() ? m_valve() : nullptr;
if ( retVal != nullptr )
{
retVal->setMeasuredDepthAndCount( branchValveMeasuredDepth(), 0.0, 1 );
}
return retVal;
}
//--------------------------------------------------------------------------------------------------
@@ -183,7 +245,9 @@ void RimWellPathTieIn::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
if ( m_addValveAtConnection )
{
m_valve->uiOrdering( "TemplateOnly", *tieInGroup );
auto valveGrp = tieInGroup->addNewGroup( "Valve Options" );
valveGrp->add( &m_customOutletValveMD );
m_valve->uiOrdering( "TemplateOnly", *valveGrp );
}
}
@@ -218,6 +282,14 @@ void RimWellPathTieIn::fieldChangedByUi( const caf::PdmFieldHandle* changedField
RiuMainWindow::instance()->setExpanded( m_childWell );
RiuMainWindow::instance()->selectAsCurrentItem( m_childWell );
}
if ( ( changedField == &m_customOutletValveMD ) && ( m_customOutletValveMD().first ) )
{
if ( m_customOutletValveMD().second == 0.0 )
{
m_customOutletValveMD.setValue( std::make_pair( true, m_tieInMeasuredDepth() ) );
}
}
}
//--------------------------------------------------------------------------------------------------
@@ -253,7 +325,7 @@ void RimWellPathTieIn::defineEditorAttribute( const caf::PdmFieldHandle* field,
auto wellPathGeo = parentWell()->wellPathGeometry();
if ( wellPathGeo )
if ( wellPathGeo && wellPathGeo->measuredDepths().size() > 0 )
{
minimumValue = wellPathGeo->measuredDepths().front();
maximumValue = wellPathGeo->measuredDepths().back();
@@ -25,6 +25,7 @@
class RimWellPath;
class RimWellPathValve;
class RimValveTemplate;
class RimWellPathTieIn : public caf::PdmObject
{
@@ -35,15 +36,23 @@ public:
void connectWellPaths( RimWellPath* parentWell, RimWellPath* childWell, double tieInMeasuredDepth );
RimWellPath* parentWell() const;
double tieInMeasuredDepth() const;
void setTieInMeasuredDepth( double measuredDepth );
double tieInMeasuredDepth() const;
void setTieInMeasuredDepth( double measuredDepth );
double branchValveMeasuredDepth() const;
void setBranchValveMeasuredDepth( double measuredDepth );
void useDefaultBranchValveMeasuredDepth();
RimWellPath* childWell() const;
void updateChildWellGeometry();
void setEnableBranchValveAtConnection( bool enable );
void setBranchValveTemplate( RimValveTemplate* valveTemplate );
void updateFirstTargetFromParentWell();
const RimWellPathValve* outletValve() const;
RimWellPathValve* outletValve() const;
private:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
@@ -57,9 +66,10 @@ private:
private:
caf::PdmField<QString> m_infoLabel;
caf::PdmPtrField<RimWellPath*> m_parentWell;
caf::PdmPtrField<RimWellPath*> m_childWell;
caf::PdmField<double> m_tieInMeasuredDepth;
caf::PdmPtrField<RimWellPath*> m_parentWell;
caf::PdmPtrField<RimWellPath*> m_childWell;
caf::PdmField<double> m_tieInMeasuredDepth;
caf::PdmField<std::pair<bool, double>> m_customOutletValveMD;
caf::PdmField<bool> m_addValveAtConnection;
caf::PdmChildField<RimWellPathValve*> m_valve;