From 5fe273b0a69720be091850cce24902c385ba0cbc Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Fri, 21 Jun 2024 12:29:22 +0530 Subject: [PATCH 1/4] build: Bump version to v0.11.dev0 --- pyproject.toml | 5 ++--- tests/test_metadata.py | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fa072a17..7cee3c2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] # Check https://python-poetry.org/docs/pyproject/ for all available sections name = "ansys-fluent-visualization" -version = "0.10.dev0" +version = "0.11.dev0" description = "A python wrapper for ansys Fluent visualization" license = "MIT" authors = ["ANSYS, Inc. "] @@ -25,11 +25,10 @@ packages = [ [tool.poetry.dependencies] python = ">=3.9,<4.0" importlib-metadata = {version = "^4.0", python = "<3.9"} -ansys-fluent-core = "~=0.21.dev1" +ansys-fluent-core = "~=0.22.dev0" vtk = ">=9.3.0.rc0" pyvista = ">=0.39.0" pyvistaqt = ">=0.7.0" -pyside6 = ">=6.2.3" matplotlib = ">=3.5.1" requests = "==2.31.0" diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 4aea85c9..239d8b47 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -2,4 +2,4 @@ def test_pkg_version(): - assert __version__ == "0.10.dev0" + assert __version__ == "0.11.dev0" From 0b8d4537252bc2d784e4ed79fe7bb911af79d262 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Tue, 10 Dec 2024 17:55:17 +0530 Subject: [PATCH 2/4] doc: Add example for meshing mode. --- examples/00-postprocessing/meshing_session.py | 127 ++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 examples/00-postprocessing/meshing_session.py diff --git a/examples/00-postprocessing/meshing_session.py b/examples/00-postprocessing/meshing_session.py new file mode 100644 index 00000000..1b4122a2 --- /dev/null +++ b/examples/00-postprocessing/meshing_session.py @@ -0,0 +1,127 @@ +""".. _ref_meshing_session: + +Postprocessing mesh +------------------- +This example uses PyVista and Matplotlib to demonstrate PyFluent +postprocessing capabilities. The 3D model in this example +is a mixing elbow that is being meshed, and you can plot it real time. + +""" + +from ansys.fluent.visualization import set_config + +set_config(blocking=False, set_view_on_display="isometric") + +import ansys.fluent.core as pyfluent +from ansys.fluent.core import examples + +from ansys.fluent.visualization.graphics.graphics_windows_manager import ( + FieldDataType, + graphics_windows_manager, +) +from ansys.fluent.visualization.pyvista import Graphics + +meshing = pyfluent.launch_fluent(mode="meshing", ui_mode="gui") +session_id = meshing._fluent_connection._id +graphics = Graphics(session=meshing) +mesh = graphics.Meshes["mesh-1"] + +active_window = None +active_window_id = None + +import_file_name = examples.download_file("mixing_elbow.pmdb", "pyfluent/mixing_elbow") + + +def open_window(window_id): + global active_window, active_window_id + active_window_id = window_id + graphics_windows_manager.open_window(window_id) + active_window = graphics_windows_manager.get_window(window_id) + active_window.post_object = mesh + active_window.overlay = True + + +mesh_data = {} +overlay = True + + +def plot_mesh(index, field_name, data): + raise RuntimeError("*****") + global mesh_data, active_window, overlay + if active_window is None: + return + if data is not None: + if index in mesh_data: + mesh_data[index].update({field_name: data}) + else: + mesh_data[index] = {field_name: data} + if "vertices" in mesh_data[index] and "faces" in mesh_data[index]: + active_window.set_data(FieldDataType.Meshes, mesh_data) + graphics_windows_manager.refresh_windows( + session_id, [active_window_id], overlay=overlay + ) + mesh_data = {} + overlay = True + else: + overlay = False + + +meshing.fields.field_data_streaming.register_callback(plot_mesh) +meshing.fields.field_data_streaming.start(provideBytesStream=True, chunkSize=1024) + +open_window("w0") + +### +mesh.show_edges = False +meshing.workflow.InitializeWorkflow(WorkflowType="Watertight Geometry") + +meshing.workflow.TaskObject["Import Geometry"].Arguments = { + "FileName": import_file_name, + "LengthUnit": "in", +} +meshing.workflow.TaskObject["Import Geometry"].Execute() + +mesh.show_edges = True +meshing.workflow.TaskObject["Add Local Sizing"].AddChildToTask() +meshing.workflow.TaskObject["Add Local Sizing"].Execute() + +#### +meshing.workflow.TaskObject["Generate the Surface Mesh"].Arguments = { + "CFDSurfaceMeshControls": {"MaxSize": 0.1} +} +meshing.workflow.TaskObject["Generate the Surface Mesh"].Execute() + +meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks( + SetupTypeChanged=False +) +meshing.workflow.TaskObject["Describe Geometry"].Arguments = { + "SetupType": "The geometry consists of only fluid regions with no voids" +} +meshing.workflow.TaskObject["Describe Geometry"].UpdateChildTasks(SetupTypeChanged=True) +meshing.workflow.TaskObject["Describe Geometry"].Execute() +meshing.workflow.TaskObject["Update Boundaries"].Arguments = { + "BoundaryLabelList": ["wall-inlet"], + "BoundaryLabelTypeList": ["wall"], + "OldBoundaryLabelList": ["wall-inlet"], + "OldBoundaryLabelTypeList": ["velocity-inlet"], +} +meshing.workflow.TaskObject["Update Boundaries"].Execute() + +### +meshing.workflow.TaskObject["Update Regions"].Execute() + +meshing.workflow.TaskObject["Add Boundary Layers"].AddChildToTask() +meshing.workflow.TaskObject["Add Boundary Layers"].InsertCompoundChildTask() +meshing.workflow.TaskObject["smooth-transition_1"].Arguments = { + "BLControlName": "smooth-transition_1", +} +meshing.workflow.TaskObject["Add Boundary Layers"].Arguments = {} +meshing.workflow.TaskObject["smooth-transition_1"].Execute() + +meshing.workflow.TaskObject["Generate the Volume Mesh"].Arguments = { + "VolumeFill": "poly-hexcore", + "VolumeFillControls": { + "HexMaxCellLength": 0.3, + }, +} +meshing.workflow.TaskObject["Generate the Volume Mesh"].Execute() From 744d3fc5a616a9b74e7ff7041115a24892a62780 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee Date: Tue, 10 Dec 2024 18:00:56 +0530 Subject: [PATCH 3/4] Ignore doc gen for this example. --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index c5a7204f..2cf4dddb 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -164,7 +164,7 @@ def _stop_fluent_container(gallery_conf, fname): "filename_pattern": r"\.py", # Disabled example scripts "ignore_pattern": r"script_manifold\.py|" - r"updated_script_manifold_example\.py|flycheck*", + r"updated_script_manifold_example\.py|meshing_session\.py|flycheck*", # Remove the "Download all examples" button from the top level gallery "download_all_examples": False, # Sort gallery example by file name instead of number of lines (default) From ddf58699209fc90de8318bdcf5e51df6ffeeb34b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Mar 2025 13:51:05 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/00-postprocessing/meshing_session.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/examples/00-postprocessing/meshing_session.py b/examples/00-postprocessing/meshing_session.py index 1b4122a2..e6a444da 100644 --- a/examples/00-postprocessing/meshing_session.py +++ b/examples/00-postprocessing/meshing_session.py @@ -1,3 +1,25 @@ +# Copyright (C) 2022 - 2025 ANSYS, Inc. and/or its affiliates. +# SPDX-License-Identifier: MIT +# +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + """.. _ref_meshing_session: Postprocessing mesh