Salome as an automatic Mesher for 3D Aerodynamic Shape Optimization

Hello Salome Community,

I am new to Salome, and before starting to work rigorously with it I need to know some capabilities of Salome’s SMesh from its experienced users.

I want to perform a 3D aerodynamic shape optimization of a wing (will be extended to wing+fuselage+tail later) using OpenMDAO, an open-source framework for MultiDisciplinary Analysis and Optimization. I am using OpenVSP for parametrizing the geometry and making the CAD model. My questions are:

  1. Assuming I can import the geometry from OpenVSP to Salome in an acceptable format (such as IGES format) is it possible to write a python script that will automatically import the geometry to Salome’s SMesh without opening the GUI?

  2. After importing the wing geometry automatically through a python script, is it possible to automatically mesh with a 3D inflation layer (to capture boundary layers effects) and unstructured mesh beyond the inflation layer? I hope to automate this through a python script.

  3. After meshing, is it possible to automatically export the mesh to .su2 format? I am currently using SU2 since it supports adjoint-based gradient evaluation which is crucial for a gradient-based optimization algorithm. If not, is there an alternate way to do it? Probably exporting it to GMSH and then exporting it to .su2 format might work out.

I understand that initially, I need to play around with the GUI to figure out the required number of inflation layers, their size etc. but after figuring them out my main objective is to automate the whole meshing process so that it can automatically and seamlessly work with the Optimization framework. If you have any other suggestions or thoughts regarding this work please let me know.

Thank You!

  1. yes, it is preferably the .STEP format. have a look at tutorial
  2. yes. see 1.
  3. no up to what I know. have a look at this interesting project maybe it supports the desired format. GitHub - MoiseRousseau/Salome-MeshIO: MeshIO plugin for Salome
    other suggestions, have a look at YACS module of salome. cyprien has also some videos about this.
    best regards,
    F.
2 Likes

Thanks a lot for the answers and suggestions! Your quick reply is much appreciated. Now I feel confident to get deep into Salome. I will figure out if there is a way to export it to .su2 format and post it here soon.

Hi vishnu67,

I’m not aware of an export straight to .su2 format, but I do have code to auto-export the raw mesh for manipulation afterwards (in my case, translating the mesh to be viewed by PyVista functions). You can run your model’s dump script in terminal mode and it will auto-export mesh nodes, elements, and groups to the working directory.

https://github.com/logangutk/Salome-AutoExportMesh

1 Like

Oh, that’s great! Thanks a lot, @LGutknecht. I will try working with it and will post the code if I manage to export it to .su2 format.

if you look in the link to the plugin of meshIO it has .su2 as format of reading and writing

1 Like

That would really simplify a lot of my work. Thanks a lot @franco.ota for taking the effort to look into it.

My 2¢ here, I’m happy to see that there are workarounds. Anyway as for now I’ve always used a small python routine that I found online and ad-hoc modified, which natively exports in su2 from salome (ASCII).

The good thing is that it supports direct export of mesh and specified groups from SALOME, it handles 3D and 2D meshes.

You may give it a try here.

Thank you @giovanni.medici for letting me know about your work! Right now I am figuring out how to mesh a 3D wing in Salome by playing around with the GUI. I am hoping to finish it soon, will explore all the options suggested by the community and keep everyone posted here.

Thanks!

Hi @franco.ota

I tried using MeshIO. Instead of using it as a plugin I directly installed it using pip as mentioned here . I tried running it in the anaconda prompt. But there were a few errors that I am not sure how to work around.

  1. MeshIO is not able to read the CGNS mesh exported from Salome’s mesher. Every time I try to run “meshio info boxmesh.cgns” it throws the following error:

     Expected "Base" in file. Malformed CGNS?
     Error: Couldn't read file boxmesh.cgns as cgns
    
  2. MeshIO seems to read the MED mesh format as expected since “meshio info boxmesh.med” displays mesh data without any errors. However, when I try to convert it to .su2 format by running “meshio convert boxmesh.med boxmesh.su2” in the anaconda prompt, it throws an error:

    File “d:\softwares\anaconda\anaconda3\lib\runpy.py”, line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File “d:\softwares\anaconda\anaconda3\lib\runpy.py”, line 87, in run_code
    exec(code, run_globals)
    File "D:\softwares\anaconda\anaconda3\Scripts\meshio.exe_main
    .py", line 7, in
    File “d:\softwares\anaconda\anaconda3\lib\site-packages\meshio_cli_main.py”, line 52, in main
    return args.func(args)
    File “d:\softwares\anaconda\anaconda3\lib\site-packages\meshio_cli_convert.py”, line 75, in convert
    write(args.outfile, mesh, **kwargs)
    File “d:\softwares\anaconda\anaconda3\lib\site-packages\meshio_helpers.py”, line 188, in write
    return writer(filename, mesh, **kwargs)
    File “d:\softwares\anaconda\anaconda3\lib\site-packages\meshio\su2_su2.py”, line 340, in write
    for index, (cell_type, data) in enumerate(mesh.cells):
    TypeError: cannot unpack non-iterable CellBlock object

I have attached the sample boxmesh that I used as it is very simple to work with.
box.hdf (168.1 KB)
boxmesh.med (74.5 KB)
boxmesh.py (2.4 KB)

Any help from your end is much appreciated.
Thanks a lot!

Hello @giovanni.medici

I tried using cfdmsh.py as mentioned in the thread you attached in your reply. I loaded the script in Salome’s GUI, selected the Mesh file and ran ExportSU2File(file=“boxmesh.su2”) in the Python Console within Salome. But I am unable to figure out what’s happening after that, I cannot see any mesh file saved in su2 format. I can only see:

ExportSU2File(file=“boxmesh.su2”)
<salome.smesh.smeshBuilder.meshProxy object at 0x000001A792A3EA90>
[i] Writing definition of domain elements… (1022 elements)
[i] Writing node coordinates… (253 nodes)
<class ‘range’>
[i] Writing definition of group elements… (0 groups)

I have attached the files I used below, could you let me know what is it that I am missing here?

box.hdf (168.1 KB)
cfdmsh.py (391.4 KB)

Thanks a lot!

Dear @vishnu67,
I’m really sorry I didn’t see your post before, possibly notifications off or whatever. Nevertheless, thanks for providing your test case, in order for it to run I had to make few modifications:

  1. In the Geometry Module : select Box_1 → Explode (Faces)

  2. In the Mesh Module : select Mesh_1 → Create Group, and create the boundaries that you’ll need afterwards in SU2 as markers.


    In this case I created 3 groups for the Face_1, Face_2, and Face_3, respectively, and one “cumulative” for the remaining faces, just to let you see that (mesh) groups shall not strictly reflect your geometry, you can group them.

  3. Run the script, in my case the line was: ExportSU2File(“Mesh_1”,“Box”, {“Face_1”,“Face_2”,“Face_3”,“Face_46”})

  1. The file will be saved in the same path where your salome executable is running. The resulting file will look something like that …

I hope it helps.

For the records, I also add here the modified *.hdf file
box_groups.hdf (232.1 KB)

1 Like