-
Notifications
You must be signed in to change notification settings - Fork 4
Maint/add example for meshing mode #464
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
Open
prmukherj
wants to merge
26
commits into
main
Choose a base branch
from
maint/add_example_for_meshing_mode
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
5fe273b
build: Bump version to v0.11.dev0
prmukherj 7da40a0
Merge branch 'main' into release/v0.11.dev0
prmukherj cd34356
Merge branch 'release/v0.11.dev0' of https://github.com/pyansys/pyflu…
prmukherj d17fb8a
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj fe41ed1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj de52b2e
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 9c7a215
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 616dea1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 30e5c5c
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 0d91d78
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 2a1d92f
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 03be4f5
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 14c2013
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 1c410d7
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 03972ed
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 0850f17
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj fab2277
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 05faa31
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj d363cb1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj b9db616
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 4b62bf5
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj 0b8d453
doc: Add example for meshing mode.
prmukherj 744d3fc
Ignore doc gen for this example.
prmukherj 7bce542
Merge branch 'main' into maint/add_example_for_meshing_mode
prmukherj d2f058c
Merge branch 'main' into maint/add_example_for_meshing_mode
prmukherj ddf5869
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
# 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 | ||
------------------- | ||
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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prmukherj The complex logic here deserves some explanatory comments.