diff --git a/examples/00-post_processing/post_processing_context_manager.py b/examples/00-post_processing/post_processing_context_manager.py index 214bd74e..4a57a27a 100644 --- a/examples/00-post_processing/post_processing_context_manager.py +++ b/examples/00-post_processing/post_processing_context_manager.py @@ -105,6 +105,7 @@ processor_count=2, start_transcript=False, mode=pyfluent.FluentMode.SOLVER, + ui_mode="gui", ) solver_session.settings.file.read_case(file_name=import_case) @@ -115,10 +116,16 @@ # Create a graphics object for the mesh display. graphics_window = GraphicsWindow() - mesh = Mesh(show_edges=True, surfaces=WallBoundaries()) + mesh = Mesh( + solver=solver_session, + show_edges=True, + surfaces=WallBoundaries(settings_source=solver_session), + ) graphics_window.add_graphics(mesh, position=(0, 0)) - mesh = Mesh(surfaces=WallBoundaries()) + mesh = Mesh( + solver=solver_session, surfaces=WallBoundaries(settings_source=solver_session) + ) graphics_window.add_graphics(mesh, position=(0, 1)) graphics_window.show() @@ -128,28 +135,28 @@ graphics_window = GraphicsWindow() surf_xy_plane = PlaneSurface.create_from_point_and_normal( - point=[0.0, 0.0, -0.0441921], normal=[0.0, 0.0, 1.0] + solver=solver_session, point=[0.0, 0.0, -0.0441921], normal=[0.0, 0.0, 1.0] ) graphics_window.add_graphics(surf_xy_plane, position=(0, 0)) surf_yz_plane = PlaneSurface.create_from_point_and_normal( - point=[-0.174628, 0.0, 0.0], normal=[1.0, 0.0, 0.0] + solver=solver_session, point=[-0.174628, 0.0, 0.0], normal=[1.0, 0.0, 0.0] ) graphics_window.add_graphics(surf_yz_plane, position=(0, 1)) surf_zx_plane = PlaneSurface.create_from_point_and_normal( - point=[0.0, -0.0627297, 0.0], normal=[0.0, 1.0, 0.0] + solver=solver_session, point=[0.0, -0.0627297, 0.0], normal=[0.0, 1.0, 0.0] ) graphics_window.add_graphics(surf_zx_plane, position=(0, 2)) # Create XY, YZ and ZX plane-surface objects and display. - surf_xy_plane = PlaneSurface.create_xy_plane(z=-0.0441921) + surf_xy_plane = PlaneSurface.create_xy_plane(solver=solver_session, z=-0.0441921) graphics_window.add_graphics(surf_xy_plane, position=(1, 0)) - surf_yz_plane = PlaneSurface.create_yz_plane(x=-0.174628) + surf_yz_plane = PlaneSurface.create_yz_plane(solver=solver_session, x=-0.174628) graphics_window.add_graphics(surf_yz_plane, position=(1, 1)) - surf_zx_plane = PlaneSurface.create_zx_plane(y=-0.0627297) + surf_zx_plane = PlaneSurface.create_zx_plane(solver=solver_session, y=-0.0627297) graphics_window.add_graphics(surf_zx_plane, position=(1, 2)) graphics_window.show() diff --git a/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py b/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py index 7378fadd..b90e132b 100644 --- a/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py +++ b/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py @@ -303,6 +303,11 @@ def _display_vector(self, obj, obj_dict): field = obj.field() field_unit = obj._api_helper.get_field_unit(field) field = f"{field}\n[{field_unit}]" if field_unit else field + clean_field = field.replace("\n", " ") + try: + scalar_bar_args["title"] = clean_field + except (NameError, UnboundLocalError): + pass mesh_obj_list = [] @@ -357,7 +362,6 @@ def _display_vector(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") vect_title = obj_dict.get("title") _mesh_dict["title"] = ( f"{vectors_of.capitalize()} " f"vectors colored by {clean_field}." @@ -377,7 +381,6 @@ def _display_vector(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") vect_title = obj_dict.get("title") _mesh_dict["title"] = ( f"{vectors_of.capitalize()} " @@ -395,10 +398,12 @@ def _display_pathlines(self, obj, obj_dict): field = obj.field() field_unit = obj._api_helper.get_field_unit(field) field = f"{field}\n[{field_unit}]" if field_unit else field + clean_field = field.replace("\n", " ") # scalar bar properties try: scalar_bar_args = self.renderer._scalar_bar_default_properties() + scalar_bar_args["title"] = clean_field except AttributeError: # In case 2d renderer is selected, the above will not be available. pass @@ -425,7 +430,6 @@ def _display_pathlines(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") path_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Pathlines colored by {clean_field}." @@ -444,6 +448,7 @@ def _display_contour(self, obj, obj_dict): field = obj.field() field_unit = obj._api_helper.get_field_unit(field) field = f"{field}\n[{field_unit}]" if field_unit else field + clean_field = field.replace("\n", " ") range_option = obj.range.option() filled = obj.filled() contour_lines = obj.contour_lines() @@ -452,6 +457,7 @@ def _display_contour(self, obj, obj_dict): # scalar bar properties try: scalar_bar_args = self.renderer._scalar_bar_default_properties() + scalar_bar_args["title"] = clean_field except AttributeError: # In case 2d renderer is selected, the above will not be available. pass @@ -493,7 +499,6 @@ def _display_contour(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -514,7 +519,6 @@ def _display_contour(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -539,7 +543,6 @@ def _display_contour(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -556,7 +559,6 @@ def _display_contour(self, obj, obj_dict): _mesh_dict = {"data": mesh.contour(isosurfaces=20)} _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -581,7 +583,6 @@ def _display_contour(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -598,7 +599,6 @@ def _display_contour(self, obj, obj_dict): _mesh_dict = {"data": mesh.contour(isosurfaces=20)} _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -620,7 +620,6 @@ def _display_contour(self, obj, obj_dict): } _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}." @@ -637,7 +636,6 @@ def _display_contour(self, obj, obj_dict): _mesh_dict = {"data": mesh.contour(isosurfaces=20)} _mesh_dict["kwargs"] = {} if obj_dict is not None: - clean_field = field.replace("\n", " ") cont_title = obj_dict.get("title") _mesh_dict["title"] = ( f"Contour of {clean_field}."