From 34d1ae6ec86ec75b5a852001dbfde5a12f5378b2 Mon Sep 17 00:00:00 2001 From: oparreno Date: Wed, 29 Jan 2025 13:26:24 +0100 Subject: [PATCH 1/4] add pin in custom and modify example --- .../05-file-IO/02-hdf5_serialize_and_read.py | 12 +++--- src/ansys/dpf/core/operators/result/custom.py | 41 +++++++++++++++++++ 2 files changed, 47 insertions(+), 6 deletions(-) diff --git a/examples/05-file-IO/02-hdf5_serialize_and_read.py b/examples/05-file-IO/02-hdf5_serialize_and_read.py index 0c4ab7daf91..e8c795a47d6 100644 --- a/examples/05-file-IO/02-hdf5_serialize_and_read.py +++ b/examples/05-file-IO/02-hdf5_serialize_and_read.py @@ -115,12 +115,12 @@ h5_stream_prov_op = dpf.operators.metadata.streams_provider() h5_stream_prov_op.inputs.data_sources.connect(h5_all_times_ds) res_deser_all_times_list = [] -h5_read_op = dpf.operators.serialization.hdf5dpf_custom_read() -h5_read_op.inputs.streams.connect(h5_stream_prov_op.outputs) +h5_read_op = dpf.operators.result.custom() +h5_read_op.inputs.streams_container.connect(h5_stream_prov_op.outputs) h5_read_op.inputs.time_scoping.connect(dpf.Scoping(ids=list(range(1, 54)), location="time")) for i, res_name in enumerate(result_names_on_all_time_steps): h5_read_op.inputs.result_name.connect(res_name) - res_deser = h5_read_op.outputs.field_or_fields_container_as_fields_container() + res_deser = h5_read_op.outputs.fields_container() res_deser_all_times_list.append(res_deser) ############################################################################### @@ -134,11 +134,11 @@ h5_stream_prov_op_2 = dpf.operators.metadata.streams_provider() h5_stream_prov_op_2.inputs.data_sources.connect(h5_set_per_set_ds) res_deser_set_per_set_list = [] -h5_read_op_2 = dpf.operators.serialization.hdf5dpf_custom_read() -h5_read_op_2.inputs.streams.connect(h5_stream_prov_op_2.outputs) +h5_read_op_2 = dpf.operators.result.custom() +h5_read_op_2.inputs.streams_container.connect(h5_stream_prov_op.outputs) for i, res_name in enumerate(result_names_time_per_time): h5_read_op_2.inputs.result_name.connect(res_name) - res_deser = h5_read_op_2.outputs.field_or_fields_container_as_fields_container() + res_deser = h5_read_op_2.outputs.fields_container() res_deser_set_per_set_list.append(res_deser) ############################################################################### diff --git a/src/ansys/dpf/core/operators/result/custom.py b/src/ansys/dpf/core/operators/result/custom.py index 6f3e4ceb8cb..7394357020c 100644 --- a/src/ansys/dpf/core/operators/result/custom.py +++ b/src/ansys/dpf/core/operators/result/custom.py @@ -66,6 +66,9 @@ class custom(Operator): is done, if 3 cyclic expansion is done and stages are merged (default is 1) + result_name : string + Name of the result that must be extracted from + the file Returns ------- @@ -95,6 +98,8 @@ class custom(Operator): >>> op.inputs.mesh.connect(my_mesh) >>> my_read_cyclic = int() >>> op.inputs.read_cyclic.connect(my_read_cyclic) + >>> my_result_name = str() + >>> op.inputs.result_name.connect(my_result_name) >>> # Instantiate operator and connect inputs in one line >>> op = dpf.operators.result.custom( @@ -106,6 +111,7 @@ class custom(Operator): ... bool_rotate_to_global=my_bool_rotate_to_global, ... mesh=my_mesh, ... read_cyclic=my_read_cyclic, + ... result_name=my_result_name, ... ) >>> # Get output data @@ -122,6 +128,7 @@ def __init__( bool_rotate_to_global=None, mesh=None, read_cyclic=None, + result_name=None, config=None, server=None, ): @@ -144,6 +151,9 @@ def __init__( self.inputs.mesh.connect(mesh) if read_cyclic is not None: self.inputs.read_cyclic.connect(read_cyclic) + if result_name is not None: + self.inputs.result_name.connect(result_name) + @staticmethod def _spec(): @@ -240,6 +250,13 @@ def _spec(): done and stages are merged (default is 1)""", ), + 60: PinSpecification( + name="result_name", + type_names=["string"], + optional=False, + document="""Name of the result that must be extracted from + the file""", + ), }, map_output_pin_spec={ 0: PinSpecification( @@ -313,6 +330,9 @@ class InputsCustom(_Inputs): >>> op.inputs.mesh.connect(my_mesh) >>> my_read_cyclic = int() >>> op.inputs.read_cyclic.connect(my_read_cyclic) + >>> my_result_name = str() + >>> op.inputs.result_name.connect(my_result_name) + """ def __init__(self, op: Operator): @@ -333,6 +353,8 @@ def __init__(self, op: Operator): self._inputs.append(self._mesh) self._read_cyclic = Input(custom._spec().input_pin(14), 14, op, -1) self._inputs.append(self._read_cyclic) + self._result_name = Input(custom._spec().input_pin(60), 60, op, -1) + self._inputs.append(self._result_name) @property def time_scoping(self): @@ -527,6 +549,25 @@ def read_cyclic(self): """ return self._read_cyclic + @property + def result_name(self): + """Allows to connect result_name input to the operator. + + Name of the result that must be extracted from the file + + Parameters + ---------- + result_name : string + + Examples + -------- + >>> from ansys.dpf import core as dpf + >>> op = dpf.operators.result.custom() + >>> op.inputs.result_name.connect(my_result_name) + >>> # or + >>> op.inputs.result_name(my_result_name) + """ + return self._read_cyclic class OutputsCustom(_Outputs): """Intermediate class used to get outputs from From 1a9a84ee006af70b2357bf79ed70f5a3c41ae396 Mon Sep 17 00:00:00 2001 From: oparreno Date: Wed, 29 Jan 2025 13:30:36 +0100 Subject: [PATCH 2/4] correction --- src/ansys/dpf/core/operators/result/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/core/operators/result/custom.py b/src/ansys/dpf/core/operators/result/custom.py index 7394357020c..a348d8db823 100644 --- a/src/ansys/dpf/core/operators/result/custom.py +++ b/src/ansys/dpf/core/operators/result/custom.py @@ -567,7 +567,7 @@ def result_name(self): >>> # or >>> op.inputs.result_name(my_result_name) """ - return self._read_cyclic + return self._result_name class OutputsCustom(_Outputs): """Intermediate class used to get outputs from From 3bc6afa2d1eb9c4c70bc96104ef47c2c9de3e53d Mon Sep 17 00:00:00 2001 From: oparreno Date: Wed, 29 Jan 2025 13:46:03 +0100 Subject: [PATCH 3/4] correction of example --- examples/05-file-IO/02-hdf5_serialize_and_read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/05-file-IO/02-hdf5_serialize_and_read.py b/examples/05-file-IO/02-hdf5_serialize_and_read.py index e8c795a47d6..59f1751f9cc 100644 --- a/examples/05-file-IO/02-hdf5_serialize_and_read.py +++ b/examples/05-file-IO/02-hdf5_serialize_and_read.py @@ -135,7 +135,7 @@ h5_stream_prov_op_2.inputs.data_sources.connect(h5_set_per_set_ds) res_deser_set_per_set_list = [] h5_read_op_2 = dpf.operators.result.custom() -h5_read_op_2.inputs.streams_container.connect(h5_stream_prov_op.outputs) +h5_read_op_2.inputs.streams_container.connect(h5_stream_prov_op_2.outputs) for i, res_name in enumerate(result_names_time_per_time): h5_read_op_2.inputs.result_name.connect(res_name) res_deser = h5_read_op_2.outputs.fields_container() From 6ad78af453e108f20ee7ba65b97a7e02899469d0 Mon Sep 17 00:00:00 2001 From: oparreno Date: Wed, 29 Jan 2025 15:10:39 +0100 Subject: [PATCH 4/4] rollback --- src/ansys/dpf/core/operators/result/custom.py | 41 ------------------- 1 file changed, 41 deletions(-) diff --git a/src/ansys/dpf/core/operators/result/custom.py b/src/ansys/dpf/core/operators/result/custom.py index a348d8db823..6f3e4ceb8cb 100644 --- a/src/ansys/dpf/core/operators/result/custom.py +++ b/src/ansys/dpf/core/operators/result/custom.py @@ -66,9 +66,6 @@ class custom(Operator): is done, if 3 cyclic expansion is done and stages are merged (default is 1) - result_name : string - Name of the result that must be extracted from - the file Returns ------- @@ -98,8 +95,6 @@ class custom(Operator): >>> op.inputs.mesh.connect(my_mesh) >>> my_read_cyclic = int() >>> op.inputs.read_cyclic.connect(my_read_cyclic) - >>> my_result_name = str() - >>> op.inputs.result_name.connect(my_result_name) >>> # Instantiate operator and connect inputs in one line >>> op = dpf.operators.result.custom( @@ -111,7 +106,6 @@ class custom(Operator): ... bool_rotate_to_global=my_bool_rotate_to_global, ... mesh=my_mesh, ... read_cyclic=my_read_cyclic, - ... result_name=my_result_name, ... ) >>> # Get output data @@ -128,7 +122,6 @@ def __init__( bool_rotate_to_global=None, mesh=None, read_cyclic=None, - result_name=None, config=None, server=None, ): @@ -151,9 +144,6 @@ def __init__( self.inputs.mesh.connect(mesh) if read_cyclic is not None: self.inputs.read_cyclic.connect(read_cyclic) - if result_name is not None: - self.inputs.result_name.connect(result_name) - @staticmethod def _spec(): @@ -250,13 +240,6 @@ def _spec(): done and stages are merged (default is 1)""", ), - 60: PinSpecification( - name="result_name", - type_names=["string"], - optional=False, - document="""Name of the result that must be extracted from - the file""", - ), }, map_output_pin_spec={ 0: PinSpecification( @@ -330,9 +313,6 @@ class InputsCustom(_Inputs): >>> op.inputs.mesh.connect(my_mesh) >>> my_read_cyclic = int() >>> op.inputs.read_cyclic.connect(my_read_cyclic) - >>> my_result_name = str() - >>> op.inputs.result_name.connect(my_result_name) - """ def __init__(self, op: Operator): @@ -353,8 +333,6 @@ def __init__(self, op: Operator): self._inputs.append(self._mesh) self._read_cyclic = Input(custom._spec().input_pin(14), 14, op, -1) self._inputs.append(self._read_cyclic) - self._result_name = Input(custom._spec().input_pin(60), 60, op, -1) - self._inputs.append(self._result_name) @property def time_scoping(self): @@ -549,25 +527,6 @@ def read_cyclic(self): """ return self._read_cyclic - @property - def result_name(self): - """Allows to connect result_name input to the operator. - - Name of the result that must be extracted from the file - - Parameters - ---------- - result_name : string - - Examples - -------- - >>> from ansys.dpf import core as dpf - >>> op = dpf.operators.result.custom() - >>> op.inputs.result_name.connect(my_result_name) - >>> # or - >>> op.inputs.result_name(my_result_name) - """ - return self._result_name class OutputsCustom(_Outputs): """Intermediate class used to get outputs from