在 fipy 中通过 Gmsh 导入 3D 网格时出现问题

Problem importing 3D Mesh by Gmsh in fipy

我正在尝试在 FiPy 中导入使用 Gmsh 生成的 3D 网格。使用 2D 网格进行的测试效果很好。如果随后使用 Gmsh3D 拉伸和导入模型,我会收到一条错误消息。

GmshException: Gmsh 没有产生任何细胞!检查您的 Gmsh 代码。

我正在使用 Python 3.7.3、Fipy 3.1.3 和 Gmsh 3.0.6(推荐)的 Win10。

test2D.geo测试文件:

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}; 
}

和:

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

错误信息是: GmshException: Gmsh 没有产生任何细胞!检查您的 Gmsh 代码。

我没有看到我的错误,希望有人能在这里帮助我。 提前致谢

为 Gmsh 输出编辑:

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

我将 Gmsh3D 中的参数名称更改为 test2D.geo 并从 geo 文件中删除了第一行,一切似乎都有效。

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

我不确定第一行的作用,但我得到 Error : Gmsh requires OpenCASCADE to add vertex 并且如果包含它则不会生成顶点或单元格,但生成网格不需要它。

我认为 FiPy Gmsh 类 接受 geo 和 msh 格式的文件,但文件名确实需要引用磁盘上的实际文件。

我使用的是 FiPy 版本 3.2+2.gccec299e 和 Gmsh 版本 3.0.6。

今天早些时候发布的 FiPy 3.3 中修复了 gmsh 和 spyder 的这个问题;感谢您报告。

其他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.

Physical Volumes("cells") = {1}; 添加到您的 .geo 脚本将解决该问题。