fealpy icon indicating copy to clipboard operation
fealpy copied to clipboard

调用TriangleMesh.from_domain_distmesh(domain, maxit=maxit)的问题

Open jibingquanm opened this issue 11 months ago • 1 comments

魏老师: 您好!我有两个问题想向您请教哇。 (1)根据您回复我如何绘制带圆孔矩形区域的命令,我在最新版本的fealpy中已经可以复现您的运行结果。然后根据您回复中的命令,我想扩展一下,在矩形区域中挖掉一个小矩形,于是导入了 import BoxWithBoxHolesDomain,即如下命令 import matplotlib.pyplot as plt from fealpy.mesh import TriangleMesh from fealpy.geometry import BoxWithBoxHolesDomain

box=[-2, 2, -2, 2], boxs=[(-1, 1, -1, 1)] hmin = 0.1 hmax = 0.1 domain = BoxWithBoxHolesDomain(box, boxs, hmin=hmin, hmax=hmax) mesh = TriangleMesh.from_domain_distmesh(domain, maxit=100) fig = plt.figure() axes = fig.add_subplot(1, 1, 1) mesh.add_plot(axes) plt.show()

运行之后却是始终报错“AttributeError: 'BoxWithBoxHolesDomain' object has no attribute 'shape'”

魏老师,我想向您请教一下,我只是将区域更换了为了,domain = BoxWithBoxHolesDomain(box, boxs, hmin=hmin, hmax=hmax), 为什么会出现此类报错呢,,应该怎么正确调用呢?

(2)魏老师,我这阵子反复研读学习了您在notebook中的帮助文档,受益良多,期待您的后续更新哇!

感谢您和您团队的无私工作!!!祝您工作顺利^ ^。 纪兵权

jibingquanm avatar Mar 14 '24 14:03 jibingquanm

代码已经更新,注意你原始的代码中 box=[-2, 2, -2, 2],多了一个逗号。

import matplotlib.pyplot as plt from fealpy.mesh import TriangleMesh from fealpy.geometry import BoxWithBoxHolesDomain

box=[-2, 2, -2, 2] boxs=[(-1, 1, -1, 1)] hmin = 0.1 hmax = 0.1 domain = BoxWithBoxHolesDomain(box, boxs, hmin=hmin, hmax=hmax) mesh = TriangleMesh.from_domain_distmesh(domain, maxit=100) fig = plt.figure() axes = fig.add_subplot(1, 1, 1) mesh.add_plot(axes) plt.show()

image

weihuayi avatar Mar 15 '24 09:03 weihuayi