From 1edac5762df8758b077844e4bec4b809f039c1df Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Wed, 6 Sep 2023 15:49:21 +0200 Subject: [PATCH] #10568 StimPlan Template: Add python api for appending Pressure Table Items --- .../CMakeLists_files.cmake | 2 + .../RimcPressureTable.cpp | 70 +++++++++++++++++++ .../RimcPressureTable.h | 45 ++++++++++++ .../create_and_export_stim_plan_model.py | 14 ++++ 4 files changed, 131 insertions(+) create mode 100644 ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp create mode 100644 ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h diff --git a/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake index 9cb5949276..d41f7fd953 100644 --- a/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModelCommands/CMakeLists_files.cmake @@ -26,6 +26,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.h ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.h ${CMAKE_CURRENT_LIST_DIR}/RimcIdenticalGridCaseGroup.h + ${CMAKE_CURRENT_LIST_DIR}/RimcPressureTable.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -56,6 +57,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcEclipseStatisticsCase.cpp ${CMAKE_CURRENT_LIST_DIR}/RimcIdenticalGridCaseGroup.cpp + ${CMAKE_CURRENT_LIST_DIR}/RimcPressureTable.cpp ) list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp new file mode 100644 index 0000000000..b3d3477615 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.cpp @@ -0,0 +1,70 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- 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 "RimcPressureTable.h" + +#include "RimPressureTable.h" +#include "RimPressureTableItem.h" + +#include "cafPdmAbstractFieldScriptingCapability.h" +#include "cafPdmFieldScriptingCapability.h" + +CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimPressureTable, RimcPressureTable_addPressure, "AddPressure" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimcPressureTable_addPressure::RimcPressureTable_addPressure( caf::PdmObjectHandle* self ) + : caf::PdmObjectMethod( self ) +{ + CAF_PDM_InitObject( "Add pressure data", "", "", "Add pressure data to pressure table." ); + + CAF_PDM_InitScriptableFieldNoDefault( &m_depth, "Depth", "", "", "", "Depth: TVDMSL [m]" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_initialPressure, "InitialPressure", "", "", "", "Initial Pressure [Bar]" ); + CAF_PDM_InitScriptableFieldNoDefault( &m_pressure, "Pressure", "", "", "", "Pressure [Bar]" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmObjectHandle* RimcPressureTable_addPressure::execute() +{ + RimPressureTableItem* pressureTableItem = new RimPressureTableItem; + pressureTableItem->setValues( m_depth, m_initialPressure, m_pressure ); + + RimPressureTable* pressureTable = self(); + pressureTable->insertItem( nullptr, pressureTableItem ); + + pressureTable->updateAllRequiredEditors(); + return pressureTableItem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimcPressureTable_addPressure::resultIsPersistent() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::unique_ptr RimcPressureTable_addPressure::defaultResult() const +{ + return std::unique_ptr( new RimPressureTableItem ); +} diff --git a/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h new file mode 100644 index 0000000000..35d4416c19 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModelCommands/RimcPressureTable.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- 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 "RimPressureTable.h" + +#include "cafPdmField.h" +#include "cafPdmObjectHandle.h" +#include "cafPdmObjectMethod.h" + +//================================================================================================== +/// +//================================================================================================== +class RimcPressureTable_addPressure : public caf::PdmObjectMethod +{ + CAF_PDM_HEADER_INIT; + +public: + RimcPressureTable_addPressure( caf::PdmObjectHandle* self ); + + caf::PdmObjectHandle* execute() override; + bool resultIsPersistent() const override; + std::unique_ptr defaultResult() const override; + +private: + caf::PdmField m_depth; + caf::PdmField m_initialPressure; + caf::PdmField m_pressure; +}; diff --git a/GrpcInterface/Python/rips/PythonExamples/create_and_export_stim_plan_model.py b/GrpcInterface/Python/rips/PythonExamples/create_and_export_stim_plan_model.py index b2d378aa5a..0ea839aacc 100644 --- a/GrpcInterface/Python/rips/PythonExamples/create_and_export_stim_plan_model.py +++ b/GrpcInterface/Python/rips/PythonExamples/create_and_export_stim_plan_model.py @@ -59,6 +59,20 @@ non_net_layers.formation = "Not" non_net_layers.facies = "Shale" non_net_layers.update() +# Add some pressure table items +pressure_table = stim_plan_model_template.pressure_table() +pressure_table.add_pressure(depth=2800.0, initial_pressure=260.0, pressure=261.0) +pressure_table.add_pressure(depth=3000.0, initial_pressure=270.0, pressure=273.0) +pressure_table.add_pressure(depth=3400.0, initial_pressure=274.0, pressure=276.0) +pressure_table.add_pressure(depth=3800.0, initial_pressure=276.0, pressure=280.0) + +print("Pressure table ({} items)".format(len(pressure_table.items()))) +for item in pressure_table.items(): + print( + "TDVMSL [m]: {} Initial Pressure: {} Pressure: {}".format( + item.depth, item.initial_pressure, item.pressure + ) + ) # Add some scaling factors elastic_properties = stim_plan_model_template.elastic_properties()