Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions src/ansys/dpf/post/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -598,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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@moe-ad Doesn't the FieldsContainer inherit a get_entries method from the Collection class?
If not, we should add it so we can have the same API and not need such conditional tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that FieldsContainer subclasses CollectionBase directly (a superclass of Collection) where get_entries isn't available. But _get_entries is available though, but I don't think we should be calling that directly.

else:
fields = self._fc.get_entries(label_space=label_space)

# Start counting values found
n_values = 0
Expand Down Expand Up @@ -832,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:
Expand Down
8 changes: 3 additions & 5 deletions src/ansys/dpf/post/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@
import ansys.dpf.core as dpf
from ansys.dpf.core.faces import Face
from ansys.dpf.core.nodes import Node
from ansys.dpf.core.property_fields_container import (
_MockPropertyFieldsContainer as PropertyFieldsContainer,
)
from ansys.dpf.core.property_fields_container import PropertyFieldsContainer

import ansys.dpf.post as post
from ansys.dpf.post import index, locations
Expand Down Expand Up @@ -266,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,
Expand Down Expand Up @@ -305,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,
Expand Down
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,10 @@ def license_context():
get_server_version(core._global_server()), "9.0"
)

SERVERS_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"
)
Expand Down
13 changes: 12 additions & 1 deletion tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
from conftest import (
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0,
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_1,
)


@fixture
Expand Down Expand Up @@ -166,6 +169,10 @@ def test_mesh_coordinates(mesh):
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 = """
Expand All @@ -189,6 +196,10 @@ def test_mesh_materials(mesh):
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)
Expand Down
Loading