From e54d42a0da0b65ca58e1c2a55a83f845c52ba133 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 30 Jul 2019 11:27:25 +0200 Subject: [PATCH] #4527 Export Flow Characteristics : Add support for Python execution --- .../GrpcInterface/GrpcProtos/Commands.proto | 12 ++++++++++++ .../GrpcInterface/Python/rips/Commands.py | 14 ++++++++++++++ .../Python/rips/tests/test_commands.py | 10 +++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto b/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto index e3794b8e18..b2c9d790c2 100644 --- a/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto +++ b/ApplicationCode/GrpcInterface/GrpcProtos/Commands.proto @@ -238,6 +238,17 @@ message CreateGridCaseGroupRequest repeated string casePaths = 1; } +message ExportFlowInfoRequest +{ + int32 caseId = 1; + repeated int32 timeSteps = 2; + repeated string injectors = 3; + repeated string producers = 4; + string fileName = 5; + double minimumCommunication = 6; + double aquiferCellThreshold = 7; +} + /* CommandParams handles both command name and parameters in one. * The message type and content is used as parameters and * the name of the variable is used to find the command name. */ @@ -276,6 +287,7 @@ message CommandParams CreateSatPressPlotRequest createSaturationPressurePlots = 25; ReplaceCaseRequests replaceMultipleCases = 26; CreateGridCaseGroupRequest createGridCaseGroup = 27; + ExportFlowInfoRequest exportFlowCharacteristics = 28; } } diff --git a/ApplicationCode/GrpcInterface/Python/rips/Commands.py b/ApplicationCode/GrpcInterface/Python/rips/Commands.py index aebab38b64..7a6c4f90c7 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/Commands.py +++ b/ApplicationCode/GrpcInterface/Python/rips/Commands.py @@ -267,3 +267,17 @@ class Commands: caseIds = [caseIds] return self.__execute(createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest(caseIds=caseIds)) + def exportFlowCharacteristics(self, caseId, timeSteps, injectors, producers, fileName, minimumCommunication=0.0, aquiferCellThreshold=0.1): + if isinstance(timeSteps, int): + timeSteps = [timeSteps] + if isinstance(injectors, str): + injectors = [injectors] + if isinstance(producers, str): + producers = [producers] + return self.__execute(exportFlowCharacteristics=Cmd.ExportFlowInfoRequest(caseId=caseId, + timeSteps=timeSteps, + injectors=injectors, + producers=producers, + fileName=fileName, + minimumCommunication = minimumCommunication, + aquiferCellThreshold = aquiferCellThreshold)) diff --git a/ApplicationCode/GrpcInterface/Python/rips/tests/test_commands.py b/ApplicationCode/GrpcInterface/Python/rips/tests/test_commands.py index 4ee0611871..c5f88482fe 100644 --- a/ApplicationCode/GrpcInterface/Python/rips/tests/test_commands.py +++ b/ApplicationCode/GrpcInterface/Python/rips/tests/test_commands.py @@ -41,4 +41,12 @@ def test_loadGridCaseGroup(rips_instance, initializeTest): casePaths.append(dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID") casePaths.append(dataroot.PATH + "/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID") groupId, groupName = rips_instance.commands.createGridCaseGroup(casePaths=casePaths) - print(groupId, groupName) \ No newline at end of file + print(groupId, groupName) + +def test_exportFlowCharacteristics(rips_instance, initializeTest): + casePath = dataroot.PATH + "/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID" + rips_instance.project.loadCase(casePath) + with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname: + print("Temporary folder: ", tmpdirname) + fileName = tmpdirname + "/exportFlowChar.txt" + rips_instance.commands.exportFlowCharacteristics(caseId=0, timeSteps=8, producers=[], injectors = "I01", fileName = fileName) \ No newline at end of file