2019-06-04 13:35:30 -05:00
|
|
|
import sys
|
|
|
|
import os
|
2019-08-14 02:43:44 -05:00
|
|
|
import grpc
|
2019-06-04 13:35:30 -05:00
|
|
|
import pytest
|
2019-09-23 04:50:33 -05:00
|
|
|
import tempfile
|
2019-06-04 13:35:30 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
2019-06-04 13:35:30 -05:00
|
|
|
import rips
|
|
|
|
|
|
|
|
import dataroot
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10kAsync(rips_instance, initialize_test):
|
2019-06-04 13:35:30 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-06-04 13:35:30 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
resultChunks = case.active_cell_property_async("DYNAMIC_NATIVE", "SOIL", 1)
|
2019-06-04 13:35:30 -05:00
|
|
|
mysum = 0.0
|
|
|
|
count = 0
|
|
|
|
for chunk in resultChunks:
|
|
|
|
mysum += sum(chunk.values)
|
|
|
|
count += len(chunk.values)
|
|
|
|
average = mysum / count
|
2021-01-26 13:48:01 -06:00
|
|
|
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)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10kSync(rips_instance, initialize_test):
|
2019-08-07 16:33:08 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-08-07 16:33:08 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", 1)
|
2019-08-07 16:33:08 -05:00
|
|
|
mysum = sum(results)
|
|
|
|
average = mysum / len(results)
|
2021-01-26 13:48:01 -06:00
|
|
|
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)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10k_set(rips_instance, initialize_test):
|
2019-08-14 02:43:44 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", 1)
|
|
|
|
case.set_active_cell_property(results, "GENERATED", "SOIL", 1)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10k_set_out_of_bounds(rips_instance, initialize_test):
|
2019-08-14 02:43:44 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", 1)
|
2019-08-14 02:43:44 -05:00
|
|
|
results.append(5.0)
|
|
|
|
with pytest.raises(grpc.RpcError):
|
2021-01-26 13:48:01 -06:00
|
|
|
assert case.set_active_cell_property(results, "GENERATED", "SOIL", 1)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10k_set_out_of_bounds_client(rips_instance, initialize_test):
|
2019-08-14 02:43:44 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
results = case.active_cell_property("DYNAMIC_NATIVE", "SOIL", 1)
|
2019-09-23 04:50:33 -05:00
|
|
|
case.chunk_size = len(results)
|
2019-08-14 02:43:44 -05:00
|
|
|
results.append(5.0)
|
|
|
|
with pytest.raises(IndexError):
|
2021-01-26 13:48:01 -06:00
|
|
|
assert case.set_active_cell_property(results, "GENERATED", "SOIL", 1)
|
2019-08-14 02:43:44 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-06-06 06:29:47 -05:00
|
|
|
def createResult(poroChunks, permxChunks):
|
2023-02-01 01:46:46 -06:00
|
|
|
for poroChunk, permxChunk in zip(poroChunks, permxChunks):
|
2019-06-06 06:29:47 -05:00
|
|
|
resultChunk = []
|
2023-02-01 01:46:46 -06:00
|
|
|
for poro, permx in zip(poroChunk.values, permxChunk.values):
|
2019-06-06 06:29:47 -05:00
|
|
|
resultChunk.append(poro * permx)
|
|
|
|
yield resultChunk
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-08-07 16:33:08 -05:00
|
|
|
def checkResults(poroValues, permxValues, poropermxValues):
|
2023-02-01 01:46:46 -06:00
|
|
|
for poro, permx, poropermx in zip(poroValues, permxValues, poropermxValues):
|
2020-04-16 09:06:18 -05:00
|
|
|
recalc = poro * permx
|
2021-01-26 13:48:01 -06:00
|
|
|
assert recalc == pytest.approx(poropermx, rel=1.0e-10)
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2019-09-19 06:25:04 -05:00
|
|
|
def test_10k_PoroPermX(rips_instance, initialize_test):
|
2019-06-06 06:29:47 -05:00
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2019-09-19 06:25:04 -05:00
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
poroChunks = case.active_cell_property_async("STATIC_NATIVE", "PORO", 0)
|
|
|
|
permxChunks = case.active_cell_property_async("STATIC_NATIVE", "PERMX", 0)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
case.set_active_cell_property_async(
|
|
|
|
createResult(poroChunks, permxChunks), "GENERATED", "POROPERMXAS", 0
|
|
|
|
)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
poro = case.active_cell_property("STATIC_NATIVE", "PORO", 0)
|
|
|
|
permx = case.active_cell_property("STATIC_NATIVE", "PERMX", 0)
|
|
|
|
poroPermX = case.active_cell_property("GENERATED", "POROPERMXAS", 0)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2019-08-07 16:33:08 -05:00
|
|
|
checkResults(poro, permx, poroPermX)
|
2019-06-06 06:29:47 -05:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2019-09-23 04:50:33 -05:00
|
|
|
def test_exportPropertyInView(rips_instance, initialize_test):
|
|
|
|
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
2021-09-01 01:25:22 -05:00
|
|
|
case = rips_instance.project.load_case(case_path)
|
|
|
|
case.create_view()
|
2019-09-23 04:50:33 -05:00
|
|
|
with tempfile.TemporaryDirectory(prefix="rips") as tmpdirname:
|
|
|
|
print("Temporary folder: ", tmpdirname)
|
2021-01-26 13:48:01 -06:00
|
|
|
rips_instance.set_export_folder(export_type="PROPERTIES", path=tmpdirname)
|
2019-11-21 01:13:15 -06:00
|
|
|
case = rips_instance.project.cases()[0]
|
|
|
|
view = case.views()[0]
|
2019-09-23 04:50:33 -05:00
|
|
|
view.export_property()
|
|
|
|
expected_file_name = case.name + "-" + str("3D_View") + "-" + "T0" + "-SOIL"
|
|
|
|
full_path = tmpdirname + "/" + expected_file_name
|
2021-01-26 13:48:01 -06:00
|
|
|
assert os.path.exists(full_path)
|