FIPY:Grid2D cellToFaceDistanceVectors 的问题给出错误 'UniformGrid2D' object has no attribute '_cellToFaceDistanceVectors'
FIPY: problem with Grid2D cellToFaceDistanceVectors gives error 'UniformGrid2D' object has no attribute '_cellToFaceDistanceVectors'
我使用 Grid2D 创建网格如下
L = 2.
N = 50
dL = L/N
mesh = Grid2D(nx=N, ny=N, dx=dL, dy=dL)
但是当我尝试让单元格面对距离向量时:
mesh.cellToFaceDistanceVectors
出现以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-7-9ab623a3d90d> in <module>()
----> 1 mesh.cellToFaceDistanceVectors
/usr/local/lib/python3.6/dist-packages/fipy/meshes/abstractMesh.py in <lambda>(s)
96 rank=1)
97
---> 98 cellToFaceDistanceVectors = property(lambda s: s._cellToFaceDistanceVectors)
99 cellDistanceVectors = property(lambda s: s._cellDistanceVectors)
100 cellVolumes = property(lambda s: s._scaledCellVolumes)
AttributeError: 'UniformGrid2D' object has no attribute '_cellToFaceDistanceVectors'
其他属性也是如此,例如:
mesh.cellDistanceVectors
有人知道我怎样才能得到人脸到单元格的距离向量吗?
我们似乎从未为 Grids
实现过该功能,而且我似乎从未对 Robin 讨论进行过多测试。我已经提交了 issue.
作为解决方法,您可以这样做
from fipy.tools import numerix
MA = numerix.MA
tmp = MA.repeat(mesh._faceCenters[..., numerix.NewAxis,:], 2, 1)
cellToFaceDistanceVectors = tmp - numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)
tmp = numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)
tmp = tmp[..., 1,:] - tmp[..., 0,:]
cellDistanceVectors = MA.filled(MA.where(MA.getmaskarray(tmp), cellToFaceDistanceVectors[:, 0], tmp))
我使用 Grid2D 创建网格如下
L = 2.
N = 50
dL = L/N
mesh = Grid2D(nx=N, ny=N, dx=dL, dy=dL)
但是当我尝试让单元格面对距离向量时:
mesh.cellToFaceDistanceVectors
出现以下错误:
AttributeError Traceback (most recent call last)
<ipython-input-7-9ab623a3d90d> in <module>()
----> 1 mesh.cellToFaceDistanceVectors
/usr/local/lib/python3.6/dist-packages/fipy/meshes/abstractMesh.py in <lambda>(s)
96 rank=1)
97
---> 98 cellToFaceDistanceVectors = property(lambda s: s._cellToFaceDistanceVectors)
99 cellDistanceVectors = property(lambda s: s._cellDistanceVectors)
100 cellVolumes = property(lambda s: s._scaledCellVolumes)
AttributeError: 'UniformGrid2D' object has no attribute '_cellToFaceDistanceVectors'
其他属性也是如此,例如:
mesh.cellDistanceVectors
有人知道我怎样才能得到人脸到单元格的距离向量吗?
我们似乎从未为 Grids
实现过该功能,而且我似乎从未对 Robin 讨论进行过多测试。我已经提交了 issue.
作为解决方法,您可以这样做
from fipy.tools import numerix
MA = numerix.MA
tmp = MA.repeat(mesh._faceCenters[..., numerix.NewAxis,:], 2, 1)
cellToFaceDistanceVectors = tmp - numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)
tmp = numerix.take(mesh._cellCenters, mesh.faceCellIDs, axis=1)
tmp = tmp[..., 1,:] - tmp[..., 0,:]
cellDistanceVectors = MA.filled(MA.where(MA.getmaskarray(tmp), cellToFaceDistanceVectors[:, 0], tmp))