-
Notifications
You must be signed in to change notification settings - Fork 56
Local surface provider. #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,41 @@ | |
| ) | ||
|
|
||
|
|
||
| class GraphicsDefn(metaclass=PyLocalNamedObjectMetaAbstract): | ||
| class BasePostObjectDefn: | ||
| """Base class for post objects.""" | ||
|
|
||
| def _pre_display(self): | ||
| local_surfaces_provider = ( | ||
| self._get_top_most_parent()._local_surfaces_provider() | ||
| ) | ||
| for surf_name in self.surfaces_list(): | ||
| if surf_name in list(local_surfaces_provider): | ||
| surf_obj = local_surfaces_provider[surf_name] | ||
| if surf_obj.surface.type() == "iso-surface": | ||
| surf_api = surf_obj._data_extractor.surface_api() | ||
| surf_api.iso_surface( | ||
| surf_obj.surface.iso_surface.field(), | ||
| surf_name, | ||
| (), | ||
| (), | ||
| surf_obj.surface.iso_surface.iso_value(), | ||
| (), | ||
| ) | ||
|
|
||
| def _post_display(self): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It deletes local surface in Fluent. |
||
| local_surfaces_provider = ( | ||
| self._get_top_most_parent()._local_surfaces_provider() | ||
| ) | ||
| for surf_name in self.surfaces_list(): | ||
| if surf_name in list(local_surfaces_provider): | ||
| surf_obj = local_surfaces_provider[surf_name] | ||
| surf_api = surf_obj._data_extractor.surface_api() | ||
| surf_api.delete_surface(surf_name) | ||
|
|
||
|
|
||
| class GraphicsDefn( | ||
| BasePostObjectDefn, metaclass=PyLocalNamedObjectMetaAbstract | ||
| ): | ||
| """Abstract base class for graphics objects.""" | ||
|
|
||
| @abstractmethod | ||
|
|
@@ -26,7 +60,7 @@ def display(self, plotter_id: Optional[str] = None): | |
| pass | ||
|
|
||
|
|
||
| class PlotDefn(metaclass=PyLocalNamedObjectMetaAbstract): | ||
| class PlotDefn(BasePostObjectDefn, metaclass=PyLocalNamedObjectMetaAbstract): | ||
| """Abstract base class for plot objects.""" | ||
|
|
||
| @abstractmethod | ||
|
|
@@ -106,7 +140,7 @@ def allowed_values(self): | |
| """Surface list allowed values.""" | ||
| return list( | ||
| self._data_extractor.field_info().get_surfaces_info().keys() | ||
| ) | ||
| ) + list(self._get_top_most_parent()._local_surfaces_provider()) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Local surfaces become available along with surfaces in Fluent. |
||
|
|
||
|
|
||
| class MeshDefn(GraphicsDefn): | ||
|
|
@@ -124,7 +158,7 @@ def allowed_values(self): | |
| """Surface list allowed values.""" | ||
| return list( | ||
| (self._data_extractor.field_info().get_surfaces_info().keys()) | ||
| ) | ||
| ) + list(self._get_top_most_parent()._local_surfaces_provider()) | ||
|
|
||
| class show_edges(metaclass=PyLocalPropertyMeta): | ||
| """Show edges for mesh.""" | ||
|
|
@@ -142,17 +176,17 @@ class show_edges(metaclass=PyLocalPropertyMeta): | |
|
|
||
| value: bool = True | ||
|
|
||
| class surface_type(metaclass=PyLocalObjectMeta): | ||
| class surface(metaclass=PyLocalObjectMeta): | ||
| """Specify surface type.""" | ||
|
|
||
| def _availability(self, name): | ||
| if name == "plane_surface": | ||
| return self.surface_type() == "plane-surface" | ||
| return self.type() == "plane-surface" | ||
| if name == "iso_surface": | ||
| return self.surface_type() == "iso-surface" | ||
| return self.type() == "iso-surface" | ||
| return True | ||
|
|
||
| class surface_type(metaclass=PyLocalPropertyMeta): | ||
| class type(metaclass=PyLocalPropertyMeta): | ||
| """Surface type.""" | ||
|
|
||
| value: str = "iso-surface" | ||
|
|
@@ -251,7 +285,7 @@ def allowed_values(self): | |
| """Surfaces list allowed values.""" | ||
| return list( | ||
| self._data_extractor.field_info().get_surfaces_info().keys() | ||
| ) | ||
| ) + list(self._get_top_most_parent()._local_surfaces_provider()) | ||
|
|
||
| class filled(metaclass=PyLocalPropertyMeta): | ||
| """Show filled contour.""" | ||
|
|
@@ -278,7 +312,7 @@ class show_edges(metaclass=PyLocalPropertyMeta): | |
|
|
||
| value: bool = False | ||
|
|
||
| class range (metaclass=PyLocalObjectMeta): | ||
| class range(metaclass=PyLocalObjectMeta): | ||
| """Specify range options.""" | ||
|
|
||
| def _availability(self, name): | ||
|
|
@@ -407,7 +441,7 @@ def allowed_values(self): | |
| """Surface list allowed values.""" | ||
| return list( | ||
| self._data_extractor.field_info().get_surfaces_info().keys() | ||
| ) | ||
| ) + list(self._get_top_most_parent()._local_surfaces_provider()) | ||
|
|
||
| class scale(metaclass=PyLocalPropertyMeta): | ||
| """Vector scale.""" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -231,8 +231,8 @@ def test_surface_object(): | |
| surf1 = pyvista_graphics.Surfaces["surf-1"] | ||
| field_info = surf1._data_extractor.field_info() | ||
|
|
||
| surf1.surface_type.surface_type = "iso-surface" | ||
| iso_surf = surf1.surface_type.iso_surface | ||
| surf1.surface.type = "iso-surface" | ||
| iso_surf = surf1.surface.iso_surface | ||
|
|
||
| assert iso_surf.field.allowed_values == [ | ||
| v["solver_name"] for k, v in field_info.get_fields_info().items() | ||
|
|
@@ -258,6 +258,19 @@ def test_surface_object(): | |
| range = field_info.get_range(iso_surf.field(), True) | ||
| assert range[0] == pytest.approx(iso_surf.iso_value()) | ||
|
|
||
| cont1 = pyvista_graphics.Contours["surf-1"] | ||
| assert "surf-1" in cont1.surfaces_list.allowed_values | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. surf-1 is now available. |
||
|
|
||
| matplotlib_plots = Plots(session=None) | ||
| p1 = matplotlib_plots.XYPlots["p-1"] | ||
| assert "surf-1" not in p1.surfaces_list.allowed_values | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By default not available in matplotlib for xy plots. |
||
|
|
||
| local_surfaces_provider = Graphics(session=None).Surfaces | ||
| matplotlib_plots = Plots( | ||
| session=None, local_surfaces_provider=local_surfaces_provider | ||
| ) | ||
| assert "surf-1" in p1.surfaces_list.allowed_values | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With local surface provider "surf-1" becomes available. |
||
|
|
||
|
|
||
| def test_create_plot_objects(): | ||
| matplotlib_plots1 = Plots(session=None) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It creates local surface in Fluent.