mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Scripting: geomechanical cell result (replaces #14952)
Make RimGeoMechResultDefinition (position, field and component) and the view's cell result scriptable, as for grid views.
This commit is contained in:
1 parent
914cab9084
commit
848c2394bb
10 files changed
+94
-14
No files matched your search
+22
@@ -0,0 +1,22 @@
|
||||
######################################################################
|
||||
# This script applies a geomechanical cell result to the first view
|
||||
# of the first GeoMech case in the project
|
||||
######################################################################
|
||||
import sys
|
||||
|
||||
import rips
|
||||
|
||||
resinsight = rips.Instance.find()
|
||||
|
||||
cases = resinsight.project.descendants(rips.GeoMechCase)
|
||||
if not cases:
|
||||
print("No GeoMech cases in project")
|
||||
sys.exit(1)
|
||||
|
||||
view = cases[0].views()[0]
|
||||
|
||||
cell_result = view.cell_result()
|
||||
cell_result.result_position_type = "ELEMENT_NODAL"
|
||||
cell_result.result_field_name = "SE"
|
||||
cell_result.result_component_name = "S33"
|
||||
cell_result.update()
|
||||
@@ -521,6 +521,11 @@ class PdmObjectBase:
|
||||
)
|
||||
try:
|
||||
pb2_object = self._pdm_object_stub.GetAncestorPdmObject(request)
|
||||
from .generated.generated_classes import class_from_keyword
|
||||
|
||||
actual_class = class_from_keyword(pb2_object.class_keyword)
|
||||
if actual_class is not None and issubclass(actual_class, class_definition):
|
||||
class_definition = actual_class
|
||||
pdm_object = class_definition(pb2_object=pb2_object, channel=self.channel())
|
||||
return pdm_object
|
||||
except grpc.RpcError as e:
|
||||
|
||||
@@ -115,6 +115,10 @@ def extract_address(address) -> int:
|
||||
@add_method(View)
|
||||
def case(self):
|
||||
"""Get the case the view belongs to"""
|
||||
if isinstance(self, GeoMechView):
|
||||
# Geomechanical views are children of their case
|
||||
return self.ancestor(rips.case.Case)
|
||||
|
||||
project = self.ancestor(rips.project.Project)
|
||||
|
||||
eclipse_case_addr = extract_address(self.eclipse_case)
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaOpenTelemetryManager.h"
|
||||
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimResultDefinitionInterface.h"
|
||||
|
||||
#include "cafPdmAbstractFieldScriptingCapability.h"
|
||||
#include "cafPdmObject.h"
|
||||
@@ -451,9 +451,7 @@ grpc::Status RiaGrpcPdmObjectService::UpdateExistingPdmObject( grpc::ServerConte
|
||||
}
|
||||
|
||||
// Validation succeeded - update UI and views
|
||||
RimEclipseResultDefinition* resultDefinition = dynamic_cast<RimEclipseResultDefinition*>( matchingObject );
|
||||
// TODO: Make this more general. Perhaps we need an interface method for updating UI fields
|
||||
if ( resultDefinition )
|
||||
if ( auto resultDefinition = dynamic_cast<RimResultDefinitionInterface*>( matchingObject ) )
|
||||
{
|
||||
resultDefinition->updateUiFieldsFromActiveResult();
|
||||
resultDefinition->loadResult();
|
||||
|
||||
Reference in new issue
Block a user