FEM mesh improvements

About the development of the FEM module/workbench.

Moderator: bernd

joha2
Posts: 236
Joined: Tue Oct 11, 2016 9:48 pm

FEM mesh improvements

Postby joha2 » Sun Apr 07, 2019 10:09 am

bernd wrote: ping
Hey bernd,

I thought about making the FEMMesh structure more versatile. There are four points where I thought about and where I would like to have your opinion:


Best wishes
Johannes
Last edited by joha2 on Sun Apr 21, 2019 5:22 pm, edited 3 times in total.
Jee-Bee
Posts: 1950
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: FEM mesh improvements

Postby Jee-Bee » Sun Apr 07, 2019 11:21 am

joha2 wrote:
Sun Apr 07, 2019 10:09 am
bernd wrote: ping
you're quoting is wrong... you forgot the user_id

it should be something like this:

Code: Select all

[quote=joha2 post_id=299653 time=1554631745 user_id=10551]
... [/quote]
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM mesh improvements

Postby bernd » Sun Apr 07, 2019 12:49 pm

since it is in FEM no qoute at all would be need! :mrgreen:

BTW time and postid are not needed too!
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM mesh improvements

Postby bernd » Sun Apr 07, 2019 1:12 pm

ahh I am on the way, means some valuable answer will follow later ...
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM mesh improvements

Postby bernd » Wed Apr 10, 2019 4:23 pm

joha2 wrote:
Sun Apr 07, 2019 10:09 am
  • The dict for your make_mesh function would be useful as a data exchange structure for small meshes. Is it possible to get such a structure also directly from the FEMMesh object? It would be very useful to continue working with these meshes or modifying them and generate a new one. Maybe this structure could be generally used as a data exchange format, such that working with the mesh is much easier.
There is a better on IMHO. Our Python API. i gone use it for FEM examples in master. https://github.com/FreeCAD/FreeCAD/blob ... tetra10.py and https://github.com/FreeCAD/FreeCAD/blob ... y#L90-L100 but it could be read in just one line too

joha2 wrote:
Sun Apr 07, 2019 10:09 am
  • For large meshes, it is maybe useful to use a hdf5 type format. Unfortunately the h5py library is not integrated into FreeCAD. We may discuss whether it is possible to integrate this library into FC.
is hdf5 med?

joha2 wrote:
Sun Apr 07, 2019 10:09 am
  • The whole mesh management is written at the moment with some more or less slow standard Python functions. It would be nice to rewrite the speed critical parts into numpy or maybe cython or numba (with the latter two I have no experience.)
This is just a matter of time from someone. But some tests have shown this makes not sense in any case. Lots of python functions are just call of C++ functions. These will not speed up. But anyway there are a lot of defs just implement in Python. They would gain a lot of speed.

joha2 wrote:
Sun Apr 07, 2019 10:09 am
  • The meshing with gmsh or netgen or other external meshers is blocking. Is it possible to perform these subprocesses in a non-blocking manner or at least - if this is not possible - with a process indicator and a cancel button?
very good point. Same on import of large ifc files. For ccx or gmsh it is simple. Since they are external programms, just kill them. This is not smart but works quite well. For netgen some break button would be cool.
User avatar
kkremitzki
Posts: 1708
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: FEM mesh improvements

Postby kkremitzki » Wed Apr 10, 2019 4:51 pm

MED is HDF5 with mesh enhancements... seems like it would be useful to improve the state of its support. I wish the docs weren't all in French!
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
joha2
Posts: 236
Joined: Tue Oct 11, 2016 9:48 pm

Re: FEM mesh improvements

Postby joha2 » Wed Apr 10, 2019 5:33 pm

bernd wrote:
Wed Apr 10, 2019 4:23 pm
There is a better on IMHO. Our Python API. i gone use it for FEM examples in master. https://github.com/FreeCAD/FreeCAD/blob ... tetra10.py and https://github.com/FreeCAD/FreeCAD/blob ... y#L90-L100 but it could be read in just one line too
Yeah, but for further analysis of the mesh or for fast data exchange the Python API is too much information. I would prefer a simple dictionary or something like this. Something which could be easily post-processed or easily transformed back into a mesh.
bernd wrote:
Wed Apr 10, 2019 4:23 pm
is hdf5 med?
kkremitzki wrote:
Wed Apr 10, 2019 4:51 pm
MED is HDF5 with mesh enhancements... seems like it would be useful to improve the state of its support. I wish the docs weren't all in French!
Since this seems to be the case, we have to have a look into it. But I think as a light weight data structure for exchange, maybe MED format is too complicated, isn't it?
bernd wrote:
Wed Apr 10, 2019 4:23 pm
This is just a matter of time from someone. But some tests have shown this makes not sense in any case. Lots of python functions are just call of C++ functions. These will not speed up. But anyway there are a lot of defs just implement in Python. They would gain a lot of speed.
I know that this makes no sense for all functions, but at least functions which are traversing the mesh structure can maybe improved by transforming the code into pure numpy or some other fast toolkits.
bernd wrote:
Wed Apr 10, 2019 4:23 pm
very good point. Same on import of large ifc files. For ccx or gmsh it is simple. Since they are external programms, just kill them. This is not smart but works quite well. For netgen some break button would be cool.
Yes, killing gmsh would be possible. But when I perform the meshing of a complicated part, I never know what gmsh actually does (some logging would be nice) or whether it is frozen. Further meshing of a part is independent from other things you can do in FreeCAD. Therefore it would be nice to execute gmsh independently from the rest of FreeCAD. Some cancel button is possible, but some intermediate feedback is maybe not so trivial.

What do you think about my points from above?

Best wishes
Johannes
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM mesh improvements

Postby bernd » Thu Apr 11, 2019 9:02 pm

joha2 wrote:
Wed Apr 10, 2019 5:33 pm
bernd wrote:
Wed Apr 10, 2019 4:23 pm
There is a better on IMHO. Our Python API. i gone use it for FEM examples in master. https://github.com/FreeCAD/FreeCAD/blob ... tetra10.py and https://github.com/FreeCAD/FreeCAD/blob ... y#L90-L100 but it could be read in just one line too
Yeah, but for further analysis of the mesh or for fast data exchange the Python API is too much information. I would prefer a simple dictionary or something like this. Something which could be easily post-processed or easily transformed back into a mesh.
IMHO the python API exactly does this, at least for me it does. If you like a dictionary more, go ahead just write an exporter. If you use yaml file format to save the dictionary into the file the importer would be just a two lines of code, because you only need to read the yaml (one line) and call the make mesh from inout mesh tools with the just read dictionary (the other line)

joha2 wrote:
Wed Apr 10, 2019 5:33 pm
bernd wrote:
Wed Apr 10, 2019 4:23 pm
is hdf5 med?
kkremitzki wrote:
Wed Apr 10, 2019 4:51 pm
MED is HDF5 with mesh enhancements... seems like it would be useful to improve the state of its support. I wish the docs weren't all in French!
Since this seems to be the case, we have to have a look into it. But I think as a light weight data structure for exchange, maybe MED format is too complicated, isn't it?
I have not much experience with med. User vejmarie was convinced of med and did implement it in FreeCAD FEM.

joha2 wrote:
Wed Apr 10, 2019 5:33 pm
bernd wrote:
Wed Apr 10, 2019 4:23 pm
This is just a matter of time from someone. But some tests have shown this makes not sense in any case. Lots of python functions are just call of C++ functions. These will not speed up. But anyway there are a lot of defs just implement in Python. They would gain a lot of speed.
I know that this makes no sense for all functions, but at least functions which are traversing the mesh structure can maybe improved by transforming the code into pure numpy or some other fast toolkits.
Same as above Johannes, go ahead and give it a try. If you have any questions I will give my best to help in any case.

joha2 wrote:
Wed Apr 10, 2019 5:33 pm
bernd wrote:
Wed Apr 10, 2019 4:23 pm
very good point. Same on import of large ifc files. For ccx or gmsh it is simple. Since they are external programms, just kill them. This is not smart but works quite well. For netgen some break button would be cool.
Yes, killing gmsh would be possible. But when I perform the meshing of a complicated part, I never know what gmsh actually does (some logging would be nice) or whether it is frozen. Further meshing of a part is independent from other things you can do in FreeCAD. Therefore it would be nice to execute gmsh independently from the rest of FreeCAD. Some cancel button is possible, but some intermediate feedback is maybe not so trivial.
In the regard of gmsh you are totally right. I have had a look into this myself some time ago. Feel free to make a bug report and asign it to me. Something in the regard of process logging for gmsh.


cheers bernd
joha2
Posts: 236
Joined: Tue Oct 11, 2016 9:48 pm

Re: FEM mesh improvements

Postby joha2 » Mon Apr 15, 2019 6:35 am

bernd wrote:
Thu Apr 11, 2019 9:02 pm
IMHO the python API exactly does this, at least for me it does. If you like a dictionary more, go ahead just write an exporter. If you use yaml file format to save the dictionary into the file the importer would be just a two lines of code, because you only need to read the yaml (one line) and call the make mesh from inout mesh tools with the just read dictionary (the other line)
Yes, this sounds like a good idea and it coincides with the plan I had.
kkremitzki wrote:
Wed Apr 10, 2019 4:51 pm
MED is HDF5 with mesh enhancements... seems like it would be useful to improve the state of its support. I wish the docs weren't all in French!
Where can I find the docs?
bernd wrote:
Thu Apr 11, 2019 9:02 pm
Same as above Johannes, go ahead and give it a try. If you have any questions I will give my best to help in any case.
I think this is a deep change in the meshing system. I will check at which places we could change the code without the ability to damage all of it.
bernd wrote:
Wed Apr 10, 2019 4:23 pm
In the regard of gmsh you are totally right. I have had a look into this myself some time ago. Feel free to make a bug report and asign it to me. Something in the regard of process logging for gmsh.
cheers bernd
Yes, I opened a bug report and assigned it to you.

Thanks for your help!

Best wishes
Johannes
User avatar
bernd
Posts: 8329
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: FEM mesh improvements

Postby bernd » Mon Apr 15, 2019 10:01 am

joha2 wrote:
Mon Apr 15, 2019 6:35 am
bernd wrote:
Wed Apr 10, 2019 4:23 pm
In the regard of gmsh you are totally right. I have had a look into this myself some time ago. Feel free to make a bug report and asign it to me. Something in the regard of process logging for gmsh.
cheers bernd
Yes, I opened a bug report and assigned it to you.
issue #3933