Page 1 of 2
salomeToElmer - export Salome mesh to Elmer
Posted: 10 May 2017, 13:35
by vencels
Hi,
I have written a script to export Salome mesh to Elmer.
https://github.com/jvencels/salomeToElmer
Typically users export Salome mesh in .unv format and then import it into Elmer. The problem is that .unv format does not support pyramids (5 nodal elements). These elements typically arise in mixed tetra and hexa 3D meshes.
I was looking for existing solutions but did not find any. Therefore decided to write salomeToElmer script to export mesh directly to Elmer's native mesh.* format.
It is barely tested so let me know if any suggestions and/or problems.
Cheers,
Juris
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 11 May 2017, 15:48
by RaJa
Does your script maintain the naming of the mesh and mesh groups? If so, I could incorporate your script into my Salome plugin the emulates the Elmer GUI.
Thanks,
Rainer
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 11 May 2017, 16:35
by vencels
Yes, it keeps names of domains and boundaries.
It would be nice to put it in your Salome plugin.
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 20 Apr 2018, 17:27
by c_prabal
I tried to export and load it in Elmer 8.2 GUI. It failed. I am attaching salome file. It is not accepting hdf files.
Prabal
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 23 Apr 2018, 11:16
by mzenker
Hi,
.hdf is the format for Salomé studies. An exported mesh has the format .unv, or, if in Elmer format, it has several files called mesh.boundary, mesh.elements, mesh.header, mesh.nodes. The mesh export is in the mesh module if you select the mesh in the tree view and do a rightclick, or activate the script.
HTH,
Matthias
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 29 Nov 2019, 16:24
by panosvar
Hi,
I tried the script as well, and Elmer is crashing when I import mesh files. I used Salome-Meca 9.3.0 and elmerfem-mpi-8.4_Windows-AMD64.exe .
P.S.: By using ElmerGrid 8 2 example_mesh.unv -autoclean, everything works fine.
Panos
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 29 Nov 2019, 18:20
by panosvar
I found out you can modify the script that comes from "Dump Study" option in Salome to convert the .unv file into *.mesh (Elmer format), by calling cmd inside that script like this:
Code: Select all
def export_elmer(filename):
"""
Input
filename: name of the .unv file exported by Salome
Output
.unv to *.mesh (Elmer format)
"""
start = time.time()
os.system('cmd /c "ElmerGrid 8 2 {}.unv -autoclean"'.format(filename))
end = time.time()
print("Salome to Elmer convertion time: {:.2f} sec".format(end - start))
# Export .unv file
try:
Structure_1.ExportUNV( r'Structure.unv' )
pass
except:
print('ExportUNV() failed. Invalid file name?')
# Export mesh to Elmer
export_elmer('Structure')
Which creates a folder with all the necessairy files in a folder with the same name as the filename you provided, in the same directory you are working on. I also found out it's good to change directory at the beginning of this .py file, in case you want both .unv files and Elmer files to be saved in another directory, like this:
Otherwise you have to open cmd with admin rights inside the .py, which I don't know how to do (Salome is really weird in handling external libraries).
Edit: However, the names are not transferred as they were in Salome, which is bad.
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 30 Nov 2019, 13:48
by kevinarden
I just changed the python script itself to write the files where I want them
if not os.path.exists(dirname):
os.makedirs(dirname)
try:
fileHeader = open("/home/titan/fea/salomeToElmer/mesh.header",'w')
fileNodes = open("/home/titan/fea/salomeToElmer/mesh.nodes",'w')
fileNames = open("/home/titan/fea/salomeToElmer/mesh.names",'w')
fileElements = open("/home/titan/fea/salomeToElmer/mesh.elements",'w')
fileBoundary = open("/home/titan/fea/salomeToElmer/mesh.boundary",'w')
except Exception:
print ("ERROR: Cannot open files for writting")
return
Kevin
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 30 Nov 2019, 23:14
by panosvar
Yeah makes sense. Did you find a way to preserve same face names from Salome to Elmer?
Re: salomeToElmer - export Salome mesh to Elmer
Posted: 01 Dec 2019, 12:15
by kevinarden
If I create groups in Salome for volumes, faces, and edges. The groups become bodies, and boundaries. The names come out in the mesh.name file
! ----- names for bodies -----
$ body1 = 1
! ----- names for boundaries -----
$ fixed_end = 2
$ load_end = 3
$ empty = 4