Skip to content

Tutorial 1 - Workpiece 1

Goal

The goal of this tutorial is to partition workpiece1 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:

hexamsh workpiece1.brep

Gmsh opens with the CAD model:

tuto_1_intro

The aim is to partition the CAD model into meshable sub-volumes:

tuto_1_intro_end

CAD partitioning

There are several ways to obtain this partitioning. This tutorial presents one possible workflow.

Create the first blocks

Use Project a point on a curve (P). Select the point to project, then select the curves to split. Double-click to finish the selection. Right-click to remove an entity from the selections.

tuto_1_click_projection_point

The point is projected onto the two curves shown below:

tuto_1_proj_1

The operation creates two new points and splits the curves:

tuto_1_projected_point_1

Entities selection and unselection

Right-click a selected entity to remove it from the selection. Double-click with the left mouse button to finish selecting.

Next, use Split a volume by a point loop (L).

Select the points that define a loop. The direction does not matter, but the points must form a closed loop. Double-click to finish the selection. Right-click to remove an entity from the selections.

tuto_1_split_point_loop_selection

This creates the first meshable block, shown in green:

tuto_1_first_block

The goal is for every block to be meshable, so all blocks should appear green.

Repeat the same feature to create a second block:

tuto_1_split_2

This creates a second meshable block:

tuto_1_split_2_done

Project points onto the vertical edges shown below:

tuto_1_projection_point_2

The result is:

tuto_1_projection_point_2_done

Then split the CAD with a point loop:

tuto_1_block_3

Split the upper section

Split the upper section into two parts with Split all volumes by a plane (3 points) (M). Select three points:

tuto_1_3_points_split

The CAD is split by an infinite plane:

tuto_1_3_points_split_done

Infinite-plane split

This operation works because the fourth point around the cylindrical hole is aligned with the other three points. Otherwise, the split would create a new point.

Project an upper point onto the lower edge to create the partition around the fillet:

tuto_1_projection_point_3

This creates three points that define a new infinite plane:

tuto_1_projection_point_3_done

Define the infinite plane that splits the CAD:

tuto_1_3_points_split_2

The new partition creates additional blocks:

tuto_1_3_points_split_2_done

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:

view_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.

Split around the cylinder

Finally, split the CAD around the cylinder:

tuto_1_split_around_cylinder

Project the corresponding points onto the cylinder edges. There are eight points to project. Then split the volumes with four point loops, each containing four points.

First block:

tuto_1_final_blocks_1

Second block:

tuto_1_final_blocks_2

Third block:

tuto_1_final_blocks_3

Fourth block:

tuto_1_final_blocks_4

The model is now fully meshable: all volumes appear green.

Mesh generation

Click Mesh CAD at the bottom of the left panel:

tuto_1_mesh_cad

HexaMSH generates a transfinite mesh on the partitioned geometry:

tuto_1_meshed

By default, five nodes are assigned to every edge. To use six nodes on selected edges, use Set number of nodes on edges:

tuto_1_set_6_nodes

To assign three nodes to a group of narrow edges, use Set number of nodes on all edges. Set the number to 3, select the edges, and double-click to finish the selection. Right-click to remove an entity from the selections.

tuto_1_set_3_nodes

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:

tuto_1_new_mesh

Once the node counts are correct, close the Gmsh window. HexaMSH writes the result to a .msh file.