How do I use FastGaussQuadrature.jl to compute the integral of a 2d triangle element and 3d tetrahedron element

I am learning about finite element methods, and was trying to implement some examples in Julia. So
one of the common steps in FEM is implementing Gauss Quadrature for approximating the integral of each element in the mesh.

I used QuadGK.jl for computing the integral in 1d. However, the QuadGK.jl package docs indicate that the package only solves 1-dimensional integrals. However, for solving 2 and 3 dimensional elements, I imagine I need to use a package like FastGaussQuadrature.jl. The QuadGK function also includes an api or function signature to handle the change of interval, such as integral, error = quadgk(x -> cos(200x), 0, 1). However, I did not find something similar for FastGaussQuadrature.

My specific question is, how do I use FastGaussQuadrature to compute the integral of a 2d (triangle) or 3d (tetrahedral) element. That means, given a set of nodes/points and their coordinates, [x, y, z], how would I use the package to compute the integral for the loading function f over a mesh element, or how would I use this package to compute the integral over a mesh element for the stiffness side of the equation.

I believe that FastGaussQuadrature computes the quadrature weights assuming an interval from [-1.0, 1.0]. So if my elements are of a different size in 2 or 3 dimensions, how would I adapt that interval to match the [-1.0, 1.0].

Thanks.

FastGaussQuadrature constructs 1d quadrature rules. Of course, you can integrate over a 2d or 3d region by doing nested integrals (either with QuadGK or via tensor products of quadrature rules), or you can use a multi-dimensional integration package like HCubature.jl. See also

If you want a fixed-order quadrature rule for a 2d triangle or 3d tetrahedron, see e.g. the SimplexQuad.jl package, or FEMQuad.jl, or the quadrature routines in NESSie.jl or …

1 Like

@stevengj yes, this makes more sense now. I can use nested integrals, that is the piece that I was missing.

So I can basically use hcubature for the multidimensional integral, and then just integrate over the first two points, and then integrate over the third point. I found a good article that explains this piece a bit better. Thanks again for the help.