-
Notifications
You must be signed in to change notification settings - Fork 56
Plane surface creation. #291
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,86 @@ | |
|
||
|
||
class LocalObjectDataExtractor: | ||
"""Class to extract data for local objects.""" | ||
|
||
class _SurfaceAPI: | ||
"""Class providing APIs for surface operations.""" | ||
|
||
def __init__(self, obj): | ||
self.obj = obj | ||
self._surface_name_on_server = self.surface_name_in_server( | ||
obj._name | ||
) | ||
|
||
@staticmethod | ||
def surface_name_in_server(local_surface_name): | ||
return "_dummy_surface_for_pyfluent:" + local_surface_name | ||
|
||
def _get_api_handle(self): | ||
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. Switch from tui to settings API can be made here in future. |
||
return self.obj._get_top_most_parent().session.tui.solver.surface | ||
|
||
def _delete_if_exist_on_server(self): | ||
field_info = self.obj._data_extractor.field_info() | ||
surfaces_list = list(field_info.get_surfaces_info().keys()) | ||
if self._surface_name_on_server in surfaces_list: | ||
self.delete_surface_on_server() | ||
|
||
def create_surface_on_server(self): | ||
if self.obj.surface.type() == "iso-surface": | ||
iso_surface = self.obj.surface.iso_surface | ||
field = iso_surface.field() | ||
iso_value = iso_surface.iso_value() | ||
if not field: | ||
raise RuntimeError("Iso surface definition is incomplete.") | ||
self._delete_if_exist_on_server() | ||
self._get_api_handle().iso_surface( | ||
field, self._surface_name_on_server, (), (), iso_value, () | ||
) | ||
elif self.obj.surface.type() == "plane-surface": | ||
plane_surface = self.obj.surface.plane_surface | ||
xy_plane = plane_surface.xy_plane | ||
yz_plane = plane_surface.yz_plane | ||
zx_plane = plane_surface.zx_plane | ||
self._delete_if_exist_on_server() | ||
self._get_api_handle().plane_surface( | ||
self._surface_name_on_server, | ||
"xy-plane" | ||
if xy_plane | ||
else "yz-plane" | ||
if yz_plane | ||
else "zx-plane", | ||
xy_plane.z() | ||
if xy_plane | ||
else yz_plane.x() | ||
if yz_plane | ||
else zx_plane.y(), | ||
) | ||
field_info = self.obj._data_extractor.field_info() | ||
surfaces_list = list(field_info.get_surfaces_info().keys()) | ||
if self._surface_name_on_server not in surfaces_list: | ||
raise RuntimeError("Surface creation failed.") | ||
|
||
def delete_surface_on_server(self): | ||
self._get_api_handle().delete_surface(self._surface_name_on_server) | ||
|
||
def __init__(self, obj): | ||
self.obj = obj | ||
self.field_info = lambda: obj._get_top_most_parent().session.field_info | ||
self.field_data = lambda: obj._get_top_most_parent().session.field_data | ||
self.surface_api = ( | ||
lambda: obj._get_top_most_parent().session.tui.solver.surface | ||
) | ||
self.id = lambda: obj._get_top_most_parent().session.id | ||
if obj.__class__.__name__ == "Surface": | ||
self.surface_api = LocalObjectDataExtractor._SurfaceAPI(obj) | ||
|
||
def remote_surface_name(self, local_surface_name): | ||
local_surfaces_provider = ( | ||
self.obj._get_top_most_parent()._local_surfaces_provider() | ||
) | ||
if local_surface_name in list(local_surfaces_provider): | ||
return LocalObjectDataExtractor._SurfaceAPI.surface_name_in_server( | ||
local_surface_name | ||
) | ||
else: | ||
return local_surface_name | ||
|
||
|
||
class Attribute: | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,8 @@ def _pre_display(self): | |
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(), | ||
(), | ||
) | ||
surf_api = surf_obj._data_extractor.surface_api | ||
surf_api.create_surface_on_server() | ||
|
||
def _post_display(self): | ||
local_surfaces_provider = ( | ||
|
@@ -38,8 +30,8 @@ def _post_display(self): | |
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) | ||
surf_api = surf_obj._data_extractor.surface_api | ||
surf_api.delete_surface_on_server() | ||
|
||
|
||
class GraphicsDefn( | ||
|
@@ -196,6 +188,70 @@ def allowed_values(self): | |
class plane_surface(metaclass=PyLocalObjectMeta): | ||
"""Plane surface data.""" | ||
|
||
def _availability(self, name): | ||
if name == "xy_plane": | ||
return self.creation_method() == "xy-plane" | ||
if name == "yz_plane": | ||
return self.creation_method() == "yz-plane" | ||
if name == "zx_plane": | ||
return self.creation_method() == "zx-plane" | ||
return True | ||
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. Plane surface creation. |
||
|
||
class creation_method(metaclass=PyLocalPropertyMeta): | ||
"""Creation Method.""" | ||
|
||
value: str = "xy-plane" | ||
|
||
@Attribute | ||
def allowed_values(self): | ||
"""Surface type allowed values.""" | ||
return ["xy-plane", "yz-plane", "zx-plane"] | ||
|
||
class xy_plane(metaclass=PyLocalObjectMeta): | ||
"""XY Plane.""" | ||
|
||
class z(metaclass=PyLocalPropertyMeta): | ||
"""Z value.""" | ||
|
||
value: float = 0 | ||
|
||
@Attribute | ||
def range(self): | ||
"""Z value range.""" | ||
return self._data_extractor.field_info().get_range( | ||
"z-coordinate", True | ||
) | ||
|
||
class yz_plane(metaclass=PyLocalObjectMeta): | ||
"""YZ Plane.""" | ||
|
||
class x(metaclass=PyLocalPropertyMeta): | ||
"""X value.""" | ||
|
||
value: float = 0 | ||
|
||
@Attribute | ||
def range(self): | ||
"""X value range.""" | ||
return self._data_extractor.field_info().get_range( | ||
"x-coordinate", True | ||
) | ||
|
||
class zx_plane(metaclass=PyLocalObjectMeta): | ||
"""ZX Plane.""" | ||
|
||
class y(metaclass=PyLocalPropertyMeta): | ||
"""Y value.""" | ||
|
||
value: float = 0 | ||
|
||
@Attribute | ||
def range(self): | ||
"""Y value range.""" | ||
return self._data_extractor.field_info().get_range( | ||
"y-coordinate", True | ||
) | ||
|
||
class iso_surface(metaclass=PyLocalObjectMeta): | ||
"""Iso surface data.""" | ||
|
||
|
@@ -292,7 +348,24 @@ class filled(metaclass=PyLocalPropertyMeta): | |
class node_values(metaclass=PyLocalPropertyMeta): | ||
"""Show nodal data.""" | ||
|
||
value: bool = True | ||
_value: bool = True | ||
|
||
@property | ||
def value(self): | ||
"""Node value property setter.""" | ||
filled = self._get_parent_by_type(ContourDefn).filled() | ||
auto_range_off = self._get_parent_by_type( | ||
ContourDefn | ||
).range.auto_range_off | ||
if not filled or ( | ||
auto_range_off and auto_range_off.clip_to_range() | ||
): | ||
self._value = True | ||
return self._value | ||
|
||
@value.setter | ||
def value(self, value): | ||
self._value = value | ||
|
||
class boundary_values(metaclass=PyLocalPropertyMeta): | ||
"""Show boundary values.""" | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
Class provides surface APIs i.e. create/delete surface.