From 3842adb458e8aaf609bf7f9a4139674019b5aad8 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 15:26:29 +0100 Subject: [PATCH 01/10] maint: remove now deprecated `MockPropertyFieldsContainer` --- pyproject.toml | 2 +- src/ansys/dpf/post/dataframe.py | 9 +++++---- src/ansys/dpf/post/mesh.py | 8 +++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 1ccd96791..a9abdf8f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ maintainers = [ {name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"}, ] dependencies = [ - "ansys-dpf-core@git+https://github.com/ansys/pydpf-core.git", + "ansys-dpf-core@git+https://github.com/ansys/pydpf-core.git@maint/update-operator-class-for-pfc", "scooby", ] classifiers = [ diff --git a/src/ansys/dpf/post/dataframe.py b/src/ansys/dpf/post/dataframe.py index 6695ec91b..77e1f8da4 100644 --- a/src/ansys/dpf/post/dataframe.py +++ b/src/ansys/dpf/post/dataframe.py @@ -36,9 +36,7 @@ import ansys.dpf.core as dpf from ansys.dpf.core.dpf_array import DPFArray from ansys.dpf.core.plotter import DpfPlotter -from ansys.dpf.core.property_fields_container import ( - _MockPropertyFieldsContainer as PropertyFieldsContainer, -) +from ansys.dpf.core.property_fields_container import PropertyFieldsContainer import ansys.dpf.gate.errors import numpy as np @@ -345,7 +343,10 @@ def select(self, **kwargs) -> DataFrame: f"'{mesh_index_name}' is not yet supported" ) if isinstance(input_fc, PropertyFieldsContainer): - fc = input_fc.rescope(mesh_scoping) + rescope_fc = dpf.operators.scoping.rescope_property_field( + fields=input_fc, mesh_scoping=mesh_scoping, server=server + ) + fc = rescope_fc.outputs[0].get_data() else: rescope_fc = dpf.operators.scoping.rescope_fc( fields_container=input_fc, diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index 9d8c1ac8a..802c2e13c 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -32,10 +32,8 @@ import ansys.dpf.core as dpf from ansys.dpf.core.faces import Face +from ansys.dpf.core.fields_container import FieldsContainer from ansys.dpf.core.nodes import Node -from ansys.dpf.core.property_fields_container import ( - _MockPropertyFieldsContainer as PropertyFieldsContainer, -) import ansys.dpf.post as post from ansys.dpf.post import index, locations @@ -264,7 +262,7 @@ def element_types(self) -> post.DataFrame: ... ... """ label = "elem_type_id" - fields_container = PropertyFieldsContainer() + fields_container = FieldsContainer() field = self._meshed_region.elements.element_types_field fields_container.add_field(label_space={}, field=field) @@ -303,7 +301,7 @@ def materials(self) -> post.DataFrame: ... ... """ label = "material_id" - fields_container = PropertyFieldsContainer() + fields_container = FieldsContainer() field = self._meshed_region.elements.materials_field fields_container.add_field(label_space={}, field=field) From 585aaa3df600974542e9d297ac4a945ae2fb1487 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 15:43:01 +0100 Subject: [PATCH 02/10] fix: update ci --- .github/workflows/ci.yml | 1 + .github/workflows/ci_release.yml | 1 + .github/workflows/docs.yml | 1 + .github/workflows/examples.yml | 1 + 4 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d84aa628..8acf3c8ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ env: MODULE: 'post' DOCUMENTATION_CNAME: 'post.docs.pyansys.com' MAIN_PYTHON_VERSION: '3.10' + DPF_DEFAULT_GRPC_MODE: 'insecure' jobs: debug: diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml index da3bf7ec2..4b306a90c 100644 --- a/.github/workflows/ci_release.yml +++ b/.github/workflows/ci_release.yml @@ -32,6 +32,7 @@ env: MODULE: 'post' DOCUMENTATION_CNAME: 'post.docs.pyansys.com' MAIN_PYTHON_VERSION: '3.10' + DPF_DEFAULT_GRPC_MODE: 'insecure' jobs: debug: diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 95af1a5e9..93464845f 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -54,6 +54,7 @@ on: env: PACKAGE_NAME: ansys-dpf-post MODULE: post + DPF_DEFAULT_GRPC_MODE: insecure jobs: doc-style: diff --git a/.github/workflows/examples.yml b/.github/workflows/examples.yml index 1c3490c5a..c5cb8c355 100644 --- a/.github/workflows/examples.yml +++ b/.github/workflows/examples.yml @@ -37,6 +37,7 @@ on: env: PACKAGE_NAME: ansys-dpf-post MODULE: post + DPF_DEFAULT_GRPC_MODE: insecure jobs: setup: From 034bf5e3dbd45609700cd198f41f08791cf3c28b Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 16:44:42 +0100 Subject: [PATCH 03/10] fix: mesh module --- src/ansys/dpf/post/mesh.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index 802c2e13c..e9d14c1a7 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -32,7 +32,7 @@ import ansys.dpf.core as dpf from ansys.dpf.core.faces import Face -from ansys.dpf.core.fields_container import FieldsContainer +from ansys.dpf.core.property_fields_container import PropertyFieldsContainer from ansys.dpf.core.nodes import Node import ansys.dpf.post as post @@ -262,7 +262,7 @@ def element_types(self) -> post.DataFrame: ... ... """ label = "elem_type_id" - fields_container = FieldsContainer() + fields_container = PropertyFieldsContainer() field = self._meshed_region.elements.element_types_field fields_container.add_field(label_space={}, field=field) @@ -301,7 +301,7 @@ def materials(self) -> post.DataFrame: ... ... """ label = "material_id" - fields_container = FieldsContainer() + fields_container = PropertyFieldsContainer() field = self._meshed_region.elements.materials_field fields_container.add_field(label_space={}, field=field) From 55e8ecba14928080cb8bc690798eeeaea31136d9 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 16:47:50 +0100 Subject: [PATCH 04/10] fix: codestyle --- src/ansys/dpf/post/mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index e9d14c1a7..0f5d77edc 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -32,8 +32,8 @@ import ansys.dpf.core as dpf from ansys.dpf.core.faces import Face -from ansys.dpf.core.property_fields_container import PropertyFieldsContainer from ansys.dpf.core.nodes import Node +from ansys.dpf.core.property_fields_container import PropertyFieldsContainer import ansys.dpf.post as post from ansys.dpf.post import index, locations From f84eb3312fe5e507087c07265816316c991af46f Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 17:04:19 +0100 Subject: [PATCH 05/10] fix: tests --- src/ansys/dpf/post/mesh.py | 4 ++-- tests/conftest.py | 4 ++++ tests/test_mesh.py | 12 +++++++++--- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/ansys/dpf/post/mesh.py b/src/ansys/dpf/post/mesh.py index 0f5d77edc..748508223 100644 --- a/src/ansys/dpf/post/mesh.py +++ b/src/ansys/dpf/post/mesh.py @@ -264,7 +264,7 @@ def element_types(self) -> post.DataFrame: label = "elem_type_id" fields_container = PropertyFieldsContainer() field = self._meshed_region.elements.element_types_field - fields_container.add_field(label_space={}, field=field) + fields_container.add_entry(label_space={}, entry=field) return post.DataFrame( data=fields_container, @@ -303,7 +303,7 @@ def materials(self) -> post.DataFrame: label = "material_id" fields_container = PropertyFieldsContainer() field = self._meshed_region.elements.materials_field - fields_container.add_field(label_space={}, field=field) + fields_container.add_entry(label_space={}, entry=field) return post.DataFrame( data=fields_container, diff --git a/tests/conftest.py b/tests/conftest.py index 25950e1c5..87ffd404d 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -391,6 +391,10 @@ def license_context(): get_server_version(core._global_server()), "9.0" ) +SERVER_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 = meets_version( + get_server_version(core._global_server()), "8.1" +) + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0 = meets_version( get_server_version(core._global_server()), "8.0" ) diff --git a/tests/test_mesh.py b/tests/test_mesh.py index d2baf3460..881d38e3d 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -28,7 +28,7 @@ from ansys.dpf.post import FluidSimulation, Mesh, StaticMechanicalSimulation from ansys.dpf.post.connectivity import ConnectivityListByIndex from ansys.dpf.post.faces import Face -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 @fixture @@ -165,7 +165,10 @@ def test_mesh_coordinates(mesh): """ # noqa assert str(coord) == ref - +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1, + reason="PropertyFieldsContainer supported for server versions greater than 8.1", +) def test_mesh_materials(mesh): materials = mesh.materials ref = """ @@ -188,7 +191,10 @@ def test_mesh_materials(mesh): """ # noqa assert str(materials_5) == ref - +@pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1, + reason="PropertyFieldsContainer supported for server versions greater than 8.1", +) def test_mesh_element_types(mesh): element_types = mesh.element_types # print(element_types) From e7d53a366a869c008d9857ea5be2f2a6f6b3ee55 Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 17:18:23 +0100 Subject: [PATCH 06/10] fix: tests --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 87ffd404d..8c512a114 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -391,7 +391,7 @@ def license_context(): get_server_version(core._global_server()), "9.0" ) -SERVER_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 = meets_version( +SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 = meets_version( get_server_version(core._global_server()), "8.1" ) From b08e03f5af3a3169586d7d6bf025a02c0d303fed Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 17:21:17 +0100 Subject: [PATCH 07/10] fix: codestyle --- tests/test_mesh.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/test_mesh.py b/tests/test_mesh.py index 881d38e3d..9332d91d9 100644 --- a/tests/test_mesh.py +++ b/tests/test_mesh.py @@ -28,7 +28,10 @@ from ansys.dpf.post import FluidSimulation, Mesh, StaticMechanicalSimulation from ansys.dpf.post.connectivity import ConnectivityListByIndex from ansys.dpf.post.faces import Face -from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1 +from conftest import ( + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1, +) @fixture @@ -165,6 +168,7 @@ def test_mesh_coordinates(mesh): """ # noqa assert str(coord) == ref + @pytest.mark.skipif( not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1, reason="PropertyFieldsContainer supported for server versions greater than 8.1", @@ -191,6 +195,7 @@ def test_mesh_materials(mesh): """ # noqa assert str(materials_5) == ref + @pytest.mark.skipif( not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1, reason="PropertyFieldsContainer supported for server versions greater than 8.1", From 09d30c156b38aca301f909207fdc2c21a05cfb5f Mon Sep 17 00:00:00 2001 From: moe-ad Date: Wed, 17 Dec 2025 17:34:04 +0100 Subject: [PATCH 08/10] fix: tests --- src/ansys/dpf/post/dataframe.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/post/dataframe.py b/src/ansys/dpf/post/dataframe.py index 77e1f8da4..ba014ab3f 100644 --- a/src/ansys/dpf/post/dataframe.py +++ b/src/ansys/dpf/post/dataframe.py @@ -599,7 +599,10 @@ def _update_str(self, max_columns: int, max_rows: int): if label_name == ref_labels.set_ids: label_name = ref_labels.time label_space[label_name] = int(value) - fields = self._fc.get_fields(label_space=label_space) + if isinstance(self._fc, dpf.FieldsContainer): + fields = self._fc.get_fields(label_space=label_space) + else: + fields = self._fc.get_entries(label_space=label_space) # Start counting values found n_values = 0 @@ -833,7 +836,10 @@ def plot(self, shell_layer=shell_layers.top, **kwargs) -> Union[DpfPlotter, None fc = merge_stages_op.outputs.fields_container() label_space.pop("stage") - fields = fc.get_fields(label_space=label_space) + if isinstance(fc, dpf.FieldsContainer): + fields = fc.get_fields(label_space=label_space) + else: + fields = fc.get_entries(label_space=label_space) # for field in fields: if len(fields) > 1: # try: From 47958724e65d096b489519728a3d85c15d01ab24 Mon Sep 17 00:00:00 2001 From: Paul Profizi <100710998+PProfizi@users.noreply.github.com> Date: Wed, 17 Dec 2025 19:07:21 +0100 Subject: [PATCH 09/10] Update pyproject.toml --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index a9abdf8f8..1ccd96791 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,7 @@ maintainers = [ {name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"}, ] dependencies = [ - "ansys-dpf-core@git+https://github.com/ansys/pydpf-core.git@maint/update-operator-class-for-pfc", + "ansys-dpf-core@git+https://github.com/ansys/pydpf-core.git", "scooby", ] classifiers = [ From 5685c3149598314c0a5e43465ea54d48c068160d Mon Sep 17 00:00:00 2001 From: PProfizi Date: Tue, 23 Dec 2025 09:38:48 +0100 Subject: [PATCH 10/10] Fix Dataframe.select for PropertyFieldsContainer --- src/ansys/dpf/post/dataframe.py | 42 +++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/ansys/dpf/post/dataframe.py b/src/ansys/dpf/post/dataframe.py index ba014ab3f..a66a5ae23 100644 --- a/src/ansys/dpf/post/dataframe.py +++ b/src/ansys/dpf/post/dataframe.py @@ -343,10 +343,12 @@ def select(self, **kwargs) -> DataFrame: f"'{mesh_index_name}' is not yet supported" ) if isinstance(input_fc, PropertyFieldsContainer): - rescope_fc = dpf.operators.scoping.rescope_property_field( - fields=input_fc, mesh_scoping=mesh_scoping, server=server - ) - fc = rescope_fc.outputs[0].get_data() + # PropertyFieldsContainer not yet handled server-side + # rescope_fc = dpf.operators.scoping.rescope_property_field( + # fields=input_fc, mesh_scoping=mesh_scoping, server=server + # ) + # fc = rescope_fc.outputs[0].get_data() + fc = self._rescope_pfc(input_fc, mesh_scoping) else: rescope_fc = dpf.operators.scoping.rescope_fc( fields_container=input_fc, @@ -411,6 +413,38 @@ def select(self, **kwargs) -> DataFrame: index=row_index, ) + def _rescope_pfc( + self, pfc: PropertyFieldsContainer, mesh_scoping: dpf.Scoping + ) -> PropertyFieldsContainer: + """Rescope a PropertyFieldsContainer based on a given mesh scoping. + + Temporary fix until DPF handles the PropertyFieldsContainer correctly. + + Parameters + ---------- + pfc: + The PropertyFieldsContainer to rescope. + mesh_scoping: + The mesh scoping to use for rescoping. + + Returns + ------- + The rescoped PropertyFieldsContainer. + + """ + rescoped_pfc = dpf.PropertyFieldsContainer(server=pfc._server) + for label in pfc.labels: + rescoped_pfc.add_label(label=label) + + for idx, pf in enumerate(pfc): + new_pf = dpf.PropertyField(location=pf.location) + new_pf.data = np.ravel( + [pf.get_entity_data_by_id(entity_id) for entity_id in mesh_scoping.ids] + ) + new_pf.scoping.ids = mesh_scoping.ids + rescoped_pfc.add_entry(pfc.get_label_space(idx), new_pf) + return rescoped_pfc + def iselect(self, **kwargs) -> DataFrame: """Returns a new DataFrame based on selection criteria (index-based).