pythonmeshfipygmsh

Problem when importing a mesh with Gmsh3D in Fipy


I am trying to import to Fipy a 3D mesh previously generated with Gmsh using the Gmsh3D function, like this:

mesh = Gmsh3D(join(output,'case_1.msh'),communicator=serialComm)

I get the same error as other similar posts, but the proposed solutions do not seem to work for me:

GmshException: Gmsh hasn't produced any cells! Check your Gmsh code.

Gmsh output:
Info    : Running 'gmsh C:\Users\pcnou\AppData\Local\Temp\tmppouz68km.geo -3 -nopopup -format msh2 -o C:\Users\pcnou\AppData\Local\Temp\tmp5es89ie5.msh' [Gmsh 4.6.0, 1 node, max. 1 thread]
Info    : Started on Wed May 05 10:22:49 2021
Info    : Reading 'C:\Users\pcnou\AppData\Local\Temp\tmppouz68km.geo'...
Info    : Done reading 'C:\Users\pcnou\AppData\Local\Temp\tmppouz68km.geo'
Info    : Meshing 1D...
Info    : Done meshing 1D (Wall 0s, CPU 0s)
Info    : Meshing 2D...
Info    : Done meshing 2D (Wall 0s, CPU 0s)
Info    : Meshing 3D...
Info    : Done meshing 3D (Wall 0s, CPU 0s)
Info    : 0 nodes 0 elements
Info    : Writing 'C:\Users\pcnou\AppData\Local\Temp\tmp5es89ie5.msh'...
Info    : Done writing 'C:\Users\pcnou\AppData\Local\Temp\tmp5es89ie5.msh'
Info    : Stopped on Wed May 05 10:22:49 2021 (From start: Wall 0.00999999s, CPU 0.03125s)

I'm working on Win10 with Fipy 3.4.2.1, Python 3.7.9 and Gmsh 4.8.4.

I tried to convert the .msh file into a .msh2 file but then the following error appears:

IndexError                                Traceback (most recent call last)
<ipython-input-47-38097a945970> in <module>
----> 1 mesh = Gmsh3D(join(output,'case_1.msh2'),communicator=serialComm) # Doesn't work

~\Anaconda3\envs\Ansys\Lib\site-packages\fipy\meshes\gmshMesh.py in __init__(self, arg, communicator, 
overlap, background)
   1991          self.cellGlobalIDs,
   1992          self.gCellGlobalIDs,
-> 1993          self._orderedCellVertexIDs_data) = self.mshFile.read()
   1994 
   1995         self.mshFile.close()

~\Anaconda3\envs\Ansys\Lib\site-packages\fipy\meshes\gmshMesh.py in read(self)
    815             parprint("Recovering coords.")
    816             parprint("numcells %d" % numCellsTotal)
--> 817             vertexCoords, vertIDtoIdx = self._vertexCoordsAndMap(cellsToGmshVerts)
    818 
    819             # translate Gmsh IDs to `vertexCoord` indices

~\Anaconda3\envs\Ansys\Lib\site-packages\fipy\meshes\gmshMesh.py in _vertexCoordsAndMap(self, 
cellsToGmshVerts)
   1008         allVerts     = nx.unique(nx.array(allVerts, dtype=nx.INT_DTYPE)) # remove dups
   1009         allVerts     = nx.sort(allVerts)
-> 1010         maxVertIdx   = allVerts[-1] + 1 # add one to offset zero
   1011         vertGIDtoIdx = nx.ones(maxVertIdx, 'l') * -1 # gmsh ID -> vertexCoords idx
   1012         vertexCoords = nx.empty((len(allVerts), self.coordDimensions))

IndexError: index -1 is out of bounds for axis 0 with size 0

And the same happens when I use the .geo file. Is it a problem of the mesh itself or am I doing something wrong with Gmsh3D? Any help will be highly appreciated.

I first tried with this mesh link that is the one that I expect to work with, but I'm not sure the mesh itself does not have any issues. So I then tried with the following .msh file: link and the corresponding .geo file: link, but did not work neither.

Thank you.


Solution