Mesh a mixing elbow for a flow analysis#

Summary: This example demonstrates how to mesh a mixing elbow for a flow analysis.

Objective#

This example meshes a mixing elbow with polyhedral elements and wall boundary layer refinement. It uses several meshing utilities available in the lucid class for convenience and ease.

Mixing elbow mesh.

Procedure#

  1. Launch Ansys Prime Server and instantiate meshing utilities from the lucid class.

  2. Import the geometry and create face zones from labels imported from the geometry.

  3. Surface mesh geometry with curvature sizing.

  4. Volume mesh with polyhedral elements and boundary layer refinement.

  5. Print statistics on the generated mesh.

  6. Write a CAS file for use in the Fluent solver.

  7. Exit the PyPrimeMesh session.

Launch Ansys Prime Server#

Import all necessary modules. Launch an instance of Ansys Prime Server. Connect the PyPrimeMesh client and get the model. Instantiate meshing utilities from the lucid class.

import os
import tempfile

from ansys.meshing import prime
from ansys.meshing.prime.graphics import PrimePlotter

prime_client = prime.launch_prime()
model = prime_client.model
mesh_util = prime.lucid.Mesh(model=model)
Using Ansys Prime Server from container ansys-prime-server-3

Import geometry#

Download the elbow geometry (FMD) file exported by SpaceClaim. Import the geometry. Create face zones from labels imported from the geometry for use in Fluent solver.

# For Windows OS users, scdoc is also available:
# mixing_elbow = prime.examples.download_elbow_scdoc()

mixing_elbow = prime.examples.download_elbow_fmd()

mesh_util.read(file_name=mixing_elbow)
mesh_util.create_zones_from_labels("inlet,outlet")

Surface mesh#

Surface mesh the geometry setting minimum and maximum sizing to use for curvature refinement.

mesh_util.surface_mesh(min_size=5, max_size=20)

Volume mesh#

Volume mesh with polyhedral elements and boundary layer refinement. Fill the volume with polyhedral and prism mesh specifying the location and number of layers for prisms. Use expressions to define the surfaces to have prisms grown where * !inlet !outlet states all not inlet or outlet.

mesh_util.volume_mesh(
    volume_fill_type=prime.VolumeFillType.POLY,
    prism_surface_expression="* !inlet !outlet",
    prism_layers=3,
)

# Display the mesh
pl = PrimePlotter(allow_picking=True)
pl.plot(model)
pl.show()
02 lucid mixing elbow

Write mesh#

Write a CAS file for use in the Fluent solver.

with tempfile.TemporaryDirectory() as temp_folder:
    mesh_file = os.path.join(temp_folder, "mixing_elbow.cas")
    mesh_util.write(mesh_file)
    assert os.path.exists(mesh_file)
    print("\nExported file:\n", mesh_file)
Exported file:
 /tmp/tmpkpkzfxbk/mixing_elbow.cas

Exit PyPrimeMesh#

prime_client.exit()

Total running time of the script: (0 minutes 18.480 seconds)

Gallery generated by Sphinx-Gallery