2019-06-03 07:33:16 -05:00
|
|
|
import grpc
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
from .Grid import Grid
|
|
|
|
from .Properties import Properties
|
|
|
|
|
2019-06-06 07:41:40 -05:00
|
|
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../generated'))
|
2019-06-03 07:33:16 -05:00
|
|
|
|
|
|
|
import Case_pb2
|
|
|
|
import Case_pb2_grpc
|
|
|
|
|
|
|
|
class Case:
|
|
|
|
def __init__(self, channel, id):
|
|
|
|
self.channel = channel
|
|
|
|
self.stub = Case_pb2_grpc.CaseStub(channel)
|
|
|
|
self.id = id
|
|
|
|
info = self.stub.GetCaseInfo(Case_pb2.CaseRequest(id=self.id))
|
|
|
|
self.name = info.name
|
|
|
|
self.groupId = info.group_id
|
|
|
|
self.type = info.type
|
|
|
|
self.properties = Properties(self)
|
|
|
|
self.request = Case_pb2.CaseRequest(id=self.id)
|
2019-06-04 05:59:06 -05:00
|
|
|
|
2019-06-06 02:13:23 -05:00
|
|
|
# Get number of grids in the case
|
2019-06-03 07:33:16 -05:00
|
|
|
def gridCount(self):
|
|
|
|
try:
|
|
|
|
return self.stub.GetGridCount(self.request).count
|
|
|
|
except grpc.RpcError as e:
|
|
|
|
if e.code() == grpc.StatusCode.NOT_FOUND:
|
|
|
|
return 0
|
|
|
|
print("ERROR: ", e)
|
|
|
|
return 0
|
|
|
|
|
2019-06-06 02:13:23 -05:00
|
|
|
# Get Grid of a given index. Returns a rips Grid object
|
2019-06-03 07:33:16 -05:00
|
|
|
def grid(self, index):
|
|
|
|
return Grid(index, self)
|
|
|
|
|
2019-06-06 02:13:23 -05:00
|
|
|
# Get a list of all rips Grid objects in the case
|
2019-06-03 07:33:16 -05:00
|
|
|
def grids(self):
|
|
|
|
gridList = []
|
|
|
|
for i in range(0, self.gridCount()):
|
|
|
|
gridList.append(Grid(i, self))
|
|
|
|
return gridList
|
|
|
|
|
|
|
|
def cellCount(self, porosityModel='MATRIX_MODEL'):
|
|
|
|
porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel)
|
2019-06-03 14:11:27 -05:00
|
|
|
request = Case_pb2.CellInfoRequest(case_request=self.request,
|
2019-06-03 07:33:16 -05:00
|
|
|
porosity_model=porosityModel)
|
|
|
|
return self.stub.GetCellCount(request)
|
|
|
|
|
|
|
|
def cellInfoForActiveCells(self, porosityModel='MATRIX_MODEL'):
|
|
|
|
porosityModelEnum = Case_pb2.PorosityModelType.Value(porosityModel)
|
2019-06-03 14:11:27 -05:00
|
|
|
request = Case_pb2.CellInfoRequest(case_request=self.request,
|
2019-06-03 07:33:16 -05:00
|
|
|
porosity_model=porosityModel)
|
|
|
|
return self.stub.GetCellInfoForActiveCells(request)
|
|
|
|
|
|
|
|
def timeSteps(self):
|
2019-06-06 02:13:23 -05:00
|
|
|
return self.stub.GetTimeSteps(self.request).dates
|
|
|
|
|
|
|
|
def daysSinceStart(self):
|
|
|
|
return self.stub.GetDaysSinceStart(self.request).day_decimals
|
2019-06-03 07:33:16 -05:00
|
|
|
|