decimal point separator is locale dependant
Hello,
"Short" summary
I just noticed today, using the 3.0.6 version of gmsh packaged by Fedora ( gmsh.x86_64 3.0.6-4.fc28 ), that the locale of the user can change the creation of a model. In the included fond.geo, I use dot (.
) as my decimal separator as I do in all my science-related work. But when I work on a computer with my locale (LANG=fr_FR.UTF-8
), the file is not read properly, as all values are truncated as integers.
Issue
Version info
This is the 3.0.6-4 package of gmsh for Fedora 28 :
Info : -------------------------------------------------------
Info : Gmsh version : 3.0.6
Info : Build OS : Linux64
Info : Build options : 64Bit Ann Bamg Bfgs Blas(Generic) C++14 Cgns Chaco DIntegration Dlopen Fltk GMP Gmm Jpeg Kbipack Lapack(Generic) LinuxJoystick MathEx Med Mesh Mmg3d NativeFileChooser Netgen ONELAB ONELABMetamodel OpenCASCADE OpenGL OptHom Parser Plugins Png Post Python Salome Solver TetGen/BR Tetgen1.5 Voro3D Zlib
Info : Build date : 20180207
Info : Build host : unknown
Info : Packager : mockbuild
How to reproduce
Using fond.geo (I also pasted the content in the end since it's a small file) :
- Run
LANG=fr_FR.UTF-8 ; gmsh fond.geo
- Use Ctrl-Shift-H to display the modified values
Expected result
A model with 1 smaller square inside another with the values :
big_size = 0.05;
quarter_coef_x = 1.1;
quarter_coef_y = 1.1;
quarter_size_x = 5.5;
quarter_size_y = 5.5;
rve_size_x = 5;
rve_size_y = 5;
rve_x_max = 5.5;
rve_x_min = 0.5;
rve_y_max = 5.5;
rve_y_min = 0.5;
small_size = 0.05;
transition_size = 0.05;
Actual result
A model with only 1 visible square and the values :
big_size = 0;
quarter_coef_x = 1;
quarter_coef_y = 1;
quarter_size_x = 5;
quarter_size_y = 5;
rve_size_x = 5;
rve_size_y = 5;
rve_x_max = 5;
rve_x_min = 0;
rve_y_max = 5;
rve_y_min = 0;
small_size = 0;
transition_size = 0;
Additional info
I can obtain the correct behaviour when I set LANG
to en_US.UTF-8
before running the gmsh command.
In the end, I don't know if this is a packaging issue or a gmsh issue, but I do think that gmsh should stick to one locale when it comes to reading .geo files and not care about the decimal separator being .
or ,
on the computer it runs on.
PS : the content of file.geo
// Gmsh project to create a 2d square RVE mesh
big_size = 0.05;
small_size = 0.05;
transition_size = 0.05;
rve_size_x = 5.0;
rve_size_y = 5.0;
quarter_coef_x = 1.1;
quarter_coef_y = 1.1;
quarter_size_x = quarter_coef_x * rve_size_x;
quarter_size_y = quarter_coef_y * rve_size_y;
rve_x_min = (quarter_coef_x - 1.0) * rve_size_x;
rve_x_max = quarter_size_x;
rve_y_min = (quarter_coef_y - 1.0) * rve_size_y;
rve_y_max = quarter_size_y;
// Point creation
Point(1) = {0 , 0 , 0, big_size};
Point(2) = {quarter_size_x , 0 , 0, big_size};
Point(3) = {rve_x_max , rve_y_min , 0, small_size};
Point(4) = {rve_x_max , rve_y_max , 0, small_size};
Point(5) = {rve_x_min , rve_y_max , 0, small_size};
Point(6) = {0 , quarter_size_y , 0, big_size};
Point(7) = {rve_x_min , rve_y_min , 0, small_size};
// Line creation
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 7};
Line(4) = {7, 5};
Line(5) = {5, 6};
Line(6) = {6, 1};
Line(7) = {5, 4};
Line(8) = {4, 3};
// Surface creation
Line Loop(1) = {6, 1, 2, 3, 4, 5};
Plane Surface(1) = {1};
Line Loop(2) = {-4, -3, -8, -7};
Plane Surface(2) = {2};
// Naming Physical objects
Physical Line("Bord") = {6, 5, 7, 8, 2, 1};
Physical Surface("Homogene") = {1};
Physical Surface("RVE") = {2};