CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Open Source Meshers: Gmsh, Netgen, CGNS, ...

gmsh basics

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   January 21, 2010, 08:21
Talking gmsh basics
  #1
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Hi there

I'm really new to OpenFoam and gmsh, so please bear with me. For starters I simply want to create a mesh in gmsh and then convert that to something that can be used in OpenFoam. So, I copied the cavity tutorial into my run folder. I deleted everything in the polyMesh folder except for the boundary file. I then pasted cavity.msh and cavity.geo into the polyMesh folder (these are the files I created in gmsh). I then went back to the cavity directory and entered: gmshToFoam cavity.msh .... but its not working. The last line of the error message says segmentation fault.

Any ideas? Should have installed gmshToFoam somewhere along the line? I saw it in the utilities folder so I figured it should take care of its self.

Any help will be greatly appreciated!

Lindsay
lindsaywestraadt is offline   Reply With Quote

Old   January 21, 2010, 23:51
Default
  #2
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Kindof the right start.

First OpenFOAM doesnt care about the .geo file. This is solely for gmsh's use.

Second OpenFOAM doesnt read the .msh file directly. You use the utility you mentioned (gmshToFoam) to convert the .msh file into the mesh files that OpenFOAM reads. gmshToFoam is pre-installed by the way, go ahead and type it in your terminal and the errors will direct you.

Once the mesh is converted you will continue to get errors, because the boundary conditions are not correctly set up yet. Try to get as far as you can. The errors are detailed and helpful. Post again when(or if, lets stay positive) you get stuck.

Cheers!
ericnutsch is offline   Reply With Quote

Old   January 22, 2010, 03:34
Default
  #3
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Hi Eric

Thanks so much for your help! I made my first mesh and viewed it in paraFoam! yay
lindsaywestraadt is offline   Reply With Quote

Old   January 26, 2010, 03:22
Default still having problems
  #4
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Hi there

So, I can make a mesh in gmsh and convert it so that I can use it in OpenFoam, but there's still a problem. When I run icoFoam (still working with the cavity tutorial) and view the results in paraFoam, the results are wrong (there is no pressure field, and the velocity field is 'broken' and incorrect). I checked all the boundary conditions and the only thing that is different between my cavity example and the one provided in the tutorial is the mesh.

Does anyone know why this is not working? Am I using the wrong type of mesh? (I specified the all hexas algorithm)

Help will be greatly appreciated at this point

Lindsay
lindsaywestraadt is offline   Reply With Quote

Old   January 26, 2010, 12:42
Default
  #5
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Does the mesh look the same as the original in paraview?(redundant but note worthy)

For viewing the contours; did you view all the time steps or just zero?(upper right hand corner of paraview)

The boundary conditions will likely not work exactly the same unless the names of the boundaries in your mesh are eXAcTly the same(case sensitive). More times than not this is where the problem is.

If none of those things spark and idea, post a full screen print screen of the broken mesh/contours in paraview.


Hope that helps!
ericnutsch is offline   Reply With Quote

Old   January 27, 2010, 01:54
Default
  #6
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Hi Eric

Thanks again for your response. Below are some screenshots that might help explain my problem:

http://www.quickshare.co.za/files/hv...orial.png.html
http://www.quickshare.co.za/files/4y...orial.png.html
http://www.quickshare.co.za/files/aq...orial.png.html

http://www.quickshare.co.za/files/wj..._gmsh.png.html
http://www.quickshare.co.za/files/y7..._gmsh.png.html
http://www.quickshare.co.za/files/4o..._gmsh.png.html

I am running all the time steps. Also, I made sure that the patch names in the boundary file match those in the initial boundary conditions of p and U. The only thing that I changed in the boundary conditions is the velocity of the movingWall: I changed it from (1 0 0) to (0 0 1) because the coordinates are different in my mesh.

Lindsay
lindsaywestraadt is offline   Reply With Quote

Old   February 3, 2010, 21:04
Red face
  #7
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Sorry to take such a long time to reply.

FYI: In the future I would attach my screen shots by clicking the manage attachments button below. If they are too big just trim them down in GIMP.(this is easier to read, and helps out people 20years down the road when the 3rd party site doesnt exist any more)

Your mesh is much different than I had visualised. You may have just have a convergence issue. Try doubling or tripling the resolution and give it another go.

If that doesn't help it is still probably a boundary issue. Confirm that you have properly specified your boundary conditions in the following files:

YOURCASE/constant/polymesh/boundary
YOURCASE/0/U
YOURCASE/0/P
YOURCASE/0/nut (if you have one)
YOURCASE/0/nuTilda (if you have one)
YOURCASE/0/... (if you have any others in your "0" folder)

If you have transformed these to your mesh and still cant get it to work, attach the files specified above to your post.

Best of luck!
ericnutsch is offline   Reply With Quote

Old   February 4, 2010, 00:37
Default
  #8
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Aah ... that's how I attach files

There was something wrong with the boundary conditions. I was correct in assuming that the velocity of the moving wall was no longer (1 0 0), but, it wasn't (0 0 1) either, it was (0 1 0) So, things are looking better, but the output is still not as smooth as the original example. I think I should just use a finer mesh. The problem I am having now is with generating a finer mesh. I need the mesh to be only 1 element thick, but when I make the mesh finer in gmsh, it also adds an extra layer of elements to the mesh, and OpenFoam doesn't like this. Make sense?
lindsaywestraadt is offline   Reply With Quote

Old   February 4, 2010, 01:34
Default
  #9
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Dont refine using the gmsh gui. You should only control mesh size with the "characteristic length" variable.

http://www.geuz.org/gmsh/doc/texinfo...ristic-lengths


The tutorials section of the user-guide also has good information on its use.

http://www.geuz.org/gmsh/doc/texinfo/gmsh.html#Tutorial
ericnutsch is offline   Reply With Quote

Old   February 4, 2010, 06:56
Default
  #10
New Member
 
Lindsay Westraadt
Join Date: Jan 2010
Posts: 13
Rep Power: 7
lindsaywestraadt is on a distinguished road
Thanks Eric, that helped
lindsaywestraadt is offline   Reply With Quote

Old   June 27, 2010, 23:17
Default
  #11
New Member
 
Join Date: May 2009
Location: Texas
Posts: 10
Rep Power: 8
Kenny is on a distinguished road
Lindsey,

So how do you phrase the command to convert *.msh into someting OpenFoam can read?
Kenny is offline   Reply With Quote

Old   June 28, 2010, 02:35
Default
  #12
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
In a sourced shell type:

gmshToFoam yourMeshName.msh
ericnutsch is offline   Reply With Quote

Old   July 14, 2010, 09:12
Default
  #13
Senior Member
 
Join Date: Apr 2010
Posts: 151
Rep Power: 7
flowris is on a distinguished road
Hello,


I am also a beginner in gmsh, trying to convert using gmshToFoam. I am sure I have a nice msh-file, because I can see the mesh in gmsh. But when I convert it, the console complains that it cannot find any cell.

This is the lower part of the console output:

Code:
...
Unhandled element 1 at line 4738
Unhandled element 1 at line 4739
Unhandled element 1 at line 4740
Unhandled element 1 at line 4741
Unhandled element 1 at line 4742
Unhandled element 1 at line 4743
Unhandled element 1 at line 4744
Unhandled element 1 at line 4745
Unhandled element 1 at line 4746
Unhandled element 1 at line 4747
Unhandled element 1 at line 4748
Mapping region 0 to Foam patch 0
Cells:
    total:0
    hex  :0
    prism:0
    pyr  :0
    tet  :0



No cells read from file "blok01.msh"
Does your file specify any 3D elements (hex=5, prism=6, pyramid=7, tet=4)?
Perhaps you have not exported the 3D elements?

    From function readCells(..)
    in file gmshToFoam.C at line 662.

FOAM exiting
This is my msh-file:
flowris is offline   Reply With Quote

Old   July 14, 2010, 09:23
Default
  #14
Senior Member
 
Join Date: Apr 2010
Posts: 151
Rep Power: 7
flowris is on a distinguished road
Posting again for coarser mesh and smaller file. The same console output:

Code:
...
Unhandled element 1 at line 435
Unhandled element 1 at line 436
Unhandled element 1 at line 437
Unhandled element 1 at line 438
Mapping region 0 to Foam patch 0
Cells:
    total:0
    hex  :0
    prism:0
    pyr  :0
    tet  :0



No cells read from file "blok01.msh"
Does your file specify any 3D elements (hex=5, prism=6, pyramid=7, tet=4)?
Perhaps you have not exported the 3D elements?

    From function readCells(..)
    in file gmshToFoam.C at line 662.

FOAM exiting
And the msh file attached:
Attached Files
File Type: gz blok01.msh.gz (11.0 KB, 10 views)
flowris is offline   Reply With Quote

Old   July 14, 2010, 13:51
Default
  #15
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Just because you can see the mesh does not indicate its quality or compatibility.

Did you make the mesh in gmsh? If so post the geo file. Its possible you have not created any volumes (openfoam only sees volumes, even in 2d)

If you are just viewing the mesh in gmsh you will need to use the openfoam converter for the program that generated it. (you may be able to import into gmsh and save, but it is hard to debug things like the existence of volumes in this fashion.
ericnutsch is offline   Reply With Quote

Old   July 14, 2010, 16:22
Default
  #16
Senior Member
 
Join Date: Apr 2010
Posts: 151
Rep Power: 7
flowris is on a distinguished road
Thanks for the quick reply. Indeed I meshed with gmsh, here is the geo-file.
Attached Files
File Type: gz blok01.geo.tar.gz (793 Bytes, 18 views)
flowris is offline   Reply With Quote

Old   July 14, 2010, 16:39
Default
  #17
Senior Member
 
Join Date: Apr 2010
Posts: 151
Rep Power: 7
flowris is on a distinguished road
Hello again,

I am also converting a mesh around an extruded "lens-shaped" half ship. The mesh has two problems:

1. Three unused points: these are the centres of the arcs. They are outside the mesh and not needed, but I do not know how to delete them.

2. High aspect ratio cells. I was able to improve mesh quality by refining the cells and by smoothing and optimizing. I used following command:
gmsh -3 -smooth 5 -optimize lens.geo

How can I use other mesh algorithms. I tried the option -algo front3d, but the concole responded
Fatal : Unknown mesh algorithm
(this also happened with the other algorithms)


BTW: I use gmsh-2.4.2 and OpenFOAM-1.6
Attached Files
File Type: txt lens02.txt (741 Bytes, 19 views)
flowris is offline   Reply With Quote

Old   July 14, 2010, 22:19
Default
  #18
Senior Member
 
Eric Nutsch
Join Date: Sep 2009
Location: Eugene, Oregon USA
Posts: 112
Rep Power: 7
ericnutsch is on a distinguished road
Send a message via Skype™ to ericnutsch
Well you have stumped me. I cleaned up you file to just the active code so others can review it quickly.

Code:
//

lc = 0.03;

Point(0) = {0, 0, 0, lc};
Point(1) = {.1, 0,  0, lc} ;
Point(2) = {.1, .3, 0, lc} ;
Point(3) = {0,  .3, 0, lc} ;
Point(4) = {0, 0, .3, lc};
Point(5) = {.1, 0,  .3, lc} ;
Point(6) = {.1, .3, .3, lc} ;
Point(7) = {0,  .3, .3, lc} ;

Line(0) = {0,1} ;
Line(1) = {1,2} ;
Line(2) = {3,2} ;
Line(3) = {0,3} ;
Line(4) = {0,4} ;
Line(5) = {1,5} ;
Line(6) = {2,6} ;
Line(7) = {3,7} ;
Line(8) = {4,5} ;
Line(9) = {5,6} ;
Line(10) = {7,6} ;
Line(11) = {4,7} ;

Line Loop(12) = {0,1,-2,-3} ;
Line Loop(13) = {0,5,-8,-4} ;
Line Loop(14) = {1,6,-9,-5} ;
Line Loop(15) = {2,6,-10,-7} ;
Line Loop(16) = {3,7,-11,-4} ;
Line Loop(17) = {8,9,-10,-11} ;

Plane Surface(20) = {12} ;
Plane Surface(21) = {13} ;
Plane Surface(22) = {14} ;
Plane Surface(23) = {15} ;
Plane Surface(24) = {16} ;
Plane Surface(25) = {17} ;

Surface Loop(100) = {20,21,22,23,24,25};
Volume(101) = {100};
It is probably a negative volume issue. I messed with the face orientations some, but didnt have any luck. I have had problems like this before and it always comes down to an issue in the .geo file. Some times it is easier to start over with a working example. I belive there is a similar tutorial here: http://www.dolfyn.net/dolfyn/gmsh/tutorial00.html

If this is a practice case you will need to resolve the issue. If you are only trying to create a box, I strongly encourage you to use the extrude command instead of the surface loop method.

I will review it later as time alots...

Here is my error statement if it helps. It recognizes the tets but not much different.

Code:
Unhandled element 1 at line 558
Unhandled element 1 at line 559
Unhandled element 1 at line 560
Unhandled element 1 at line 561
Unhandled element 1 at line 562
Unhandled element 1 at line 563
Unhandled element 1 at line 564
Unhandled element 1 at line 565
Mapping region 0 to Foam patch 0
Mapping region 0 to Foam cellZone 0
Cells:
    total:1748
    hex  :0
    prism:0
    pyr  :0
    tet  :1748

CellZones:
Zone    Size
    0    1748

Skipping tag  at line 2971
Patch 0 gets name patch0

--> FOAM Warning : 
    From function polyMesh::polyMesh(... construct from shapes...)
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 582
    Found 656 undefined faces in mesh; adding to default patch.
Finding faces of patch 0
ericnutsch is offline   Reply With Quote

Reply

Tags
gmshtofoam

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Gmsh nishant_hull Open Source Meshers: Gmsh, Netgen, CGNS, ... 19 July 31, 2015 05:10
CAD -> gMsh -> enGrid -> OpenFOAM Problem AlGates OpenFOAM 7 August 6, 2010 12:46
Error converting Gmsh mesh to OpenFOAM format Martin_ OpenFOAM Meshing & Mesh Conversion 3 December 9, 2009 10:35
gmsh to openfoam sarajags_89 OpenFOAM 1 October 8, 2009 05:15
How does Gmsh deal with overlap boundaries? yuhai Open Source Meshers: Gmsh, Netgen, CGNS, ... 1 April 24, 2009 13:34


All times are GMT -4. The time now is 14:13.