Example of an Hex mesh with GMSH

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Example of an Hex mesh with GMSH

Post by bernd »

I played a bit too. The problem is the line

Code: Select all

Transfinite Line "*" = 5 Using Bump 1.;
it says GMSH to use 20 element on any edges. This works great on this modell, but not on most other where we have edges with totally different lengths. But without this line and with MaxCharacteristicLength I get errors ... We need to play more ...
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Example of an Hex mesh with GMSH

Post by HoWil »

sodelo wrote:Did not contact the devs but played a little bit with Freecad and gmsh instead.
I created a CompoundFilter and exported as a Brep.
freecad.png
With a very simple geo file I got this.
mesh.png
There is some potential there!


Place the Brep and geo file in the same directory. Open the geo file and click on Mesh/define/3D.
Hi sodelo,
Since you are far more into gmsh as I am, I want to ask if you also see/know a possibility to create a BoundaryLayer mesh in gmsh (see also https://forum.freecadweb.org/viewtopic. ... er#p155616)

Thanks in advance,
Howil
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Example of an Hex mesh with GMSH

Post by HoWil »

bernd wrote:I played a bit too. The problem is the line

Code: Select all

Transfinite Line "*" = 5 Using Bump 1.;
it says GMSH to use 20 element on any edges. This works great on this modell, but not on most other where we have edges with totally different lengths. But without this line and with MaxCharacteristicLength I get errors ... We need to play more ...
Only an idea?
What happens if you use fc mesh regions on each edge? Do you than still need this setting?
Br
Howil
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Example of an Hex mesh with GMSH

Post by bernd »

HoWil wrote:
bernd wrote:I played a bit too. The problem is the line

Code: Select all

Transfinite Line "*" = 5 Using Bump 1.;
it says GMSH to use 20 element on any edges. This works great on this modell, but not on most other where we have edges with totally different lengths. But without this line and with MaxCharacteristicLength I get errors ... We need to play more ...
Only an idea?
What happens if you use fc mesh regions on each edge? Do you than still need this setting?
Mhh could work, it is worth a try ...

BTW @ sodelo
If you use GMSH mesh in FreeCAD you can change some parameter in property widget and watch out for report vie the created geo file is printed there. If you open this file you will find the gmsh command to run the meshing. I have been using this and copied your lines to play. Still I get valid meshes if I use the Transfinite Line command but not without this command and the use of CharacteristicLength
sodelo
Posts: 73
Joined: Tue Jan 24, 2017 9:20 am

Re: Example of an Hex mesh with GMSH

Post by sodelo »

BTW @ sodelo
If you use GMSH mesh in FreeCAD you can change some parameter in property widget and watch out for report vie the created geo file is printed there. If you open this file you will find the gmsh command to run the meshing. I have been using this and copied your lines to play. Still I get valid meshes if I use the Transfinite Line command but not without this command and the use of CharacteristicLength
I tried but nothing was displayed in the WatchOut report so I fear I did not understand the process.

Sorry guys if I did not mention the limitations you found out yourselves. I was very exited and wanted to share it. I think getting a working solution (with a full control on the mesh) might be difficult. We may have to figure out how the edges are translated from the Freecad internal through BREP to the GMSH internal to be able to relate each edge to its requested number of elements. Might be some work and I hope there is an easier path.
sodelo
Posts: 73
Joined: Tue Jan 24, 2017 9:20 am

Re: Example of an Hex mesh with GMSH

Post by sodelo »

Hi sodelo,
Since you are far more into gmsh as I am, I want to ask if you also see/know a possibility to create a BoundaryLayer mesh in gmsh (see also https://forum.freecadweb.org/viewtopic. ... er#p155616)
I am still very unexperienced with GMSH. I had a look however at the 2d example. Meshing is very long and lead to a big mesh because of the triangles. The best route would be to create a layer in the geometry (volume subdivision) and to mesh it with a few elements in the thickness and to connect it to the rest using a bias (progressive increase of density). All of this can be done with GMSH. We "just" have to find a way to transfer this information.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Example of an Hex mesh with GMSH

Post by bernd »

sodelo wrote:
BTW @ sodelo
If you use GMSH mesh in FreeCAD you can change some parameter in property widget and watch out for report vie the created geo file is printed there. If you open this file you will find the gmsh command to run the meshing. I have been using this and copied your lines to play. Still I get valid meshes if I use the Transfinite Line command but not without this command and the use of CharacteristicLength
I tried but nothing was displayed in the WatchOut report so I fear I did not understand the process.

Sorry guys if I did not mention the limitations you found out yourselves. I was very exited and wanted to share it. I think getting a working solution (with a full control on the mesh) might be difficult. We may have to figure out how the edges are translated from the Freecad internal through BREP to the GMSH internal to be able to relate each edge to its requested number of elements. Might be some work and I hope there is an easier path.
I'm still very exited about what you posted :D BREP is native format of GMSH as it is of FreeCAD. Means we could use edgenumbering from FreeCAD to transfer adjustments to GMSH. MeshRegion works the same way but uses CharacteristicLength which is a node property.
sodelo
Posts: 73
Joined: Tue Jan 24, 2017 9:20 am

Re: Example of an Hex mesh with GMSH

Post by sodelo »

So what I can do is post an example of a geometry prepared with Freecad and write the GEO file with all the commands for a nicely controlled mesh definition.

Edit: see below for the GEO file and the result.
test.png
test.png (19.13 KiB) Viewed 2565 times

Code: Select all

Merge "test.brep";
// For the progressive distribution of element size on some edges. HoWill this is for you!
Bias=1.2;
Transfinite Line{1,2,7,9,15,20,21,24} = 3;
Transfinite Line{3,4,11,12,16,18,25,26} = 10;
// Progressive distribution. Some lines are not oriented in the same way. So the invers of Bias is used.
Transfinite Line{22,23} = 10 Using Progression 1/Bias;
Transfinite Line{27,28} = 10 Using Progression Bias;
Transfinite Line{13,14,17,19} = 10;
Transfinite Line{5,6,8,10} = 4;
Transfinite Surface "*";
Recombine Surface "*";
Transfinite Volume "*";
Hope you can automatically generate this kind of GEO file!
Attachments
test.brep
(26.63 KiB) Downloaded 82 times
Last edited by sodelo on Thu Feb 23, 2017 1:48 pm, edited 1 time in total.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Example of an Hex mesh with GMSH

Post by bernd »

sodelo wrote:So what I can do is post an example of a geometry prepared with Freecad and write the GEO file with all the commands for a nicely controlled mesh definition.
That would be cool. I would than have a look how this could be integrated in the FreeCAD GMSH mesh object.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Example of an Hex mesh with GMSH

Post by bernd »

sodelo wrote:Hope you can automatically generate this kind of GEO file!
This is possible. Workflow will be similar to the MeshRegion Object. But it will take some days to implement ...
Post Reply