#4465 Implement all remaining command file commands and add tests for some commands

This commit is contained in:
Gaute Lindkvist 2019-06-05 11:26:19 +02:00
parent 5b39860a41
commit a0d81a08e8
5 changed files with 120 additions and 3 deletions

View File

@ -169,6 +169,9 @@ if (PYTHON_EXECUTABLE AND EXISTS ${PYTHON_EXECUTABLE})
"examples/SoilAverage.py"
"examples/SoilAverageNoComm.py"
"tests/test_cases.py"
"tests/test_commands.py"
"tests/test_grids.py"
"tests/test_properties.py"
"tests/conftest.py"
"tests/dataroot.py"
"requirements.txt"

View File

@ -83,7 +83,7 @@ enum CompdatExportType
enum CompdatCombinationMode
{
INDIVIDUALLY = 0;
COMBINED = 1;
caCOMBINED = 1;
}
message ExportWellPathCompRequest

View File

@ -14,6 +14,13 @@ resInsight.commands.setMainWindowSize(width=800, height=500)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
print("Temporary folder: ", tmpdirname)
resInsight.commands.setExportFolder(type='SNAPSHOTS', path=tmpdirname)
resInsight.commands.setExportFolder(type='PROPERTIES', path=tmpdirname)
resInsight.commands.exportSnapshots()
print(os.listdir(tmpdirname))
assert(len(os.listdir(tmpdirname)) > 0)
assert(len(os.listdir(tmpdirname)) > 0)
case = resInsight.project.case(id=0)
resInsight.commands.exportPropertyInViews(0, "3D View", 0)
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T3" + "-SOIL"
fullPath = tmpdirname + "/" + expectedFileName
assert(os.path.exists(fullPath))

View File

@ -73,6 +73,35 @@ class Commands:
viewNames=viewNames,
undefinedValue=undefinedValue))
def exportWellPathCompletions(self, caseId, timeStep, wellPathNames, fileSplit,
compdatExport, includePerforations, includeFishbones,
excludeMainBoreForFishbones, combinationMode):
if (isinstance(wellPathNames, str)):
wellPathNames = [wellPathNames]
return self.execute(exportWellPathCompletions=Cmd.ExportWellPathCompRequest(caseId=caseId,
timeStep=timeStep,
wellPathNames=wellPathNames,
fileSplit=fileSplit,
compdatExport=compdatExport,
includePerforations=includePerforations,
includeFishbones=includeFishbones,
excludeMainBoreForFishbones=excludeMainBoreForFishbones,
combinationMode=combinationMode))
def exportSimWellFractureCompletions(self, caseId, viewName, timeStep, simulationWellNames, fileSplit, compdatExport):
if(isinstance(simulationWellNames, str)):
simulationWellNames = [simulationWellNames]
return self.execute(exportSimWellFractureCompletions=Cmd.ExportSimWellPathFraqRequest(caseId=caseId,
viewName=viewName,
timeStep=timeStep,
simulationWellNames=simulationWellNames,
fileSplit=fileSplit,
compdatExport=compdatExport))
def exportMsw(self, caseId, wellPath):
return self.execute(exportMsw=Cmd.ExportMswRequest(caseId=caseId,
wellPath=wellPath))
def exportWellPaths(self, wellPaths=[], mdStepSize=5.0):
if isinstance(wellPaths, str):
wellPaths = [wellpaths]
@ -100,7 +129,53 @@ class Commands:
def setMainWindowSize(self, width, height):
return self.execute(setMainWindowSize=Cmd.SetMainWindowSizeParams(width=width, height=height))
def computeCaseGroupStatistics(self, caseIds):
if isinstance(caseIds, int):
caseIds = [caseIds]
return self.execute(computeCaseGroupStatistics=Cmd.ComputeCaseGroupStatRequest(caseIds=caseIds))
def setTimeStep(self, caseId, timeStep):
return self.execute(setTimeStep=Cmd.SetTimeStepParams(caseId=caseId, timeStep=timeStep))
def scaleFractureTemplate(self, id, halfLength, height, dFactor, conductivity):
return self.execute(scaleFractureTemplate=Cmd.ScaleFractureTemplateRequest(id=id,
halfLength=halfLength,
height=height,
dFactor=dFactor,
conductivity=conductivity))
def setFractureContainment(self, id, topLayer, baseLayer):
return self.execute(setFractureContainment=Cmd.SetFracContainmentRequest(id=id,
topLayer=topLayer,
baseLayer=baseLayer))
def createMultipleFractures(self, caseId, templateId, wellPathNames, minDistFromWellTd,
maxFracturesPerWell, topLayer, baseLayer, spacing, action):
if isinstance(wellPathNames, str):
wellPathNames = [wellPathNames]
return self.execute(createMultipleFractures=Cmd.MultipleFracAction(caseId=caseId,
templateId=templateId,
wellPathNames=wellPathNames,
minDistFromWellTd=minDistFromWellTd,
maxFracturesPerWell=maxFracturesPerWell,
topLayer=topLayer,
baseLayer=baseLayer,
spacing=spacing,
action=action))
def createLgrForCompletions(self, caseId, timeStep, wellPathNames, refinementI, refinementJ, refinementK, splitType):
if isinstance(wellPathNames, str):
wellPathNames = [wellPathNames]
return self.execute(createLgrForCompletions=Cmd.CreateLgrForCompRequest(caseId=caseId,
timeStep=timeStep,
wellPathNames=wellPathNames,
refinementI=refinementI,
refinementJ=refinementJ,
refinementK=refinementK,
splitType=splitType))
def createSaturationPressurePlots(self, caseIds):
if isinstance(caseIds, int):
caseIds = [caseIds]
return self.execute(createSaturationPressurePlots=Cmd.CreateSatPressPlotRequest(caseIds=caseIds))

View File

@ -0,0 +1,32 @@
import sys
import os
import tempfile
sys.path.insert(1, os.path.join(sys.path[0], '..'))
import rips
import dataroot
def test_exportSnapshots(rips_instance, initializeTest):
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
rips_instance.project.loadCase(casePath)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
print("Temporary folder: ", tmpdirname)
rips_instance.commands.setExportFolder(type='SNAPSHOTS', path=tmpdirname)
rips_instance.commands.exportSnapshots()
print(os.listdir(tmpdirname))
assert(len(os.listdir(tmpdirname)) > 0)
for fileName in os.listdir(tmpdirname):
assert(os.path.splitext(fileName)[1] == '.png')
def test_exportPropertyInView(rips_instance, initializeTest):
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
rips_instance.project.loadCase(casePath)
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
print("Temporary folder: ", tmpdirname)
rips_instance.commands.setExportFolder(type='PROPERTIES', path=tmpdirname)
case = rips_instance.project.case(id=0)
rips_instance.commands.exportPropertyInViews(0, "3D View", 0)
expectedFileName = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
fullPath = tmpdirname + "/" + expectedFileName
assert(os.path.exists(fullPath))