From 3b65038348b56d3e98781f3c1a5c489f96fd38ed Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Fri, 17 Jul 2026 09:34:34 +0200 Subject: [PATCH 01/11] Add mesh related any casts --- src/ansys/dpf/core/any.py | 12 ++++++++++++ tests/test_any.py | 26 ++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index 5e1922a6b14..ec5543c11d6 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -125,6 +125,8 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 scoping, string_field, workflow, + meshed_region, + meshes_container ) if issubclass(obj, int): @@ -223,6 +225,16 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 self._api.any_new_from_cyclic_support, self._api.any_get_as_cyclic_support, ) + elif issubclass(obj, meshed_region.MeshedRegion): + return ( + self._api.any_new_from_meshed_region, + self._api.any_get_as_meshed_region, + ) + elif issubclass(obj, meshes_container.MeshesContainer): + return ( + self._api.any_new_from_meshes_container, + self._api.any_get_as_meshes_container, + ) elif issubclass(obj, Any): return ( lambda x: x, diff --git a/tests/test_any.py b/tests/test_any.py index 043b1d91ef1..ac65adce6fd 100644 --- a/tests/test_any.py +++ b/tests/test_any.py @@ -169,3 +169,29 @@ def test_cast_fields_container_any(server_type): new_entity = any_dpf.cast() assert entity.name == new_entity.name + +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, + reason="any does not support operator below 10.0", +) +def test_cast_meshed_region_any(server_type): + entity = dpf.MeshedRegion(server=server_type) + entity.unit = "mm" + any_dpf = dpf.Any.new_from(entity) + new_entity = any_dpf.cast() + + assert entity.unit == new_entity.unit + +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, + reason="any does not support operator below 10.0", +) +def test_cast_meshes_container_any(server_type): + entity = dpf.MeshesContainer(server=server_type) + entity.add_label("idx") + entity.add_mesh({"idx": 0}, dpf.MeshedRegion(server=server_type)) + + any_dpf = dpf.Any.new_from(entity) + new_entity = any_dpf.cast() + + assert entity.get_label_space(0) == new_entity.get_label_space(0) From 999df29e6d8987f487005fb2824526a5c47e0ac4 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Fri, 17 Jul 2026 10:11:09 +0200 Subject: [PATCH 02/11] Run pre-commit hooks --- src/ansys/dpf/core/any.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index ec5543c11d6..81110afec6e 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -121,12 +121,12 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 fields_container, generic_data_container, generic_support, + meshed_region, + meshes_container, property_field, scoping, string_field, workflow, - meshed_region, - meshes_container ) if issubclass(obj, int): From dcdc81c866fea97c70ea541fb2b6d3820253f22d Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 09:27:20 +0200 Subject: [PATCH 03/11] Add grpc methods --- src/ansys/dpf/gate/any_grpcapi.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index 5f32eb94d93..57335658895 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -40,6 +40,8 @@ def _type_to_message_type(): data_sources, generic_data_container, generic_support, + meshed_region, + meshes_container, string_field, scoping, data_tree, @@ -61,6 +63,8 @@ def _type_to_message_type(): (generic_data_container.GenericDataContainer, base_pb2.Type.GENERIC_DATA_CONTAINER), (generic_support.GenericSupport, base_pb2.Type.GENERIC_SUPPORT), (cyclic_support.CyclicSupport, base_pb2.Type.CYCLIC_SUPPORT), + (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), + (meshes_container.MeshesContainer, base_pb2.Type.MESHES_CONTAINER), (scoping.Scoping, base_pb2.Type.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), @@ -175,6 +179,13 @@ def any_get_as_generic_support(any): def any_get_as_cyclic_support(any): return AnyGRPCAPI._get_as(any).cyc_support + @staticmethod + def any_get_as_meshed_region(any): + return AnyGRPCAPI._get_as(any).meshed_region + @staticmethod + def any_get_as_meshes_container(any): + return AnyGRPCAPI._get_as(any).meshes_container + @staticmethod def _new_from(any, client=None): from ansys.grpc.dpf import dpf_any_pb2 @@ -280,3 +291,12 @@ def any_new_from_generic_support(any): @staticmethod def any_new_from_cyclic_support(any): return AnyGRPCAPI._new_from(any, any._server) + + @staticmethod + def any_new_from_meshed_region(any): + return AnyGRPCAPI._new_from(any, any._server) + + @staticmethod + def any_new_from_meshes_container(any): + return AnyGRPCAPI._new_from(any, any._server) + From 59595497c55f97a670623dcec1e26c17433810dd Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 10:23:33 +0200 Subject: [PATCH 04/11] Try with only mesh --- src/ansys/dpf/core/any.py | 6 ------ src/ansys/dpf/gate/any_grpcapi.py | 10 ---------- tests/test_any.py | 13 ------------- 3 files changed, 29 deletions(-) diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index 81110afec6e..158657c587a 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -122,7 +122,6 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 generic_data_container, generic_support, meshed_region, - meshes_container, property_field, scoping, string_field, @@ -230,11 +229,6 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 self._api.any_new_from_meshed_region, self._api.any_get_as_meshed_region, ) - elif issubclass(obj, meshes_container.MeshesContainer): - return ( - self._api.any_new_from_meshes_container, - self._api.any_get_as_meshes_container, - ) elif issubclass(obj, Any): return ( lambda x: x, diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index 57335658895..e1c78565251 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -41,7 +41,6 @@ def _type_to_message_type(): generic_data_container, generic_support, meshed_region, - meshes_container, string_field, scoping, data_tree, @@ -64,7 +63,6 @@ def _type_to_message_type(): (generic_support.GenericSupport, base_pb2.Type.GENERIC_SUPPORT), (cyclic_support.CyclicSupport, base_pb2.Type.CYCLIC_SUPPORT), (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), - (meshes_container.MeshesContainer, base_pb2.Type.MESHES_CONTAINER), (scoping.Scoping, base_pb2.Type.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), @@ -182,9 +180,6 @@ def any_get_as_cyclic_support(any): @staticmethod def any_get_as_meshed_region(any): return AnyGRPCAPI._get_as(any).meshed_region - @staticmethod - def any_get_as_meshes_container(any): - return AnyGRPCAPI._get_as(any).meshes_container @staticmethod def _new_from(any, client=None): @@ -295,8 +290,3 @@ def any_new_from_cyclic_support(any): @staticmethod def any_new_from_meshed_region(any): return AnyGRPCAPI._new_from(any, any._server) - - @staticmethod - def any_new_from_meshes_container(any): - return AnyGRPCAPI._new_from(any, any._server) - diff --git a/tests/test_any.py b/tests/test_any.py index ac65adce6fd..2e7415839f2 100644 --- a/tests/test_any.py +++ b/tests/test_any.py @@ -182,16 +182,3 @@ def test_cast_meshed_region_any(server_type): assert entity.unit == new_entity.unit -@pytest.mark.skipif( - not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, - reason="any does not support operator below 10.0", -) -def test_cast_meshes_container_any(server_type): - entity = dpf.MeshesContainer(server=server_type) - entity.add_label("idx") - entity.add_mesh({"idx": 0}, dpf.MeshedRegion(server=server_type)) - - any_dpf = dpf.Any.new_from(entity) - new_entity = any_dpf.cast() - - assert entity.get_label_space(0) == new_entity.get_label_space(0) From ef23193bdd0185d30ec5bbf1d789b07b4f145257 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 12:59:10 +0200 Subject: [PATCH 05/11] Revert "Try with only mesh" This reverts commit 59595497c55f97a670623dcec1e26c17433810dd. --- src/ansys/dpf/core/any.py | 6 ++++++ src/ansys/dpf/gate/any_grpcapi.py | 10 ++++++++++ tests/test_any.py | 13 +++++++++++++ 3 files changed, 29 insertions(+) diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index 158657c587a..81110afec6e 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -122,6 +122,7 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 generic_data_container, generic_support, meshed_region, + meshes_container, property_field, scoping, string_field, @@ -229,6 +230,11 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 self._api.any_new_from_meshed_region, self._api.any_get_as_meshed_region, ) + elif issubclass(obj, meshes_container.MeshesContainer): + return ( + self._api.any_new_from_meshes_container, + self._api.any_get_as_meshes_container, + ) elif issubclass(obj, Any): return ( lambda x: x, diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index e1c78565251..57335658895 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -41,6 +41,7 @@ def _type_to_message_type(): generic_data_container, generic_support, meshed_region, + meshes_container, string_field, scoping, data_tree, @@ -63,6 +64,7 @@ def _type_to_message_type(): (generic_support.GenericSupport, base_pb2.Type.GENERIC_SUPPORT), (cyclic_support.CyclicSupport, base_pb2.Type.CYCLIC_SUPPORT), (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), + (meshes_container.MeshesContainer, base_pb2.Type.MESHES_CONTAINER), (scoping.Scoping, base_pb2.Type.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), @@ -180,6 +182,9 @@ def any_get_as_cyclic_support(any): @staticmethod def any_get_as_meshed_region(any): return AnyGRPCAPI._get_as(any).meshed_region + @staticmethod + def any_get_as_meshes_container(any): + return AnyGRPCAPI._get_as(any).meshes_container @staticmethod def _new_from(any, client=None): @@ -290,3 +295,8 @@ def any_new_from_cyclic_support(any): @staticmethod def any_new_from_meshed_region(any): return AnyGRPCAPI._new_from(any, any._server) + + @staticmethod + def any_new_from_meshes_container(any): + return AnyGRPCAPI._new_from(any, any._server) + diff --git a/tests/test_any.py b/tests/test_any.py index 2e7415839f2..ac65adce6fd 100644 --- a/tests/test_any.py +++ b/tests/test_any.py @@ -182,3 +182,16 @@ def test_cast_meshed_region_any(server_type): assert entity.unit == new_entity.unit +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, + reason="any does not support operator below 10.0", +) +def test_cast_meshes_container_any(server_type): + entity = dpf.MeshesContainer(server=server_type) + entity.add_label("idx") + entity.add_mesh({"idx": 0}, dpf.MeshedRegion(server=server_type)) + + any_dpf = dpf.Any.new_from(entity) + new_entity = any_dpf.cast() + + assert entity.get_label_space(0) == new_entity.get_label_space(0) From f874a3bb706be6fe58307ad4791036c06e91ad95 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 13:00:24 +0200 Subject: [PATCH 06/11] Use collection type for meshes_container --- src/ansys/dpf/gate/any_grpcapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index 57335658895..d8dbb1e5887 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -64,7 +64,7 @@ def _type_to_message_type(): (generic_support.GenericSupport, base_pb2.Type.GENERIC_SUPPORT), (cyclic_support.CyclicSupport, base_pb2.Type.CYCLIC_SUPPORT), (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), - (meshes_container.MeshesContainer, base_pb2.Type.MESHES_CONTAINER), + (meshes_container.MeshesContainer, base_pb2.Type.COLLECTION, base_pb2.Type.MESHED_REGION), (scoping.Scoping, base_pb2.Type.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), From 595059f5b2c6b2454014b44baef8725d95cf4673 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 13:47:04 +0200 Subject: [PATCH 07/11] Add scopings container --- src/ansys/dpf/core/any.py | 6 ++++++ src/ansys/dpf/gate/any_grpcapi.py | 10 ++++++++++ tests/test_any.py | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/ansys/dpf/core/any.py b/src/ansys/dpf/core/any.py index 81110afec6e..572613ccefc 100644 --- a/src/ansys/dpf/core/any.py +++ b/src/ansys/dpf/core/any.py @@ -125,6 +125,7 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 meshes_container, property_field, scoping, + scopings_container, string_field, workflow, ) @@ -180,6 +181,11 @@ def _type_to_new_from_get_as_method(self, obj): # noqa: PLR0911, PLR0912, C901 self._api.any_new_from_scoping, self._api.any_get_as_scoping, ) + elif issubclass(obj, scopings_container.ScopingsContainer): + return ( + self._api.any_new_from_scopings_container, + self._api.any_get_as_scopings_container, + ) elif issubclass(obj, data_tree.DataTree): return ( self._api.any_new_from_data_tree, diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index d8dbb1e5887..d6b823cb1d1 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -44,6 +44,7 @@ def _type_to_message_type(): meshes_container, string_field, scoping, + scopings_container, data_tree, custom_type_field, collection_base, @@ -66,6 +67,7 @@ def _type_to_message_type(): (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), (meshes_container.MeshesContainer, base_pb2.Type.COLLECTION, base_pb2.Type.MESHED_REGION), (scoping.Scoping, base_pb2.Type.SCOPING), + (scopings_container.ScopingsContainer, base_pb2.Type.COLLECTION.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), (collection_base.CollectionBase, base_pb2.Type.COLLECTION, base_pb2.Type.ANY), @@ -147,6 +149,10 @@ def any_get_as_generic_data_container(any): def any_get_as_scoping(any): return AnyGRPCAPI._get_as(any).scoping + @staticmethod + def any_get_as_scopings_container(any): + return AnyGRPCAPI._get_as(any).scopings_container + @staticmethod def any_get_as_data_sources(any): return AnyGRPCAPI._get_as(any).data_sources @@ -268,6 +274,10 @@ def any_new_from_generic_data_container(any): def any_new_from_scoping(any): return AnyGRPCAPI._new_from(any, any._server) + @staticmethod + def any_new_from_scopings_container(any): + return AnyGRPCAPI._new_from(any, any._server) + @staticmethod def any_new_from_data_sources(any): return AnyGRPCAPI._new_from(any, any._server) diff --git a/tests/test_any.py b/tests/test_any.py index ac65adce6fd..2ec78fe3a30 100644 --- a/tests/test_any.py +++ b/tests/test_any.py @@ -195,3 +195,17 @@ def test_cast_meshes_container_any(server_type): new_entity = any_dpf.cast() assert entity.get_label_space(0) == new_entity.get_label_space(0) + +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_10_0, + reason="any does not support operator below 10.0", +) +def test_cast_scopings_container_any(server_type): + entity = dpf.ScopingsContainer(server=server_type) + entity.add_label("idx") + entity.add_scoping({"idx": 0}, dpf.Scoping(server=server_type)) + + any_dpf = dpf.Any.new_from(entity) + new_entity = any_dpf.cast() + + assert entity.get_label_space(0) == new_entity.get_label_space(0) From 6db1b5761772118fd39fcfa63e100d7626f2160a Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 14:42:53 +0200 Subject: [PATCH 08/11] Update src/ansys/dpf/gate/any_grpcapi.py Co-authored-by: Rafael Canton <107186344+rafacanton@users.noreply.github.com> --- src/ansys/dpf/gate/any_grpcapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index d6b823cb1d1..b90e2750ce2 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -187,7 +187,7 @@ def any_get_as_cyclic_support(any): @staticmethod def any_get_as_meshed_region(any): - return AnyGRPCAPI._get_as(any).meshed_region + return AnyGRPCAPI._get_as(any).mesh @staticmethod def any_get_as_meshes_container(any): return AnyGRPCAPI._get_as(any).meshes_container From e5333fd60bd8bfa30a71826e042b6601fbe96902 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 14:43:03 +0200 Subject: [PATCH 09/11] Update src/ansys/dpf/gate/any_grpcapi.py Co-authored-by: Rafael Canton <107186344+rafacanton@users.noreply.github.com> --- src/ansys/dpf/gate/any_grpcapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index b90e2750ce2..b5928a1ed5e 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -151,7 +151,7 @@ def any_get_as_scoping(any): @staticmethod def any_get_as_scopings_container(any): - return AnyGRPCAPI._get_as(any).scopings_container + return AnyGRPCAPI._get_as(any).collection @staticmethod def any_get_as_data_sources(any): From 2f47b95e99b11bacb1d9800ec5282bd095958a86 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 14:43:12 +0200 Subject: [PATCH 10/11] Update src/ansys/dpf/gate/any_grpcapi.py Co-authored-by: Rafael Canton <107186344+rafacanton@users.noreply.github.com> --- src/ansys/dpf/gate/any_grpcapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index b5928a1ed5e..f0721804704 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -190,7 +190,7 @@ def any_get_as_meshed_region(any): return AnyGRPCAPI._get_as(any).mesh @staticmethod def any_get_as_meshes_container(any): - return AnyGRPCAPI._get_as(any).meshes_container + return AnyGRPCAPI._get_as(any).collection @staticmethod def _new_from(any, client=None): From ea74d7c6aa9de15adad8948afc85c6669fac3eb5 Mon Sep 17 00:00:00 2001 From: Jan von Rickenbach Date: Tue, 21 Jul 2026 14:50:42 +0200 Subject: [PATCH 11/11] Update src/ansys/dpf/gate/any_grpcapi.py Co-authored-by: Rafael Canton <107186344+rafacanton@users.noreply.github.com> --- src/ansys/dpf/gate/any_grpcapi.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/gate/any_grpcapi.py b/src/ansys/dpf/gate/any_grpcapi.py index f0721804704..b5a43cc702a 100644 --- a/src/ansys/dpf/gate/any_grpcapi.py +++ b/src/ansys/dpf/gate/any_grpcapi.py @@ -67,7 +67,7 @@ def _type_to_message_type(): (meshed_region.MeshedRegion, base_pb2.Type.MESHED_REGION), (meshes_container.MeshesContainer, base_pb2.Type.COLLECTION, base_pb2.Type.MESHED_REGION), (scoping.Scoping, base_pb2.Type.SCOPING), - (scopings_container.ScopingsContainer, base_pb2.Type.COLLECTION.SCOPING), + (scopings_container.ScopingsContainer, base_pb2.Type.COLLECTION, base_pb2.Type.SCOPING), (data_tree.DataTree, base_pb2.Type.DATA_TREE), (workflow.Workflow, base_pb2.Type.WORKFLOW), (collection_base.CollectionBase, base_pb2.Type.COLLECTION, base_pb2.Type.ANY),