diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index ac51333d63..a5f84ffe5b 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -52,9 +52,9 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathFractureFeature, "RicNewWellPathFractureFeatu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicNewWellPathFractureFeature::addFracture( gsl::not_null wellPath, double measuredDepth ) +RimWellPathFracture* RicNewWellPathFractureFeature::addFracture( gsl::not_null wellPath, double measuredDepth ) { - if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return; + if ( !RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem( wellPath ) ) return nullptr; RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection(); CVF_ASSERT( fractureCollection ); @@ -68,23 +68,23 @@ void RicNewWellPathFractureFeature::addFracture( gsl::not_null wel } } + auto wellPathGeometry = wellPath->wellPathGeometry(); + CVF_ASSERT( wellPathGeometry ); + if ( !wellPathGeometry ) return nullptr; + + RimOilField* oilfield = nullptr; + fractureCollection->firstAncestorOrThisOfType( oilfield ); + if ( !oilfield ) return nullptr; + RimWellPathFracture* fracture = new RimWellPathFracture(); fractureCollection->addFracture( fracture ); fracture->setMeasuredDepth( measuredDepth ); fracture->setFractureUnit( wellPath->unitSystem() ); - auto wellPathGeometry = wellPath->wellPathGeometry(); - CVF_ASSERT( wellPathGeometry ); - if ( !wellPathGeometry ) return; - cvf::Vec3d positionAtWellpath = wellPathGeometry->interpolatedPointAlongWellPath( measuredDepth ); fracture->setAnchorPosition( positionAtWellpath ); - RimOilField* oilfield = nullptr; - fractureCollection->firstAncestorOrThisOfType( oilfield ); - if ( !oilfield ) return; - fracture->setName( RicFractureNameGenerator::nameForNewFracture() ); auto unitSet = wellPath->unitSystem(); @@ -105,6 +105,7 @@ void RicNewWellPathFractureFeature::addFracture( gsl::not_null wel } Riu3DMainWindowTools::selectAsCurrentItem( fracture ); + return fracture; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h index bdbcdf080b..4b1bb21744 100644 --- a/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h +++ b/ApplicationLibCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h @@ -25,6 +25,7 @@ class RimWellPathFractureCollection; class RimWellPath; +class RimWellPathFracture; //================================================================================================== /// @@ -34,7 +35,7 @@ class RicNewWellPathFractureFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void addFracture( gsl::not_null wellPath, double measuredDepth ); + static RimWellPathFracture* addFracture( gsl::not_null wellPath, double measuredDepth ); protected: void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index cd642895b5..af2feaa9fe 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -39,7 +39,9 @@ #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" +#include "cafPdmFieldScriptingCapability.h" #include "cafPdmObject.h" +#include "cafPdmObjectScriptingCapability.h" #include @@ -50,7 +52,7 @@ CAF_PDM_SOURCE_INIT( RimFractureTemplateCollection, "FractureDefinitionCollectio //-------------------------------------------------------------------------------------------------- RimFractureTemplateCollection::RimFractureTemplateCollection() { - CAF_PDM_InitObject( "Fracture Templates", ":/FractureTemplates16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Fracture Templates", ":/FractureTemplates16x16.png", "", "" ); CAF_PDM_InitField( &m_defaultUnitsForFracTemplates, "DefaultUnitForTemplates", diff --git a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index 5bc39a509d..69dfcd6a6c 100644 --- a/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationLibCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -45,7 +45,9 @@ #include "RivWellFracturePartMgr.h" +#include "cafPdmFieldScriptingCapability.h" #include "cafPdmObject.h" +#include "cafPdmObjectScriptingCapability.h" #include "cafPdmUiDoubleSliderEditor.h" #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiTextEditor.h" @@ -68,7 +70,7 @@ CAF_PDM_SOURCE_INIT( RimStimPlanFractureTemplate, "RimStimPlanFractureTemplate" //-------------------------------------------------------------------------------------------------- RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() { - CAF_PDM_InitObject( "Fracture Template", ":/FractureTemplate16x16.png", "", "" ); + CAF_PDM_InitScriptableObject( "Fracture Template", ":/FractureTemplate16x16.png", "", "" ); CAF_PDM_InitFieldNoDefault( &m_stimPlanFileName, "StimPlanFileName", "File Name", "", "", "" ); m_stimPlanFileName.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); diff --git a/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake index 0a6f3daada..46472a002b 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake @@ -18,6 +18,8 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimcWellLogTrack.h ${CMAKE_CURRENT_LIST_DIR}/RimcWellPathGeometryDef.h ${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.h + ${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.h + ${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -40,6 +42,8 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimcWellLogTrack.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcWellPathGeometryDef.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp new file mode 100644 index 0000000000..26eb3d14bf --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimcFractureTemplateCollection.h" + +#include "FractureCommands/RicFractureNameGenerator.h" +#include "FractureCommands/RicNewStimPlanFractureTemplateFeature.h" +#include "FractureCommands/RicNewStimPlanModelFeature.h" + +#include "RimEclipseCase.h" +#include "RimFractureTemplate.h" + +#include "RimFractureTemplateCollection.h" +#include "RimStimPlanFractureTemplate.h" + +#include "cafPdmAbstractFieldScriptingCapability.h" +#include "cafPdmFieldScriptingCapability.h" + +CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimFractureTemplateCollection, + RimcFractureTemplateCollection_newFractureTemplate, + "NewFractureTemplate" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimcFractureTemplateCollection_newFractureTemplate::RimcFractureTemplateCollection_newFractureTemplate( caf::PdmObjectHandle* self ) + : caf::PdmObjectMethod( self ) +{ + CAF_PDM_InitObject( "Create Fracture Template", "", "", "Create a new StimPlan Fracture Template" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path to StimPlan Countour File" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* RimcFractureTemplateCollection_newFractureTemplate::execute() +{ + RimFractureTemplateCollection* stimPlanModelTemplateCollection = self(); + + bool reuseExistingTemplatesWithMatchingNames = false; + auto newTemplates = + RicNewStimPlanFractureTemplateFeature::createNewTemplatesFromFiles( { m_filePath }, + reuseExistingTemplatesWithMatchingNames ); + + if ( newTemplates.empty() ) return nullptr; + + stimPlanModelTemplateCollection->updateAllRequiredEditors(); + return newTemplates[0]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimcFractureTemplateCollection_newFractureTemplate::resultIsPersistent() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::unique_ptr RimcFractureTemplateCollection_newFractureTemplate::defaultResult() const +{ + return std::unique_ptr( new RimStimPlanFractureTemplate ); +} diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h new file mode 100644 index 0000000000..b3fbfbb59d --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcFractureTemplateCollection.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimFractureTemplateCollection.h" + +#include "cafPdmField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmObjectMethod.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RimcFractureTemplateCollection_newFractureTemplate : public caf::PdmObjectMethod +{ + CAF_PDM_HEADER_INIT; + +public: + RimcFractureTemplateCollection_newFractureTemplate( caf::PdmObjectHandle* self ); + + caf::PdmObjectHandle* execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + +private: + caf::PdmField m_filePath; +}; diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp new file mode 100644 index 0000000000..b62a63c3b8 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp @@ -0,0 +1,77 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimcWellPath.h" + +#include "RimStimPlanFractureTemplate.h" +#include "RimWellPath.h" +#include "RimWellPathFracture.h" + +#include "FractureCommands/RicNewWellPathFractureFeature.h" + +#include "cafPdmAbstractFieldScriptingCapability.h" +#include "cafPdmFieldScriptingCapability.h" + +CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPath, RimcWellPath_newFracture, "NewFracture" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimcWellPath_newFracture::RimcWellPath_newFracture( caf::PdmObjectHandle* self ) + : caf::PdmObjectMethod( self ) +{ + CAF_PDM_InitObject( "Add StimPlan Fracture", "", "", "Add StimPlan Fracture" ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_md, "MeasuredDepth", "", "", "", "Measured Depth" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_stimPlanFractureTemplate, + "StimPlanFractureTemplate", + "", + "", + "", + "StimPlan Fracture Template" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* RimcWellPath_newFracture::execute() +{ + auto wellPath = self(); + + RimWellPathFracture* wellPathFracture = RicNewWellPathFractureFeature::addFracture( wellPath, m_md() ); + + if ( m_stimPlanFractureTemplate ) wellPathFracture->setFractureTemplate( m_stimPlanFractureTemplate() ); + + return wellPathFracture; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimcWellPath_newFracture::resultIsPersistent() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::unique_ptr RimcWellPath_newFracture::defaultResult() const +{ + return std::unique_ptr( new RimWellPathFracture ); +} diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h new file mode 100644 index 0000000000..a6a2ac201b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmObjectMethod.h" +#include "cafPdmPtrField.h" + +#include + +class RimStimPlanFractureTemplate; + +//================================================================================================== +/// +//================================================================================================== +class RimcWellPath_newFracture : public caf::PdmObjectMethod +{ + CAF_PDM_HEADER_INIT; + +public: + RimcWellPath_newFracture( caf::PdmObjectHandle* self ); + + caf::PdmObjectHandle* execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + +private: + caf::PdmField m_md; + caf::PdmPtrField m_stimPlanFractureTemplate; +}; diff --git a/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py b/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py new file mode 100644 index 0000000000..9817279897 --- /dev/null +++ b/GrpcInterface/Python/rips/PythonExamples/import_fractures_on_well.py @@ -0,0 +1,39 @@ +# Load ResInsight Processing Server Client Library +import rips +import tempfile +from os.path import expanduser +from pathlib import Path + +# Connect to ResInsight instance +resinsight = rips.Instance.find() +project = resinsight.project + +# Look for input files in the home directory of the user +home_dir = expanduser("~") +stim_plan_file_path = (Path(home_dir) / "contour.xml").as_posix() +print("StimPlan contour file path:", stim_plan_file_path) + +# Find a case +cases = resinsight.project.cases() +case = cases[0] + +# Create stim plan template +fmt_collection = project.descendants(rips.FractureDefinitionCollection)[0] +fracture_template = fmt_collection.new_fracture_template(file_path=stim_plan_file_path) + +well_name = "B-2 H" + +# Find a well +well_path = project.well_path_by_name(well_name) +print("well path:", well_path.name) + +# Place fracture at given depths +measured_depths = [3200.0, 3400.0, 3600.0] +for measured_depth in measured_depths: + + print("Placing fracture at {} depth (MD)".format(measured_depth)) + # Create stim plan at a give measured depth + fracture = well_path.new_fracture( + measured_depth=measured_depth, + stim_plan_fracture_template=fracture_template, + )