Tutorial 2 - Workpiece 2
Goal
The goal of this tutorial is to partition workpiece2 into meshable blocks and generate a structured hexahedral mesh.
You will use HexaMSH to partition the CAD model and generate the mesh.
Before you begin
Download the CAD file here.
Open it from a prompt in a Python environment that contains HexaMSH:
Gmsh opens with the CAD model:
The aim is to partition the CAD model into meshable sub-volumes:
CAD partitioning
There are several ways to obtain this partitioning. This tutorial presents one possible workflow.
Create the first blocks
Use Split a volume by a point loop (L).
Select the points that define the loop, then double-click to finish the selection:
The operation splits the geometry and creates a new surface:
Repeat the same command on the next four points. This creates the first meshable block, shown in green:
Use Add a volume between two surfaces (D). Select the lower surface first, then the upper surface:
The command creates a new volume between the selected surfaces:
How is the volume created?
Three connecting surfaces already exist between the selected volumes. HexaMSH only needs to create the remaining surface, which produces a new sub-volume.
Repeat the command on the next two surfaces:
This creates another volume between the selected surfaces:
Separate the CAD with Split a volume by a point loop, selecting the four points shown below:
The operation splits the geometry and creates a new surface:
Repeat the operation on the upper points. First create two new points with Project a point on a curve (P):
Then project the second point:
Finally, split the volume with a point loop:
The operation splits the geometry and creates a new surface:
Project the point onto the curve shown below:
Now split the CAD into two parts with Split all volumes by a plane (3 points) (M). Select three points:
The result is:
Add a new volume with Add a volume between two surfaces:
The command directly creates three new meshable sub-volumes:
Repeat the same command three times to create the remaining volumes:
The result is:
Use Merge two surfaces (V) to simplify the CAD:
Create a new volume in two steps:
- Project points onto curves:
- Split the volume with a point loop:
The last operation creates a wedge, which cannot be meshed with the transfinite methods.
Use Split a wedge volume (I) and select the two triangular faces:
This generates meshable sub-volumes inside the wedge:
Add a volume between the two surfaces shown below:
The result is:
Finally, use the same feature to split the remaining orange volume in that region:
The result is:
Propagate the four surfaces vertically down to the CAD ground:
The result is:
Play with views and geometry display
At any time, we can hide/show the green and orange volumes using the view options in the left pannel:
We can also use the Gmsh options to hide/show surfaces (alt + S), curves (alt + L) and points (alt + P) for a better visibility.
Partition the other side
Repeat the same strategy for the matching shape on the other side of the CAD model:
Follow the same sequence:
- Split vertically to create a wedge:
- Split the wedge:
- Add volumes to create meshable blocks.
A projection can create an unwanted split
Projecting points can sometimes create unwanted points when geometries intersect:
Instead, use Add a point on a curve. Adjust the ratio, select the curves to split, and double-click to finish the selection. Adjust the ratio again if needed, then press E to validate the split.
Then split the volume with a point loop. This produces a cleaner, meshable split:
Undo an unexpected operation
Use Back to previous CAD to revert an operation. The keyboard shortcut is Ctrl + Z.
The partitioned model should now look like this:
Partition around the hole
Split the CAD around the hole:
Use the following commands in sequence to create this partition:
Combine features to complete the partitioning
HexaMSH often requires a combination of features. For the result above, use Add a volume between two surfaces for most operations. For the final split, use Add a point on a curve:
Then split the volume with a point loop.
Project the point onto the curve shown below:
Split the CAD with an infinite plane by selecting three points:
Propagate the pocket
Propagate the pocket down to the ground:
Use Project surface onto surface (S) to generate a new volume. Select the upper surface first, then the ground surface:
Split the CAD by projecting points onto curves and then using Split a volume by a point loop:
The result is:
A point loop can contain more than four points
Some point loops contain five points here. Select all five points to split the CAD correctly.
Create the next split to force surfaces with four curves:
Partition this part:
The result is:
Split the volume at the location shown below:
The result is:
Split the next volume at the location shown below:
The result is:
Finally, split the full CAD with an infinite plane defined by three points:
Split the pocket at the location shown below:
The result is:
Remove the orange surface created by the infinite-plane split with Remove surfaces (R), double-click to finish the selection:
Change the surface view
Press Alt + T to switch to the solid surface view:
wireframe view is more suitable for editing the CAD. Press Alt + T again to return to it.
The model is now fully meshable: all volumes appear green.
Mesh generation
Click Mesh CAD at the bottom of the left panel to generate a structured hexahedral mesh:
By default, five nodes are assigned to every edge. To use three nodes on selected edges, use Set number of nodes on edges:
To assign n nodes to a group of wider edges, use Set number of nodes on all edges. Set the number, select the edges, and double-click to finish the selection.
You only need to select one edge. HexaMSH automatically applies the same number of nodes to the opposite edges, which appear green. The mesh updates immediately:
Once the node counts are correct, close the Gmsh window. HexaMSH writes the result to a .msh file.