mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#8038 Python: add api to insert a fracture template and a fracture at given MD
This commit is contained in:
parent
15b4077876
commit
ed2beec359
@ -52,9 +52,9 @@ CAF_CMD_SOURCE_INIT( RicNewWellPathFractureFeature, "RicNewWellPathFractureFeatu
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewWellPathFractureFeature::addFracture( gsl::not_null<RimWellPath*> wellPath, double measuredDepth )
|
||||
RimWellPathFracture* RicNewWellPathFractureFeature::addFracture( gsl::not_null<RimWellPath*> 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<RimWellPath*> 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<RimWellPath*> wel
|
||||
}
|
||||
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( fracture );
|
||||
return fracture;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -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<RimWellPath*> wellPath, double measuredDepth );
|
||||
static RimWellPathFracture* addFracture( gsl::not_null<RimWellPath*> wellPath, double measuredDepth );
|
||||
|
||||
protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
|
@ -39,7 +39,9 @@
|
||||
#include "RimWellPathFracture.h"
|
||||
#include "RimWellPathFractureCollection.h"
|
||||
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmObjectScriptingCapability.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
@ -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",
|
||||
|
@ -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() );
|
||||
|
@ -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})
|
||||
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// 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<RimFractureTemplateCollection>();
|
||||
|
||||
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<caf::PdmObjectHandle> RimcFractureTemplateCollection_newFractureTemplate::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimStimPlanFractureTemplate );
|
||||
}
|
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmObjectMethod.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
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<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_filePath;
|
||||
};
|
77
ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp
Normal file
77
ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.cpp
Normal file
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// 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<RimWellPath>();
|
||||
|
||||
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<caf::PdmObjectHandle> RimcWellPath_newFracture::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimWellPathFracture );
|
||||
}
|
47
ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h
Normal file
47
ApplicationLibCode/ProjectDataModelCommands/RimcWellPath.h
Normal file
@ -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 <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmObjectMethod.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
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<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<double> m_md;
|
||||
caf::PdmPtrField<RimStimPlanFractureTemplate*> m_stimPlanFractureTemplate;
|
||||
};
|
@ -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,
|
||||
)
|
Loading…
Reference in New Issue
Block a user