fealpy icon indicating copy to clipboard operation
fealpy copied to clipboard

New issue in CrouzeixRaviartFiniteElementSpace

Open xieweidc opened this issue 1 year ago • 2 comments

在运行 example/PoissonCRWithDirichletBC_example.py 时,遇到两个问题,

(1) https://github.com/weihuayi/fealpy/blob/7e2bbe3178d0aa859cc5cf926e1c891901062e06/example/PoissonCRWithDirichletBC_example.py#L15

这个解法器实际上并没有在程序中用到。

(2) 注释掉 pyamg 以后,报错如下:

The 0-th computation:
Traceback (most recent call last):

  File "C:\Users\19649\Desktop\fealpy\example\PoissonCRWithDirichletBC_example.py", line 63, in <module>
    uh = space.function()

  File "c:\users\19649\desktop\fealpy\fealpy\functionspace\CrouzeixRaviartFiniteElementSpace.py", line 369, in function
    f = Function(self, dim=dim, array=array, coordtype='barycentric')

  File "c:\users\19649\desktop\fealpy\fealpy\functionspace\Function.py", line 21, in __new__
    self = space.array(dim=dim, dtype=dtype).view(cls)

TypeError: array() got an unexpected keyword argument 'dtype'

这里的问题应该是 CrouzeixRaviartFiniteElementSpacearray 函数没有给出相应的 dtype 参数。

https://github.com/weihuayi/fealpy/blob/7e2bbe3178d0aa859cc5cf926e1c891901062e06/fealpy/functionspace/CrouzeixRaviartFiniteElementSpace.py#L372

(3) 在修正以上问题以后,程序仍然有如下报错信息:

The 0-th computation:
Traceback (most recent call last):

  File "C:\Users\19649\Desktop\fealpy\example\PoissonCRWithDirichletBC_example.py", line 64, in <module>
    A = space.stiff_matrix()

  File "c:\users\19649\desktop\fealpy\fealpy\functionspace\CrouzeixRaviartFiniteElementSpace.py", line 251, in stiff_matrix
    A = csr_matrix((A.flat, (I.flat, J.flat)), shape=(gdof, gdof))

  File "C:\Users\19649\anaconda3\lib\site-packages\scipy\sparse\_compressed.py", line 53, in __init__
    self._coo_container(arg1, shape=shape, dtype=dtype)

  File "C:\Users\19649\anaconda3\lib\site-packages\scipy\sparse\_coo.py", line 196, in __init__
    self._check()

  File "C:\Users\19649\anaconda3\lib\site-packages\scipy\sparse\_coo.py", line 283, in _check
    raise ValueError('row index exceeds matrix dimensions')

ValueError: row index exceeds matrix dimensions

由于 CR 元还没学习完全,所以暂时不知道是哪一步导致了索引超出矩阵维数。

xieweidc avatar Apr 17 '23 09:04 xieweidc

我这两天找时间调试一下程序

weihuayi avatar Apr 22 '23 00:04 weihuayi

我这两天找时间调试一下程序

好的,感谢老师

xieweidc avatar Apr 22 '23 01:04 xieweidc