本文整理汇总了Python中mesh.Mesh.connectivity方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.connectivity方法的具体用法?Python Mesh.connectivity怎么用?Python Mesh.connectivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mesh.Mesh
的用法示例。
在下文中一共展示了Mesh.connectivity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_linear_element
# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import connectivity [as 别名]
def test_linear_element():
'''Test the implementation of the linear element with simple integrals'''
dx = 5.
num_elem = 5
mesh = Mesh(type='uniform', ox=0., lx=dx, nx=num_elem)
elem_num = 1
connect = mesh.connectivity(elem_num)
vertices = mesh.coordinates(connect)
elem = LinearElement(elem_num, connect, vertices)
# --- test some integrals
ex = lambda x: x
ex2 = lambda x: x ** 2
# Integrate[phi]
ans = elem.integrate()
exact = integrate(N, (x, 0, 1))
assert areclose(ans, exact)
# Integrate[dphi]
ans = elem.integrate(derivative=True)
exact = integrate(dN, (x, 0, 1))
assert areclose(ans, exact)
# Integrate[x phi]
ans = elem.integrate(ex)
exact = integrate(x * N, (x, 0, 1))
assert areclose(ans, exact)
# Integrate[x dphi]
ans = elem.integrate(ex, derivative=True)
exact = integrate(x * dN, (x, 0, 1))
assert areclose(ans, exact)
# Integrate[x x phi]
ans = elem.integrate(ex, ex)
exact = integrate(x * x * N, (x, 0, 1))
assert areclose(ans, exact)
# Integrate[x x dphi]
ans = elem.integrate(ex,ex,derivative=True)
exact = integrate(x*x*dN,(x,0,1))
assert areclose(ans, exact)