#6495 Update python api to changes in fracture model + template.

This commit is contained in:
Kristian Bendiksen
2020-09-25 19:13:37 +02:00
parent 24fe32bf54
commit 9f92f15279
10 changed files with 211 additions and 43 deletions

View File

@@ -1,30 +1,45 @@
# Load ResInsight Processing Server Client Library
import rips
import tempfile
from os.path import expanduser
# Connect to ResInsight instance
resinsight = rips.Instance.find()
# Example code
project = resinsight.project
# Create fracture model template
home_dir = expanduser("~")
elastic_properties_file_path = home_dir + "/elastic_properties.csv"
facies_properties_file_path = home_dir + "/facies_id.roff"
fmt_collection = project.descendants(rips.FractureModelTemplateCollection)[0]
fracture_model_template = fmt_collection.new_fracture_model_template(elastic_properties_file_path=elastic_properties_file_path,
facies_properties_file_path=facies_properties_file_path)
fracture_model_template.overburden_formation = "Garn"
fracture_model_template.overburden_facies = "Shale"
fracture_model_template.underburden_formation = "Garn"
fracture_model_template.underburden_facies = "Shale"
fracture_model_template.overburden_height = 68
fracture_model_template.update()
print("Overburden: ", fracture_model_template.overburden_formation)
# Set eclipse result for facies definition
eclipse_result = fracture_model_template.facies_properties().facies_definition()
eclipse_result.result_type = "INPUT_PROPERTY"
eclipse_result.result_variable = "OPERNUM_1"
eclipse_result.update()
# Find a well
well_path = project.well_path_by_name("Well-1")
well_path = project.well_path_by_name("B-2_H")
print("well path:", well_path)
fracture_model_collection = project.descendants(rips.FractureModelCollection)[0]
# Create fracture model at a give measured depth
measured_depth = 4100.0
elastic_properties_file_path = "/home/resinsight/stimplan/complete_dataset_2020-06-22/Elastic_Template_CSV_file-with-biot.csv"
fracture_model = fracture_model_collection.new_fracture_model(well_path=well_path, measured_depth=measured_depth, elastic_properties_file_path=elastic_properties_file_path)
fracture_model.overburden_formation = "Garn"
fracture_model.overburden_facies = "Shale"
fracture_model.underburden_formation = "Garn"
fracture_model.underburden_facies = "Shale"
fracture_model.overburden_height = 68
fracture_model.update()
print("Overburden: ", fracture_model.overburden_formation)
measured_depth = 3200.0
fracture_model = fracture_model_collection.new_fracture_model(well_path=well_path, measured_depth=measured_depth, fracture_model_template=fracture_model_template)
cases = resinsight.project.cases()
case = cases[0]
@@ -39,6 +54,7 @@ fracture_model_plot = fracture_model_plot_collection.new_fracture_model_plot(ecl
export_folder = tempfile.gettempdir()
print("Exporting fracture model to: ", export_folder)
fracture_model_plot.export_to_file(directory_path=export_folder)
fracture_model_plot.export_snapshot(export_folder=export_folder)

View File

@@ -246,15 +246,7 @@ void RimFractureModel::fieldChangedByUi( const caf::PdmFieldHandle* changedField
changedField == &m_autoComputeBarrier )
{
updateThicknessDirection();
if ( m_autoComputeBarrier )
{
updateDistanceToBarrierAndDip();
}
else
{
clearBarrierAnnotation();
}
updateBarrierProperties();
}
if ( changedField == &m_autoComputeBarrier || changedField == &m_hasBarrier )
@@ -502,6 +494,21 @@ cvf::Vec3d RimFractureModel::calculateTSTDirection() const
return ( direction / static_cast<double>( numContributingCells ) ).getNormalized();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFractureModel::updateBarrierProperties()
{
if ( m_autoComputeBarrier )
{
updateDistanceToBarrierAndDip();
}
else
{
clearBarrierAnnotation();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -1159,6 +1166,7 @@ void RimFractureModel::setMD( double md )
m_MD = md;
updatePositionFromMeasuredDepth();
updateThicknessDirection();
updateBarrierProperties();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -164,6 +164,7 @@ private:
static RigEclipseCaseData* getEclipseCaseData();
static RimEclipseCase* getEclipseCase();
void updateBarrierProperties();
void addBarrierAnnotation( const cvf::Vec3d& startPosition, const cvf::Vec3d& endPosition );
void clearBarrierAnnotation();
RimAnnotationCollection* annotationCollection();

View File

@@ -25,7 +25,9 @@
#include "RimFractureModelTemplate.h"
#include "RimProject.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObject.h"
#include "cafPdmObjectScriptingCapability.h"
CAF_PDM_SOURCE_INIT( RimFractureModelTemplateCollection, "FractureModelTemplateCollection" );
@@ -34,9 +36,14 @@ CAF_PDM_SOURCE_INIT( RimFractureModelTemplateCollection, "FractureModelTemplateC
//--------------------------------------------------------------------------------------------------
RimFractureModelTemplateCollection::RimFractureModelTemplateCollection()
{
CAF_PDM_InitObject( "Fracture Model Templates", ":/FractureTemplates16x16.png", "", "" );
CAF_PDM_InitScriptableObject( "Fracture Model Templates", ":/FractureTemplates16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_fractureModelTemplates, "FractureDefinitions", "", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_fractureModelTemplates,
"FractureModelTemplates",
"Fracture Model Templates",
"",
"",
"" );
m_fractureModelTemplates.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_nextValidId, "NextValidId", 0, "", "", "", "" );

View File

@@ -52,13 +52,13 @@ RimFaciesProperties::RimFaciesProperties()
m_propertiesTable.uiCapability()->setUiReadOnly( true );
m_propertiesTable.xmlCapability()->disableIO();
CAF_PDM_InitFieldNoDefault( &m_faciesDefinition, "FaciesDefinition", "", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_faciesDefinition, "FaciesDefinition", "", "", "", "" );
m_faciesDefinition.uiCapability()->setUiHidden( true );
m_faciesDefinition.uiCapability()->setUiTreeChildrenHidden( true );
m_faciesDefinition = new RimEclipseResultDefinition;
m_faciesDefinition->findField( "MResultType" )->uiCapability()->setUiName( "Facies Definiton" );
CAF_PDM_InitFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors", "", "", "" );
CAF_PDM_InitScriptableFieldNoDefault( &m_colorLegend, "ColorLegend", "Colors", "", "", "" );
m_colorLegend = RimRegularLegendConfig::mapToColorLegend( RimRegularLegendConfig::ColorRangesType::NORMAL );
setUiName( "Facies Properties" );

View File

@@ -5,6 +5,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.h
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.h
${CMAKE_CURRENT_LIST_DIR}/RimcProject.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelTemplateCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelPlotCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimcSurfaceCollection.h
@@ -19,6 +20,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimcSummaryCase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcSummaryResampleData.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcProject.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelTemplateCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelPlotCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureModelPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcSurfaceCollection.cpp

View File

@@ -23,6 +23,7 @@
#include "RimFractureModel.h"
#include "RimFractureModelCollection.h"
#include "RimFractureModelTemplate.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
@@ -42,12 +43,7 @@ RimcFractureModelCollection_newFractureModel::RimcFractureModelCollection_newFra
CAF_PDM_InitObject( "Create Fracture Model", "", "", "Create a new Fracture Model" );
CAF_PDM_InitScriptableFieldNoDefault( &m_wellPath, "WellPath", "", "", "", "Well Path" );
CAF_PDM_InitScriptableFieldNoDefault( &m_md, "MeasuredDepth", "", "", "", "Measured Depth" );
CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertiesFilePath,
"ElasticPropertiesFilePath",
"",
"",
"",
"Elastic Properties File Path" );
CAF_PDM_InitScriptableFieldNoDefault( &m_fractureModelTemplate, "FractureModelTemplate", "", "", "", "Fracture Model Template" );
}
//--------------------------------------------------------------------------------------------------
@@ -55,11 +51,11 @@ RimcFractureModelCollection_newFractureModel::RimcFractureModelCollection_newFra
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcFractureModelCollection_newFractureModel::execute()
{
RimFractureModel* newFractureModel = nullptr;
RimFractureModel* newFractureModel = nullptr;
RimFractureModelCollection* fractureModelCollection = self<RimFractureModelCollection>();
if ( m_wellPath )
{
RimFractureModelCollection* fractureModelCollection = self<RimFractureModelCollection>();
RimWellPathCollection* wellPathCollection = nullptr;
RimWellPathCollection* wellPathCollection = nullptr;
fractureModelCollection->firstAncestorOrThisOfTypeAsserted( wellPathCollection );
newFractureModel = RicNewFractureModelFeature::addFractureModel( m_wellPath, wellPathCollection );
@@ -68,12 +64,8 @@ caf::PdmObjectHandle* RimcFractureModelCollection_newFractureModel::execute()
if ( newFractureModel )
{
newFractureModel->setMD( m_md() );
// TODO: fix this!!!
// RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_elasticPropertiesFilePath,
// newFractureModel );
self<RimFractureModelCollection>()->updateAllRequiredEditors();
newFractureModel->setFractureModelTemplate( m_fractureModelTemplate() );
fractureModelCollection->updateAllRequiredEditors();
}
return newFractureModel;

View File

@@ -29,6 +29,7 @@
#include <QString>
class RimFractureModelCollection;
class RimFractureModelTemplate;
class RimWellPath;
//==================================================================================================
@@ -48,5 +49,5 @@ public:
private:
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<double> m_md;
caf::PdmField<QString> m_elasticPropertiesFilePath;
caf::PdmPtrField<RimFractureModelTemplate*> m_fractureModelTemplate;
};

View File

@@ -0,0 +1,91 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- 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 "RimcFractureModelTemplateCollection.h"
#include "RicElasticPropertiesImportTools.h"
#include "RicFaciesPropertiesImportTools.h"
#include "FractureCommands/RicFractureNameGenerator.h"
#include "FractureCommands/RicNewFractureModelFeature.h"
#include "RimFractureModelTemplate.h"
#include "RimFractureModelTemplateCollection.h"
#include "cafPdmAbstractFieldScriptingCapability.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimFractureModelTemplateCollection,
RimcFractureModelTemplateCollection_newFractureModelTemplate,
"NewFractureModelTemplate" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcFractureModelTemplateCollection_newFractureModelTemplate::RimcFractureModelTemplateCollection_newFractureModelTemplate(
caf::PdmObjectHandle* self )
: caf::PdmObjectMethod( self )
{
CAF_PDM_InitObject( "Create Fracture Model Template", "", "", "Create a new Fracture Model Template" );
CAF_PDM_InitScriptableFieldNoDefault( &m_faciesPropertiesFilePath,
"FaciesPropertiesFilePath",
"",
"",
"",
"Facies Properties File Path" );
CAF_PDM_InitScriptableFieldNoDefault( &m_elasticPropertiesFilePath,
"ElasticPropertiesFilePath",
"",
"",
"",
"Elastic Properties File Path" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RimcFractureModelTemplateCollection_newFractureModelTemplate::execute()
{
RimFractureModelTemplate* newFractureModelTemplate = new RimFractureModelTemplate;
RimFractureModelTemplateCollection* fractureModelTemplateCollection = self<RimFractureModelTemplateCollection>();
newFractureModelTemplate->setName( RicFractureNameGenerator::nameForNewFractureModelTemplate() );
fractureModelTemplateCollection->addFractureModelTemplate( newFractureModelTemplate );
RicElasticPropertiesImportTools::importElasticPropertiesFromFile( m_elasticPropertiesFilePath,
newFractureModelTemplate );
RicFaciesPropertiesImportTools::importFaciesPropertiesFromFile( m_faciesPropertiesFilePath,
newFractureModelTemplate,
true );
fractureModelTemplateCollection->updateAllRequiredEditors();
return newFractureModelTemplate;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimcFractureModelTemplateCollection_newFractureModelTemplate::resultIsPersistent() const
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::unique_ptr<caf::PdmObjectHandle> RimcFractureModelTemplateCollection_newFractureModelTemplate::defaultResult() const
{
return std::unique_ptr<caf::PdmObjectHandle>( new RimFractureModelTemplate );
}

View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2020- 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 "RimFractureModelTemplateCollection.h"
#include "cafPdmField.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmObjectMethod.h"
#include "cafPdmPtrArrayField.h"
#include "cafPdmPtrField.h"
#include <QString>
class RimFractureModelTemplateCollection;
//==================================================================================================
///
//==================================================================================================
class RimcFractureModelTemplateCollection_newFractureModelTemplate : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimcFractureModelTemplateCollection_newFractureModelTemplate( caf::PdmObjectHandle* self );
caf::PdmObjectHandle* execute() override;
bool resultIsPersistent() const override;
std::unique_ptr<PdmObjectHandle> defaultResult() const override;
private:
caf::PdmField<QString> m_elasticPropertiesFilePath;
caf::PdmField<QString> m_faciesPropertiesFilePath;
};