Skip to content

Commit

Permalink
Review new example (and skim old examples)
Browse files Browse the repository at this point in the history
  • Loading branch information
PipKat committed Nov 6, 2023
1 parent 5a0f6bb commit 62a78ce
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 118 deletions.
7 changes: 5 additions & 2 deletions examples/gallery/01_bracket_scaffold.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,12 @@
# Get the part summary.
# Display the model to show edges by connection.
# Use keyboard shortcuts to switch between
# the surface (s) and wireframe (w) representation.
# the surface (``s``) and wireframe (``w``) representations.
# Color code for edge connectivity:
# Red: free; Black: double; Purple: triple.
#
# - Red: free
# - Black: double
# - Purple: triple

part = model.get_part_by_name('bracket_mid_surface-3')
part_summary_res = part.get_summary(prime.PartSummaryParams(model, print_mesh=False))
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/02_lucid_mixing_elbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
~~~~~~~~~
This example meshes a mixing elbow with polyhedral elements and wall boundary
layer refinement. You use several meshing utilities available in the ``lucid`` class for
layer refinement. It uses several meshing utilities available in the ``lucid`` class for
convenience and ease.
.. image:: ../../../images/elbow.png
Expand Down Expand Up @@ -68,7 +68,7 @@
# Surface mesh
# ~~~~~~~~~~~~
# Surface mesh the geometry setting minimum and maximum sizing
# to be used for curvature refinement.
# to use for curvature refinement.

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

Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/03_lucid_pipe_tee.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
# Read and display the geometry file.
# The file contains several unmeshed parts, which is what you would get after you
# import from a CAD file.
# For Windows OS users, scdoc is also available:
# pipe_tee = prime.examples.download_pipe_tee_scdoc()
# For Windows OS users, the SCDOC format is also available:
# ``pipe_tee = prime.examples.download_pipe_tee_scdoc()``
pipe_tee = prime.examples.download_pipe_tee_fmd()
mesh_util.read(pipe_tee)

Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/04_lucid_toy_car.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
# Coarse wrap to close the holes and delete the originals.
# You could use leakage detection to close these regions.
# This example uses a coarse wrap and disables feature edge refinement to walk over the holes.
# As this is not the final wrap, the example does not remesh after the wrap.
# As this is not the final wrap, this example does not remesh after the wrap.
# Wrapping each object in turn avoids coarse wrap bridging across narrow gaps.

coarse_wrap = {"cabin": 1.5, "exhaust": 0.6, "engine": 1.5}
Expand Down Expand Up @@ -156,7 +156,7 @@
# The last label in the list wins.
# Providing no ``label_expression`` flattens all labels into zones.
# For example, if ``LabelA`` and ``LabelB`` are overlapping, three zones are
# createdL ``LabelA``, ``LabelB``, and ``LabelA_LabelB``.
# created: ``LabelA``, ``LabelB``, and ``LabelA_LabelB``.

mesh_util.create_zones_from_labels()

Expand Down
25 changes: 12 additions & 13 deletions examples/gallery/05_pcb_stacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
Objective
~~~~~~~~~~
In this example, you can mesh the solids of a printed circuit board,
using the volume sweeper, for a structural thermal analysis
using predominantly hexahedral elements.
This example uses the volume sweeper to mesh the solids of a printed circuit board for a
structural thermal analysis using predominantly hexahedral elements.
.. image:: ../../../images/pcb_stacker.png
:align: center
Expand All @@ -25,7 +24,7 @@
* Read the CAD geometry.
* Create a base face, projecting edge loops and imprinting to capture the geometry.
* Surface mesh the base face with quad elements.
* Stack the base face mesh through the volumes to create mainly hexahedral volume mesh.
* Stack the base face mesh through the volumes to create a mainly hexahedral volume mesh.
* Write the mesh for the structural thermal analysis.
"""

Expand All @@ -49,15 +48,15 @@
###############################################################################
# Import geometry
# ~~~~~~~~~~~~~~~
# Download the pcb geometry file (.pmdat).
# Import geometry.
# Display imported geometry. Purple edges indicate that the geometry is
# Download the PCB geometry (PMDAT) file.
# Import the geometry.
# Display the imported geometry. Purple edges indicate that the geometry is
# connected and the topology is shared between the different volumes.
# This will mean the mesh will also be connected between volumes.
# This means that the mesh is also to be connected between volumes.

# For Windows OS users scdoc is also available.
# In order to read the geometry as connected with shared topology
# the WORKBENCH cad reader route must be used:
# For Windows OS users, SCDOC files are also available.
# To read the geometry as connected with shared topology, you must use
# the Workbench ``CadReaderRoute``:

# mesh_util.read(
# file_name=prime.examples.download_pcb_scdoc(),
Expand All @@ -83,7 +82,7 @@
#
# Create the base face from the part and volumes.
# Define a label for the generated base faces and display.
# When coloured by ZONELET the display shows the imprints
# When coloured by zonelet, the display shows the imprints
# on the base face.

part = model.parts[0]
Expand Down Expand Up @@ -128,7 +127,7 @@
###############################################################################
# Stack base face
# ~~~~~~~~~~~~~~~~~~~~~~
# Create mainly hexahedral volume mesh using the stacker method.
# Create a mainly hexahedral volume mesh using the stacker method.
# Display the volume mesh.

stackbase_results = sweeper.stack_base_face(
Expand Down
4 changes: 2 additions & 2 deletions examples/gallery/06_blade_morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
~~~~~~~~~~
This example appends a CDB mesh with a CAD geometry
and match morphes the mesh to the geometry.
and match morphs the mesh to the geometry.
.. image:: ../../../images/turbine_blade.png
:align: center
Expand Down Expand Up @@ -81,7 +81,7 @@
# ~~~~~~~~~~~~~~~~
# Set the target type to be for topoface because the target is geometry.
# Morph the source face zonelets of ``source_part`` to the
# target topo faces of the geometry.
# target topofaces of the geometry.

morpher = prime.Morpher(model)
match_pair = prime.MatchPair(
Expand Down
14 changes: 7 additions & 7 deletions examples/gallery/07_saddle_bracket.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Objective
~~~~~~~~~
To create a mainly hexahedral mesh on a thin solid volume.
This example creates a mainly hexahedral mesh on a thin solid volume.
.. image:: ../../../images/saddle_bracket.png
:align: center
Expand All @@ -23,7 +23,7 @@
* Launch Ansys Prime Server.
* Import the CAD geometry.
* Quad surface mesh the source face.
* Surface mesh the remaining unmeshed TopoFaces with tri.
* Surface mesh the remaining unmeshed TopoFaces with tri surface mesh.
* Delete the topology.
* Define volume meshing controls to use thin volume meshing.
* Volume mesh with hexahedral and prism cells.
Expand Down Expand Up @@ -145,11 +145,11 @@
# Specify source and target faces for the thin volume using imported labels.
# Set the number of layers of cells through the thickness of the thin solid to be 4.
# To create a fully hexahedral and prism mesh the side faces must be imprinted on
# the side faces. If needed, a buffer region at the sides of the volume can be
# defined where the volume fill type used for the volume mesh parameters will be
# used to infill. This is useful on more complex geometries, where it provides
# more robustness of the method. To create a buffer region set ``imprint_sides``
# to False and specify how many rings of cells to ignore at the sides
# the side faces. If needed, a buffer region at the sides of the volume can be
# defined where the volume fill type used for the volume mesh parameters is
# used to infill. This is useful on more complex geometries, where it provides
# more robustness of the method. To create a buffer region set ``imprint_sides``
# to ``False`` and specify how many rings of cells to ignore at the sides
# using ``n_ignore_rings``.

auto_mesh_params = prime.AutoMeshParams(model=model)
Expand Down
48 changes: 24 additions & 24 deletions examples/gallery/08_lucid_generic_f1_rear_wing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
Meshing a generic F1 car rear wing for external aero simulation
================================================================
**Summary**: This example showcases the process of generating a mesh for a generic F1 rear wing
**Summary**: This example demonstrates how to generate a mesh for a generic F1 rear wing
STL file model.
Objective
~~~~~~~~~~
The example demonstrates how to connect various parts of a rear wing from
a generic F1 car and volume mesh the resulting model using a poly-hexcore mesh containing prisms.
To simplify the process and enhance convenience, multiple meshing utilities provided in the
"lucid" class are used.
The example connects various parts of a rear wing from a generic F1 car
and volume meshes the resulting model using a poly-hexcore mesh containing prisms.
To simplify the process and enhance convenience, this example uses multiple
meshing utilities provided in the ``lucid`` class.
.. image:: ../../../images/generic_rear_wing.png
:align: center
Expand All @@ -30,11 +30,11 @@
* Use the connect operation to join the components together.
* Define local size controls on aero surfaces.
* Generate a surface mesh with curvature sizing.
* Compute volume zones and define fluid zone type.
* Define boundary layer definition.
* Compute volume zones and define the fluid zone type.
* Define the boundary layer.
* Generate a volume mesh using poly-hexcore elements and apply boundary layer refinement.
* Print statistics on the generated mesh.
* Write a `.cas` file for use in the Fluent solver.
* Write a CAS file for use in the Fluent solver.
* Exit the PyPrimeMesh session.
"""

Expand All @@ -59,7 +59,7 @@
###############################################################################
# Import geometry
# ~~~~~~~~~~~~~~~
# Download the generic F1 rear wing geometries (stl files).
# Download the generic F1 rear wing geometries (STL files).
# Import each geometry and append to the model.
# Display the imported geometry.

Expand All @@ -80,7 +80,7 @@
# Merge parts
# ~~~~~~~~~~~
# Establish the global size parameter to regulate mesh refinement.
# Merge all individual parts into a unified part named `f1_car_rear_wing`.
# Merge all individual parts into a unified part named ``f1_car_rear_wing``.

# Define global sizes
model.set_global_sizing_params(prime.GlobalSizingParams(model, min=4, max=32, growth_rate=1.2))
Expand All @@ -97,7 +97,7 @@
###############################################################################
# Mesh connect
# ~~~~~~~~~~~~
# In order to generate a volume mesh for a closed domain, it is necessary to ensure
# To generate a volume mesh for a closed domain, it is necessary to ensure
# that the components of the rear wing are properly connected.
# To achieve this, perform a connect operation using labels to join the components of
# the rear wing.
Expand All @@ -118,17 +118,17 @@
print(f"Total number of free edges present is {surf_report.n_free_edges}")

###############################################################################
# Define local size-control and generate size-field
# Define local size control and generate size-field
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# In order to accurately represent the physics of the DRS wing, a limitation of 8 mm
# To accurately represent the physics of the DRS wing, a limitation of 8 mm
# is imposed on the mesh size of the wing.
# This is accomplished by implementing curvature size control, which refines the
# This is accomplished by implementing a curvature size control, which refines the
# mesh according to the curvature of the DRS surfaces.
# Additionally, to accurately capture the curved surfaces of other sections of the
# wing, curvature control is defined with a normal angle of 18 degrees.
# These controls are used during surface mesh generation.
# A volumetric size-field is then computed based on the defined size controls.
# The volumetric size-field plays a crucial role in controlling
# A volumetric size field is then computed based on the defined size controls.
# The volumetric size field plays a crucial role in controlling
# the growth and refinement of the volume mesh.

# Local curvature size control for DRS
Expand Down Expand Up @@ -188,13 +188,13 @@
###############################################################################
# Define volume controls
# ~~~~~~~~~~~~~~~~~~~~~~
# In order to prevent the generation of a volume mesh within the solid wing,
# the type of a volume zone within the rear wing can be defined as "dead".
# To prevent the generation of a volume mesh within the solid wing,
# the type of a volume zone within the rear wing can be defined as "dead."
# To accomplish this, Volume Control is utilized to assign the type for the
# specific volume zone.
# Expressions are employed to define the volume zones that need to be filled, with
# "* !f1_rw_enclosure" indicating that it applies to all volume zones except
# for "f1_rw_enclosure".
# ``* !f1_rw_enclosure`` indicating that it applies to all volume zones except
# for ``f1_rw_enclosure``.

volume_control = model.control_data.create_volume_control()
volume_control.set_params(
Expand All @@ -213,7 +213,7 @@
# Define prism controls
# ~~~~~~~~~~~~~~~~~~~~~
# A prism control can be used to define inflation layers on the external aero surfaces.
# Specify the aero surfaces using labels, here prism scope is defined on zones associated
# Specify the aero surfaces using labels. Here prism scope is defined on zones associated
# with labels ``*drs*`` and ``*plane*``.
# The growth for the prism layer is controlled by defining the offset type to
# be ``uniform`` with a first height of 0.5mm .
Expand Down Expand Up @@ -283,21 +283,21 @@
# Print statistics on meshed part
print(part_summary_res)
print(
"\nMaximum inverse-orthoginal quality of the Volume Mesh : ",
"\nMaximum inverse-orthoginal quality of the volume mesh : ",
results.quality_results_part[0].max_quality,
)

# Mesh check
result = prime.VolumeMeshTool(model).check_mesh(part.id, params=prime.CheckMeshParams(model))
print("\nMesh Check", result, sep="\n")
print("\nMesh check", result, sep="\n")

scope = prime.ScopeDefinition(model, part_expression="*", label_expression="* !*enclosure*")
display(scope=scope)

###############################################################################
# Write mesh
# ~~~~~~~~~~
# Export as cas file for external aero simulations
# Export as CAS file for external aero simulations.

with tempfile.TemporaryDirectory() as temp_folder:
print(temp_folder)
Expand Down
Loading

0 comments on commit 62a78ce

Please sign in to comment.