def test_scheme(scheme, tol):
triangle = numpy.array([
[0.0, 0.0],
[1.0, 0.0],
[0.0, 1.0]
])
def eval_orthopolys(x):
bary = numpy.array([x[0], x[1], 1.0-x[0]-x[1]])
out = numpy.concatenate(orthopy.triangle.tree(
scheme.degree+1, bary, 'normal', symbolic=False
))
return out
vals = quadpy.triangle.integrate(eval_orthopolys, triangle, scheme)
# Put vals back into the tree structure:
# len(approximate[k]) == k+1
approximate = [
vals[k*(k+1)//2:(k+1)*(k+2)//2]
for k in range(scheme.degree+2)
]
exact = [numpy.zeros(k+1) for k in range(scheme.degree+2)]
exact[0][0] = numpy.sqrt(2.0) / 2
degree = check_degree_ortho(approximate, exact, abs_tol=tol)
assert degree >= scheme.degree, \
'Observed: {}, expected: {}'.format(degree, scheme.degree)
return
评论列表
文章目录