首页 > 解决方案 > 将 gmsh 生成的 3D 网格导入 fipy 时出错

问题描述

我在将 3D 网格从 导入gmshfipy. 我已经浏览了关于gmshfipy在这个论坛上的所有问题,但不幸的是我没有找到类似的主题。

我正在将生成的 3D 圆柱网格导入gmsh 4.0到 FiPy 中。我目前使用的是 python 2.7,我的操作系统是 Windows 10,64 位。

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

from fipy import * 

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

此外,我的 Gmsh exe、mesh (cylinder.msh) 以及我的 python 代码都位于同一目录中。

但是,我不断收到“[错误 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'

标签: pythonmeshfipy

解决方案


FiPy 3.3 解决了 Windows 上 Gmsh 的一些问题。请升级并让我们知道您是否仍有问题。


推荐阅读