Interpolation module

Overview

The Interpolation module defines an interface for talking about polynomial spaces and interpolation. The central concept of this module is that of an AbstractElement{D,T}, which maps points on a reference domain (of type <:AbstractReferenceShape) to values of type T. The AbstractElement interface expects the methods (el::AbstractElement)(u), which evaluates the underlying interpolant at the (reference) coordinate u, and jacobian(el,u), which computes the jacobian at the (reference) coordinate u.

AbstractElements are commonly used to describe functions over AbstractReferenceShapes, and such functions can in turn be used to describe more complex geometrical shapes used e.g. in a mesh. By composing a function representation on a reference element with the representation of the element itself as a map from the reference element, we can therefore represent a function over a (possibly complex) geometrical element.

The Interpolation module provides a few concrete implementations of AbstractElements which are described next, but other packages may use the interface by implementing the methods (::AbstractElement)(x) and jacobian(el,x) (see e.g. ParametricElement in the ParametricSurfaces package).

LagrangeElements

One of the simplest AbstractElements is the LagrangeElement{D,T,Np}, which defines a polynomial mapping the Np reference nodes on D to Np values of type T. The reference_nodes depend only on D and Np (and therefore on the type of the element). We use the same convention as Gmsh to define the order of the reference nodes on the various reference shapes; see node ordering on the Gmsh documentation for a more in-depth description.

In WaveProp, LagrangeElements are often used to describe (possibly curved) mesh elements. The triangle with vertices (1,1),(2,2),(1.5,3) can for example be created using:

using WavePropBase, Plots
pts = (1,1),(2,2),(1.5,3)
el  = Interpolation.LagrangeTriangle(pts)
plot(el)
savefig("el1.png")

triangular element

Note that, as per the AbstractElement interface, you may evaluate the parametrization and the jacobian at any point on the reference element (not just the reference nodes):

u = Geometry.Point2D(0.25,0.25)
@show el(u), jacobian(el,u)
([1.375, 1.75], [1.0 0.5; 1.0 2.0])

If the triangle is instead in three dimensions, it suffices to pass three-dimensional points:

pts = (1,1,0),(2,2,1),(1.5,3,1)
el  = Interpolation.LagrangeTriangle(pts)
plot(el)
savefig("el2.png")

triangular element

Very similar constructs can be used to work higher order (curved) triangles, or with other LagrangeElements such as LagrangeSquare or LagrangeTetrahedron; see their docstrings for more details.