CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   SU2 (https://www.cfd-online.com/Forums/su2/)
-   -   Tool to convert OpenFoam mesh to SU2 mesh (2D and 3D) (https://www.cfd-online.com/Forums/su2/127445-tool-convert-openfoam-mesh-su2-mesh-2d-3d.html)

fluxCatcher August 11, 2017 13:33

Hi Laurent,

Thanks for the quick response.

This seems to have fixed the throwing of the error. But now I have another problem from the same line. During the format conversion process, it gets stuck while doing one particular cell, (cell no. 18003 out of 1738006).. When I tried to debug, it appears that this 'if' conditional is never true, so the outer 'while' loop never gets terminated.. (for the previous cells, the process didnt enter this 'while' loop, so the problem appeared only for this cell) :

Code:

if (len(CommonPoints(listFaces[listCells[i][j]], listFaces[listCells[i][listLateralFacesOrdered[p]]])) == 2):
Should there have been an 'else' block to handle this situation? Or is it a problem with my mesh? (checkMesh seems to indicate no mesh errors).

Can you please help fix this.
Thanks

Prakriteesh

Combas August 11, 2017 16:24

1 Attachment(s)
It's a long time I have not used this tool and I have never tried to convert meshes with pyramids. Nevertheless, I have looked at the part of the code for the pyramids and found that there is a mistake. I have done a small correction and I hope it will help you. The new code is in attachement.

If you find other bugs, don't hesitate to correct them and share your new code with the community of SU2 users.

Regards,
Laurent

fluxCatcher August 12, 2017 09:12

Hi ,

Thanks for the new code. The bug isn't gone yet for pyramid cells, but I will try fixing it if I can.

Kind regards

Prakriteesh

alexmogavero October 25, 2017 06:17

Very Useful
 
Hi Combas,
thank you for posting this script, it is very useful. May I suggest that you put it on the SU2 project, it would be a very nice contribution.

However I am now facing a problem during the writing of the su2 mesh:
Code:

*******************************************************
 Program to convert OpenFoam meshes to SU2 mesh format
 This program has been written by Laurent Berdoulat
 laurent.berdoulat@wolfconseil.com
 date: 11/12/2013
*******************************************************


Enter the name of the input file:TemplateOpenFoamToSU2_2D.txt
Reading of the input file TemplateOpenFoamToSU2_2D.txt
pathOpenFoamMesh = HB2-24/constant/polyMesh
pathSU2Mesh      = ./
nameSU2MeshFile  = hb2-OF.su2
kindMesh (2D/3D) = 2D
axisProjection  = Z
Input file read correctly

Reading of the 'points' file
nb points =  277191
'points' file read correctly

Reading of the 'faces' file
nb faces =  551610
'faces' file read correctly

Reading of the 'owner' file
nb cells = 137700
nb internal faces = 274420
'owner' file read correctly

Reading of the 'neighbour' file
'neighbour' file read correctly

Reading of the 'boundary' file
nb boundaries = 7
Boundaries = {'frontAndBack': [275400, 0, 'empty'], 'wall': [275400, 810, 'wall'], 'inlet': [274420, 810, 'patch'], 'frontAndBack_pos': [276210, 137700, 'wedge'], 'outlet': [275230, 170, 'patch'], 'frontAndBack_neg': [413910, 137700, 'wedge'], 'axis': [275400, 0, 'symmetryPlane']}
'boundary' file read correctly

Beginning of the format conversion process
Conversion progress: 10 % done
Conversion progress: 20 % done
Conversion progress: 30 % done
Conversion progress: 40 % done
Conversion progress: 50 % done
Conversion progress: 60 % done
Conversion progress: 70 % done
Conversion progress: 80 % done
Conversion progress: 90 % done
Conversion progress: 100% done
Conversion to 2D mesh
listCorrespondance done
listFaces updated
listCellsPoints updated
Final listPoints created
Final listCellsPoints created
listBoundaries updated
Format conversion process ended with success!

Beginning of the .su2 mesh file writting
pathAndFileName = ./hb2-OF.su2
File opened
Problem during the .su2 mesh file writting

Any idea of what the problem can be?

Combas October 26, 2017 04:46

Hi,

I am sorry but I have no idea...
You should check first that you don't have a problem of hard disc full on your computer. Then, you can open the output file and check if it is empty or not. If it is not empty, you can find which part of the writing process fails.
Finally, you can add some "print" commands in the script, or use a Python debugger to find what is wrong.

Regards,
Laurent

alexmogavero October 26, 2017 04:59

Thank you, I have found what was wrong. The Open Foam mesh was not generated by extrusion, but using an app to transform it into a wedge.

Using your app before the transformation into a wedge, solved the issue.

raz November 10, 2017 10:57

Quote:

Originally Posted by Combas (Post 465933)
(*) In fact, I use meshes in Fluent .msh format that I convert in a first time in OpenFoam format (with fluentMeshToFoam command) and then to SU2 format, so if anyone has a method to convert directly Fluent meshes (.msh) directly to SU2 without using Fluent, it would be easier for me... And I woud avoid bugs of fluentMeshToFoam...


Many thanks for this. I was actually looking for a *.cgns to *.su2 converter but since ICEM can also export *.msh this might work as well.

talbring November 13, 2017 04:22

Hi,

thanks for this nice and useful tool! Can someone quickly summarize the capabilities of the current version? If the main creator agrees, we would like to add it to the mesh tools repo (https://github.com/su2code/MeshTools).

Thanks guys!
Tim

harsha_kulkarni June 30, 2018 06:05

OpenFOAM mesh to .SU2
 
Hello friends ,


I got following message while converting OpenFOAM mesh to .SU2 format



Problem during the input file reading (InputOpenFoam2SU2.dat)

harsha_kulkarni June 30, 2018 08:51

Quote:

Originally Posted by Combas (Post 466547)
Hello,

Indeed, this case has a little difference in the "owner" file format (problem of spaces)
I have corrected the python tool and now it works. You can find it in attachment.
Don't hesitate to tell me if you get other bugs!

Laurent


************************************************** *****
Program to convert OpenFoam meshes to SU2 mesh format
This program has been written by Laurent Berdoulat
laurent.berdoulat@wolfconseil.com
date: 11/12/2013
************************************************** *****


Enter the name of the input file:input.txt
Reading of the input file input.txt
pathOpenFoamMesh = /home/harsha/OpenFOAM/harsha-2.4.0/steam_jet_ejector_cfMesh/constant/polyMesh
pathSU2Mesh = /home/harsha/OpenFOAM/harsha-2.4.0/steam_jet_ejector_cfMesh
nameSU2MeshFile = ejector.su2
kindMesh (2D/3D) = 3D
Input file read correctly

Reading of the 'points' file
nb points = 190671
'points' file read correctly

Reading of the 'faces' file
nb faces = 513776
'faces' file read correctly

Reading of the 'owner' file
Problem during the 'owner' file reading


I got this error while converting Mesh

harsha_kulkarni September 2, 2018 06:19

Quote:

Originally Posted by Combas (Post 466547)
Hello,

Indeed, this case has a little difference in the "owner" file format (problem of spaces)
I have corrected the python tool and now it works. You can find it in attachment.
Don't hesitate to tell me if you get other bugs!

Laurent

It does not work. Problem during the 'owner' file reading

harsha_kulkarni September 20, 2018 06:52

Quote:

Originally Posted by Combas (Post 466547)
Hello,

Indeed, this case has a little difference in the "owner" file format (problem of spaces)
I have corrected the python tool and now it works. You can find it in attachment.
Don't hesitate to tell me if you get other bugs!

Laurent

Mesh created using snappyHexmesh or cfmesh is not getting converted into .su2 format

hoyos98 January 14, 2022 14:00

Openfoam7
 
Thank you!

hoyos98 January 14, 2022 14:28

To msh file
 
Hello. Thanks for your help.
I already created the su2 2D file from foam mesh. Now I'm trying to conver the su2 file to .msh (or any format that fluent can read).

Any sugestion?
Thanks

bigfootedrockmidget January 14, 2022 15:21

You can convert directly from foam to fluent with FoamMeshToFluent. You can also use pypi meshio to convert meshes in python.

hoyos98 January 14, 2022 17:10

2D OpenFOAM to 2D fluent
 
Hello. The problem is that using foam convert, a 3D mesh is obtain in fluent (from 2D openFOAM case). Thats why I converted first to SU2 2D. Meshio doesnt works neither.

bigfootedrockmidget January 15, 2022 03:36

What is the problem with meshio? It might be that you lose the boundary conditions, but you can add them in Fluent again.
The best option is maybe (if you have the original CAD file) to export the CAD in a format that you can import in the Fluent Mesher, like cgns, and then mesh in Fluent.

hoyos98 January 15, 2022 14:46

1 Attachment(s)
Hello. I attach the capture of the error of meshio from su2 to msh.
Moreover, the url for the su2 mesh if you can take a look:

https://drive.google.com/file/d/1uat...ew?usp=sharing

Thanks for helping.

bigfootedrockmidget January 17, 2022 05:38

OK, try creating a mesh with only one cell type (either triangles or quadrilaterals), because it is complaining that you need to supply more information if you have a mixed mesh.


Can you not convert convert to a cgns? You can then read the same mesh with fluent and su2.

hoyos98 January 17, 2022 11:49

It is suppose it has only quads. Moreover I tried with cgns but the only way to read that mesh in ansys is via ICEM, but it says that the cgns file was written in a recent version of cgns. I did not found information about how to upgrade the library cgns of ansys (I have the 2020 R2 ansys)


All times are GMT -4. The time now is 23:35.