diff --git a/ApplicationCode/GrpcInterface/CMakeLists.cmake b/ApplicationCode/GrpcInterface/CMakeLists.cmake index 2a97999a08..d2f39634c0 100644 --- a/ApplicationCode/GrpcInterface/CMakeLists.cmake +++ b/ApplicationCode/GrpcInterface/CMakeLists.cmake @@ -170,13 +170,15 @@ if (PYTHON_EXECUTABLE) "rips/View.py" "rips/examples/InstanceExample.py" "rips/examples/CommandExample.py" - "rips/examples/CaseGridGroup.py" + "rips/examples/CaseGridGroup.py" "rips/examples/CaseInfoStreamingExample.py" "rips/examples/SoilPorvAsync.py" "rips/examples/SoilPorvSync.py" "rips/examples/SelectedCases.py" "rips/examples/AllCases.py" "rips/examples/SetGridProperties.py" + "rips/examples/SetCellResult.py" + "rips/examples/SetFlowDiagnosticsResult.py" "rips/examples/GridInformation.py" "rips/examples/InputPropTestSync.py" "rips/examples/InputPropTestAsync.py" diff --git a/ApplicationCode/GrpcInterface/Python/rips/PdmObject.py b/ApplicationCode/GrpcInterface/Python/rips/PdmObject.py index 6de90478c3..1369a8dceb 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/PdmObject.py +++ b/ApplicationCode/GrpcInterface/Python/rips/PdmObject.py @@ -59,7 +59,7 @@ class PdmObject: elif isinstance(value, list): listofstrings = [] for val in value: - listofstrings.append(self.__fromValue(val)) + listofstrings.append(self.__fromValue('\"' + val + '\"')) return "[" + ", ".join(listofstrings) + "]" else: return str(value) diff --git a/ApplicationCode/GrpcInterface/Python/rips/View.py b/ApplicationCode/GrpcInterface/Python/rips/View.py index b47496545c..d895e1bf34 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/View.py +++ b/ApplicationCode/GrpcInterface/Python/rips/View.py @@ -30,4 +30,48 @@ class View (PdmObject): def cellResult(self): """Retrieve the current cell results""" - return self.children("GridCellResult")[0] \ No newline at end of file + return self.children("GridCellResult")[0] + + def applyCellResult(self, resultType, resultVariable): + """Apply a regular cell result + Arguments: + resultType [str]: String representing the result category + The valid values are: "DYNAMIC_NATIVE", "STATIC_NATIVE", "SOURSIMRL", + "GENERATED", "INPUT_PROPERTY", "FORMATION_NAMES", + "FLOW_DIAGNOSTICS" and "INJECTION_FLOODING" + resultVariable [str]: String representing the result value. + """ + cellResult = self.cellResult() + cellResult.setValue("ResultType", resultType) + cellResult.setValue("ResultVariable", resultVariable) + cellResult.update() + + def applyFlowDiagnosticsCellResult(self, + resultVariable = 'TOF', + selectionMode = 'FLOW_TR_BY_SELECTION', + injectors = [], + producers = []): + """Apply a flow diagnostics cell result + + Arguments: + resultVariable [str]: String representing the result value + The valid values are 'TOF', 'Fraction', 'MaxFractionTracer' and 'Communication'. + selectionMode [str]: String specifying which tracers to select. + The valid values are FLOW_TR_INJ_AND_PROD (all injector and producer tracers) + FLOW_TR_PRODUCERS (all producers) + FLOW_TR_INJECTORS (all injectors) + FLOW_TR_BY_SELECTION (specify individual tracers in the + injectorTracers and producerTracers variables) + injectorTracers [list]: List of injector names (strings) to select. + Requires selectionMode to be 'FLOW_TR_BY_SELECTION'. + producerTracers [list]: List of producer tracers (strings) to select. + Requires selectionMode to be 'FLOW_TR_BY_SELECTION'. + """ + cellResult = self.cellResult() + cellResult.setValue("ResultType", "FLOW_DIAGNOSTICS") + cellResult.setValue("ResultVariable", resultVariable) + cellResult.setValue("FlowTracerSelectionMode", selectionMode) + if selectionMode == 'FLOW_TR_BY_SELECTION': + cellResult.setValue("SelectedInjectorTracers", injectors) + cellResult.setValue("SelectedProducerTracers", producers) + cellResult.update() \ No newline at end of file diff --git a/ApplicationCode/GrpcInterface/Python/rips/examples/SetCellResult.py b/ApplicationCode/GrpcInterface/Python/rips/examples/SetCellResult.py index 2414744387..de0b3e31b1 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/examples/SetCellResult.py +++ b/ApplicationCode/GrpcInterface/Python/rips/examples/SetCellResult.py @@ -3,12 +3,4 @@ import rips resInsight = rips.Instance.find() view = resInsight.project.view(0) - -cellResult = view.cellResult() - -cellResult.printObjectInfo() - -cellResult.setValue("ResultType", "FLOW_DIAGNOSTICS") -cellResult.setValue("ResultVariable", "TOF") - -cellResult.update() \ No newline at end of file +view.applyCellResult(resultType='STATIC_NATIVE', resultVariable='DX') diff --git a/ApplicationCode/GrpcInterface/Python/rips/examples/SetFlowDiagnosticsResult.py b/ApplicationCode/GrpcInterface/Python/rips/examples/SetFlowDiagnosticsResult.py new file mode 100644 index 0000000000..3e13e32dca --- /dev/null +++ b/ApplicationCode/GrpcInterface/Python/rips/examples/SetFlowDiagnosticsResult.py @@ -0,0 +1,14 @@ +# Load ResInsight Processing Server Client Library +import rips +# Connect to ResInsight instance +resInsight = rips.Instance.find() + +view = resInsight.project.view(0) +view.applyFlowDiagnosticsCellResult(resultVariable='Fraction', + selectionMode='FLOW_TR_INJ_AND_PROD') + +# Example of setting individual wells. Commented out because well names are case specific. +#view.applyFlowDiagnosticsCellResult(resultVariable='Fraction', +# selectionMode='FLOW_TR_BY_SELECTION', +# injectors = ['C-1H', 'C-2H', 'F-2H'], +# producers = ['B-1AH', 'B-3H', 'D-1H']) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index 7d34398e1a..76a2a903ba 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -1210,8 +1210,12 @@ void RimEclipseResultDefinition::setSelectedSouringTracers(const std::vector