#4463 Working creation of grid case groups

This commit is contained in:
Gaute Lindkvist
2019-07-18 10:53:59 +02:00
parent 7a2b9926a0
commit 6b7a9b8da5
14 changed files with 228 additions and 21 deletions

View File

@@ -71,7 +71,8 @@ class Commands:
"""
commandReply = self.__execute(loadCase=Cmd.FilePathRequest(path=path))
assert commandReply.HasField("loadCaseResult")
assert(commandReply is not None)
assert(commandReply.HasField("loadCaseResult"))
return Case(self.channel, commandReply.loadCaseResult.id)
def replaceCase(self, newGridFile, caseId=0):
@@ -83,7 +84,7 @@ class Commands:
"""
return self.__execute(replaceCase=Cmd.ReplaceCaseRequest(newGridFile=newGridFile,
caseId=caseId))
caseId=caseId))
def replaceSourceCases(self, gridListFile, caseGroupId=0):
"""Replace all source cases within a case group
@@ -94,7 +95,22 @@ class Commands:
"""
return self.__execute(replaceSourceCases=Cmd.ReplaceSourceCasesRequest(gridListFile=gridListFile,
caseGroupId=caseGroupId))
caseGroupId=caseGroupId))
def createGridCaseGroup(self, casePaths):
"""Create a Grid Case Group from a list of cases
Arguments:
casePaths (list): list of file path strings
Returns:
A case group id and name
"""
commandReply = self.__execute(createGridCaseGroup=Cmd.CreateGridCaseGroupRequest(casePaths=casePaths))
assert(commandReply is not None)
assert(commandReply.HasField("createGridCaseGroupResult"))
return (commandReply.createGridCaseGroupResult.groupId, commandReply.createGridCaseGroupResult.groupName)
##################
# Export Commands
##################

View File

@@ -0,0 +1,14 @@
import sys
import os
sys.path.insert(1, os.path.join(sys.path[0], '../../'))
import rips
resInsight = rips.Instance.find()
casePaths = []
casePaths.append("../../../../TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID")
casePaths.append("../../../../TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID")
groupId, groupName = resInsight.commands.createGridCaseGroup(casePaths=casePaths)
print("Group id = " + str(groupId))
print("Group name = " + groupName)

View File

@@ -88,4 +88,4 @@ def test_replaceCase(rips_instance, initializeTest):
assert(len(cases) is 1)
case = project.case(id=0)
assert(case.name == "Real0--BRUGGE_0000.EGRID")
assert(case.id == 0)
assert(case.id == 0)

View File

@@ -33,4 +33,12 @@ def test_exportPropertyInView(rips_instance, initializeTest):
rips_instance.commands.exportPropertyInViews(0, "3D View", 0)
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
fullPath = tmpdirname + "/" + expectedFileName
assert(os.path.exists(fullPath))
assert(os.path.exists(fullPath))
@pytest.mark.skipif(sys.platform.startswith('linux'), reason="Brugge is currently exceptionally slow on Linux")
def test_loadGridCaseGroup(rips_instance, initializeTest):
casePaths = []
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)