2020-02-21 03:24:58 -06:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
import grpc
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
import rips.generated.NNCProperties_pb2 as NNCProperties_pb2
|
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
sys.path.insert(1, os.path.join(sys.path[0], "../../"))
|
2020-02-21 03:24:58 -06:00
|
|
|
import rips
|
|
|
|
|
|
|
|
import dataroot
|
|
|
|
|
|
|
|
|
|
|
|
def test_10kSync(rips_instance, initialize_test):
|
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
|
|
|
|
|
|
|
properties = case.available_nnc_properties()
|
2021-01-26 13:48:01 -06:00
|
|
|
assert len(properties) == 1
|
2020-02-21 03:24:58 -06:00
|
|
|
|
2021-01-26 13:48:01 -06:00
|
|
|
assert "TRAN" == properties[0].name
|
|
|
|
assert (
|
|
|
|
NNCProperties_pb2.NNCPropertyType.Value("NNC_STATIC")
|
|
|
|
== properties[0].property_type
|
|
|
|
)
|
2020-02-21 03:24:58 -06:00
|
|
|
|
|
|
|
nnc_connections = case.nnc_connections()
|
2021-01-26 13:48:01 -06:00
|
|
|
assert len(nnc_connections) == 3627
|
2020-02-21 03:24:58 -06:00
|
|
|
|
|
|
|
connection = nnc_connections[0]
|
2021-01-26 13:48:01 -06:00
|
|
|
assert connection.cell1.i == 33
|
|
|
|
assert connection.cell1.j == 40
|
|
|
|
assert connection.cell1.k == 14
|
|
|
|
assert connection.cell_grid_index1 == 0
|
2020-02-21 13:40:26 -06:00
|
|
|
|
|
|
|
tran_vals = case.nnc_connections_static_values("TRAN")
|
2021-01-26 13:48:01 -06:00
|
|
|
assert len(tran_vals) == len(nnc_connections)
|
2020-02-21 13:40:26 -06:00
|
|
|
|
|
|
|
for t in tran_vals:
|
2021-01-26 13:48:01 -06:00
|
|
|
assert isinstance(t, float)
|
2020-02-21 13:40:26 -06:00
|
|
|
|
2020-02-25 17:21:19 -06:00
|
|
|
# Generate some data
|
|
|
|
new_data = []
|
|
|
|
for (c, _) in enumerate(nnc_connections):
|
|
|
|
new_data.append(float(c))
|
|
|
|
|
|
|
|
property_name = "NEW_PROP"
|
|
|
|
case.set_nnc_connections_values(new_data, property_name, 0)
|
|
|
|
new_prop_vals = case.nnc_connections_generated_values(property_name, 0)
|
2021-01-26 13:48:01 -06:00
|
|
|
assert len(new_prop_vals) == len(new_data)
|
2020-02-25 17:21:19 -06:00
|
|
|
for i in range(0, len(new_data)):
|
2021-01-26 13:48:01 -06:00
|
|
|
assert new_data[i] == new_prop_vals[i]
|
2020-02-25 17:21:19 -06:00
|
|
|
|
|
|
|
# Set some other data for second time step
|
|
|
|
for i in range(0, len(new_data)):
|
|
|
|
new_data[i] = new_data[i] * 2.0
|
|
|
|
|
|
|
|
case.set_nnc_connections_values(new_data, property_name, 1)
|
|
|
|
new_prop_vals = case.nnc_connections_generated_values(property_name, 1)
|
2021-01-26 13:48:01 -06:00
|
|
|
assert len(new_prop_vals) == len(nnc_connections)
|
2020-02-25 17:21:19 -06:00
|
|
|
for i in range(0, len(new_data)):
|
2021-01-26 13:48:01 -06:00
|
|
|
assert new_data[i] == new_prop_vals[i]
|
2020-02-25 17:21:19 -06:00
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 13:40:26 -06:00
|
|
|
def test_non_existing_dynamic_values(rips_instance, initialize_test):
|
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
|
|
|
|
|
|
|
with pytest.raises(grpc.RpcError):
|
|
|
|
case.nnc_connections_dynamic_values("x", 0)
|
|
|
|
|
2020-04-16 09:06:18 -05:00
|
|
|
|
2020-02-21 13:40:26 -06:00
|
|
|
def test_invalid_time_steps(rips_instance, initialize_test):
|
|
|
|
casePath = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
|
|
|
case = rips_instance.project.load_case(path=casePath)
|
|
|
|
with pytest.raises(grpc.RpcError):
|
2020-05-12 05:48:50 -05:00
|
|
|
case.nnc_connections_generated_values("Formation Allan", 9999)
|