繁体   English   中英

将 gmsh 生成的 3D 网格导入 fipy 时出现点坐标错误

[英]Point coordinates error in importing 3D mesh generated from gmsh into fipy

帮助将 gmsh 文件导入到 fipy,我已经阅读了本论坛上有关 gmsh 和 fipy 的所有问题,但不幸的是我没有发现类似的错误。 我正在将由 gmsh 3.0.6(如推荐)生成的 3D 网格导入到 FiPy (3.3) 中。 我目前使用的是python 3.7,我的操作系统是Windows 10, 64-bit。 我的slope1.geo文件是:

Point(1) = {0, 0, 0, 1.0};
Point(2) = {1, 0, 0, 1.0};
Point(3) = {0.3, 0.7, 0, 1.0};
Point(4) = {0, 0.7, 0, 1.0};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(1) = {3, 4, 1, 2};
Plane Surface(1) = {1};
Extrude {0, 0, 0.8} {Surface{1}; Layers{8}; Recombine;}

我用gmsh命令gmsh.exe D:\\gmsh\\slope1.geo -3 -nopopup -format msh3 -o D:\\gmsh\\slope1.msh生成slope1.msh文件,然后我写:

import fipy as fp 
import numpy as np 
import os
mesh = fp.Gmsh3D(os.path.splitext("D:\\gmsh\\slope1")[0] + '.msh', communicator=fipy.serialComm)
np.savetxt("E:\\transfer_data\\gp.txt", mesh.vertexCoords.T,fmt='%f, %f, %f', newline='\n')
np.savetxt("E:\\transfer_data\\ele.txt", mesh._cellVertexIDs.T,fmt='%d, %d, %d,%d, %d, %d, %d, %d', newline='\n')

产生此警告:

C:\Users\yang\python\python.exe "E:/python projects/data_file/1.py"
C:\Users\yang\python\lib\site-packages\fipy\meshes\gmshMesh.py:781: SyntaxWarning: Partition count 8 does not agree with number of remaining tags 0.
  facesData) = self._parseElementFile()
C:\Users\yang\python\lib\site-packages\fipy\meshes\mesh.py:201: RuntimeWarning: invalid value encountered in true_divide
  norm = norm / numerix.sqrtDot(norm, norm)
C:\Users\yang\python\lib\site-packages\fipy\meshes\mesh.py:205: RuntimeWarning: invalid value encountered in less
  orientation = 1 - 2 * (numerix.dot(faceNormals, self.cellDistanceVectors) < 0)
C:\Users\yang\python\lib\site-packages\fipy\meshes\mesh.py:219: RuntimeWarning: invalid value encountered in less
  orientation = 1 - 2 * (numerix.dot(self.faceNormals, faceCellToCellNormals) < 0)
C:\Users\yang\python\lib\site-packages\fipy\meshes\mesh.py:256: RuntimeWarning: invalid value encountered in true_divide
  faceTangents1 = tmp / numerix.sqrtDot(tmp, tmp)
C:\Users\yang\python\lib\site-packages\fipy\meshes\mesh.py:363: RuntimeWarning: invalid value encountered in true_divide
  return self._scaledFaceAreas / self._cellDistances

最后,我检查了slope1.msh gp.txtele.txt发现在很多点坐标gp.txt0,0,0 ,而slope1.msh ele.txt很好,我认为这是一个错误导入,但我可以”想通了。 任何指针表示赞赏。 提前谢谢了!

FiPy 只理解 Gmsh MSH 格式版本 2。

任何一个

gmsh.exe D:\gmsh\slope1.geo -3 -nopopup -format msh2 -o D:\gmsh\slope1.msh

或者

mesh = fp.Gmsh3D("D:\\gmsh\\slope1.geo")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM