Separating FEM and meshing

About the development of the FEM module/workbench.

Moderator: bernd

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

Re: Separating FEM and meshing

Post by bernd »

crobar wrote:... Correct me if I'm wrong, but doesn't the Mesh Design WB only create surface meshes, and not volume meshes?
sure ...

FreeCADs MeshWB (standard, mefisto, netgen, ) --> surface mesh (Triangles) --> could be converted by Python in a FEM Shell Mesh
FreeCADs FEMWB (netgen) --> FEM Volume Mesh Tet4 or Tet10
GMSH Macro --> FEM Volume Mesh, FEM Shell Mesh, FEM Beam Mesh (all are possible.)
Last edited by bernd on Fri Sep 04, 2015 9:09 am, edited 3 times in total.
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Separating FEM and meshing

Post by crobar »

bernd wrote:
crobar wrote:... Might it be possible to separate out the meshing component from the workbench? In the long run this would make life easier for those of us who want to do other types of finite element analysis using meshes generated in FreeCAD, e.g. heat flow, or electromagnetics, or fluid dynamics.
...
Sure it would be possible, BUT ...
see Workbenches. The tools of the different workbenches are available in any other Workbench as well. I see no reason for separating FEM Mesh Generation from FEM Workbench. There are so many things to do. I'm on shell and beam analysis as well as multiple materials and of course the wiki. All not yet finished. If you would like to have it go for it and give it a try.
That's interesting, are you implementing a way of creating a partition mesh to use multiple materials in the same mesh? This is the key thing missing from a mesh suitable for electromagnetic simulation. Generally I'd like to make a mesh of multiple parts, e.g. a magnet in a box of air where the box is one Part and the magnet another Part, but you end up with a single mesh, with different regions of the mesh given appropriate labels of some kind which you can use in your finite element package. For a mechanical example, the same idea might be a part of one metal welded to a part of another metal. You would want one mesh, but different regions of the mesh to have different materials.

I've attached an example .unv file of what I mean (created in Salome) it is a cylinder inside a box of air. When I import this in FreeCAD it only appears to show the outer surface, but I can't tell if it has really imported the actual 3D volume mesh.

Here is what the mesh looks like in wireframe in Salome this was imported from the .unv file into Salome)
mesh_in_salome.png
mesh_in_salome.png (66.55 KiB) Viewed 1951 times
Here is what the mesh looks like when imported from the .unv file into FreeCAD when viewed as wireframe. I don't know if FreeCAD has only imported the surface, or if it's just a display issue.
imported_mesh_in_freecad.png
imported_mesh_in_freecad.png (34.85 KiB) Viewed 1951 times
I've also attached the .unv file, but zipped it first as the forum will not allow me to upload a .unv file extension
Attachments
cylinder_mag.unv.zip
Zipped mesh unv file originally exported from Salome
(100.32 KiB) Downloaded 45 times
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Separating FEM and meshing

Post by bernd »

Mhh, just tested on a simple box. If the show inner is changed to True and displaymode is wireframe the inner elements are shown. See attached picture.
screen.png
screen.png (246.52 KiB) Viewed 1943 times
In your Mesh they are not shown (For me too). But they are imported. Check in python console:

Code: Select all

App.ActiveDocument.getObject("cylinder_mag").FemMesh
========================== Dump contents of mesh ==========================

1) Total number of nodes:   	868
2) Total number of edges:   	122
3) Total number of faces:   	1078
4) Total number of polygons:	0
5) Total number of volumes:	4332
6) Total number of polyhedrons:	0

7) Total number of linear edges:	122
8) Total number of linear faces:	1078
8.1) Number of linear triangles:  	1078
8.2) Number of linear quadrangles:	0
9) Total number of linear volumes:	4332
9.1) Number of linear hexahedrons:	0
9.2) Number of linear tetrahedrons:	4332
9.3) Number of linear prisms:      	0
9.4) Number of linear pyramids:	0

10) Total number of quadratic edges:	0
11) Total number of quadratic faces:	0
12) Total number of quadratic volumes:	0

===========================================================================
There are 4332 volumes, but only 122 edges. I do not know how the viewprovider works. What exactly is displayed. I would assume the reason for not displaying the inner elements of you mesh is a view provieder problem.


EDIT: It is a display problem. The mesh was imported completely. Just export the mesh again to *.unv and open the mesh in GMSH ...
Attachments
screen2.png
screen2.png (258.37 KiB) Viewed 1942 times
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Separating FEM and meshing

Post by crobar »

Incidentally, other things you might like to do in a mechanical analysis is have a mesh with big elements in most places, but small elements in some region of particular interest, to make the FEA calculation smaller but still get the results you need.

This is why I was suggesting splitting it out, as creating a good mesh can often be a significant task in it's own right, deserving of a WB, where you make the mesh, assign named regions, etc. It would also advertise the existance of this functionality to users. Actually the natural place to me would be to have the FEM Mesh tools also appear by default in the Mesh WB.

I can totally understand the extra work involved might make it prohibitive. Personally I am interested in ultimately making an 'Elmerfem' WB https://www.csc.fi/web/elmer.
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Separating FEM and meshing

Post by bernd »

Yeah, crobar we all are with you. These are great features. Making the mesh more fine where it is needed and mor coarse where it is not needed. Whould be very cool to have such features and Mesh checking and and and :D As you stated someone needs to implement it :shock: Of course if we have all these stuff it could make sense to make an own FEMMeshWB. ...
crobar wrote: … That's interesting, are you implementing a way of creating a partition mesh to use multiple materials in the same mesh?
No.
crobar wrote: … You would want one mesh, but different regions of the mesh to have different materials.
This is what I did. I used one big FemMesh and extracted the Elements belonging to the different materials. In CalculiX these Elements are written as different Elsets.

See viewtopic.php?f=18&t=10640#p90166 But there is development going on. The guil will change again !
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Separating FEM and meshing

Post by crobar »

bernd wrote:Yeah, crobar we all are with you. These are great features. Making the mesh more fine where it is needed and mor coarse where it is not needed. Whould be very cool to have such features and Mesh checking and and and :D As you stated someone needs to implement it :shock: Of course if we have all these stuff it could make sense to make an own FEMMeshWB. ...
crobar wrote: … That's interesting, are you implementing a way of creating a partition mesh to use multiple materials in the same mesh?
No.
crobar wrote: … You would want one mesh, but different regions of the mesh to have different materials.
This is what I did. I used one big FemMesh and extracted the Elements belonging to the different materials. In CalculiX these Elements are written as different Elsets.

See viewtopic.php?f=18&t=10640#p90166 But there is development going on. The guil will change again !
ok, all I would say is that if you do plan to implement these features, it might be better to start out down the partition mesh/submesh route in the first place, as this might make life easier in the long run. It might mean users do not need to fuse their parts into one big part to do the calculations for instance, and the nodes in different regions would come pre-labelled for use in any FEA code when the mesh is exported.

I have had a look at the meshing code a few times, but it seems quite tightly intertwined with the GUI code which means starting on tweaking it means learning all about the FreeCAD GUI code organisation. It's also C++, which is ok, I work in C++ quite a lot, but it means recompiling FreeCAD for every change. The SMESH C++ API also doesn't seem to be that well documented anywhere either. Considering all this I'm impressed at what you've done already, if you can point me to some documentation for the SMESH version being used in FreeCAD that would make it more likely that I could help.

All this is why I am interested in looking at PythonOCC as I could develop the python backend meshing functions and convert to GUI widgets later if I wanted. It also seems likely that the PythonOCC SMESH will be maintained going forward. It also seems like there will be blog posts explaining how to use it, as the dev has a few posts up about it already. Is anyone in the FreeCAD universe maintaining the version used in FreeCAD?
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Separating FEM and meshing

Post by crobar »

oh, and incidentally, in case there's any uncertainty, I can confirm that the exported unv from FreeCAD preserved the mesh group numbers which were imported. So that's nice!
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Separating FEM and meshing

Post by bernd »

crobar wrote:... ok, all I would say is that if you do plan to implement these features, it might be better to start out down the partition mesh/submesh route in the first place, as this might make life easier in the long run. It might mean users do not need to fuse their parts into one big part to do the calculations for instance, and the nodes in different regions would come pre-labelled for use in any FEA code when the mesh is exported.
Sure, it would be better to go this way, even for performance reason. What I implemented in python is really slow on bigger fem volume meshes. But it is fast enought for fem shell meshes (the once I'm interested). Mhh and the main reason is I only know Python (at the moment).

Ahh regarding your cube-cylinder-mesh. It really seams to be the ViewProvider. Attached a simple box example with two FEM Meshes. For one mesh the inner volumes are displayed and for the other not. It seams if the volumes are really small, or there are so many they just will be not displayed. The ViewProvider is C++ and it is a monster :o I can not say exactly whenn the inner are displayed and when not.
show-inner-volumes-test.FCStd
(134.23 KiB) Downloaded 41 times
BTW: If the inner volumes are displayed the "Menue View --> Clipping Plane" works !! Looks quite cool if Display Mode is set to Elements ...
User avatar
bernd
Veteran
Posts: 12851
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Separating FEM and meshing

Post by bernd »

clipping plane and inner elements:
Attachments
screen3.png
screen3.png (259.52 KiB) Viewed 1927 times
crobar
Posts: 160
Joined: Fri Aug 29, 2014 1:26 pm

Re: Separating FEM and meshing

Post by crobar »

Incidentally, it looks like the PythonOCC python SMESH interface isn't quite as advanced as I thought:

https://groups.google.com/forum/#!topic ... zsTZbXODos
Post Reply