Skip to content

Commit

Permalink
FIX: Icepak Mesh Binary Tree (#5600)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Samuelopez-ansys and pre-commit-ci[bot] authored Dec 20, 2024
1 parent 87ca0cc commit 5ea9436
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 48 deletions.
2 changes: 1 addition & 1 deletion src/ansys/aedt/core/application/design.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def boundaries(self) -> List[BoundaryObject]:
del self._boundaries[k]
for boundary, boundarytype in zip(current_boundaries, current_types):
if boundary in self._boundaries:
self._boundaries[boundary]._initialize_bynary_tree()
self._boundaries[boundary]._initialize_tree_node()
continue
if boundarytype == "MaxwellParameters":
maxwell_parameter_type = self.get_oo_property_value(self.odesign, f"Parameters\\{boundary}", "Type")
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/aedt/core/modules/boundary/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def _get_args(self, props=None):
return arg

@pyaedt_function_handler()
def _initialize_bynary_tree(self):
def _initialize_tree_node(self):
if self._child_object:
BinaryTreeNode.__init__(self, self._name, self._child_object, False)
return True
Expand Down Expand Up @@ -222,7 +222,7 @@ def __init__(self, app, name, props=None, boundarytype=None, auto_update=True):
self.__props = BoundaryProps(self, props) if props else {}
self._type = boundarytype
self.auto_update = auto_update
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand Down Expand Up @@ -542,7 +542,7 @@ def create(self):
else:
return False

return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def update(self):
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/aedt/core/modules/boundary/hfss_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def __init__(self, app, component_name, props, component_type):
self._name = component_name
self.__props = BoundaryProps(self, props) if props else {}
self.auto_update = True
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand Down Expand Up @@ -138,7 +138,7 @@ def create(self):
self._app.oradfield.AddAntennaOverlay(self._get_args())
elif self.type == "FieldSourceGroup":
self._app.oradfield.AddRadFieldSourceGroup(self._get_args())
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def update(self):
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/aedt/core/modules/boundary/layout_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __init__(self, app, component_type, component_name, props):
self.native_properties = self.__props["NativeComponentDefinitionProvider"]
self.auto_update = True

self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand Down Expand Up @@ -218,7 +218,7 @@ def create(self):
self.excitation_name = a[0].split(":")[0]
except (GrpcApiError, IndexError):
self.excitation_name = self._name
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def update(self):
Expand Down Expand Up @@ -295,7 +295,7 @@ def __init__(self, app, name, props=None, boundarytype="Port"):
self.__props = BoundaryProps(self, props)
self.type = boundarytype
self.auto_update = True
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/aedt/core/modules/boundary/maxwell_boundary.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, app, name, props=None, boundarytype=None):
self.auto_update = True
self.__reduced_matrices = None
self.matrix_assignment = None
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def reduced_matrices(self):
Expand Down Expand Up @@ -177,7 +177,7 @@ def create(self):
self._app.o_maxwell_parameters.AssignLayoutForce(self._get_args())
else:
return False
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def update(self):
Expand Down
6 changes: 3 additions & 3 deletions src/ansys/aedt/core/modules/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def __init__(self, mesh, name, props, meshoptype):
self._type = meshoptype
self._name = name
self.auto_update = True
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand Down Expand Up @@ -259,7 +259,7 @@ def create(self):
self._mesh.omeshmodule.AssignCylindricalGapOp(self._get_args())
else:
return False
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def update(self, key_name=None, value=None):
Expand Down Expand Up @@ -405,7 +405,7 @@ def delete(self):
return True

@pyaedt_function_handler()
def _initialize_bynary_tree(self):
def _initialize_tree_node(self):
if self._child_object:
BinaryTreeNode.__init__(self, self._name, self._child_object, False)
return True
Expand Down
103 changes: 74 additions & 29 deletions src/ansys/aedt/core/modules/mesh_icepak.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ def __contains__(self, x):
return x in self.keys()


class MeshRegionCommon(object):
class MeshRegionCommon(BinaryTreeNode):
"""
Manages Icepak mesh region settings.
Expand All @@ -626,10 +626,26 @@ def __init__(self, units, app, name):
self._name = name
self._model_units = units
self._app = app
child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}")
self._initialize_tree_node()

if child_object:
BinaryTreeNode.__init__(self, self._name, child_object, False)
@property
def _child_object(self):
"""Object-oriented properties.
Returns
-------
class:`ansys.aedt.core.modeler.cad.elements_3d.BinaryTreeNode`
"""
child_object = None
design_childs = self._app.get_oo_name(self._app.odesign)

if "Mesh" in design_childs:
cc = self._app.get_oo_object(self._app.odesign, "Mesh")
cc_names = self._app.get_oo_name(cc)
if self._name in cc_names:
child_object = cc.GetChildObject(self._name)
return child_object

@abstractmethod
def update(self):
Expand All @@ -643,26 +659,58 @@ def delete(self):
def create(self):
"""Create the mesh region object."""

@pyaedt_function_handler()
def _initialize_tree_node(self):
if self._name == "Settings":
return True

if self._child_object:
child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}")
if child_object:
BinaryTreeNode.__init__(self, self._name, child_object, False)
return True
return False

# backward compatibility
def __getattr__(self, name):
if "settings" in self.__dict__ and name in self.__dict__["settings"]:
return self.__dict__["settings"][name]
elif name == "UserSpecifiedSettings":
return self.__dict__["manual_settings"]
else:
return self.__dict__[name]
try:
self.__getattribute__(name)
except AttributeError:
if "settings" in self.__dict__ and name in self.__dict__["settings"]:
return self.__dict__["settings"][name]
elif name == "UserSpecifiedSettings":
return self.__dict__["manual_settings"]
else:
return self.__dict__[name]

def __setattr__(self, name, value):
skip_properties = [
"manual_settings",
"settings",
"_name",
"_model_units",
"_app",
"_assignment",
"enable",
"name",
]
skip_properties_binary = [
"_props",
"_saved_root_name",
"_get_child_obj_arg",
"_node",
"child_object",
"auto_update",
"_children",
"_BinaryTreeNode__first_level",
]
if ("settings" in self.__dict__) and (name in self.settings):
self.settings[name] = value
elif name == "UserSpecifiedSettings":
self.__dict__["manual_settings"] = value
elif (
("settings" in self.__dict__)
and not (name in self.settings)
and name
not in ["manual_settings", "settings", "_name", "_model_units", "_app", "_assignment", "enable", "name"]
):
elif name in skip_properties_binary:
super(BinaryTreeNode, self).__setattr__(name, value)
elif ("settings" in self.__dict__) and not (name in self.settings) and name not in skip_properties:
self._app.logger.error(
f"Setting name {name} is not available. Available parameters are: {', '.join(self.settings.keys())}."
)
Expand Down Expand Up @@ -725,10 +773,7 @@ def create(self):
self.delete()
self.global_region = Region(self._app)
self.global_region.create(self.padding_types, self.padding_values)
child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}")

if child_object:
BinaryTreeNode.__init__(self, self._name, child_object, False)
return self._initialize_tree_node()


class MeshRegion(MeshRegionCommon):
Expand Down Expand Up @@ -796,6 +841,8 @@ def name(self):
-------
str
"""
if self._child_object:
self._name = str(self.properties["Name"])
return self._name

@name.setter
Expand All @@ -812,7 +859,8 @@ def name(self, value):
)
self._app.modeler.refresh()
self._name = value
if isinstance(self.assignment, SubRegion):
result = self._initialize_tree_node()
if isinstance(self.assignment, SubRegion) and result:
self._assignment = self.assignment

@pyaedt_function_handler
Expand All @@ -834,7 +882,7 @@ def update(self):
args += ["UserSpecifiedSettings:=", self.manual_settings]
try:
self._app.omeshmodule.EditMeshRegion(self.name, args)
return True
return self._initialize_tree_node()
except GrpcApiError: # pragma : no cover
return False

Expand Down Expand Up @@ -934,13 +982,10 @@ def create(self):
self._app.omeshmodule.AssignMeshRegion(args)
self._app.mesh.meshregions.append(self)
self._app.modeler.refresh_all_ids()
self._assignment = self.assignment
child_object = self._app.get_oo_object(self._app.odesign, f"Mesh/{self._name}")

if child_object:
BinaryTreeNode.__init__(self, self._name, child_object, False)

return True
result = self._initialize_tree_node()
if result:
self._assignment = self.assignment
return result

# backward compatibility
@property
Expand Down
10 changes: 5 additions & 5 deletions src/ansys/aedt/core/modules/solve_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def __init__(self, app, solution_type, name="MySetupAuto", is_new_setup=True):
self._is_new_setup = is_new_setup
# self._init_props(is_new_setup)
self.auto_update = True
self._initialize_bynary_tree()
self._initialize_tree_node()

@property
def _child_object(self):
Expand All @@ -94,7 +94,7 @@ def _child_object(self):
return child_object

@pyaedt_function_handler()
def _initialize_bynary_tree(self):
def _initialize_tree_node(self):
if self._child_object:
BinaryTreeNode.__init__(self, self._name, self._child_object, False)
return True
Expand Down Expand Up @@ -569,7 +569,7 @@ def create(self):
arg = ["NAME:" + self._name]
_dict2arg(self.props, arg)
self.omodule.InsertSetup(soltype, arg)
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler(update_dictionary="properties")
def update(self, properties=None):
Expand Down Expand Up @@ -1172,7 +1172,7 @@ def create(self):
arg = ["NAME:SimSetup"]
_dict2arg(self.props, arg)
self._setup(soltype, arg)
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler()
def _setup(self, soltype, arg, newsetup=True):
Expand Down Expand Up @@ -1913,7 +1913,7 @@ def create(self):
arg = ["NAME:" + self.name]
_dict2arg(self.props, arg)
self.omodule.Add(arg)
return self._initialize_bynary_tree()
return self._initialize_tree_node()

@pyaedt_function_handler(update_dictionary="properties")
def update(self, properties=None):
Expand Down
4 changes: 4 additions & 0 deletions src/ansys/aedt/core/visualization/report/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, report_setup, trace_name, oo=None):
@pyaedt_function_handler()
def _initialize_tree_node(self):
BinaryTreeNode.__init__(self, self.line_name, self._oo, False)
return True

@pyaedt_function_handler()
def _change_property(self, props_value):
Expand Down Expand Up @@ -259,6 +260,7 @@ def __init__(
@pyaedt_function_handler()
def _initialize_tree_node(self):
BinaryTreeNode.__init__(self, self.aedt_name, self._oo, False)
return True

@property
def curve_properties(self):
Expand Down Expand Up @@ -419,6 +421,8 @@ def _initialize_tree_node(self):
oo = self._post.oreportsetup.GetChildObject(self._legacy_props["plot_name"])
if oo:
BinaryTreeNode.__init__(self, self._legacy_props["plot_name"], oo, False)
return True
return False

@property
def __all_props(self):
Expand Down

0 comments on commit 5ea9436

Please sign in to comment.