Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions examples/00-post_processing/post_processing_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +307 to +310

mesh_obj_list = []

Expand Down Expand Up @@ -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}."
Expand All @@ -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()} "
Expand All @@ -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
Expand All @@ -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}."
Expand All @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand All @@ -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}."
Expand Down
Loading