Useful additional gmsh functionality

Hi,

after playing around with the Mesh optimization steps in prepomax, it seems that these settings are only taken into account for Netgen but not for Gmsh, right?

In Gmsh the option “Optimize quality of thetrahedra with Netgen” can be activated, this optimization can help a lot to avoid creating elements with negative Jacobian:

Can this option be added under “Tetrahedral Gmsh”?

In addition, in Gmsh the remaining elements with negative Jacobian can usually be eliminated subsequently by using “Regularization of high-order elements” with the default values/settings. It would be great if this option could also be added under Model > Tools > select part.

Greetings

1 Like

You are right. Also, the Elements per edge is currently only a Netgen parameter.

Do you have experience with bad meshes created by Gmsh? In my tests I did not encounter such problems. But it is a nice idea and easy to add.

Do you know if only the node positions change during this procedure or if any new elements are also created?

I think following prozess shows best what i mean and how effective the additional gmsh optimizations can help to mesh “dirty CAD geometries” (my job is creating such dirty CAD parts :wink:
The initial mesh is created with gmsh in prepomax. The goal is to create a working mesh with a minimum number of nodes.

By using “Regularization of high-order elements” only the node positions change (at least for the default algorithm “Optimization”).

You can test this with attached file
step.zip (74.7 KB)

Note: for the initial mesh i use “Midside nodes on geometry = Yes”

1 Like

"I can confirm Gunnar’s observation regarding bad geometry. I had a corrugated hose that needed to be meshed, and it failed with Gmsh due to negaitve jacobian determinants. However, with Netgen, I managed to obtain a working mesh and results from Calculix, at least. It seems that Gmsh, in its current state in PreProMax, isn’t capable of handling complicated or dirty CAD, making it useless at the moment.

The Gmsh documentation mentions something about high-order tools to prevent negative Jacobians.

https://gmsh.geuz.narkive.com/nW6gEHZR/detect-negative-jacobians
type or paste code here

Nevertheless, thank you so much for putting in the effort to incorporate Gmsh into Prepromax!

Daniel

1 Like

Maybe it is a little bit too much for a critic. GMSH is very capable in many aspects, and even if it is not suitable for your specific situation, it does not mean it is useless. Actually, in my opinion, it is very useful for my needs. :saluting_face:

2 Likes

As I mentioned before, I am very grateful for Gmsh in PreProMax. However, for industrial applications with real geometry, Gmsh in its current implementation in PreProMax is not usable for me, at least. This should not be taken as harsh criticism of Gmsh or PreproMax.

2 Likes

Yes, I understand. Hopefully, both the PrePoMax implementation and GMSH itself will be more capable in the future. :smile:

1 Like

I’ve seen several reports about the negative jacobian errors when using Gmsh in FreeCAD. It’s even described on their wiki: FEM MeshGmshFromShape - FreeCAD Documentation

But, to be honest, most of the aforementioned cases where caused by the fact that the geometry was not well prepared for simulations. Many people using the FEM workbench in FreeCAD have no experience with FEA and they just take their designs with all the details and modeling issues (like intersections) and want to analyze them without the recommended (regardless of the simulation software) clean-ups and simplifications. Many cases where also involved thin-walled parts that should be meshed with shell elements.

I haven’t tested Gmsh in PrePoMax on complex geometries yet but my first advice in most cases would be to simplify the geometry as much as possible and use 2D/shell models when applicable. Even if Netgen works for some cases, the obtained mesh may not be suitable for accurate FEA. Still, there’s certainly an area for improvement in Gmsh itself (PrePoMax only provides an interface for it) but I wouldn’t say that it’s useless for “real geometry” since many people use it for quite complex models including organic shapes like biomechanical structures. Maybe some specific cases can be too difficult for Gmsh but then it would be good to discuss them on particular examples and maybe ask Gmsh devs for help.

4 Likes

I hope it is clear that my intention was not to make gmsh bad. Quite the opposite, I just wanted to point out that activating these options makes it even better (they are part of gmsh). The biggest advantage for prepomax is probably to have the ability for creating structural meshes now. For my shown example with the selected parameters, netgen works not much better to prevent elements with negative jacobians → Important using “Midside nodes on geometry = Yes”. Without that, netgen + gmsh created meshes without faulty elements.
The other point is, everybody who uses FEM serious should know that the first step should be to cleanup/simplify the CAD geometry in such cases. I just wanted to show that it is possible.

Yes, of course, Gmsh is also suitable for complex geometry. However, in some of my cases, I couldn’t make progress with Gmsh. And yes, I have cleaned up and simplified the geometry using numerous tools. There were also thin structures where I couldn’t proceed even with shell elements.

I just wanted to say that having the optimizations in Gmsh that Gunnar suggested would be helpful. That’s really all I meant to say. I expressed myself poorly, sorry :slight_smile:

I know and I didn’t want to be misunderstood too :+1:

indeed, i tested this file by several meshes tuned setting and tetrahedral algorithm selection in Gmsh menus but still not succeed in solver. Problem always related to bad mesh shape and negative Jacobian.

it’s probably right, suggestion to Optimize quality with Netgen is important feature to make tetrahedral mesh results of complex geometry by Gmsh mesher to become usable.

cleanup geometry such as fillet can be problematic due to sharp edges, and it may lead to stress singularities. Try to avoid whenever possible since the solution s unknown, use coarse mesh and quadratic instead.

unfortunately, layering for setting number of element trough thickness is not yet available. It seems single element trough thickness of quadratic tetrahedral element (C3D10) can be far better than linear triangle (S3) or quadrangle (S4). Also, it may still comparable with quadratic triangle (S6) or quadrangle (S8/S8R). Tetrahedral mesh of thin part also have another advantage over single layer shell element, mesh can be refined at desired location and eliminates improperly definition of edge rotational boundary condition.

I was testing the optimization settings in Gmsh and found out the following.
Firstly, there is a possibility to use Netgen for optimization of first order elements. Namely, if this optimization is started after the second order mesh is created it changes the mesh back to first order mesh.
Secondly, a high order optimization can be used to optimize second order meshes. If first a Netgen optimization is used it helps to speed up the high order optimization.

So, I decided to add both possibilities.

I will test this functionality further on shell meshes.

2 Likes

Okay i understand, when using “Optimize 3D (Netgen)” after creating the 2nd order mesh, the tetrahedral elements will be converted to 1st order elements. But what i mean is activating the checkbox before creating the 2nd order mesh. Then the optimization will also be made without converting them to 1st order elements. In the meantime i figured out that sometimes “Optimize quality of tetrahedra” for other examples works better than netgen, so it makes sense if this option also could be added.

The optimization only affects 3d tetrahedral elements.

1 Like

Well, in the API it is a little different. There are some different functions to call, and I am unsure if they are the same as in GUI.

Currently, I have implemented the function:

gmsh/model/mesh/optimize

which has the following options:

Gmsh
Netgen
HighOrder
HighOrderElastic
HighOrderFastCurving
Laplace2D
Relocate2D
Relocate3D
QuadQuasiStructured
UntangleMeshGeometry

I have split them into the following user options:

First order shell elements: None, Laplace2D, Relocate2D, QuadQuasiStructured
First order solid elements: None, Gmsh, Netgen, Relocate3D
Second order elements: None, HighOrder, HighOrderElastic, HighOrderFastCurving

And then, after some testing, I decided to use 10 loops for first order optimization and then 1 loop for second order optimisation.

For solid elements, the user can select first order and second order optimizations. Gmsh first creates first order mesh. Then, the first order optimization is performed. After that the mesh is converted to second order mesh, and then the second order optimization is performed.

1 Like

Thanks for clarifying. I don’t know most of these functions, so thank you for having them all available in the future.

Now i have made a new observation. Sorry this has nothing to do with this topic, i just wanted to mention it here. I tried to create a Transfinite mesh on a simple wedge-shaped part (attached the 3d file). It’s similar to your example shown in the video “PrePoMax & CalculiX - Transfinite volume meshes”.
However, when i select “Recombine Yes” i get an error. Hence i guess Transfinite mesh for five sided volumes is no longer working? I tested with v2.0.1 and 2.0.2. With v2.0.0 it’s still working.

wedge.zip (871 Bytes)

1 Like

For me, it works in 2.0.1 and in my developer version 2.0.2. Did you use any Mesing parameters for the size settings? Can you share the .pmx file in which it does not work?

1 Like

Attached the pmx file. Now i figured out that it works for me in v2.0.1+2.0.2 when i select Mesh type 2nd order “Yes” but not for 1st order mesh. In v2.0.0 both options work.

1.pmx (8.4 KB)

1 Like