CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Meshing & Mesh Conversion

[Gmsh] gmshToFoam problem: not the same mesh in Gmsh vs. paraview

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 12, 2010, 12:53
Post gmshToFoam problem: not the same mesh in Gmsh vs. paraview
  #1
New Member
 
Zoltan Hernadi
Join Date: Jul 2010
Posts: 12
Rep Power: 16
zhernadi is on a distinguished road
Hi there,

I am a new user of OpenFOAM and I have some problems using gmshToFoam. When I convert an .msh file for using in OpenFOAM the resulting mesh is not the same. There might be some problems with boundaries linked (I have to create 'defaultFaces' boundaries, otherwise paraFoam fails).

I use 64bit Ubuntu 10.04 with OpenFoam 1.7.0, ParaView 3.8.0 and Gmsh 2.4.2. I write down my very simple example so anyone can reproduce this problem.

1. I created an empty directory:
mkdir cuboid
cd cuboid/

2. I created a text file for the geometry:
nano cuboid.geo

Code:
Point(1) = {0, 0, 0};
Point(2) = {0, 0, 3};
Point(3) = {0, 2, 0};
Point(4) = {0, 2, 3};
Point(5) = {1, 0, 0};
Point(6) = {1, 0, 3};
Point(7) = {1, 2, 0};
Point(8) = {1, 2, 3};
Line(1) = {8, 7};
Line(2) = {7, 3};
Line(3) = {3, 4};
Line(4) = {4, 8};
Line(5) = {6, 5};
Line(6) = {5, 1};
Line(7) = {1, 2};
Line(8) = {2, 6};
Line(9) = {4, 2};
Line(10) = {6, 8};
Line(11) = {7, 5};
Line(12) = {1, 3};
Line Loop(13) = {10, -4, 9, 8};
Plane Surface(14) = {13};
Line Loop(15) = {9, -7, 12, 3};
Plane Surface(16) = {15};
Line Loop(17) = {6, 12, -2, 11};
Plane Surface(18) = {17};
Line Loop(19) = {11, -5, 10, 1};
Plane Surface(20) = {19};
Line Loop(21) = {8, 5, 6, 7};
Plane Surface(22) = {21};
Line Loop(23) = {4, 1, 2, 3};
Plane Surface(24) = {23};
Surface Loop(25) = {14, 20, 18, 22, 16, 24};
Volume(26) = {25};
Physical Surface("outlet") = {14};
Physical Surface("noslipwall") = {20, 24, 16, 22};
Physical Surface("inlet") = {18};
Physical Volume(27) = {26};
3. I created the mesh in cuboid.msh with this command:
gmsh cuboid.geo -3

4. I created three files as follows.

mkdir system 0
cp $FOAM_TUTORIALS/incompressible/icoFoam/elbow/system/controlDict system/
nano 0/p

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volScalarField;
    object      p;
}
dimensions      [0 2 -2 0 0 0 0];
internalField   uniform 0;
boundaryField
{
    noslipwall          
    {
        type            zeroGradient;
    }
    inlet
    {
        type            zeroGradient;
    }
    outlet 
    {
        type            fixedValue;
        value           uniform 0;
    }
    defaultFaces
    {
        type            fixedValue;
        value           uniform 0;
    }
}
nano 0/U

Code:
FoamFile
{
    version     2.0;
    format      ascii;
    class       volVectorField;
    object      U;
}
dimensions      [0 1 -1 0 0 0 0];
internalField   uniform (0 0 0);
boundaryField
{
    noslipwall          
    {
        type            fixedValue;
        value           uniform (0 0 0);
    }
    inlet
    {
        type            fixedValue;
        value           uniform (0 0 1);
    }
    outlet 
    {
        type            zeroGradient;
    }
    defaultFaces 
    {
        type            zeroGradient;
    }
}
5. I converted the Gmsh mesh to OpenFoam with this command:
gmshToFoam cuboid.msh

At this point I noticed a warning message:

--> FOAM Warning :
From function polyMesh::polyMesh(... construct from shapes...)
in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 576
Found 372 undefined faces in mesh; adding to default patch.


6. I copied some files for solving the model:
cp $FOAM_TUTORIALS/incompressible/icoFoam/elbow/system/fvS* system/
cp $FOAM_TUTORIALS/incompressible/icoFoam/elbow/constant/transportProperties constant/

7. I studied the mesh in ParaView using paraFoam command and I noticed that the mesh is not the same and the boundary definitions are not correct.



8. I tried to run icoFoam and it solved the model without problems, but the solution is not realistic.

I think the problem comes from gmshToFoam, the OpenFOAM mesh is not the same as Gmsh mesh. Can you help me using a Gmsh mesh in OpenFOAM? If you can share any (tutorial) model for creating an OpenFOAM model using a Gmsh mesh, it would be also highly appreciated.

Thank you,
Zoltan
Attached Images
File Type: jpg cuboid.jpg (64.6 KB, 238 views)
zhernadi is offline   Reply With Quote

Old   July 19, 2010, 14:37
Default
  #2
New Member
 
Join Date: Sep 2009
Posts: 13
Rep Power: 17
cgoniva is on a distinguished road
Hi Zoltan!

I'm not familiar with gmsh, but I had a similar problem:
I once notized with an other CAD tool (SALOME) that I can either export the geometry (usually very coarse) or the mesh I built for the geometry. Maybe you exported the geometry and not the mesh?

regards, chris
cgoniva is offline   Reply With Quote

Old   July 21, 2010, 07:30
Default
  #3
Member
 
Arina
Join Date: Oct 2009
Location: Belarus
Posts: 71
Rep Power: 17
Akuji is on a distinguished road
Send a message via ICQ to Akuji
Hi, Zoltan!
A'm trying to make a simple example using gmsh and OpanFOAM. I have got a question for you: how did you make named physical surfaces as inlet, outlet and noslipwall? I have some troubles with it...
Akuji is offline   Reply With Quote

Old   July 21, 2010, 10:07
Default
  #4
New Member
 
Zoltan Hernadi
Join Date: Jul 2010
Posts: 12
Rep Power: 16
zhernadi is on a distinguished road
Chris, thank you for your reply. I will try Salome. I think .geo is for geomety and .msh is for the mesh in Gmsh.

Arina, I used Gmsh GUI to create this example, so it gave numbers as 'Physical Surface' index. I noted which index is for which boundary, then I used a text editor to modify the numbers in the .geo file to "inlet", "outlet" and "noslipwall". That's the trick.
zhernadi is offline   Reply With Quote

Old   July 21, 2010, 10:23
Default It works!
  #5
New Member
 
Zoltan Hernadi
Join Date: Jul 2010
Posts: 12
Rep Power: 16
zhernadi is on a distinguished road
I figured out that there was no problem with the conversion. It works!

Recent paraFoam has some problem with localization, so I started "LC_ALL=C paraFoam". After this, the mesh was the same as in Gmsh and the solution generated by icoFoam was also realistic.

So one may try the instructions in the first post of this thread as a tutorial for gmshToFoam.
zhernadi is offline   Reply With Quote

Old   July 22, 2010, 05:07
Default
  #6
Member
 
Arina
Join Date: Oct 2009
Location: Belarus
Posts: 71
Rep Power: 17
Akuji is on a distinguished road
Send a message via ICQ to Akuji
Quote:
Originally Posted by zhernadi View Post
Arina, I used Gmsh GUI to create this example, so it gave numbers as 'Physical Surface' index. I noted which index is for which boundary, then I used a text editor to modify the numbers in the .geo file to "inlet", "outlet" and "noslipwall". That's the trick.
Hi, Zoltan.
Thanks for quick reply. But I have one more question: did you open .geo and just replace for example Surface (50) to Surface ("inlet")?
Akuji is offline   Reply With Quote

Old   July 28, 2010, 06:21
Default
  #7
New Member
 
Zoltan Hernadi
Join Date: Jul 2010
Posts: 12
Rep Power: 16
zhernadi is on a distinguished road
Quote:
Originally Posted by Akuji View Post
Hi, Zoltan.
Thanks for quick reply. But I have one more question: did you open .geo and just replace for example Surface (50) to Surface ("inlet")?
Yes, that's the trick.
zhernadi is offline   Reply With Quote

Old   July 5, 2011, 09:17
Default
  #8
New Member
 
Richard Moser
Join Date: Aug 2009
Posts: 29
Rep Power: 17
moser_r is on a distinguished road
I've been trying to get the physical surfaces into the boundary file, but with no success. I copied your exact file above, meshed it in gmsh, then used gmshToFoam, but those surfaces do not come across - I just get patch0 and defaultFaces. Any idea what I might be doing wrong?
moser_r is offline   Reply With Quote

Old   July 7, 2011, 03:28
Default
  #9
New Member
 
Richard Moser
Join Date: Aug 2009
Posts: 29
Rep Power: 17
moser_r is on a distinguished road
I've managed to sort the problem by downloading the latest (nightly) build of gmsh (2.5.1). All patches now come through to OpenFOAM properly.
moser_r is offline   Reply With Quote

Reply

Tags
gmsh, gmshtofoam, mesh conversion


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
mesh quality problem for displacementSBRStress motion solver zhaozhenkai OpenFOAM 0 January 22, 2017 12:02
[snappyHexMesh] SHM problem : KVLCC2 with appendage mesh sc.park OpenFOAM Meshing & Mesh Conversion 1 March 13, 2016 14:28
[Other] engineFoam new mesh problem ayhan515 OpenFOAM Meshing & Mesh Conversion 5 August 10, 2015 09:45
Moving mesh Niklas Wikstrom (Wikstrom) OpenFOAM Running, Solving & CFD 122 June 15, 2014 07:20
unstructured vs. structured grids Frank Muldoon Main CFD Forum 1 January 5, 1999 11:09


All times are GMT -4. The time now is 09:10.