salomeToElmer - export Salome mesh to Elmer
salomeToElmer - export Salome mesh to Elmer
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
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
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
Thanks,
Rainer
Re: salomeToElmer - export Salome mesh to Elmer
Yes, it keeps names of domains and boundaries.
It would be nice to put it in your Salome plugin.
It would be nice to put it in your Salome plugin.
Re: salomeToElmer - export Salome mesh to Elmer
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
Prabal
Re: salomeToElmer - export Salome mesh to Elmer
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
.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
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
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
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:
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.
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')
Code: Select all
os.chdir(path)
Edit: However, the names are not transferred as they were in Salome, which is bad.
-
- Posts: 2366
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: salomeToElmer - export Salome mesh to Elmer
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
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
Yeah makes sense. Did you find a way to preserve same face names from Salome to Elmer?
-
- Posts: 2366
- Joined: 25 Jan 2019, 01:28
- Antispam: Yes
Re: salomeToElmer - export Salome mesh to Elmer
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
! ----- names for bodies -----
$ body1 = 1
! ----- names for boundaries -----
$ fixed_end = 2
$ load_end = 3
$ empty = 4