1

PyTOUGH: Creating a mulgrid object from Gmesh

Hi there,

@adrian_croucher

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 

Fernando

5 replies

null
    • Senior Research Fellow
    • Adrian_Croucher
    • 1 yr ago
    • Reported - view

    Hi Fernando,

    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.

    • FGuerrero
    • 1 yr ago
    • Reported - view

    Hi Adrian,

    Thank you for your reply, I suspected something like that was happening... I'll try converting my .msh file as you suggest.

    Best
    Fernando

    • Senior Research Fellow
    • Adrian_Croucher
    • 1 yr ago
    • Reported - view

    hi Fernando, I have just pushed a fix to the PyTOUGH testing branch which I think will allow you to import GMSH format 4.1 files using mulgrid from_gmsh(). Give it a try and let me know if it resolves your issue.

    - Adrian

    • FGuerrero
    • 1 yr ago
    • Reported - view


    Hi Adrian, sorted, it works! Thank you for your help with this. Something to incorporate in forthcoming versions of PyTOUGH :-)

    Best,
    Fernando

      • Senior Research Fellow
      • Adrian_Croucher
      • 1 yr ago
      • Reported - view

      Fernando Guerrero It'll be in the next release.

      - Adrian

Content aside

  • 1 Likes
  • 1 yr agoLast active
  • 5Replies
  • 70Views
  • 2 Following