From 05208a24a2265a1d4c5161ca2aad21e2d29c363f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Nov 2024 14:20:25 +0100 Subject: [PATCH] #11901 Python: Make more well completion parameters available Add access to all MSW parameters in Python : "msw_settings = well_path.msw_settings()" Make all parameters of the well completion object available in Python. --- .../RimMswCompletionParameters.cpp | 41 ++++++++----- .../RimWellPathCompletionSettings.cpp | 17 +++--- .../ProjectDataModelCommands/RimcWellPath.cpp | 58 +++++++++++++++++++ .../ProjectDataModelCommands/RimcWellPath.h | 16 +++++ 4 files changed, 110 insertions(+), 22 deletions(-) diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp index f94aa76643..7c49e03ff9 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimMswCompletionParameters.cpp @@ -22,6 +22,8 @@ #include "RimWellPath.h" +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiObjectEditorHandle.h" #include @@ -31,8 +33,8 @@ namespace caf template <> void RimMswCompletionParameters::ReferenceMDEnum::setUp() { - addItem( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD, "GridIntersectionRefMD", "Grid Entry Point" ); - addItem( RimMswCompletionParameters::ReferenceMDType::MANUAL_REFERENCE_MD, "ManualRefMD", "User Defined" ); + addItem( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD, "GridEntryPoint", "Grid Entry Point", { "GridIntersectionRefMD" } ); + addItem( RimMswCompletionParameters::ReferenceMDType::MANUAL_REFERENCE_MD, "UserDefined", "User Defined", { "ManualRefMD" } ); setDefault( RimMswCompletionParameters::ReferenceMDType::AUTO_REFERENCE_MD ); } @@ -61,22 +63,33 @@ CAF_PDM_SOURCE_INIT( RimMswCompletionParameters, "RimMswCompletionParameters" ); //-------------------------------------------------------------------------------------------------- RimMswCompletionParameters::RimMswCompletionParameters() { - CAF_PDM_InitObject( "MSW Completion Parameters", ":/CompletionsSymbol16x16.png" ); + CAF_PDM_InitScriptableObjectWithNameAndComment( "MSW Completion Parameters", + ":/CompletionsSymbol16x16.png", + "", + "", + "MswSettings", + "Multi Segment Well Completion Settings" ); - CAF_PDM_InitFieldNoDefault( &m_refMDType, "RefMDType", "Reference MD" ); - CAF_PDM_InitField( &m_refMD, "RefMD", 0.0, "" ); + CAF_PDM_InitScriptableFieldWithScriptKeywordNoDefault( &m_refMDType, "RefMDType", "ReferenceMdType", "" ); + CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_refMD, "RefMD", "UserDefinedReferenceMd", 0.0, "User Defined Reference MD" ); - CAF_PDM_InitField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral" ); + CAF_PDM_InitScriptableField( &m_customValuesForLateral, "CustomValuesForLateral", false, "Custom Values for Lateral" ); const auto unitSystem = RiaDefines::EclipseUnitSystem::UNITS_METRIC; - CAF_PDM_InitField( &m_linerDiameter, "LinerDiameter", RimMswCompletionParameters::defaultLinerDiameter( unitSystem ), "Liner Inner Diameter" ); - CAF_PDM_InitField( &m_roughnessFactor, "RoughnessFactor", RimMswCompletionParameters::defaultRoughnessFactor( unitSystem ), "Roughness Factor" ); - - CAF_PDM_InitFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" ); - CAF_PDM_InitFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth" ); - - CAF_PDM_InitField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" ); - CAF_PDM_InitField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" ); + CAF_PDM_InitScriptableField( &m_linerDiameter, + "LinerDiameter", + RimMswCompletionParameters::defaultLinerDiameter( unitSystem ), + "Liner Inner Diameter" ); + CAF_PDM_InitScriptableField( &m_roughnessFactor, + "RoughnessFactor", + RimMswCompletionParameters::defaultRoughnessFactor( unitSystem ), + "Roughness Factor" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_pressureDrop, "PressureDrop", "Pressure Drop" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_lengthAndDepth, "LengthAndDepth", "Length and Depth" ); + + CAF_PDM_InitScriptableField( &m_enforceMaxSegmentLength, "EnforceMaxSegmentLength", false, "Enforce Max Segment Length" ); + CAF_PDM_InitScriptableField( &m_maxSegmentLength, "MaxSegmentLength", 200.0, "Max Segment Length" ); m_maxSegmentLength.uiCapability()->setUiHidden( true ); } diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp index 332c42ce57..91e75108ff 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimWellPathCompletionSettings.cpp @@ -81,19 +81,20 @@ CAF_PDM_SOURCE_INIT( RimWellPathCompletionSettings, "WellPathCompletionSettings" RimWellPathCompletionSettings::RimWellPathCompletionSettings() { CAF_PDM_InitScriptableObject( "Completion Settings", ":/CompletionsSymbol16x16.png" ); + CAF_PDM_InitScriptableField( &m_wellNameForExport, "WellNameForExport", QString(), "Well Name" ); m_wellNameForExport.uiCapability()->setUiEditorTypeName( caf::PdmUiLineEditor::uiEditorTypeName() ); CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_groupName, "WellGroupNameForExport", "GroupNameForExport", QString(), "Group Name" ); - CAF_PDM_InitField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" ); + CAF_PDM_InitScriptableField( &m_referenceDepth, "ReferenceDepthForExport", QString(), "Reference Depth for BHP" ); CAF_PDM_InitScriptableFieldNoDefault( &m_preferredFluidPhase, "WellTypeForExport", "Preferred Fluid Phase" ); - CAF_PDM_InitField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" ); - CAF_PDM_InitFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation" ); - CAF_PDM_InitFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in" ); - CAF_PDM_InitField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" ); - CAF_PDM_InitField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" ); - CAF_PDM_InitFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" ); - CAF_PDM_InitField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" ); + CAF_PDM_InitScriptableField( &m_drainageRadiusForPI, "DrainageRadiusForPI", QString( "0.0" ), "Drainage Radius for PI" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_gasInflowEquation, "GasInflowEq", "Gas Inflow Equation" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_automaticWellShutIn, "AutoWellShutIn", "Automatic well shut-in" ); + CAF_PDM_InitScriptableField( &m_allowWellCrossFlow, "AllowWellCrossFlow", true, "Allow Well Cross-Flow" ); + CAF_PDM_InitScriptableField( &m_wellBoreFluidPVTTable, "WellBoreFluidPVTTable", 0, "Wellbore Fluid PVT table" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_hydrostaticDensity, "HydrostaticDensity", "Hydrostatic Density" ); + CAF_PDM_InitScriptableField( &m_fluidInPlaceRegion, "FluidInPlaceRegion", 0, "Fluid In-Place Region" ); CAF_PDM_InitFieldNoDefault( &m_mswParameters, "MswParameters", "Multi Segment Well Parameters" ); m_mswParameters = new RimMswCompletionParameters; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp index 4fc4720cee..d7a2000e1a 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp @@ -23,6 +23,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCaseTools.h" +#include "RimMswCompletionParameters.h" #include "RimPerforationCollection.h" #include "RimPerforationInterval.h" #include "RimStimPlanFractureTemplate.h" @@ -31,6 +32,7 @@ #include "RimTools.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPathCompletionSettings.h" #include "RimWellPathFracture.h" #include "RigStimPlanModelTools.h" @@ -223,3 +225,59 @@ std::unique_ptr RimcWellPath_appendPerforationInterval::de { return std::unique_ptr( new RimPerforationInterval ); } + +CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPath, RimcWellPath_multiSegmentWellSettings, "MswSettings" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimcWellPath_multiSegmentWellSettings::RimcWellPath_multiSegmentWellSettings( caf::PdmObjectHandle* self ) + : caf::PdmObjectMethod( self ) +{ + CAF_PDM_InitObject( "MSW Settings", "", "", "Multi Segment Well Settings" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* RimcWellPath_multiSegmentWellSettings::execute() +{ + auto wellPath = self(); + + // RimMswCompletionParameters is a child object of RimWellPathCompletionSettings. To simplify the Python API, we return + // RimMswCompletionParameters directly from a well path object in Python. Two parameters are already exposed as part of the completion + // settings object, see RimWellPathCompletionSettings and the proxy fields liner_diameter and roughness. These fields are kept to + // ensure backward compatibility with existing scripts. + // + // https://github.com/OPM/ResInsight/issues/11901 + + if ( auto completionSettings = wellPath->completionSettings() ) + { + return completionSettings->mswCompletionParameters(); + } + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimcWellPath_multiSegmentWellSettings::resultIsPersistent() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimcWellPath_multiSegmentWellSettings::isNullptrValidResult() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::unique_ptr RimcWellPath_multiSegmentWellSettings::defaultResult() const +{ + return std::unique_ptr( new RimMswCompletionParameters ); +} diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h index bf82d0b9ed..277741e9df 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h @@ -90,3 +90,19 @@ class RimcWellPath_appendPerforationInterval : public caf::PdmObjectMethod caf::PdmField m_diameter; caf::PdmField m_skinFactor; }; + +//================================================================================================== +/// +//================================================================================================== +class RimcWellPath_multiSegmentWellSettings : public caf::PdmObjectMethod +{ + CAF_PDM_HEADER_INIT; + +public: + RimcWellPath_multiSegmentWellSettings( caf::PdmObjectHandle* self ); + + caf::PdmObjectHandle* execute() override; + bool resultIsPersistent() const override; + bool isNullptrValidResult() const override; + std::unique_ptr defaultResult() const override; +};