def _integrate_exact(f, triangle):
#
# Note that
#
# \int_T f(x) dx = \int_T0 |J(xi)| f(P(xi)) dxi
#
# with
#
# P(xi) = x0 * (1-xi[0]-xi[1]) + x1 * xi[0] + x2 * xi[1].
#
# and T0 being the reference triangle [(0.0, 0.0), (1.0, 0.0), (0.0,
# 1.0)].
# The determinant of the transformation matrix J equals twice the volume of
# the triangle. (See, e.g.,
# <http://math2.uncc.edu/~shaodeng/TEACHING/math5172/Lectures/Lect_15.PDF>).
#
xi = sympy.DeferredVector('xi')
x_xi = \
+ triangle[0] * (1 - xi[0] - xi[1]) \
+ triangle[1] * xi[0] \
+ triangle[2] * xi[1]
abs_det_J = 2 * quadpy.triangle.volume(triangle)
exact = sympy.integrate(
sympy.integrate(abs_det_J * f(x_xi), (xi[1], 0, 1-xi[0])),
(xi[0], 0, 1)
)
return float(exact)
评论列表
文章目录