def _integrate_exact(f, tetrahedron):
#
# 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 tetrahedron [(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 tetrahedron. (See, e.g.,
# <http://math2.uncc.edu/~shaodeng/TEACHING/math5172/Lectures/Lect_15.PDF>).
#
xi = sympy.DeferredVector('xi')
x_xi = \
+ tetrahedron[0] * (1 - xi[0] - xi[1] - xi[2]) \
+ tetrahedron[1] * xi[0] \
+ tetrahedron[2] * xi[1] \
+ tetrahedron[3] * xi[2]
abs_det_J = 6 * quadpy.tetrahedron.volume(tetrahedron)
exact = sympy.integrate(
sympy.integrate(
sympy.integrate(abs_det_J * f(x_xi), (xi[2], 0, 1-xi[0]-xi[1])),
(xi[1], 0, 1-xi[0])
),
(xi[0], 0, 1)
)
return float(exact)
评论列表
文章目录