#4547 Add simplified synchronous methods for activeCellProperty and gridProperty

This commit is contained in:
Gaute Lindkvist
2019-08-07 23:33:08 +02:00
parent 136251c4b1
commit 0a30e6c340
10 changed files with 99 additions and 72 deletions

View File

@@ -7,11 +7,11 @@ import rips
import dataroot
def test_10k(rips_instance, initializeTest):
def test_10kAsync(rips_instance, initializeTest):
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.loadCase(path=casePath)
resultChunks = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
resultChunks = case.properties.activeCellPropertyAsync('DYNAMIC_NATIVE', 'SOIL', 1)
mysum = 0.0
count = 0
for chunk in resultChunks:
@@ -22,6 +22,16 @@ def test_10k(rips_instance, initializeTest):
assert(average != pytest.approx(0.0158893, abs=0.0000001))
assert(average == pytest.approx(0.0558893, abs=0.0000001))
def test_10kSync(rips_instance, initializeTest):
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.loadCase(path=casePath)
results = case.properties.activeCellProperty('DYNAMIC_NATIVE', 'SOIL', 1)
mysum = sum(results)
average = mysum / len(results)
assert(mysum == pytest.approx(621.768, abs=0.001))
assert(average != pytest.approx(0.0158893, abs=0.0000001))
assert(average == pytest.approx(0.0558893, abs=0.0000001))
def createResult(poroChunks, permxChunks):
for (poroChunk, permxChunk) in zip(poroChunks, permxChunks):
@@ -30,9 +40,8 @@ def createResult(poroChunks, permxChunks):
resultChunk.append(poro * permx)
yield resultChunk
def checkResults(poroChunks, permxChunks, poroPermXChunks):
for (poroChunk, permxChunk, poroPermXChunk) in zip(poroChunks, permxChunks, poroPermXChunks):
for (poro, permx, poropermx) in zip(poroChunk.values, permxChunk.values, poroPermXChunk.values):
def checkResults(poroValues, permxValues, poropermxValues):
for (poro, permx, poropermx) in zip(poroValues, permxValues, poropermxValues):
recalc = poro * permx
assert(recalc == pytest.approx(poropermx, rel=1.0e-10))
@@ -40,16 +49,16 @@ def test_10k_PoroPermX(rips_instance, initializeTest):
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
case = rips_instance.project.loadCase(path=casePath)
poroChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
permxChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PERMX', 0)
poroChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PORO', 0)
permxChunks = case.properties.activeCellPropertyAsync('STATIC_NATIVE', 'PERMX', 0)
case.properties.setActiveCellPropertyAsync(createResult(poroChunks, permxChunks), 'GENERATED', 'POROPERMXAS', 0)
poroChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
permxChunks = case.properties.activeCellProperty('STATIC_NATIVE', 'PERMX', 0)
poroPermXChunks = case.properties.activeCellProperty('GENERATED', 'POROPERMXAS', 0)
poro = case.properties.activeCellProperty('STATIC_NATIVE', 'PORO', 0)
permx = case.properties.activeCellProperty('STATIC_NATIVE', 'PERMX', 0)
poroPermX = case.properties.activeCellProperty('GENERATED', 'POROPERMXAS', 0)
checkResults(poroChunks, permxChunks, poroPermXChunks)
checkResults(poro, permx, poroPermX)