有关将gmsh文件导入到fipy的帮助,我已经在该论坛上阅读了有关gmsh和fipy的所有问题,但不幸的是我没有找到类似的错误。
我将由gmsh 3.0.6(按要求)生成的3D网格导入FiPy(3.3)。我目前使用的是python 3.7,我的操作系统是Windows 10(64位)。
我的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.txt
和ele.txt
,发现gp.txt
中的许多点坐标是0,0,0
,而slope1.msh
ele.txt
很好,我认为这是导入错误,但我无法弄清楚。
任何指针表示赞赏。提前非常感谢!
答案 0 :(得分:1)
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")