Basic 3D geometry creation using Gmsh

This basic tutorial covers 3D geometries. Although, we have already covered the fundamentals of 2D geometries with Gmsh and the generation of the 3D geometry is quite similar (or identical), I want to mention a couple of attributes that might be of interest when modeling unbounded domains, i.e. air, water, etc.

Let’s start where we left off. We will start with the circle we have created in our previous post “Basic 2D Geometry Creation Using Gmsh“. This way we will showcase how to create a sphere. In the sphere case we can use the very first version of our circle as we will only need to create two additional points to create 3 intersecting circles. This can be done in one step in the .dat file:


Add two points to the circle and a Flag 

As we see above, we have also included another flag. Whenever we work in 3D, we can work with a solid domain or just with a shell surface. The first part of the script will be omitted as it’s the same as the one found in the circle .geo file:


Sphere .geo file

The Line Loop feature groups all the lines, which in this case are defined by the Circle (arches), and then to create the surfaces, we use the Ruled Surface feature which is meant to create surfaces from curved geometries. Finally we can create a volume, which in this case will be our solid geometry. Now, in Gmsh you only see line and surfaces even if you have created a volume. How can we know for sure that it is a solid volume? Go to the top menu, click Tools > Visibility  and a window with all the defined Elementary Entities will pop up.


Tools > Visibility

It’s clear that the volume has been created when we select the Sphere to be a solid and will be described by Volume 30, which we have defined in our .geo file.

So far we have covered most of the features under Add in the Geometry node. In 3D we will find other features useful such as: Translate, Rotate, etc. Let’s use Translate as an example. Going back to the circle example, we could just extrude it and create a cylinder. Depending on our modeling end goal, there are different types of extrusion. You can extrude: Points, Lines and Surfaces, creating Lines, Surfaces and Volumes respectively. Let’s extrude the lines that define our circle:


Extrude Line

The result will look something like this



Here we’ll see a couple of interesting facts. Note that the blue numbers represent the line labels and the gray ones the surfaces. So far we have created all geometries by entering numbers one by one in our text editor but here we have used the GUI. The first line we selected to be extruded was line 1, and that gives us a pattern that will be useful whenever we are creating more complicated geometries that need to be parametrized. The way the extrusion labels the lines is: top, right, left. Evidently, the numbering is a little odd as automatically there will be overlapping lines and surfaces which will be removed to avoid duplicates. Furthermore, we see that there have been generated 4 surfaces in addition to the bottom surface we initially generated when creating the circle. If we want to close our cylinder we need to go back to Geometry > Add > Plane Surface, and if we need a Volume, as long as you have a closed domain you can go to Geometry > Add > Volume and finalize the solid cylinder.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s