Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

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: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

@qingfeng.xia

It's been a while ... Are you still interested in merging this? I rebased it on master. See https://github.com/berndhahnebach/FreeC ... gmshexport I may go for some refactor in gmsh tools. Means this should be merged before.

To be merged it would need some testing and may be one or two fixes.
Jee-Bee
Veteran
Posts: 2566
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by Jee-Bee »

since @ still don't work ;)
qingfeng.xia wrote: ping
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

I am still alive :D , but forget my forum password to reply you guys.

This function, may be available in my CFD workbench, where I fork Bernd's GmshMesher class.
I may turn off some mesh format. otherwise make the open /export dropbox too long.
If you think that feature is useful, I will give it a test on your rebase and you can send the PR from you rebase directly.

The most important I think, I have worked out a new feature Xmas 2018 (general initial value and body source), It has not yet been merged.
see the link.
https://forum.freecadweb.org/viewtopic. ... ia#p286331
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

bernd wrote: Tue Sep 03, 2019 11:47 am @qingfeng.xia

It's been a while ... Are you still interested in merging this? I rebased it on master. See https://github.com/berndhahnebach/FreeC ... gmshexport I may go for some refactor in gmsh tools. Means this should be merged before.

To be merged it would need some testing and may be one or two fixes.
1) src/Mod/Fem/feminout/importGmshMesh.py
the last 2 functions should be removed, Fenics has move away from VTK, so we can not plot()

For openfoam mesh, def export_foam_mesh(obj, meshfileString, foamCaseFolder=None): this should be in CFD workbench, not here.

2) gmsh have upgraded from v2 to v4, some mesh export test is needed.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

qingfeng.xia wrote: Tue Sep 03, 2019 3:53 pm 1) src/Mod/Fem/feminout/importGmshMesh.py
the last 2 functions should be removed, Fenics has move away from VTK, so we can not plot()
done
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

the get_group_data and write_group needs to be reviewed: https://github.com/berndhahnebach/FreeC ... 9R342-R661 ATM I have no idea why all this group code has changed and I have not tested your implementations. Would be good if you could give some feedback what is happening and what is your indentation.
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

test result: it is fine to use this feature in GUI and nonGUI mode, except for 3 formats, see result report below

There is some bugs I fixed, it is on my FreeCAD repo, just one commit top on Bernd's

To https://github.com/qingfengxia/FreeCAD.git
* [new branch] femgmshexport -> femgmshexport

https://github.com/qingfengxia/FreeCAD/ ... gmshexport

Code: Select all

#to run this test script in console
#mo=
#get the meshobj in FreeCAD python console, then paste the lines into the console


import femmesh.gmshtools as gmshtools
gmsh = gmshtools.GmshTools(mo)
from importGmshMesh import _run_command


for k in gmshtools.GmshTools.output_format_suffix:
    fileString = "/tmp/test" + gmshtools.GmshTools.output_format_suffix[k]
    ret = gmsh.export_mesh(k, fileString)
    _run_command(["gmsh", "-open", fileString])

######### result ############
I have warning during UNV mesh write
Warning : Unknown element type for UNV export (MSH type 15) - output file might be invalid
but gmsh can read back this mesh properly

tested on gmsh 4.3 ubuntu 18.04 64bit, 3 formats failed

I have no domain knowledge to solve these errors.

1. error inp.
Error : '/tmp/test.inp', line 1 : syntax error (*)

cat this inp file, first 3 lines
'''
*Heading
/tmp/test.inp
*NODE
'''

2. error ply2
Error : Wrong vertex index 97

3. error su2
Error : '/tmp/test.su2', line 2 : syntax error (NELEM)

'''
NDIME= 3
NELEM= 217
10 71 90 100 63 0
10 90 73 81 100 1
'''
Last edited by qingfeng.xia on Wed Sep 04, 2019 12:25 pm, edited 2 times in total.
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
stair
Posts: 5
Joined: Fri May 25, 2018 10:01 am

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by stair »

Can I request that one of the export formats is GMSH V2 although I am not certain how to achieve this since I have been unable to find the correct switch in the GMSH docs even though it is a GUI option.

Slightly off topic but definitely relevant, it would be very convenient to be able to write the .geo file to a user location, or even just along side the .fcstd, without having to actually generate the mesh and then dig out shape2mesh.geo

Thanks
Stair
qingfeng.xia
Posts: 227
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford UK/Shenzhen China
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by qingfeng.xia »

It is possible, by adding a new Property to Gmsh's DocumentObject, while most solvers still use V1 formats like Fenics. wait for Bernd's suggestion.

move out *.geo from tmp folder is not quite necessary, it refers to brep goemetry file while is also in a temp path. the path info has been reported to console, so you are free to hack on it, actually I did that before, to test out new features.
stair wrote: Tue Sep 03, 2019 4:45 pm Can I request that one of the export formats is GMSH V2 although I am not certain how to achieve this since I have been unable to find the correct switch in the GMSH docs even though it is a GUI option.

Slightly off topic but definitely relevant, it would be very convenient to be able to write the .geo file to a user location, or even just along side the .fcstd, without having to actually generate the mesh and then dig out shape2mesh.geo

Thanks
Stair
Ubuntu 18.04 LTS 64bit, python3, always work with latest FreeCAD daily build
Working on Cfd module for FreeCAD, FreeCAD_Module_Develop_Guide
https://github.com/ukaea/parallel-preprocessor/
https://github.com/qingfengxia/Cfd
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Feature: add extra FemMesh mesh file export format, potentially usable by other solvers

Post by bernd »

stair wrote: Tue Sep 03, 2019 4:45 pm Slightly off topic but definitely relevant, it would be very convenient to be able to write the .geo file to a user location, or even just along side the .fcstd, without having to actually generate the mesh and then dig out shape2mesh.geo
It has been on my ToDo for a long time to check if it makes sense to reuse the solver code which defines the input file location for the gmsh mesh creation as well. IMHO it makes sense to save them both on the same location. I may have a look at this. This is related to https://github.com/FreeCAD/FreeCAD/pull/2465
Post Reply