CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > SU2

Tool to convert OpenFoam mesh to SU2 mesh (2D and 3D)

Register Blogs Community New Posts Updated Threads Search

Like Tree17Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 11, 2017, 14:33
Default
  #21
New Member
 
Prakriteesh Sarma
Join Date: Oct 2016
Posts: 6
Rep Power: 10
fluxCatcher is on a distinguished road
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

Last edited by fluxCatcher; August 11, 2017 at 14:35. Reason: text layout gone wrong
fluxCatcher is offline   Reply With Quote

Old   August 11, 2017, 17:24
Default
  #22
Member
 
Join Date: Sep 2013
Posts: 43
Rep Power: 13
Combas is on a distinguished road
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
Attached Files
File Type: gz ConvertOpenFoam2SU2.py.gz (5.2 KB, 169 views)
Combas is offline   Reply With Quote

Old   August 12, 2017, 10:12
Default
  #23
New Member
 
Prakriteesh Sarma
Join Date: Oct 2016
Posts: 6
Rep Power: 10
fluxCatcher is on a distinguished road
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
fluxCatcher is offline   Reply With Quote

Old   October 25, 2017, 07:17
Default Very Useful
  #24
New Member
 
Alessandro Mogavero
Join Date: Nov 2012
Location: Glasgow
Posts: 15
Rep Power: 14
alexmogavero is on a distinguished road
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?
alexmogavero is offline   Reply With Quote

Old   October 26, 2017, 05:46
Default
  #25
Member
 
Join Date: Sep 2013
Posts: 43
Rep Power: 13
Combas is on a distinguished road
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
Combas is offline   Reply With Quote

Old   October 26, 2017, 05:59
Default
  #26
New Member
 
Alessandro Mogavero
Join Date: Nov 2012
Location: Glasgow
Posts: 15
Rep Power: 14
alexmogavero is on a distinguished road
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.
alexmogavero is offline   Reply With Quote

Old   November 10, 2017, 11:57
Default
  #27
raz
Member
 
Join Date: Nov 2015
Posts: 30
Rep Power: 11
raz is on a distinguished road
Quote:
Originally Posted by Combas View Post
(*) 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.
raz is offline   Reply With Quote

Old   November 13, 2017, 05:22
Default
  #28
Super Moderator
 
Tim Albring
Join Date: Sep 2015
Posts: 195
Rep Power: 11
talbring is on a distinguished road
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
__________________
Developer Director @ SU2 Foundation

Get involved:
talbring is offline   Reply With Quote

Old   June 30, 2018, 07:05
Default OpenFOAM mesh to .SU2
  #29
Senior Member
 
harshawardhank
Join Date: Mar 2014
Posts: 209
Rep Power: 13
harsha_kulkarni is on a distinguished road
Hello friends ,


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



Problem during the input file reading (InputOpenFoam2SU2.dat)
harsha_kulkarni is offline   Reply With Quote

Old   June 30, 2018, 09:51
Default
  #30
Senior Member
 
harshawardhank
Join Date: Mar 2014
Posts: 209
Rep Power: 13
harsha_kulkarni is on a distinguished road
Quote:
Originally Posted by Combas View Post
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 is offline   Reply With Quote

Old   September 2, 2018, 07:19
Default
  #31
Senior Member
 
harshawardhank
Join Date: Mar 2014
Posts: 209
Rep Power: 13
harsha_kulkarni is on a distinguished road
Quote:
Originally Posted by Combas View Post
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 is offline   Reply With Quote

Old   September 20, 2018, 07:52
Default
  #32
Senior Member
 
harshawardhank
Join Date: Mar 2014
Posts: 209
Rep Power: 13
harsha_kulkarni is on a distinguished road
Quote:
Originally Posted by Combas View Post
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
harsha_kulkarni is offline   Reply With Quote

Old   January 14, 2022, 15:00
Default Openfoam7
  #33
New Member
 
jose daniel
Join Date: Apr 2020
Posts: 26
Rep Power: 6
hoyos98 is on a distinguished road
Thank you!
hoyos98 is offline   Reply With Quote

Old   January 14, 2022, 15:28
Default To msh file
  #34
New Member
 
jose daniel
Join Date: Apr 2020
Posts: 26
Rep Power: 6
hoyos98 is on a distinguished road
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
hoyos98 is offline   Reply With Quote

Old   January 14, 2022, 16:21
Default
  #35
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 649
Rep Power: 19
bigfootedrockmidget is on a distinguished road
You can convert directly from foam to fluent with FoamMeshToFluent. You can also use pypi meshio to convert meshes in python.
bigfootedrockmidget is offline   Reply With Quote

Old   January 14, 2022, 18:10
Default 2D OpenFOAM to 2D fluent
  #36
New Member
 
jose daniel
Join Date: Apr 2020
Posts: 26
Rep Power: 6
hoyos98 is on a distinguished road
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.
hoyos98 is offline   Reply With Quote

Old   January 15, 2022, 04:36
Default
  #37
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 649
Rep Power: 19
bigfootedrockmidget is on a distinguished road
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.
bigfootedrockmidget is offline   Reply With Quote

Old   January 15, 2022, 15:46
Default
  #38
New Member
 
jose daniel
Join Date: Apr 2020
Posts: 26
Rep Power: 6
hoyos98 is on a distinguished road
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.
Attached Images
File Type: png Capture.PNG (130.2 KB, 25 views)
hoyos98 is offline   Reply With Quote

Old   January 17, 2022, 06:38
Default
  #39
Senior Member
 
bigfoot
Join Date: Dec 2011
Location: Netherlands
Posts: 649
Rep Power: 19
bigfootedrockmidget is on a distinguished road
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.
bigfootedrockmidget is offline   Reply With Quote

Old   January 17, 2022, 12:49
Default
  #40
New Member
 
jose daniel
Join Date: Apr 2020
Posts: 26
Rep Power: 6
hoyos98 is on a distinguished road
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)
hoyos98 is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



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