Skip to content
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

Maint/add example for meshing mode #464

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5fe273b
build: Bump version to v0.11.dev0
prmukherj Jun 21, 2024
7da40a0
Merge branch 'main' into release/v0.11.dev0
prmukherj Jun 24, 2024
cd34356
Merge branch 'release/v0.11.dev0' of https://github.com/pyansys/pyflu…
prmukherj Jul 2, 2024
d17fb8a
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 8, 2024
fe41ed1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 9, 2024
de52b2e
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 16, 2024
9c7a215
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 24, 2024
616dea1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 19, 2024
30e5c5c
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 20, 2024
0d91d78
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 21, 2024
2a1d92f
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 28, 2024
03be4f5
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 5, 2024
14c2013
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 12, 2024
1c410d7
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 18, 2024
03972ed
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Oct 8, 2024
0850f17
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Oct 10, 2024
fab2277
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Oct 17, 2024
05faa31
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Nov 5, 2024
d363cb1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Nov 28, 2024
b9db616
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Nov 28, 2024
4b62bf5
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Nov 29, 2024
0b8d453
doc: Add example for meshing mode.
prmukherj Dec 10, 2024
744d3fc
Ignore doc gen for this example.
prmukherj Dec 10, 2024
7bce542
Merge branch 'main' into maint/add_example_for_meshing_mode
prmukherj Dec 20, 2024
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
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
127 changes: 127 additions & 0 deletions examples/00-postprocessing/meshing_session.py
Original file line number Diff line number Diff line change
@@ -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()
Loading