Dolfin-convert: ValueError when converting .msh to .xml

Hello everyone,

I am running FEniCS 2018.1.0 from Docker on macOS version 10.14.3, and I encountered an error with dolfin-convert.

I imported a .step geometry file from FreeCAD into Gmsh and created a 3D mesh, which looked completely normal in Gmsh.

Here is my .geo file:

Merge "test3d_cad.step";
SetFactory("OpenCASCADE");
Physical Volume("working_vol") = {1};
Physical Surface("electrode") = {7};
Physical Surface("walls") = {6, 4, 5, 3, 2, 1};

I then ran “dolfin-convert test3d.msh test3d.xml” and received the following error message:

Converting from Gmsh format (.msh, .gmsh) to DOLFIN XML format
Traceback (most recent call last):
  File "/usr/local/bin/dolfin-convert", line 132, in <module>
    main(sys.argv[1:])
  File "/usr/local/bin/dolfin-convert", line 79, in main
    meshconvert.convert2xml(ifilename, ofilename, iformat=iformat)
  File "/usr/local/lib/python3.6/dist-packages/dolfin_utils/meshconvert/meshconvert.py", line 1301, in convert2xml
    convert(ifilename, XmlHandler(ofilename), iformat=iformat)
  File "/usr/local/lib/python3.6/dist-packages/dolfin_utils/meshconvert/meshconvert.py", line 1322, in convert
    gmsh2xml(ifilename, handler)
  File "/usr/local/lib/python3.6/dist-packages/dolfin_utils/meshconvert/meshconvert.py", line 271, in gmsh2xml
    num_elements = int(line)
ValueError: invalid literal for int() with base 10: '8 10129\n'

Does anyone know how to solve this issue?

Thank you

It may be that your version of gmsh is producing 4.0 format and the script expects 2.0 format, try Mesh.MshFileVersion = 2.0;

Also, dolfin-convert is going away soon I would recommend using meshio instead

1 Like

That was exactly my issue! I will start using meshio instead as well.
Thank you very much!