|
[Sponsors] |
[Salome] Script for converting a mesh from Salome-Platform to OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
March 21, 2015, 11:28 |
|
#41 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,981
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Nicolas: I've created a basic wiki page to help getting your salomeToOpenFOAM script(s) known to the community that uses OpenFOAM technology: http://openfoamwiki.net/index.php/Co...lomeToOpenFOAM May you or anyone else feel free to update that wiki page! Best regards, Bruno Last edited by wyldckat; March 21, 2015 at 14:46. |
|
March 23, 2015, 05:02 |
|
#42 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi Bruno thanks for the stub!
Next time I modify the script I'll see if I can't find time to update the wiki as well. /Nicolas Last edited by nsf; March 23, 2015 at 05:03. Reason: fixed typo |
|
June 17, 2015, 13:30 |
|
#43 |
Member
Pierluigi Cirrottola
Join Date: Jun 2013
Posts: 52
Rep Power: 13 |
Hi Nicolas,
perhaps do you have a solution about direct reading a .vtk mesh file into Salomé? At present I'm pushed to a work-around: step 1) using GMESH I read .vtk and I save to .med step 2) using Salomé I read .med and , after some editing, I use your tool to export to openFOAM. Thanks a lot Piero |
|
June 23, 2015, 15:37 |
|
#44 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
/Nicolas |
||
October 5, 2015, 14:24 |
|
#45 |
Member
hssn
Join Date: Mar 2015
Posts: 31
Rep Power: 11 |
hi
icreated mesh and load scrip salomeToOpenFOAM.py and what happened than? which file created ? and where? |
|
October 5, 2015, 17:05 |
|
#46 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
With the little information you've provided that's really all I can say. Please read through this thread and I think you'll find out how to use the script. Best Regards |
||
January 12, 2016, 08:21 |
problem with select a mesh
|
#47 |
Member
Paul Palladium
Join Date: Jan 2016
Posts: 94
Rep Power: 10 |
Hi,
I got a strange error and i don't understand the problem. I didn't find any information on the internet. When i run the script (on Salome 7.7.1) I get an error message : >>> execfile(r"/home/g-met/Bureau/calculB_mesh/salomeToOpenFOAM.py") You have to select a mesh object and then run this script. or run the export function directly from TUI import SalomeToOpenFOAM SalomeToOpenFOAM.exportToFoam(mesh,path) Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/g-met/Bureau/calculB_mesh/salomeToOpenFOAM.py", line 615, in <module> main() File "/home/g-met/Bureau/calculB_mesh/salomeToOpenFOAM.py", line 605, in main for mesh in meshes: TypeError: 'NoneType' object is not iterable But i did select Mesh_1 in the object Brower... I printed selected=salome.sg.getSelected(i) selobjID=salome.myStudy.FindObjectID(selected) selobj=selobjID.GetObject() and i got 0:1:2:3 <SALOMEDS._objref_SObject instance at 0x45a24c0> <salome.smesh.smeshBuilder.meshProxy instance at 0x279e59c0> Do you have any idea about this ? Thanks for your help Best Regards |
|
January 12, 2016, 17:09 |
|
#48 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
Thanks for using the code! I havn't had time to try out Salome 7.7.1. It would seem they changed the class name of meshes. I don't have time to investigate this today but if you'd like to give it a try the snippet that checks if the user actually selected a mesh is around line 572. You could try to comment out those lines and just have the function return meshes. But I don't know what else got changed so there might be other errors as well. I'll see if I can find some time to look at it this week. Let me know if you give it a try. Best Regards Nicolas |
||
January 14, 2016, 17:39 |
|
#49 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
I've pushed an update to github that works for a small testcase on Salome 7.7.
I haven't had time for proper testing so please let me know if you find bugs. Best Regards Nicolas |
|
January 15, 2016, 05:09 |
|
#50 |
Member
Paul Palladium
Join Date: Jan 2016
Posts: 94
Rep Power: 10 |
Thanks Nicolas for your help,
I tried this morning on a mesh. it works. But when I refine my mesh it seems to take a long long time to convert. After 5 min the conversion is still not finished. Is it normal ? Regards |
|
January 15, 2016, 06:35 |
|
#51 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
I'm sure it could be speed up alot. But the main problem is that there is no information (or at least not last I checked) on neighbours of a cell face in salome. That means the script has to look up which faces it already has added. At around 1 million cells it's actually faster to generate the mesh than to convert it. If you'd like to improve the script then please go ahead! |
||
January 15, 2016, 07:09 |
|
#52 |
Member
Paul Palladium
Join Date: Jan 2016
Posts: 94
Rep Power: 10 |
Thanks for your reply Nicolas.
I am afraid I can't improve your script. It's really not my domain of knowledge. In fact, I wanted to use your script because the UNV to FOAM procedure gave me a lot of errors (especially when I have prisms layers with a complex geometry shape). The mesh on salome is ok but when I convert it to openfoam I get negative volume, non orthogonal faces and/or high ratio elements). I read a post of you explaining those problems could come from the conversation unv to foam. The speed of the conversion is not really a problem for me. I was just a bit surprised . Thanks again for your help. |
|
July 6, 2016, 12:14 |
Am I converting my mesh correctly?
|
#53 |
New Member
Sian
Join Date: Jun 2016
Posts: 5
Rep Power: 10 |
Hi,
Thanks for all your posts. They've been really helpful. Thanks also to Nicolas for creating the script. I'm converting a mesh from Salome 7.8.0 for OpenFOAM 2.1.1, using the Salome 7.7 version of the script. I followed the instructions in the README file, but found that creating groups of volumes on the mesh as indicated in the file, didn't allow me to define my boundaries. I created groups of faces on my mesh instead and was able to create the required mesh and modify by boundaries. I was then able to run it in OpenFOAM and check it in paraFOAM. I'm a little worried that creating groups of volumes on the mesh was required for another purpose, that I may have missed. Also, do I need to specify which are internal faces and should be treated as face matching or face merging? I'm a little concerned as OpenFOAM cannot converge to a solution on my mesh. This is most likely due to a completely separate issue though. Thanks, Siân |
|
July 6, 2016, 17:16 |
|
#54 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi Siân,
Groups of volumes is for creating cell zones. For use with setFields or similar tools. As you've already noted groups of faces is for creating boundaries. You should not set boundaries for internal faces. The exception would be if you want a baffle. Please check the included sample scripts. The mesh could be a source of problem but the most probable is ill defined boundary conditions. If check mesh is fine try to run something more simple like potentialFoam and see if that works. Best regards Nicolas |
|
November 2, 2016, 09:10 |
|
#55 |
Member
Sören Sander
Join Date: Sep 2012
Location: Germany
Posts: 43
Rep Power: 14 |
Hello Nicolas,
thank you very much for your great work. Most of the meshes I exported are working fine. However, I cannot export a wedge to openFoam. The mesh is successfully exported, but the "wedge" is missing in the boundary file. What I did: 1. I defined a pipe-like geometry, with an inlet at the y-Plane, an outlet downstream and an axis along and on the x-Axis. The parallel side is named walls. 2. I created a netgen 1D-2D hypothesis based surface mesh 3. I created and added the boundaries (edges for walls, inlet, outlet, axis and 1 surface "front") and added them to the mesh 4. I rotated the mesh -2.5 degree around x-axis 5. I revolved the mesh 5 degree around x-axis 6. This leaves me with a 3D wedge with several boudaries (edges, surfaces, volumes). I deleted all except the groups of faces for front, back (front_rotated), walls_rotated, inlet_rotated, outlet_rotated and the groups of edges: axis. 7. I applied your script: Code:
>>> execfile(r"/.../salomeToOpenFOAM.py") found selected mesh exporting to /.../pipe/constant/polyMesh Number of nodes: 18679 Number of cells: 18398 Counting number of faces: total number of faces: 64433, internal: 27357, external 37076 Converting mesh to OpenFOAM Finished processing boundary faces . . . . . . . . . : . . . . . . . . . : . Finished processing volumes. Sorting faces in upper triangular order Writing the file points Writing the file faces Writing the file owner Writing the file neighbour Writing the file boundary Finished writing to /.../pipe Converted mesh in 14s Wrote mesh in 1s Total time: 15s I use Salome 7.6.0. |
|
November 2, 2016, 15:52 |
|
#56 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi Sören,
It's nice to see you've found uses for the script. I've actually never worked with wedges. Therefore I never considered them while writing the script. I'm not sure I can think of a bullet proof way for the script to know it should create a wedge. But I can offer two workarounds. 1) Export the mesh as a 3D mesh using salomeToOpenFOAM. Then go to constant/polyMesh/boundary and manually adjust the file so it works. You'll have to set "type wedge;" for the front and back patches. You'll also have to add Code:
axis { type empty; inGroups 1(empty); nFaces 0; startFace 14855; //since nFaces is 0 this number doesn't matter. } 2) Is to mesh a 2D surface in salome and save it as an STL, then extrude it as a wedge. Have a lookt at $FOAM_APP/utilities/mesh/generation/extrude/extrudeMesh/extrudeMeshDict which shows how to extrude an STL to a 3D wedge. Since you cant name edges in STL-files you'll have to recreate the patches. Have a look at the autoPatch utility. Personally I would go for option 1 first. If you encounter a major problem I would go for option 2. Now, as I already pointed out in this thread. The script is pure python and one of the first scripts I created. It's very slow. Unbearably slow for meshes larger than 1M cells. Good luck! Best Regards Nicolas |
|
November 3, 2016, 05:10 |
|
#57 |
New Member
Join Date: Mar 2015
Location: Earth yet
Posts: 25
Rep Power: 11 |
Code:
>>> execfile(r".../openFOAM/salomeToOpenFOAM.py") You have to select a mesh object and then run this script. or run the export function directly from TUI import SalomeToOpenFOAM SalomeToOpenFOAM.exportToFoam(mesh,path) Traceback (most recent call last): File "<input>", line 1, in <module> File ".../openFOAM/salomeToOpenFOAM.py", line 607, in <module> main() File ".../openFOAM/salomeToOpenFOAM.py", line 597, in main for mesh in meshes: TypeError: 'NoneType' object is not iterable >>> Hi Nicholas, I am getting the same error report as a few post earlier on Salomé 7.8.0, I did select a mesh to export and I also used the updated 02/2016 version of salomeToFoam. I tried it on some old mesh I know I had succesfully exported with previous salomé version and your old python script, but it does not work either. Is there a workaround for that? Thanks in advance for your effort |
|
November 3, 2016, 18:19 |
|
#58 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi cocccone,
I've just installed salome 7.8 and it seems to work. I can't reproduce your problem. For some reason the script doesn't recognize whatever you selected as a mesh, I can't guess as to why. I have however just pushed a commit that will improve the error message. Best Regards Nicolas |
|
November 4, 2016, 05:03 |
|
#59 | |
New Member
Join Date: Mar 2015
Location: Earth yet
Posts: 25
Rep Power: 11 |
Quote:
I just tried the last one you pushed yesterday and it works with that, no error showing up. I wondered if I was mistaken using the previous version I had (10/02/2016) so I tried with that again and it still did not work. Attached there is the troublesome version if you want to dig into it, as far as it concerns me I am fine with the new one. Thanks again for your time, I appreciated it. Take care, coccone |
||
December 13, 2016, 06:31 |
extra faces in salome
|
#60 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 12 |
Dear,
I am really appreciated for Nicolas's work. It saved me a lot of time!!! I have solved the problem about the internal faces. Just post to make the problem clear and provide possible solutions. I met a problem with internal faces. The simple geometry is attached. I used partition tool in Salome, which helps me to divide the whole block into several blocks, but there are extra faces, as highlighted in the attachment. They are not expected to be defined in OpenFOAM, as they are actully in the flow domain(The small square is the solid domain). When I read the salome file, these undefined faces will be added to a new group defaulPatches. Code:
>>> execfile(r"/home/LEPT/ywang/OpenFOAM/ywang-3.0.1/runsalomeToOpenFOAM-mastersalomeToOpenFOAM.py") found selected mesh exporting to /home/LEPT/ywang/OpenFOAM/ywang-3.0.1/runlome/Mesh_1/constant/polyMesh. Number of nodes: 592480 Number of cells: 0 Counting number of faces: total number of faces: 296880, internal: -296880, external 593760 Converting mesh to OpenFOAM Warning, some elements don't have a group (BC). Adding to a new group called defaultPatches Finished processing boundary faces Finished processing volumes. Sorting faces in upper triangular order Writing the file points Writing the file faces Writing the file owner Writing the file neighbour Writing the file boundary Finished writing to /home/LEPT/ywang/OpenFOAM/ywang-3.0.1/runlome//home/LEPT/ywang/OpenFOAM/ywang-3.0.1/runsalome/Mesh_1/constant/polyMesh Converted mesh in 2703s Wrote mesh in 6s Total time: 2709s finished exporting >>> Code:
Sorting boundary faces according to group (patch) 0: inlet is #0 Foam::error::printStack (Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in "/lib/x86_64-linux-gnu/libc.so.6" #3 ? at ??:? #4 ___libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #5 ? at ??:? Segmentation fault --> FOAM FATAL IO ERROR: Expected a ')' or a '}' while reading List, found on lie 296898 the label 4 file: /home/LEPT/ywang/OpenFOAM/ywang-3.0.1/run/UC/constant/polyMesh/faces at line 296898. From function Istream::readEndList(const char*) in file db/IOstreams/IOstreams/IOstream.C at line 159. The solution is simple but has cost me some time to figure out, just add Prism_3D in the applied algorithms. The mesh can be successfully exported and without any defaultPatches. Thank you. Regards, Bill Last edited by 6863523; December 14, 2016 at 11:28. |
|
Tags |
mesh conversion, openfoam, salome meca |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Salome] how to setFields in openFOAM when you have imported mesh from salome or other package | 13msmemusman | OpenFOAM Meshing & Mesh Conversion | 11 | May 18, 2022 08:30 |
[Salome] import mesh from salome to openfoam | dome90 | OpenFOAM Meshing & Mesh Conversion | 2 | April 21, 2016 00:58 |
[Salome] Step to export mesh from SALOME to OpenFoam for 3D MRF geometry | aminem | OpenFOAM Meshing & Mesh Conversion | 0 | September 16, 2014 11:18 |
[Salome] Mesh Salome 7.3.0 to OpenFoam | Ahadi | OpenFOAM Meshing & Mesh Conversion | 5 | July 1, 2014 11:11 |
Mesh conversion problem from Salome to openfoam | jishnusoni | OpenFOAM | 15 | March 3, 2010 02:53 |