Friday, December 13, 2013

Code_Aster, Gmsh and Salome are all together in one book

Recently, this post from Gmsh's mailing list announced a publication of a new book dedicated to such numerical modeling tools as Code_Aster, Gmsh and Salome. The book's title is "Beginning with Code_Aster. A practical introduction to finite element method using Code_Aster, Gmsh and Salome". It's available for free downloading from the publisher site.

Monday, December 3, 2012

Gmsh. Funny detail

Trying to build Gmsh from its sources on different machines, I have spent a lot of time reading CMakeLists.txt file, that contains descriptions for configuring project with CMake. I have read this file for different Gmsh versions, starting 2.4.2 up to several developing versions after 2.5.1. And I found some funny text, that is worth looking at.

Here is a piece of the CMakeLists.txt from Gmsh 2.4.2

  # remove really annoying (and stupid, and wrong) warning about
  # bool/int cast performance in Visual C++
  set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800)")

Now let's look at the CMakeLists.txt from Gmsh 2.5.1

  # remove annoying warning about bool/int cast performance
  set(GMSH_CONFIG_PRAGMAS "#pragma warning(disable:4800)")
  # <...>
  # some new commands were added
  # <...>

Did you notice the difference in the commentaries before setting GMSH_CONFIG_PRAGMAS for building with Microsoft's compiler?
In the newer versions we see that Gmsh's authors became more tolerate to Microsoft's product. Good to know :)

Thursday, August 30, 2012

Gmsh tasting

Gmsh is a mesh generator, but it permits to create geometry too. However there are some limitations for that. For example, you cannot create shapes that intersect each other. This feature rises from the way that Gmsh uses to define geometry. The process of geometry creation is sequential. At first you should define points, then lines, and so on. The full list of entities, that you should determine to create 3D model is here:
  1. points
  2. lines
  3. line loops
  4. surfaces
  5. surface loops
  6. volumes
Therefore to define intersecting shapes you should calculate points of intersecting surfaces, define lines, etc. So the process is difficult. That's why for complex models you need to use any third-party CAD software. For example,
To bind the model from these packages with Gmsh, you need to export geometry in one of OpenCascade formats (BRep, STEP or IGES, but note that IGES format is not recommended), or any other compatible to Gmsh format (STL, etc). Then you can load such model into Gmsh just typing in command line

$ gmsh model.brep

Note, that in some cases you'll need to turn off two options to see the model. They are "Remove small edges" and "Remove small faces" on Options -> Geometry -> General of GUI

Or write in geometry file (model.geo):

Merge "model.brep";
Geometry.OCCFixSmallEdges=0; // Remove small edges from GUI
Geometry.OCCFixSmallFaces=0; // Remove small faces from GUI
Mesh.CharacteristicLengthFactor = 0.5; // any actions with model

In this case Gmsh is launched:

$ gmsh model.geo

There is one additional feature: to load OpenCascade models, Gmsh should be built with OCCT support. And a little hint: if any of presented packages doesn't export a model in OCCT format, you can save it in some CAD format and then use CAD Exchanger for converting.

Wednesday, August 15, 2012

Gmsh launching

I would like to say several words about Gmsh launching. If you want to start Gmsh without any input arguments, for example, by double-clicking on its icon (in systems with desktop environment), or typing only

$ path_to_gmsh_bin_directory/gmsh

in the command line (using Terminal in Unix-like systems, or, for example, Total Commander in Windows systems), in all these cases, you might face some problems. Being launched without input parameters, Gmsh creates a default file "untitled.geo", and uses it as an input argument. For Windows7 this file is created here


regardless the place where you launched Gmsh.
Now we simulate the situation when someone started Gmsh without arguments and made some actions using menu window. For example, we add 2 new points (Geometry->Elementary entities->Add->New->Point). When we'll close Gmsh, and launch it again (without input parameters), we'll see that all changes are saved in the default file (i.e. we'll see our 2 points). Now imagine that someone made actions, that led to Gmsh's crush. It's difficult to invent something of this kind right now, so we'll just write the following string to the default file.


After that, we close Gmsh, and start it again in the same way as before. What will we see? Gmsh appears and closes immediately. I think the cause is clear - the Exit command forces Gmsh to shut down. This situation shows that if the default file contains something making Gmsh's crush, you, probably, will not know why this crush happens, because there is no error message from Gmsh or something else. The reason is just bad default file.
So the remedy is obvious:
I. To find the default geometry file (look for "untitled.geo") and
1. delete it;
2. change it to cancel all actions that lead to such bad result.
II. To start Gmsh with new geometry file as an argument

gmsh newfile.geo

The second solution will not return the geometry you previously created, but Gmsh will start anyway.

If you launch Gmsh without input parameters under Unix-like system, the behaviour stays the same. But in this case the default file "untitled.geo" is created in the directory where you start Gmsh. So to find this file is a little bit easier.

Be careful launching Gmsh without arguments!

Tuesday, July 10, 2012

Gmsh. Introduction

What is Gmsh?

Gmsh is a software package described by its authors as "a three-dimensional finite element mesh generator with built-in pre- and post-processing facilities". Gmsh is free and open-source (GNU GPL2 license). It was developed by Christophe Geuzaine and Jean-Fran├žois Remacle. Now it is being developed and supported by Applied and Computational Electromagnetics group from Montefiore Institute.
Gmsh has good manual (though it doesn't cover all Gmsh's capabilities), several tutorials and alive mailing list. The main location of resources is Gmsh's site

What is Gmsh designed for?

One can divide a process of mathematical modeling of some physical phenomenon into several parts:
  1. pre-processing part
    • geometry definition
    • mesh building
  2. task solving
  3. post-processing part
    • data preparation
    • visualization
Gmsh provides the tools to work with all these parts, even with task-solving stage (but in this case you should bind Gmsh with some outer solver (your own or, for example, GetDP written by P. Dular and C. Geuzaine and therefore easily embedded into Gmsh)).

Is there an alternative to Gmsh?

Yes, there is a lot. Many FEM-packages have their own triangulators. Here, I just want to mention two: Tetgen and Netgen. They are very widely used, and it is interesting that they are connected via Gmsh. Here is a quotation from the Gmsh's manual:

"6.1 Choosing the right unstructured algorithm
In 3D two unstructured algorithms are available:
1. The "Delaunay" algorithm is split into two separate steps. First, an initial mesh of the union of all the volumes in the model is performed using H. Si’s Tetgen algorithm. Then a three-dimensional version of the 2D Delaunay algorithm described above is applied.
2. The "Frontal" algorithm uses J. Schoeberl’s Netgen algorithm."

So the relationship between Gmsh, Netgen and Tetgen can be seen as:

I mean that on one hand, Gmsh is the same mesh generator as others, but on another hand, it contains mesh building algorithms from such packages as Netgen and Tetgen. It even has Netgen optimization. So Gmsh does build a good mesh.

Where is Gmsh?

Gmsh can be downloaded from its site. There are binaries (including all stable releases and automated nightly builds) for Windows, Linux and Mac OS X systems, as well as source code of all stable Gmsh versions and last developing version from SVN.