2019-08-19 13:46:14 +02:00
|
|
|
########################################################################################
|
|
|
|
|
# This example generates a derived property in an asynchronous manner
|
|
|
|
|
# Meaning it does not wait for all the data for each stage to be read before proceeding
|
|
|
|
|
########################################################################################
|
2019-06-03 21:11:27 +02:00
|
|
|
import rips
|
2019-06-04 10:34:31 +02:00
|
|
|
import time
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Internal function for creating a result from a small chunk of poro and permx results
|
|
|
|
|
# The return value of the function is a generator for the results rather than the result itself.
|
2019-09-19 15:14:01 +02:00
|
|
|
def create_result(poro_chunks, permx_chunks):
|
2019-08-19 13:46:14 +02:00
|
|
|
# Loop through all the chunks of poro and permx in order
|
2019-09-19 15:14:01 +02:00
|
|
|
for (poroChunk, permxChunk) in zip(poro_chunks, permx_chunks):
|
2019-05-30 18:52:38 +02:00
|
|
|
resultChunk = []
|
2019-08-19 13:46:14 +02:00
|
|
|
# Loop through all the values inside the chunks, in order
|
2019-05-30 18:52:38 +02:00
|
|
|
for (poro, permx) in zip(poroChunk.values, permxChunk.values):
|
|
|
|
|
resultChunk.append(poro * permx)
|
2019-08-19 13:46:14 +02:00
|
|
|
# Return a generator object that behaves like a Python iterator
|
2019-05-30 18:52:38 +02:00
|
|
|
yield resultChunk
|
|
|
|
|
|
2021-01-26 20:48:01 +01:00
|
|
|
|
|
|
|
|
resinsight = rips.Instance.find()
|
2019-06-04 10:34:31 +02:00
|
|
|
start = time.time()
|
2019-11-21 08:13:15 +01:00
|
|
|
case = resinsight.project.cases()[0]
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Get a generator for the poro results. The generator will provide a chunk each time it is iterated
|
2021-01-26 20:48:01 +01:00
|
|
|
poro_chunks = case.active_cell_property_async("STATIC_NATIVE", "PORO", 0)
|
2019-08-19 13:46:14 +02:00
|
|
|
# Get a generator for the permx results. The generator will provide a chunk each time it is iterated
|
2021-01-26 20:48:01 +01:00
|
|
|
permx_chunks = case.active_cell_property_async("STATIC_NATIVE", "PERMX", 0)
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-08-19 13:46:14 +02:00
|
|
|
# Send back the result with the result provided by a generator object.
|
|
|
|
|
# Iterating the result generator will cause the script to read from the poro and permx generators
|
|
|
|
|
# And return the result of each iteration
|
2021-01-26 20:48:01 +01:00
|
|
|
case.set_active_cell_property_async(
|
|
|
|
|
create_result(poro_chunks, permx_chunks), "GENERATED", "POROPERMXAS", 0
|
|
|
|
|
)
|
2019-05-30 18:52:38 +02:00
|
|
|
|
2019-06-04 10:34:31 +02:00
|
|
|
end = time.time()
|
|
|
|
|
print("Time elapsed: ", end - start)
|
2019-08-19 13:46:14 +02:00
|
|
|
print("Transferred all results back")
|
2021-01-26 20:48:01 +01:00
|
|
|
view = case.views()[0].apply_cell_result("GENERATED", "POROPERMXAS")
|