mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9323 Thermal Fracture: add python methods for importing fracture template.
Fixes #9323.
This commit is contained in:
parent
dc80f582bd
commit
accf5713ac
@ -45,14 +45,22 @@ void RicPlaceThermalFractureUsingTemplateDataFeature::onActionTriggered( bool is
|
||||
|
||||
if ( !fracture->fractureTemplate() ) return;
|
||||
|
||||
placeUsingTemplateData( fracture );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicPlaceThermalFractureUsingTemplateDataFeature::placeUsingTemplateData( RimWellPathFracture* fracture )
|
||||
{
|
||||
RimThermalFractureTemplate* thermalTemplate = dynamic_cast<RimThermalFractureTemplate*>( fracture->fractureTemplate() );
|
||||
if ( !thermalTemplate ) return;
|
||||
if ( !thermalTemplate ) return false;
|
||||
|
||||
RimWellPath* wellPath = nullptr;
|
||||
fracture->firstAncestorOrThisOfTypeAsserted( wellPath );
|
||||
|
||||
auto wellPathGeometry = wellPath->wellPathGeometry();
|
||||
if ( !wellPathGeometry ) return;
|
||||
if ( !wellPathGeometry ) return false;
|
||||
|
||||
auto [centerPosition, rotation] = thermalTemplate->computePositionAndRotation();
|
||||
|
||||
@ -77,6 +85,7 @@ void RicPlaceThermalFractureUsingTemplateDataFeature::onActionTriggered( bool is
|
||||
fracture->updateConnectedEditors();
|
||||
RimProject* project = RimProject::current();
|
||||
project->reloadCompletionTypeResultsInAllViews();
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -29,6 +29,9 @@ class RicPlaceThermalFractureUsingTemplateDataFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static bool placeUsingTemplateData( RimWellPathFracture* fracture );
|
||||
|
||||
protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
@ -20,12 +20,13 @@
|
||||
#include "FractureCommands/RicFractureNameGenerator.h"
|
||||
#include "FractureCommands/RicNewStimPlanFractureTemplateFeature.h"
|
||||
#include "FractureCommands/RicNewStimPlanModelFeature.h"
|
||||
#include "FractureCommands/RicNewThermalFractureTemplateFeature.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
#include "RimStimPlanFractureTemplate.h"
|
||||
#include "RimThermalFractureTemplate.h"
|
||||
|
||||
#include "cafPdmAbstractFieldScriptingCapability.h"
|
||||
#include "cafPdmFieldScriptingCapability.h"
|
||||
@ -78,3 +79,52 @@ std::unique_ptr<caf::PdmObjectHandle> RimcFractureTemplateCollection_appendFract
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimStimPlanFractureTemplate );
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimFractureTemplateCollection,
|
||||
RimcFractureTemplateCollection_appendThermalFractureTemplate,
|
||||
"AppendThermalFractureTemplate" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcFractureTemplateCollection_appendThermalFractureTemplate::RimcFractureTemplateCollection_appendThermalFractureTemplate(
|
||||
caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Create Fracture Template", "", "", "Create a new Thermal Fracture Template" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_filePath, "FilePath", "", "", "", "File Path to Thermal Fracture CSV File" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcFractureTemplateCollection_appendThermalFractureTemplate::execute()
|
||||
{
|
||||
RimFractureTemplateCollection* fractureTemplateCollection = self<RimFractureTemplateCollection>();
|
||||
|
||||
bool reuseExistingTemplatesWithMatchingNames = false;
|
||||
auto newTemplates =
|
||||
RicNewThermalFractureTemplateFeature::createNewTemplatesFromFiles( { m_filePath },
|
||||
reuseExistingTemplatesWithMatchingNames );
|
||||
|
||||
if ( newTemplates.empty() ) return nullptr;
|
||||
|
||||
fractureTemplateCollection->updateAllRequiredEditors();
|
||||
return newTemplates[0];
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcFractureTemplateCollection_appendThermalFractureTemplate::resultIsPersistent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcFractureTemplateCollection_appendThermalFractureTemplate::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimThermalFractureTemplate );
|
||||
}
|
||||
|
@ -43,3 +43,21 @@ public:
|
||||
private:
|
||||
caf::PdmField<QString> m_filePath;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcFractureTemplateCollection_appendThermalFractureTemplate : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcFractureTemplateCollection_appendThermalFractureTemplate( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute() override;
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmField<QString> m_filePath;
|
||||
};
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "RimcWellPath.h"
|
||||
|
||||
#include "FractureCommands/RicPlaceThermalFractureUsingTemplateDataFeature.h"
|
||||
#include "RiaLogging.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
@ -26,6 +27,7 @@
|
||||
#include "RimPerforationInterval.h"
|
||||
#include "RimStimPlanFractureTemplate.h"
|
||||
#include "RimStimPlanModel.h"
|
||||
#include "RimThermalFractureTemplate.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
@ -123,6 +125,59 @@ std::unique_ptr<caf::PdmObjectHandle> RimcWellPath_addFracture::defaultResult()
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimWellPathFracture );
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPath, RimcWellPath_addThermalFracture, "AddThermalFracture" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimcWellPath_addThermalFracture::RimcWellPath_addThermalFracture( caf::PdmObjectHandle* self )
|
||||
: caf::PdmObjectMethod( self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Add Thermal Fracture", "", "", "Add Thermal Fracture" );
|
||||
|
||||
CAF_PDM_InitScriptableField( &m_md, "MeasuredDepth", 0.0, "Measured Depth" );
|
||||
CAF_PDM_InitScriptableFieldNoDefault( &m_fractureTemplate, "FractureTemplate", "", "", "", "Thermal Fracture Template" );
|
||||
CAF_PDM_InitScriptableField( &m_placeUsingTemplateData, "PlaceUsingTemplateData", true, "Place using template data" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
caf::PdmObjectHandle* RimcWellPath_addThermalFracture::execute()
|
||||
{
|
||||
auto wellPath = self<RimWellPath>();
|
||||
|
||||
RimWellPathFracture* wellPathFracture = RicNewWellPathFractureFeature::addFracture( wellPath, m_md() );
|
||||
|
||||
if ( m_fractureTemplate )
|
||||
{
|
||||
wellPathFracture->setFractureTemplate( m_fractureTemplate() );
|
||||
}
|
||||
|
||||
if ( m_placeUsingTemplateData )
|
||||
{
|
||||
RicPlaceThermalFractureUsingTemplateDataFeature::placeUsingTemplateData( wellPathFracture );
|
||||
}
|
||||
|
||||
return wellPathFracture;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimcWellPath_addThermalFracture::resultIsPersistent() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::unique_ptr<caf::PdmObjectHandle> RimcWellPath_addThermalFracture::defaultResult() const
|
||||
{
|
||||
return std::unique_ptr<caf::PdmObjectHandle>( new RimWellPathFracture );
|
||||
}
|
||||
|
||||
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPath, RimcWellPath_appendPerforationInterval, "AppendPerforationInterval" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include <QString>
|
||||
|
||||
class RimStimPlanFractureTemplate;
|
||||
class RimThermalFractureTemplate;
|
||||
class RimEclipseCase;
|
||||
|
||||
//==================================================================================================
|
||||
@ -49,6 +50,26 @@ private:
|
||||
caf::PdmPtrField<RimEclipseCase*> m_eclipseCase;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimcWellPath_addThermalFracture : public caf::PdmObjectMethod
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimcWellPath_addThermalFracture( caf::PdmObjectHandle* self );
|
||||
|
||||
caf::PdmObjectHandle* execute() override;
|
||||
bool resultIsPersistent() const override;
|
||||
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimThermalFractureTemplate*> m_fractureTemplate;
|
||||
caf::PdmField<double> m_md;
|
||||
caf::PdmField<bool> m_placeUsingTemplateData;
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
|
@ -0,0 +1,36 @@
|
||||
# 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("~")
|
||||
fracture_file_path = (Path(home_dir) / "fracture.csv").as_posix()
|
||||
print("Thermal fracture file path:", fracture_file_path)
|
||||
|
||||
# Find a case
|
||||
cases = resinsight.project.cases()
|
||||
case = cases[0]
|
||||
|
||||
# Create thermal template
|
||||
fmt_collection = project.descendants(rips.FractureTemplateCollection)[0]
|
||||
fracture_template = fmt_collection.append_thermal_fracture_template(
|
||||
file_path=fracture_file_path
|
||||
)
|
||||
|
||||
well_name = "F-1 H"
|
||||
|
||||
# Find a well
|
||||
well_path = project.well_path_by_name(well_name)
|
||||
print("Well path:", well_path.name)
|
||||
|
||||
# Create fracture and place it using data from the fracture template
|
||||
fracture = well_path.add_thermal_fracture(
|
||||
fracture_template=fracture_template,
|
||||
place_using_template_data=True,
|
||||
)
|
Loading…
Reference in New Issue
Block a user