将gmsh生成的三维网格导入fipy时出错

2024-10-16 20:45:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我在将3D网格从gmsh导入fipy时遇到了很多问题。我已经浏览了这个论坛上所有关于gmshfipy的问题,但不幸的是,我没有找到类似的主题。你知道吗

我将gmsh 4.0生成的三维圆柱形网格导入FiPy。我目前使用的是python2.7,我的操作系统是windows10,64位。你知道吗

根据fipy手册,Gmsh3D函数应该将gmsh网格转换成fipy网格,因此我写了:

from fipy import * 

mesh = Gmsh3D('C:\Users\William\Documents\Python Scripts\cylinder3.msh')

另外,我的Gmsh exe,mesh(圆柱体.msh)以及我的python代码都位于同一个目录中。你知道吗

但是,我不断得到“[Error 32]进程无法访问该文件,因为它正被另一个进程使用”。我附上完整的错误信息如下。有人经历过并解决过这个问题吗?感谢您的指点。提前谢谢!你知道吗

完整错误消息:

runfile('C:/Users/William/Documents/Python Scripts/cylinder1.py', wdir='C:/Users/William/Documents/Python Scripts')

回溯(最近一次呼叫):

File "<ipython-input-1-c2ebfb9899c3>", line 1, in <module>
    runfile('C:/Users/William/Documents/Python Scripts/cylinder1.py', wdir='C:/Users/William/Documents/Python Scripts')

File "C:\Users\William\Anaconda2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
    execfile(filename, namespace)

File "C:\Users\William\Anaconda2\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 93, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

File "C:/Users/William/Documents/Python Scripts/cylinder1.py", line 23, in <module>
    mesh = Gmsh3D('C:\Users\William\Documents\Python Scripts\cylinder3.msh')

File "C:\Users\William\Anaconda2\lib\site-packages\fipy\meshes\gmshMesh.py", line 1944, in __init__
    self._orderedCellVertexIDs_data) = self.mshFile.read()

File "C:\Users\William\Anaconda2\lib\site-packages\fipy\meshes\gmshMesh.py", line 853, in read
    os.unlink(self.elemsPath)

WindowsError: [Error 32] The process cannot access the file because it is being used by another process: 'c:\\users\\william\\appdata\\local\\temp\\tmp1bhyl6Elements'

Tags: inpy网格libpackageslinescriptssite