Skip to content

Commit 3fd97ad

Browse files
committed
Add MeshedRegion.is_empty() query handling retro for faces
1 parent ea1912c commit 3fd97ad

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/ansys/dpf/core/meshed_region.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
from ansys.dpf.core import field, property_field, scoping, server as server_module
3737
from ansys.dpf.core.cache import class_handling_cache
38-
from ansys.dpf.core.check_version import server_meet_version, version_requires
38+
from ansys.dpf.core.check_version import meets_version, server_meet_version, version_requires
3939
from ansys.dpf.core.common import (
4040
locations,
4141
nodal_properties,
@@ -701,3 +701,15 @@ def field_of_properties(self, property_name):
701701
# Not sure we go through here since the only datatype not int is coordinates,
702702
# which is already dealt with previously.
703703
return field.Field(server=self._server, field=field_out)
704+
705+
def is_empty(self) -> bool:
706+
"""Whether the mesh is empty.
707+
708+
A mesh is considered empty when it has zero element, zero face, and zero node.
709+
"""
710+
no_faces = True
711+
if meets_version(self._server, "7.0"):
712+
no_faces = self.faces.n_faces == 0
713+
no_elements = self.elements.n_elements == 0
714+
no_nodes = self.nodes.n_nodes == 0
715+
return no_nodes and no_faces and no_elements

src/ansys/dpf/core/plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ def plot_contour(
895895
mesh = meshed_region
896896
else:
897897
mesh = self._mesh
898-
if mesh.elements.n_elements == 0 and mesh.nodes.n_nodes == 0 and mesh.faces.n_faces == 0:
898+
if mesh.is_empty():
899899
raise dpf_errors.EmptyMeshPlottingError
900900

901901
# get mesh scoping

0 commit comments

Comments
 (0)