def boundary_nodes(fs):
"""Find the list of boundary nodes in fs. This is a
unit-square-specific solution. A more elegant solution would employ
the mesh topology and numbering.
"""
eps = 1.e-10
f = Function(fs)
def on_boundary(x):
"""Return 1 if on the boundary, 0. otherwise."""
if x[0] < eps or x[0] > 1 - eps or x[1] < eps or x[1] > 1 - eps:
return 1.
else:
return 0.
f.interpolate(on_boundary)
return np.flatnonzero(f.values)
评论列表
文章目录