0

I am trying to import a 3D mesh produced with Gmsh in FiPy. A test with a 2D mesh worked fine. If the model then is extruded and imported with Gmsh3D I get an error message.

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

I'm working on Win10 with Python 3.7.3, Fipy 3.1.3 and Gmsh 3.0.6 (as recommended).

The test2D.geo test file:

SetFactory("OpenCASCADE");
cl = 0.5;
bs = 2.;
Point(1) = {0, 0, 0, cl};
Point(2) = {0, bs, 0, cl};
Point(4) = { bs,  0, 0, cl};
Point(3) = {bs,  bs, 0, cl};
Line(5) = {1, 2};
Line(6) = {2, 3};
Line(7) = {3, 4};
Line(8) = {4, 1};

Line Loop(10) = {6, 7, 8, 5};
Plane Surface(1) = {10};
Extrude {0, 0, 1} {
  Surface{1}; 
}

and:

from fipy import *
mesh = Gmsh3D("test2D.msh")

The error message is: GmshException: Gmsh hasn't produced any cells! Check your Gmsh code.

I don't see my mistake and hope someone can help me here. Thanks in advance

Edited for the Gmsh output:

Gmsh output:
Info    : Running 'gmsh C:\Users\Tinka\AppData\Local\Temp\tmpj4zr8g_c.geo -3 -nopopup -format msh -o C:\Users\Tinka\AppData\Local\Temp\tmpnz1bp4vu.msh' [Gmsh 3.0.6, 1 node, max. 1 thread]
Info    : Started on Tue May 28 19:50:42 2019
Info    : Reading 'C:\Users\Tinka\AppData\Local\Temp\tmpj4zr8g_c.geo'...
Info    : Done reading 'C:\Users\Tinka\AppData\Local\Temp\tmpj4zr8g_c.geo'
Info    : Finalized high order topology of periodic connections
Info    : Meshing 1D...
Info    : Done meshing 1D (0 s)
Info    : Meshing 2D...
Info    : Done meshing 2D (0 s)
Info    : Meshing 3D...
Info    : Done meshing 3D (0 s)
Info    : 0 vertices 0 elements
Info    : Writing 'C:\Users\Tinka\AppData\Local\Temp\tmpnz1bp4vu.msh'...
Info    : Done writing 'C:\Users\Tinka\AppData\Local\Temp\tmpnz1bp4vu.msh'
Info    : Stopped on Tue May 28 19:50:42 2019
TThe
  • 69
  • 1
  • 7
  • This works for me. Can you post the output from gmsh when it generates `test2D.msh`? – jeguyer May 28 '19 at 15:38
  • I have added the output to my question. Thanks for your help. – TThe May 28 '19 at 17:54
  • I'm not positive, but it appears that gmsh isn't finding any content in your .geo file. I note that this is running on temporary files. Are you sure that `tmpnz1bp4vu.geo` holds what you think it does? My output looks like https://gist.github.com/guyer/ab57a69ffa1f228eb599cc0d7cb37f2a. – jeguyer May 28 '19 at 18:10
  • Only the corresponding mesh file exists. I don't understand where these files come from and therefore don't know what I think they contain. I'm sorry, I obviously know very little. – TThe May 28 '19 at 18:16
  • What are the actions you take to produce the output `Gmsh output: Info : Running 'gmsh C:\Users\Tinka\AppData\Local\Temp\tmpj4zr8g_c.geo -3 -nopopup -format msh -o C:\Users\Tinka\AppData\Local\Temp\tmpnz1bp4vu.msh' [Gmsh 3.0.6, 1 node, max. 1 thread]`? Step-by-step, what do you do? – jeguyer May 28 '19 at 18:21
  • The output is generated after executing the Python code as described above in Spyder. – TThe May 28 '19 at 18:25
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/194072/discussion-between-jeguyer-and-tthe). – jeguyer May 28 '19 at 18:35

2 Answers2

0

I changed the name of the argument in Gmsh3D to test2D.geo and removed the first line from the geo file and things seem to be working.

>>> from fipy import Gmsh3D
>>> mesh = Gmsh("test2D.geo")
>>> print(mesh.cellCenters)
[[1.34821429 1.24404762 1.34821429 ...
...

I'm not sure what the first line does, but I get Error : Gmsh requires OpenCASCADE to add vertex and no vertices or cells are generated if it's included, but it isn't necessary for generating the mesh.

I think that FiPy Gmsh classes take both geo and msh formatted files, but the file name does need to refer to the actually file on disk.

I'm using FiPy version, 3.2+2.gccec299e, and Gmsh version, 3.0.6.

wd15
  • 1,068
  • 5
  • 8
  • Unfortunately it doesn't work for me either, but thanks for the idea. I get the same error. – TThe May 28 '19 at 18:05
0

This problem with gmsh and spyder has been fixed in FiPy 3.3, released earlier today; thank you for reporting it.

The other problem you reported in the chat is different. As documented for Gmsh2D, but not Gmsh3D:

... // attention: if you use any "Physical" labels, you *must* label
... // all elements that correspond to FiPy Cells (Physical Surface in 2D
... // and Physical Volume in 3D) or Gmsh will not include them and FiPy
... // will not be able to include them in the Mesh.
...
... // note: if you do not use any labels, all Cells will be included.

Adding Physical Volumes("cells") = {1}; to your .geo script will remedy that issue.

jeguyer
  • 2,379
  • 1
  • 11
  • 15