gmshToFoam fails on 2d mesh
Summary
Running gmshToFoam
on a 2d aerofoil generated with gmsh fails with the following error:
Read format version 4.1 ascii 0
Starting to read physical names at line 5
Physical names:6
Surface 2 frontAndBack
Surface 3 INLET
Surface 4 OUTLET
Surface 5 AEROFOIL
Surface 6 WALL
Volume 1 internal
Skipping tag $Entities at line 14
Starting to read points at line 134
Vertices to be read:33
--> FOAM FATAL IO ERROR:
Attempt to get back from bad stream
file: IStringStream.sourceFile at line 0.
From function bool Foam::Istream::getBack(Foam::token&)
in file db/IOstreams/IOstreams/Istream.C at line 56.
FOAM exiting
Steps to reproduce
Create the following .geo file
Point(1) = {0.0, 0.0, 0.0,0.03};
Point(2) = {0.05, 0.03536583774295713, 0.0,0.03};
Point(3) = {0.1, 0.046561895043862704, 0.0,0.03};
Point(4) = {0.15, 0.05311268702404877, 0.0,0.03};
Point(5) = {0.2, 0.056968557150769476, 0.0,0.03};
Point(6) = {0.25, 0.05894098946517453, 0.0,0.03};
Point(7) = {0.3, 0.05948422462775665, 0.0,0.03};
Point(8) = {0.35, 0.05889444914557436, 0.0,0.03};
Point(9) = {0.4, 0.05738266105317275, 0.0,0.03};
Point(10) = {0.45, 0.05510718623369896, 0.0,0.03};
Point(11) = {0.5, 0.05219019673131475, 0.0,0.03};
Point(12) = {0.55, 0.0487269132550839, 0.0,0.03};
Point(13) = {0.6, 0.04479110070446828, 0.0,0.03};
Point(14) = {0.65, 0.04043853324299891, 0.0,0.03};
Point(15) = {0.7, 0.03570927685952479, 0.0,0.03};
Point(16) = {0.75, 0.030629248159782282, 0.0,0.03};
Point(17) = {0.8, 0.025211311562171167, 0.0,0.03};
Point(18) = {0.85, 0.019456071721943937, 0.0,0.03};
Point(19) = {0.9, 0.013352458679209828, 0.0,0.03};
Point(20) = {0.95, 0.006878168380048492, 0.0,0.03};
Point(21) = {1.0, 1.650594053104193e-17, 0.0,0.03};
Point(22) = {0.95, -0.006878168380048492, 0.0,0.03};
Point(23) = {0.9, -0.013352458679209828, 0.0,0.03};
Point(24) = {0.85, -0.019456071721943937, 0.0,0.03};
Point(25) = {0.8, -0.025211311562171167, 0.0,0.03};
Point(26) = {0.75, -0.030629248159782282, 0.0,0.03};
Point(27) = {0.7, -0.03570927685952479, 0.0,0.03};
Point(28) = {0.65, -0.04043853324299891, 0.0,0.03};
Point(29) = {0.6, -0.04479110070446828, 0.0,0.03};
Point(30) = {0.55, -0.0487269132550839, 0.0,0.03};
Point(31) = {0.5, -0.05219019673131475, 0.0,0.03};
Point(32) = {0.44999999999999996, -0.05510718623369899, 0.0,0.03};
Point(33) = {0.4, -0.05738266105317275, 0.0,0.03};
Point(34) = {0.35, -0.05889444914557436, 0.0,0.03};
Point(35) = {0.30000000000000004, -0.05948422462775666, 0.0,0.03};
Point(36) = {0.25, -0.05894098946517453, 0.0,0.03};
Point(37) = {0.19999999999999996, -0.05696855715076947, 0.0,0.03};
Point(38) = {0.15000000000000002, -0.05311268702404877, 0.0,0.03};
Point(39) = {0.09999999999999998, -0.046561895043862704, 0.0,0.03};
Point(40) = {0.050000000000000044, -0.035365837742957144, 0.0,0.03};
Spline(1)={1:40,1};
Point(41) = {0.0, 5.0, 0.0};
Point(42) = {0.0, -5.0, 0.0};
Point(43) = {-5.0, 0.0, 0.0};
Point(44) = {5.0, 5.0, 0.0};
Point(45) = {5.0, -5.0, 0.0};
Circle(41)= {42, 1, 43};
Circle(42)= {43, 1, 41};
Line(43) = {41, 44};
Line(44) = {44, 45};
Line(45) = {45, 42};
Curve Loop(2) = {41,42,43,44,45};
Curve Loop(3) = {1};
Plane Surface(1) = {2,3};
meshThickness=1.0;
surfaceVector[] = Extrude {0, 0, meshThickness} {
Surface{1};
Layers{1};
Recombine;
};
Physical Volume("internal") = surfaceVector[1];
Physical Surface("frontAndBack") = {surfaceVector[0],1};
Physical Surface("INLET")={surfaceVector[2],surfaceVector[3]};
Physical Surface("OUTLET")={surfaceVector[5]};
Physical Surface("AEROFOIL")={surfaceVector[7]};
Physical Surface("WALL")={surfaceVector[4],surfaceVector[6]};
Run gmsh -2 aerofoil.geo
, producing aerofoil.msh
. Copy the mesh into the case directory (for instance the airFoil2d tutorial case) and run gmshToFoam aerofoil.msh
. The output is
gmshToFoam aerofoil.msh
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Version: 10
\\/ M anipulation |
\*---------------------------------------------------------------------------*/
Build : 10-ca8d59f36e52
Exec : gmshToFoam aerofoil.msh
Date : Dec 06 2022
Time : 22:11:07
Host : "ideapad5pro"
PID : 28850
I/O : uncollated
Case : /home/olep/Documents/Studium/Semester5/CFD/Coursework/openFoam/airFoil2D
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
Using #calcEntry at line 79 in file "/home/olep/Documents/Studium/Semester5/CFD/Coursework/openFoam/airFoil2D/system/controlDict/functions/calcForceCoefficients"
Using #codeStream with "/home/olep/Documents/Studium/Semester5/CFD/Coursework/openFoam/airFoil2D/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodeStream_c7da6e67d288c520ac44204bb8ed36273ea0c732.so"
codeStream : dictionary:"/home/olep/Documents/Studium/Semester5/CFD/Coursework/openFoam/airFoil2D/system/controlDict/functions/calcForceCoefficients" master-only-reading:1
Starting to read mesh format at line 2
Read format version 4.1 ascii 0
Starting to read physical names at line 5
Physical names:6
Surface 2 frontAndBack
Surface 3 INLET
Surface 4 OUTLET
Surface 5 AEROFOIL
Surface 6 WALL
Volume 1 internal
Skipping tag $Entities at line 14
Starting to read points at line 134
Vertices to be read:33
--> FOAM FATAL IO ERROR:
Attempt to get back from bad stream
file: IStringStream.sourceFile at line 0.
From function bool Foam::Istream::getBack(Foam::token&)
in file db/IOstreams/IOstreams/Istream.C at line 56.
FOAM exiting
Relevant logs and/or images
This is the mesh generated by gmsh:
Environment information
- OpenFOAM version : 10-ca8d59f36e52
- Operating system : Manjaro linux (Arch)
- Hardware info : AMD 5800h
- Compiler : default from AUR
Possible fixes
Better error logging