PyTOUGH: Creating a mulgrid object from Gmesh
I'm trying to define a mulgrid object from a mesh created in Gmesh. It's a simple 2D regular mesh (I attach the source and .msh files). First I created an empty mulgrid object: geo=mulgrid(), and then I applied the method geo.from_gmsh( ... ). I'm getting an error related with reading the number of nodes in my .msh file:
-> 1631 num_nodes = int(gmsh.readline().strip()) 1632 for i in range(num_nodes): 1633 items = gmsh.readline().strip().split(' ') ValueError: invalid literal for int() with base 10: '9 48 1 48'
Any ideas on why this is happening? It seems 'from_gmsh' is not able to read the number of nodes in my .msh file, probably because it is presented within a line of four integers: 9 48 1 48.
Thank you in advance
I think the problem is that the GMSH format has changed (in a non-backwards-compatible way) a number of times and the mulgrid.from_gmsh() method has not been updated accordingly.
The second line of your file indicates it is using GMSH format version 4.1. PyTOUGH's from_gmsh() method has been tested with GMSH format 2.2, but nothing much since then. It should be updated, but I am not always aware of changes that have been made to other software like GMSH until someone alerts me to it - as you have just done.
As a workaround for now, you could try converting your mesh to GMSH format 2.2, which should work. You should be able to do the conversion using the GMSH software itself, or using something else like the meshio library.