Reputation: 11
Help with gmsh file import to fipy, I have readed all the questions regarding gmsh and fipy on this forum, but unfortunately I didn't find a similar error.
I am importing a 3D mesh generated by gmsh 3.0.6 (as recommanded) into FiPy (3.3). I am currently using python 3.7, and my operation system is Windows 10, 64-bit.
My slope1.geo
file is:
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;}
I used the Gmsh command gmsh.exe D:\gmsh\slope1.geo -3 -nopopup -format msh3 -o D:\gmsh\slope1.msh
to generate the slope1.msh
file, and then I wrote:
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')
Produces this warnings:
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
Finally I checked the slope1.msh
gp.txt
and ele.txt
found many point coordinates in gp.txt
are 0,0,0
while slope1.msh
ele.txt
is well, I think this is a importing error, but I can't figure it out.
Any pointer is appreciated. Many thanks in advance!
Upvotes: 1
Views: 180
Reputation: 2484
FiPy only understands Gmsh MSH format version 2.
Either
gmsh.exe D:\gmsh\slope1.geo -3 -nopopup -format msh2 -o D:\gmsh\slope1.msh
or
mesh = fp.Gmsh3D("D:\\gmsh\\slope1.geo")
Upvotes: 1