GMSH to OPenFOAM - What am I doing wrong?
Ok, so I've tried to make a simulation of a complex geometry however I've failed to import GMSH .msh file into OpenFOAM. Therefore I've decide to practice a little bit on a very simple geometry. Yet, still I cannot import the mesh using gmshToFoam command. I'll try to describe step by step what I am doing. Please help me with that issue. I think I am making a basic mistake but I have no idea what is it.
1. I've created a simple geometry of mixing tee using GMSH and saved it as geo file: Quote:
3. I've copied the mesh file which looks like that: Quote:
5. I've run gmshToFoam with the following result: Quote:
So, what am I doing wrong? It looks so extremly simple on any of tutorials. The situation is identical for GMSH (4.5.4) for windows (Win 10) and BlueCFD OpenFOAM (OF 5.x) as well as for GMSH (4.5.4) for Linux (Ubuntu) and OpenFoam 7.x. Big thanks for help! |
You have forgotten to define the volume, so just add this line to your script:
Physical Volume("air") = {1}; |
Dear mzzmrt,
The volume did not solve the problem: Quote:
|
Interesting! I have tried this with Gmsh 3.0.6 and OpenFOAM 4.1 on Linux and works as usual.
Here is the geo script: // Gmsh project created on Fri Mar 20 11:50:21 2020 //+ SetFactory("OpenCASCADE"); Cylinder(1) = {0, 0, 0, 0, 0, 0.872, 0.023, 2*Pi}; //+ Cylinder(2) = {0, 0, 0.272, 0, 0.05, 0, 0.003, 2*Pi}; //+ BooleanUnion{ Volume{1}; Delete; }{ Volume{2}; Delete; } //+ Physical Surface("inlet1") = {2}; //+ Physical Surface("inlet2") = {5}; //+ Physical Surface("outlet") = {3}; //+ Physical Surface("wall") = {1, 4}; //+ Physical Volume("air") = {1}; Here is the gmshToFoam result: Starting to read mesh format at line 2 Read format version 2.2 ascii 0 Starting to read physical names at line 5 Physical names:5 Surface 1 inlet1 Surface 2 inlet2 Surface 3 outlet Surface 4 wall Volume 5 air Starting to read points at line 13 Vertices to be read:77 Vertices read:77 Starting to read cells at line 93 Cells to be read:264 Mapping region 4 to Foam patch 0 Mapping region 1 to Foam patch 1 Mapping region 3 to Foam patch 2 Mapping region 2 to Foam patch 3 Mapping region 5 to Foam cellZone 0 Cells: total:114 hex :0 prism:0 pyr :0 tet :114 CellZones: Zone Size 0 114 Skipping tag at line 360 Patch 0 gets name wall Patch 1 gets name inlet1 Patch 2 gets name outlet Patch 3 gets name inlet2 --> FOAM Warning : From function Foam::polyMesh::polyMesh(const Foam::IOobject&, const Foam::Xfer<Foam::Field<Foam::Vector<double> > >&, const cellShapeList&, const faceListList&, const wordList&, const wordList&, const Foam::word&, const Foam::word&, const wordList&, bool) in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 595 Found 150 undefined faces in mesh; adding to default patch. Finding faces of patch 0 Finding faces of patch 1 Finding faces of patch 2 Finding faces of patch 3 FaceZones: Zone Size Writing zone 0 to cellZone air and cellSet End |
1 Attachment(s)
Could it be an issue with the GMSH 4.5.4? I've tried to walk around this problem. I've exported the mesh into nastran file, then it was imported to fluent. In fluent also no boundaries were visible (inlet, outlet, wall) but the mesh was ok. But I've named the surfaces and exported cas file. The cas file was imported to OpenFoam correctly.
I've attached the geo file with mesh generated for element size factor = 0.25. Dear mzzmrt I would be gratefull if you could take a look at them. Could you try to import the msh file into OpenFoam? Could you generate such msh file for me and I'll try to import it. |
I have tried your *.msh file but there is a problem with it.
I have made and exported the mesh with gmsh 4.5.4 (named as x.msh) and imported it to the OpenFOAM 7, no problem at all. You can get this mesh and the secreen capture at http://www.fileconvoy.com/dfl.php?id...1e93d59e5657b1 |
5 Attachment(s)
Thank you for your answer. The mesh also works for me.
Concluding the problem is at the stage of mesh export. I've asked my colleague to download gmsh and generate a simple mesh of any random geometry. He has encountered exactly the same issue. All surfaces stitched into patch0. The same proble appears in GMSH 4.5.5. One of the difference between your mesh and my mesh is the elements notation. In your mesh it is: $Elements 73952 1 2 2 4 1 1 1231 83 In my mesh: $Elements 2120 1 15 2 0 1 1 (7 parameters vs. 5 parameters) I've attached the step by step screens presenting the mesh export process. What am I doing wrong? |
Just do NOT use "save all elements" while exporting!
|
2 Attachment(s)
Your advise works as long as I am using geometry generated in GMSH. Then, everything works fine. But when I've exported a step file another problem appeard. Take a look on the screenshots. When the mesh is saved without "all elements" option GMSH saves only the surface mesh of patches (although a physical patch of volume is also made). When I try to import such mesh to OpenFoam the following error appears:
Quote:
|
Hi,
1. gmshToFoam converts MSH files, not GEO. 2. gmshToFoam converts version 2 MSH files (-format msh2 command line switch). Though if you files are version 4, usually error is different. 3. gmshToFoam can handle only these types of elements: Code:
static label MSHTRI = 2; |
Hi alexeym,
The problem appears only when the geometry is created via stp file import. In all other cases everything works fine. And the stp file is ok - it was used in ANSYS MESH and in Salome mesh module without any issues. I guess I'll have to switch to other software. Best regards |
Hi,
If you have Ansys or Salome mesh, why not just import it into OpenFOAM? If you have STP, you can convert it to STL and then use snappyHexMesh to create mesh. Guess, since you are ready to switch to another software, utilitsation of Gmsh for meshing is not your aim. |
I was forced to use the open-license sotwere (I have some experience using ANSYS Fluent but it could not be used in this case). When I asked for advice for the best meshing software everyone told me to try GMSH. Unfortunately, it did not work form me. I switched to Salome and it works.
Well, thank you all for your help. |
I'm having the same problem. It seems like element 15 and 1 correspond to the points and lines, respectively, found in: gmsh - Tools - Statistics - Mesh. Haven't found a solution yet when using gmsh, however.
|
Fix
Things I found out when trying to fix this issue exporting from SOLIDWORKS to gmsh, and then to OpenFOAM:
If you're importing STEP file from SOLIDWORKS, you should add the command SetFactory("OpenCASCADE") in your .geo file. If I didn't do this, I could not extrude my mesh/fluid domain. I had to extrude it since OpenFOAM requires the mesh to be 3-dimensional. Extrude the mesh with one layer, where the size of this layer does not matter. To add on this, I had to use 3D mesh when generating the mesh before importing into OpenFOAM. Not only did I need to define physical surfaces, the physical volume also had to be defined before I could import it properly into OpenFOAM. When exporting the mesh from gmsh, I went to File - Export, and used the .msh format. I then chose version 2 ASCII, and left both the "Save all elements" and "Save parametric coordinates" unchecked. If "Save all elements" was checked, I would get the "Unhandled element 1" and "Unhandled element 15" errors, since it saves the points (15) and lines (1) as well. I hope someone found this helpful :D |
All times are GMT -4. The time now is 20:05. |