【问题标题】:Problem importing 3D Mesh by Gmsh in fipy在 fipy 中通过 Gmsh 导入 3D 网格时出现问题
【发布时间】:2019-05-28 11:36:59
【问题描述】:

我正在尝试在 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

【问题讨论】:

  • 这对我有用。当 gmsh 生成 test2D.msh 时,您可以发布输出吗?
  • 我已将输出添加到我的问题中。感谢您的帮助。
  • 我不肯定,但 gmsh 似乎没有在您的 .geo 文件中找到任何内容。我注意到这是在临时文件上运行的。您确定tmpnz1bp4vu.geo 拥有您认为的功能吗?我的输出看起来像gist.github.com/guyer/ab57a69ffa1f228eb599cc0d7cb37f2a
  • 只有对应的mesh文件存在。我不明白这些文件来自哪里,因此不知道我认为它们包含什么。对不起,我显然知道的很少。
  • 您采取了哪些操作来生成输出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]?一步一步,你是做什么的?

标签: mesh fipy


【解决方案1】:

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

另一个problem you reported in the chat 不同。作为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 脚本将解决该问题。

【讨论】:

    【解决方案2】:

    我将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。

    【讨论】:

    • 不幸的是,它对我也不起作用,但感谢您的想法。我得到同样的错误。
    猜你喜欢
    • 1970-01-01
    • 2019-08-19
    • 2021-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多