Mesh Settings

About the development of the FEM module/workbench.

Moderator: bernd

ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Mesh Settings

Post by ulrich1a »

I just saw that Bernd has added different mesh element size for shape elements. I could not figure out how it works.

My idea is to make a new object: mesh-setting. This is a very similar object like a constraint. It contains a reference to a face, edge or vertex and it contains a characteristic length.
There should be a way to put these information into the geo file for Gmsh.

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

Re: Mesh Settings

Post by bernd »

ulrich1a wrote:I could not figure out how it works.
Python only ATM.

- start FreeCAD --> StartWB --> 3D FEM example
- delete FEM Netgen mesh object
- activate the analysis --> select the Part object Cube --> click on GMSH Mesh object in FEM WB
- make an new FEM mesh with default values
- run the following python code

Code: Select all

femmesh = App.ActiveDocument.getObject("Box_Mesh")
femmesh.CharacteristicLengthMap = {'Face3':'50'}
- double click on GMSH mesh object and again make the mesh with default values.

It should look like the attached screen. But since the example has only 8 nodes it is rather boring. I'll have a look for a better one.
Attachments
screen1.jpg
screen1.jpg (300.26 KiB) Viewed 3630 times
Last edited by bernd on Tue Nov 29, 2016 8:21 am, edited 1 time in total.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Mesh Settings

Post by bernd »

OK attached a much better example to play with:

Code: Select all

femmesh = App.ActiveDocument.getObject("CompSolid_Mesh")
femmesh.CharacteristicLengthMap = {'Face51':'1', 'Vertex3':'1', 'Solid7':'2', 'Edge23':'0.5'}
The vertex does not seam to work, but it is in the geo file. Some GMSH expert could may be explain this.
multibody--10solids.fcstd
(350.21 KiB) Downloaded 98 times
screen2.jpg
screen2.jpg (220.63 KiB) Viewed 3629 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Mesh Settings

Post by bernd »

ulrich1a wrote:There should be a way to put these information into the geo file for Gmsh.
ATM I use a PropertyMap. The property name is CharacteristicLengthMap = {'ElementNameOfTheShapeToMesh' : 'ElementLengthInMilimeter'} I'm not convinced this it the way to go but it works quite well. That is why I just implemented it without GUI.
ulrich1a wrote: My idea is to make a new object: mesh-setting. This is a very similar object like a constraint. It contains a reference to a face, edge or vertex and it contains a characteristic length.
This was my idea first too. I changed and thought we could save it in the GMSH mesh object too. Than I made the ProperyMap implementation. It worked but I was not happy with it.

At the moment I would prefer the following:
- an constraint for each needed CharacteristicLength the user would like to use. The constraint object only needs two properties, a PropertyLength and a PropertySubLink. With this we are much more stable since we gone use real properties instead of the weak map I have been using. The selection could be similar to the material constraint for multi body.

How about this?
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Mesh Settings

Post by ulrich1a »

bernd wrote:At the moment I would prefer the following:
- an constraint for each needed CharacteristicLength the user would like to use. The constraint object only needs two properties, a PropertyLength and a PropertySubLink. With this we are much more stable since we gone use real properties instead of the weak map I have been using. The selection could be similar to the material constraint for multi body.

How about this?
This is quite the thing, what I have in mind. But it could be a PropertyLinkSubList like in a typical constraint. I tried today myself to make a mesh with different characteristic lengths. I used the Gmsh command "Characteristic Length" which needs a list of vertex numbers. It did the job.

The constraint approach for the characteristic length has another advantage. It allows to store important properties of the mesh, without having the mesh itself in the document. Sometimes you do not want to have the mesh in the document, because of its storage size.
In a similar direction goes the Gmesh-mesh property "Optimize". I had to set it, because otherwise I got always meshes with a negative Jacobian. I think this has to be set in the Gmesh-Task dialog or in the Gmesh-Properties. Otherwise you have at least make the mesh a second time, if you want to have this option set. Or set the default-value to True.
bernd wrote:The vertex does not seam to work, but it is in the geo file. Some GMSH expert could may be explain this.
It worked here for me. I am using Gmesh 2.9.3.



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

Re: Mesh Settings

Post by bernd »

ulrich1a wrote:This is quite the thing, what I have in mind. But it could be a PropertyLinkSubList like in a typical constraint.
Sure it has to be a PropertyLinkSubList. I will try to go this way and come up with something, but it will take some days.
ulrich1a wrote:I tried today myself to make a mesh with different characteristic lengths. I used the Gmsh command "Characteristic Length" which needs a list of vertex numbers. It did the job.
Have you been reading my first two post? CharacteristicLength is exactly what I use in UpToDate FreeCAD Master to generate the different element size of the meshes posted in the screen. It really works well except if I use only one vertex in the CharacteristicLength. Attached again the mutlibody10solid but the CharacteristicLength PropertyMap included already. Download the file, open it, double click on teh GMSH mesh object, remesh and you will have different element size for some elements. Attached furthermore the geo and brep file. The CharacteristicLength for Solid7, Face51 and Edge23 are recognized, but for the Vertex3 not. But they all are in the geo file.
CompSolid_Geometry.brep
(35.24 KiB) Downloaded 122 times
delete .txt
shape2mesh.geo.txt
(1.69 KiB) Downloaded 123 times
Last edited by bernd on Wed Nov 30, 2016 7:30 am, edited 2 times in total.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Mesh Settings

Post by bernd »

BTW: Have you seen the PropertyEditor of GMSH mesh object. The Algorithm2D, Algorithm3D and different Mesh optimizations could be activated. Just make a GMSH mehs object, close it, change the Properties, double click and it uses the adjusted Properties will be used in the geo file. Means you can optimize the GMSH mesh from FreeCAD GUI.

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

Re: Mesh Settings

Post by bernd »

bernd wrote:
ulrich1a wrote:This is quite the thing, what I have in mind. But it could be a PropertyLinkSubList like in a typical constraint.
Sure it has to be a PropertyLinkSubList. I will try to go this way and come up with something, but it will take some days.
How do we name such object which defines mesh fem-element length for shape-elements of the shape to mesh? Any suggestions?
ulrich1a
Veteran
Posts: 1957
Joined: Sun Jul 07, 2013 12:08 pm

Re: Mesh Settings

Post by ulrich1a »

bernd wrote:How do we name such object which defines mesh fem-element length for shape-elements of the shape to mesh? Any suggestions?
I first thought "Mesh-Setting" but I think, "Mesh-Constraint" is good for this type of element.
bernd wrote:BTW: Have you seen the PropertyEditor of GMSH mesh object. The Algorithm2D, Algorithm3D and different Mesh optimizations could be activated. Just make a GMSH mehs object, close it, change the Properties, double click and it uses the adjusted Properties will be used in the geo file. Means you can optimize the GMSH mesh from FreeCAD GUI.
I did the first experiments with the Windows-version, which lags behind and did not have this. I gave up compiling myself, since the windows versions are supplied by sgrogan. Thanks to sgrogan for this!
Yes, I saw the new properties at home and will do some experiments with it. See, if I can get a hex-mesh.

As already said, Vertex 3 was working for me. So it may be a bug in a certain version of Gmsh.

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

Re: Mesh Settings

Post by bernd »

ulrich1a wrote: See, if I can get a hex-mesh.
I tried too but my knowledge of GMSH is limited. I got a quad mesh for a plane but failed in CalculiX due some strange nodes in the mesh. Would be cool if you are able to mesh hex elements by GMSH. If you need some more sitches of GMSH they are really easy to add.

bernd
Post Reply