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

[Gmsh] New version of gmshToFoam?

Register Blogs Community New Posts Updated Threads Search

Like Tree17Likes
  • 4 Post By stootoon
  • 7 Post By stootoon
  • 3 Post By openfoamtutorials
  • 3 Post By Talder

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 15, 2018, 12:13
Default New version of gmshToFoam?
  #1
New Member
 
Sina Tootoonian
Join Date: Nov 2018
Posts: 3
Rep Power: 8
stootoon is on a distinguished road
Hi folks,

I'm running OpenFoam-6 and gmsh 4.0.4 on macOS High Sierra.

My question: Is there a version of gmshToFoam that supports the latest .msh format generated by the latest version of gmsh?

Background:
I've just started learning to mesh with gmsh with the aim of doing some simple simulations in OpenFoam. I followed some simple gmsh tutorials such as https://www.youtube.com/watch?v=C_sCHpLaz3Y and generated some very simple meshes. However whenever I tried to run gmshToFoam, I'd get the following fatal IOError:

--> FOAM FATAL IO ERROR:
wrong token type - expected word, found on line 0 the label 18

I managed to track this down to the format of the .msh file generated by gmsh. The latest version of gmsh (4.0.4) uses a format in which e.g. the size of the $Nodes block is set with two numbers, such as

$Nodes
27 1331
...

whereas the .msh files generated by older versions of gmsh (such as 2.9.3 used in the youtube tutorial above) specify $Nodes as

$Nodes
1331
...

This older .msh format seems to be what the latest version of gmshToFoam is expecting, as I was able to run it successfully on the .msh file generated by the old gmsh version.

Is there a version of gmshToFoam that supports the latest .msh formats?

Thanks for your help,

Sina
stootoon is offline   Reply With Quote

Old   November 16, 2018, 08:38
Default
  #2
New Member
 
Sina Tootoonian
Join Date: Nov 2018
Posts: 3
Rep Power: 8
stootoon is on a distinguished road
SOLVED: There doesn't appear to be a version of gmshToFoam that supports the new .msh format, but there is an option in the latest gmsh to export to the old .msh format: File > Export > *.msh > Version 2 ASCII.
stootoon is offline   Reply With Quote

Old   November 24, 2018, 21:47
Default
  #3
New Member
 
Robert
Join Date: Nov 2018
Posts: 8
Rep Power: 7
openfoamtutorials is on a distinguished road
Hi, author of the linked tutorial video here. Thanks for making a post about this! You can also specify the old format (until gmshToFoam is updated) in the command line via "gmsh ... -format msh2". I will be using this in all of my future videos!
openfoamtutorials is offline   Reply With Quote

Old   January 26, 2019, 07:56
Default gmsh to OpenFoam v1812
  #4
New Member
 
Tom Alderweireldt
Join Date: Jan 2015
Location: Schilde, Belgium
Posts: 16
Rep Power: 11
Talder is on a distinguished road
Thanks Stootoon,


I ran in exactly the same 'gmshToFoam' FATAL ERROR issue, with a recently build mesh with gmsh 4.0.7. When I regenerated the mesh with an older gmsh 2.10 version, the problem disappeared.



Many thanks for locating this issue !!
Talder is offline   Reply With Quote

Old   February 13, 2019, 18:25
Default Foam Error bad token, expecting a word
  #5
New Member
 
Tom Alderweireldt
Join Date: Jan 2015
Location: Schilde, Belgium
Posts: 16
Rep Power: 11
Talder is on a distinguished road
In my cases, I found out by just editing the .msh files obtained and adding a line with '$End' just to give it a word it was expecting, made it perfectly happy !!
I could convert any .msh file with this added '$end' line with gmshToFoam into Foam, ParaFoam didn't seem to have any issue.


Hope this helps,
Tom.
Talder is offline   Reply With Quote

Old   April 17, 2019, 14:19
Default error in paraview after calculation
  #6
Member
 
Dokeun, Hwang
Join Date: Apr 2010
Location: Korea, Republic of
Posts: 98
Rep Power: 16
dokeun is on a distinguished road
Quote:
Originally Posted by stootoon View Post
SOLVED: There doesn't appear to be a version of gmshToFoam that supports the new .msh format, but there is an option in the latest gmsh to export to the old .msh format: File > Export > *.msh > Version 2 ASCII.
It's awesome !! Thank you for solving my nettlesome problem.
I converted Gmsh ver2 file successfully and ran the icoFoam from cavity.
But I got an error message from paraview when I load the result.
It tells some problem about discordance of face number and I and stuck there.

The error is as below.

ERROR: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/IO/Geometry/vtkOpenFOAMReader.cxx, line 6876
vtkOpenFOAMReaderPrivate (0x7f9f900ad050): The end face number 309 of patch top is not consistent with the start face number 280 of patch bottom

ERROR: In /Users/kitware/dashboards/buildbot-slave/8275bd07/build/superbuild/paraview/src/VTK/Common/ExecutionModel/vtkExecutive.cxx, line 782
vtkPVCompositeDataPipeline (0x600001d097a0): Algorithm vtkPOpenFOAMReader(0x7f9f90097060) returned failure for request: vtkInformation (0x600027bdbac0)
Debug: Off
Modified Time: 4803293
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FROM_OUTPUT_PORT: 0
ALGORITHM_AFTER_FORWARD: 1
FORWARD_DIRECTION: 0
----------
and here is my case set.
Does it have relevance to converting stuff?





It was because boundary file
I changed physicalType as below

back
{
type empty;
physicalType empty;
nFaces 100;
startFace 180;
}
bottom
{
type wall;
physicalType wall;
nFaces 10;
startFace 280;
}
right
{
type wall;
physicalType wall;
nFaces 10;
startFace 290;
}
top
{
type zeroGradient;
physicalType zeroGradient;
nFaces 10;
startFace 300;
}
left
{
type wall;
physicalType wall;
nFaces 10;
startFace 310;
}
front
{
type empty;
physicalType empty;
nFaces 100;
startFace 320;
}

from zipped file.
Attached Files
File Type: zip cavity.zip (21.7 KB, 7 views)
dokeun is offline   Reply With Quote

Old   May 23, 2019, 12:32
Default
  #7
New Member
 
Abbasi Maaz
Join Date: Oct 2018
Location: Germany
Posts: 3
Rep Power: 8
Abbasi_Maaz is on a distinguished road
Quote:
Originally Posted by Talder View Post
In my cases, I found out by just editing the .msh files obtained and adding a line with '$End' just to give it a word it was expecting, made it perfectly happy !!
I could convert any .msh file with this added '$end' line with gmshToFoam into Foam, ParaFoam didn't seem to have any issue.


Hope this helps,
Tom.
Thank you. It worked for me.
Abbasi_Maaz is offline   Reply With Quote

Old   February 14, 2022, 10:01
Default Update :)
  #8
Member
 
Sourav Mandal
Join Date: Jul 2019
Posts: 55
Rep Power: 7
sourav90 is on a distinguished road
I dunno why but this is what's happening with two versions of OpenFOAM in macOS Monterey, arm64 M1Pro:
  • OpenFOAMv-2106
    PHP Code:
    /*---------------------------------------------------------------------------*\
    | =========                 |                                                 |
    | \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
    |  \\    /   O peration     | Version:  v2106                                 |
    |   \\  /    A nd           | Website:  www.openfoam.com                      |
    |    \\/     M anipulation  |                                                 |
    \*---------------------------------------------------------------------------*/
    Build  _c15bfde3cb-20210624 OPENFOAM=2106
    Arch   
    "LSB;label=32;scalar=64"
    Exec   gmshToFoam NeighborhoodConnected_MedianRadius5_ROI300_OctreeDepth7Original.msh
    Date   
    Feb 14 2022
    Time   
    14:57:33
    Host   
    coldandwhite.local
    PID    
    41390
    I
    /O    uncollated
    Case   : /Users/massisenergy/OpenFOAM/massisenergy-9/run/TestingGmshToFoam
    nProcs 
    1
    trapFpe
    Floating point exception trapping not supported on this platform
    fileModificationChecking 
    Monitoring run-time modified files using timeStampMaster (fileModificationSkew 5maxFileModificationPolls 20)
    allowSystemOperations Allowing user-supplied system call operations

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Create time



    --> FOAM FATAL IO ERROR: (openfoam-2106)
    Wrong token type expected wordfound on line 0variable "$Entities"

    fileinput at line 0.

        From Foam
    ::Istream &Foam::operator>>(Foam::Istream &, Foam::word &)
        
    in file primitives/strings/word/wordIO.C at line 70.

    FOAM exiting 
  • OpenFOAM-9
    PHP Code:
    /*---------------------------------------------------------------------------*\
      =========                 |
      \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
       \\    /   O peration     | Website:  https://openfoam.org
        \\  /    A nd           | Version:  9
         \\/     M anipulation  |
    \*---------------------------------------------------------------------------*/
    Build  9
    Exec   
    gmshToFoam NeighborhoodConnected_MedianRadius5_ROI300_OctreeDepth7Original.msh
    Date   
    Feb 14 2022
    Time   
    14:57:44
    Host   
    "coldandwhite.local"
    PID    41623
    I
    /O    uncollated
    Case   : /Users/massisenergy/OpenFOAM/massisenergy-9/run/TestingGmshToFoam
    nProcs 
    1
    sigFpe 
    Enabling floating point exception trapping (FOAM_SIGFPE).
    fileModificationChecking Monitoring run-time modified files using timeStampMaster (fileModificationSkew 10)
    allowSystemOperations Allowing user-supplied system call operations

    // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
    Create time

    Skipping tag $end at line 2
    Starting to read points at line 6
    Vertices to be read
    :789686
    Vertices read
    :789686

    Starting to read cells at line 789695
    Cells to be read
    :4697264

    Mapping region 2 to Foam patch 0
    Mapping region 2 to Foam cellZone 0
    Cells
    :
        
    total:4247972
        hex  
    :0
        prism
    :0
        pyr  
    :0
        tet  
    :4247972

    CellZones
    :
    Zone    Size
        0    4247972

    Skipping tag $End at line 5486962
    Patch 0 gets name patch0

    --> FOAM Warning :
        
    From function Foam::polyMesh::polyMesh(const Foam::IOobject &, Foam::pointField &&, const Foam::cellShapeList &, const Foam::faceListList &, const Foam::wordList &, const Foam::wordList &, const Foam::word &, const Foam::word &, const Foam::wordList &, const bool)
        
    in file meshes/polyMesh/polyMeshFromShapeMesh.C at line 595
        Found 449292 undefined faces in mesh
    adding to default patch.
    Finding faces of patch 0

    FaceZones
    :
    Zone    Size

    Writing zone 0 to cellZone cellZone_0 
    and cellSet
    End 

I could visualise it with paraFoam. So, with version 2 ascii .msh exported from Gmsh, gmshToFoam command is working in OpenFOAM-9 but not with v-2106. Haven't figured out how to specify the boundary conditions yet, but that's the topic of another post!

gmshToFoam.jpg
sourav90 is offline   Reply With Quote

Reply

Tags
gmsh, gmshtofoam


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
[OpenFOAM] Multiple version of ParaView Pavel Rodin ParaView 1 October 13, 2017 11:21
How can i uninstall new version of OF shipman OpenFOAM Installation 5 August 12, 2013 05:01
version GLIBCXX_3.4.9 and GLIBCXX_3.4.11 not found ovie Main CFD Forum 1 April 19, 2010 15:00
[OpenFOAM] Problem with paraFoam on a linux-64 bit bunni ParaView 4 April 14, 2010 21:55
Version 12 speed compared to 11 maka OpenFOAM Running, Solving & CFD 2 December 21, 2005 06:42


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