Manuscript Offprint
arXiv:2611.01414Extensible Programmatic Specification of Finite Element Methods
THEADORA FIELDS COLLIN, Massachusetts Institute of Technology, USA
ODED STEIN, University of Southern California, USA and Technion—Israel Institute of Technology, Israel
GILBERT BERNSTEIN, University of Washington, USA
SAMAN AMARASINGHE, Massachusetts Institute of Technology, USA

Fig. 1. From a high level description of a finite element and an operator, our system produces routines that can be used to deliver better higher order solutions to a variety of graphics problems. Yellow dotted circles indicate telltales that the bottom solutions are higher quality.
Finite element methods (FEMs) are a powerful and ubiquitous tool for solving engineering problems. Experimenting with different finite elements can improve the quality and efficiency of solutions. In some cases, the wrong (but nonetheless most common) choice of finite element will produce solutions which converge to the wrong answer regardless of mesh resolution. However, in practice, the choice of finite element is not explored due to the complexity of re-deriving and re-implementing finite element methods. Trying a new finite element is challenging because practitioners must manually deduce formulas to use these elements and they must implement these formulas within the context of a potentially complex system. We address this problem by introducing ElementForge, a finite element system that is parametric over the literate mathematical specification of a finite element in a domain-specific language (DSL). The ElementForge compiler reasons about tensor spaces, tensors, and tensor bases from first principles to derive implementations of finite elements. The ElementForge compiler is able to automatically derive implementations of finite elements previously only derived by hand. Further, ElementForge minimally couples several key mathematical concepts, mainly tensor fields, mesh topologies, sparse tensors, and assembled finite element operators, to produce a complete finite element system that is parametric over the choice of element. Consequently, the elements derived by the compiler can be applied parametrically to new meshes, PDEs, and boundary conditions. We evaluate our system by implementing several simulations with different finite elements, demonstrating that our system can explore tradeoffs in generality, accuracy, speed, and representational complexity. For example, we are able to implement the Morley, Bell, Argyris, and Hermite like elements with less than 50 lines of code and use them all in a single simulation.
CCS Concepts: • Mathematics of computing → Discretization; Partial differential equations; • Computing methodologies → Computer graphics; Symbolic and algebraic manipulation; • Software and its engineering → Domain specific languages.
Additional Key Words and Phrases: Finite Element Methods, Domain Specific Languages, Programming Languages, Physical Simulation
1 Introduction
Finite Element Methods (FEMs) have become an important tool in a variety of fields, including applied mathematics, scientific computing, engineering, and computer graphics [Brenner and Scott 2008; Ciarlet 2002; Hughes 2000]. Within computer graphics, FEMs are a fundamental tool for many simulation and geometry processing pipelines. FEMs are powerful because one can vary the mesh, the problem formulation, the solver, and the element, a discrete local function space. One can choose from more than 100 families of finite elements [Scroggs 2023], each of which provide specific quantitative and qualitative advantages and disadvantages. Within computer graphics specifically, practitioners have examined the trade-offs between convergence and computational cost of various higher order Lagrange elements [Fernández-Fernández et al. 2025; Schneider et al. 2019, 2022].
However, practitioners face three challenges if they want to determine and exploit the trade-offs that different finite elements (FEs) offer. The first challenge is that practitioners must deduce, from the definition of the FE, various mathematical formulas that software packages require to implement an FE [Ham et al. 2025; Kirby 2004]. The second challenge is that practitioners must understand global FE operations (e.g., methods to build a sparse matrix or enforce a boundary condition) at both a mathematical and software level so that they can reimplement these operations for their class of FE. The third challenge is that for practitioners to explore these trade-offs, they must experiment with multiple FEs, encountering the first two challenges each time, and they must also experiment with their problem formulation to properly exploit some FEs.
The first challenge motivates our focus on deriving element transformations directly from mathematical specifications. Many systems offer partial solutions to the second challenge because they internally provide an interface to FEs and use this interface to implement many global FEM operations [Anderson et al. 2021; Kirby
Authors' addresses: Theadora Fields Collin, teoc@mit.edu, Massachusetts Institute of Technology, Cambridge, Massachusetts, USA; Oded Stein, ostein@usc.edu, University of Southern California, Los Angeles, California, USA and Technion—Israel Institute of Technology, Haifa, Israel; Gilbert Bernstein, gilbo@cs.washington.edu, University of Washington, Seattle, Washington, USA; Saman Amarasinghe, saman@csail.mit.edu, Massachusetts Institute of Technology, Cambridge, Massachusetts, USA.
2 • Collin et al.
and Mitchell 2019; Renard and Poulios 2020]. In software packages that offer solutions to a set of narrow problems, interfaces to an FE might not be present (the FE is baked into the script) or the interface only serves a narrow set of problems (e.g., it only supports certain derivatives or boundary conditions (BCs)). Finally, many systems address third problem via libraries or domain specific languages (DSLs) to vary the problem formulation [Alnæs et al. 2014; Anderson et al. 2021; Dedner et al. 2012; Fernández-Fernández et al. 2025; Gangl et al. 2020; Logg et al. 2012; Rathgeber et al. 2016]. These DSLs offer a high degree of flexibility for problem specifications and can work with different FEs. Our focus is the additional step of deriving reference-to-world transformations from element definitions, rather than requiring element-specific implementations of those transformations. As a practical consequence of the prior lack of automation, many communities stick to varying the problem to work with linear Lagrange elements, hiding a large space of trade-offs involving both higher order Lagrange elements and non-Lagrangian elements. Thus, we propose to significantly lower the cost of varying FEs and problems with ElementForge, the first FE DSL that is fully parametric over a mathematical definition of an FE. This parametricity extends through the FEM pipeline: interpolation, boundary-condition handling, and operator assembly are expressed using common primitives that adapt to the chosen element's mathematical definition (section 7). We believe that ElementForge will allow many to find and take advantage of trade-offs among FEs and associated problem formulations.
To meet all three challenges, our work, ElementForge, offers abstractions, languages, and deductive systems for fundamental aspects of FEM. To answer the first challenge, ElementForge contains a language for specifying FEs and a compiler that automatically deduces the formulas required to be implemented by hand in other packages, thus automating work previously found in mathematical journals. To answer the second challenge, ElementForge offers several core primitives that we show are sufficient for users to systematically generate global finite element operations that translate local formulas to useful code for building and manipulating sparse matrices. To answer the third challenge, ElementForge allows users to specify suitable problems with the same language that it provides to specify FEs. Finally, ElementForge agglomerates these solutions into a single package that allows users to define, reuse, and combine various FEs, problem specifications, and global routines to rapidly explore FEMs.
The core design principle of ElementForge is to systematically model the discrete mathematical objects of FEMs. In contrast to prior work, our software architecture does not emphasize either the global theory of PDEs or the structure of a specific class of problems. ElementForge emphasizes the discrete mathematical objects at the core of FEM implementations as these are the tools required to save labor through automation. Consequently, ElementForge pays special care to pointwise manipulation of tensor fields on manifolds, the definition of an FE, the construction of a discrete mesh, and the algebraic construction of global operations via the interaction of pointwise expressions and discrete meshes. These new tools provide the means to go from a mathematically specified FE and operator to a sparse matrix, automatically, and, hopefully, understandably.
Our implementation is not without some limitations, especially as we currently do not pay attention to low level performance issues; many FEM packages have outlined techniques to optimize code generated for FEs with special structures and these techniques could eventually be employed here [Homolya et al. 2017; Kempf et al. 2020; Sun et al. 2020]. Even with these limitations, we are able to implement novel simulations of independent interest to different areas of computer graphics. Moreover, we view these simulations and our software as part of an effort to make FEs more accessible. We make the following contributions:
(1) To the best of our knowledge, the first FE DSL that is fully parametric over a mathematical definition of an FE, enabling users to reuse and adapt global FEM routines across different elements and problems.
(2) A novel DSL and compiler for specifying FEs and operators via pointwise integrals of coordinate-free tensor algebra. This system enables the automated deduction of formulas needed to implement FEs at the local level.
(3) An interface for the systematic construction of global FE operations, enabling core and new global FE operations to be built on a wide variety of elements.
(4) An overall compiler taking as input (i) an FE description, (ii) operator specifications, and (iii) a mesh, and producing discretization operators (and interpolation functions) as output.
(5) Several novel simulations of interest to computer graphics:
(a) A more efficient yet simpler data interpolation/smoothing method based on the natural BCs of the biharmonic equation, identified in [Stein et al. 2018], and the Morley element [Li et al. 2022]. Moreover, we have explored a variety of FEs for this class of problems, leading to characterization of some of the tradeoffs involved.
(b) To the best of our knowledge, the first implementation of the finite element exterior calculus (FEEC) that is derived purely and automatically from the mathematical specification, which allows us to re-implement the analogues of all the discrete exterior calculus (DEC) operators, leading to FEM versions of classic DEC applications. Our methods also expose the cheaper first kind Nédélec elements [Arnold et al. 2010], which are not properly characterized in the graphics literature (compared to the standard second kind elements).
(c) Several FEs for Stokes flows problems in 2D+time and 3D+time, illustrating the phenomena of locking incompressible fluids (in contrast to prior work that focused on elasticity).

Fig. 2. Our system can be decomposed into roughly three components mirroring the three methods/implementations sections. The first component consists of a core language, Integrated Pointwise Tensor Expressions on Manifolds (IPTEM), and an associated compiler. The second component features a software description of finite elements and infrastructure to generate Vandermonde matrices, one of the core challenges of using general elements. The second component uses IPTEMs to describe element and uses IPTEM compiler to produce Vandermonde matrices. The third component allows users to write global FEM code over general elements. In particular, we imagine that users will perform the following loop: (1) instantiate some initial global objects (meshes, input data), (2) combine these with IPTEM (representing operators and other computations) to build global tensor objects called SVAO (partially via the IPTEM compiler), (3) use a few SVAO operations to produce new global objects, which can be used for more assemblies or passed as raw data to IO/- solvers/dense array routines/sparse array routines/etc. Red text indicates how this outline maps on to our paper.
and handling boundary data leads to the global interface (section 7). After this, we provide mathematical background (in section 3) to properly define certain FEM concepts; we will define the quantities that our system automatically provides to further the automation of FEMs. In the next three sections, we will describe our system; we will show how we actually implement previously non-automated aspects of FEMs. We outline these sections in fig. 2. After we finish describing our system, we apply it to several different simulations of interest to computer graphics (in section 8). Therein, we analyze how the automations impact our ability to explore these simulations and the utilities of the tradeoffs of different explored paths.
2 Examples
To illustrate the scope of our system and our way of thinking, we run through a few examples that use our highest-level interface.
from EF import *
2
3 # Load a mesh.
4 mesh = TriangleVertexListReader(filename)
5
6 @pointwiseIntegral
7 def laplace(u: field(R), v: field(R)):
8 return grad(u).dot(grad(v))
9
10 # Make a sparse matrix, the cotan Laplacian.
11 laplaceMatrix = assemble(mesh, [laplace], [linearLagrange, linearLagrange])
12
13 # Create boundary DOFs
14 # on the boundary, which DOFs in the input spaces are relevant:
15 boundaryDofs = propagate(mesh.topologicalBoundary(), laplaceMatrix.
inputSections[0])
16
17 # setup boundary values
18 f = lambda x: ...
19 boundaryValues = assemble(mesh, LinearLagrange, [f])
20
21 # Setup linear system via elimination method for bcs
22 Ainterior = laplaceMatrix.reduce([["inputDofs0", "inputDofs1"]].getSlice([
~boundaryDofs, ~boundaryDofs]).asScipyMatrix()
23 Abdry = laplaceMatrix.reduce([["inputDofs0", "inputDofs1"]].getSlice([
~boundaryDofs, boundaryDofs]).asScipyMatrix()
24 b = boundaryValues.reduce([["outputDofs"]].getSlice(boundaryDofs).
asDenseVector())
25 # Solve
26 uvals = spsolve(Ainterior, -Abdry.dot(b))
27 # wrap values back into the system:
28 from EF import GlobalDofField
29 u = GlobalDofField(mesh, LinearLagrange, uvals)
30 # u can be visualized, used for further assemble calls, etc.
Listing 1. Solving the Laplace equation with FEM in ElementForge.
2.1 Laplace's Equation
Given a surface and a boundary condition , we want to find a function such that
Our program, listing 1, uses linear Lagrange finite elements to produce the familiar cotangent Laplace matrix and solve Laplace's equation. Listing 1 shows how this works in our system: we read a mesh (line 4), express a formulation of the Laplacian (line 7), assemble the corresponding Laplacian matrix (line 11), assemble boundary DOFs (line 15) by propagating marked boundary edges to marked boundary DOFs, determine the boundary values (line 19), eliminate the boundary conditions from the system (line 22-line 24), solve our system (line 26), and post-process (line 29).
A few aspects of this program raise questions, especially when it comes to solving other problems:
(1) Why does our Laplace function not directly implement as seen in eq. (1)?
(2) What really is propagate doing to help enforce boundary conditions and how does this generalize to other conditions?
(3) Where does our element, LinearLagrange, come from and how does it generalize?
All these concerns are tied together via the concept of weak formulations. To deeply understand the fundamental issues of matrices of PDEs, boundary conditions, and elements, we must understand the weak formulation.
Collin et al.
2.2 Weak Formulations of Laplace and the Biharmonic Equation
Prior to writing listing 1, we transformed the initial problem. By choosing an appropriate space of functions, , we can integrate by parts to go from eq. (1) to the weak formulation [Brenner and Scott 2008]: find a that satisfies the BCs in eq. (1) such that for all :
Similar weak formulations and matrices for PDEs (stiffness, mass, etc) emerge via two steps: (1) using integration by parts to transform a strong form problem with order 2n derivatives to a weak one with order n derivatives and then (2) picking a space of functions V such that (at a minimum) the integration by parts is valid and the homogeneous version of the boundary condition can be identified [Meyer et al. 2003]. These two steps tie the weak formulation to the mathematical structures of elements and boundary conditions.
2.2.1 The Biharmonic Equation and Other Elements Applications such as elasticity, Stokes flow, cage coordinates, and data interpolation can all be studied with the biharmonic equation. Given a domain and BCs , we seek a such that
and
Together, these prescribe Dirichlet data for the fourth-order biharmonic problem: both the value and the normal derivative are fixed. The homogeneous case f = g = 0 gives clamped boundary conditions.
We transform the problem into its weak form with a space of functions and . Our weak formulation reads: find a subject to (4) such that for all :
where the last step uses and the rest use integration by parts.
Based on this analysis, a natural start to solving the biharmonic equation would be to replace the function in listing 1:line 7 with the biharmonic operator in listing 2 and just ignore boundary conditions for the moment.
However, if we do this, then listing 1:line 11 will produce a zero matrix. To understand why, we consider the definition of LinearLagrange in listing 3.
Returning to listing 2, we see the problem is at first just the polynomial degree: second derivatives of affine functions are zero. A natural second attempt is to use quadratic functions, as in listing 4.
However, this will still result in a catastrophic error as the matrix will be singular. How can we debug? We can question the fundamental assumptions that got us to this point. Since the original PDE problem has a unique solution, the two manipulations that we used to deduce the weak formulation were integration by parts and the
@pointwiseIntegral def biharmonic(c: chart, u: field(R), v: field(R)): # trace of Hessian with respect to metric # because the inner product of tensors is a trace deltau = (c.Ct.inner().dot(D(D(u))) deltav = (c.Ct.inner().dot(D(D(v))) return deltau * deltav
Listing 2. The Biharmonic Operator. This operator utilizes a chart which allows access to the metric of the geometry through the co-tangent space's inner produt. When we use a chart as an argument type, we are providing access to an arbitrary paramtermization of some unknown geometry.
1 cty = ChartType(0) # on objects of dimension 0 2 @pointwiseEval(cty, barycentricCoordinate=0.0) 3 def vertexEval(u: field(cty, R)): 4 return u(0) # u(0) is the field value i.e., the zeroth derivative. 5 # face type, degree/domain of polynomials, List[Dof] 6 LinearLagrangeEdge = FE(1, Pure(Simplex(1), 1), [vertexEval]) 7 LinearLagrange = FE(2, Pure(Simplex(2), 1), [vertexEval])
Listing 3. How to write down linear Lagrange FEs. We construct a pointwise evaluation on an abstract vertex by using the ChartType (0). The ChartType (0) indicates the use of parameterization of an object of dimension zero, which is to say the provision of a point. We interpret pointwise operators as being replicated across all objects in a domain (e.g. two evaluations per line, three per triangle, four per quad). The final elements are defined by pairing a list of DOFs with a representation of a domain (an int here) and a polynomial space (Pure).
1 ctyl = ChartType(1) # on objects of dimension 1 2 @pointwiseEval(ctyl, barycentricCoordinate=(0.5, 0.5)) 3 def edgeMidEval(u: field(ctyl, R)): 4 return u(0) 5 6 # face type, degree/domain, List[Dof] 7 quadEdge = FE(1, Pure(Simplex(1), 2), [vertexEval, edgeMidEval]) 8 quadTri = FE(2, Pure(Simplex(2), 2), [vertexEval, edgeMidEval])
Listing 4. A Quadratic Lagrange DOF, specifying a pointwise evaluation on an edge.
definition of . We can test if these manipulations that we assumed actually work in practice with our system. We start with integration by parts. If we integrate by parts on a simple mesh, , we get
Thus, we need to test:
1 @pointwiseIntegral(BoundaryChart, reduction=difference) 2 def interior(c: BoundaryChart, u: field(R), v: field(R)): 3 n0 = c.normalVector(v_chartOf()) 4 deltau = u_chartOf().CT.inner().dot(u(2)) 5 return deltau * v(1).dot(n0) # deltau * dv/dn 6 7 interiorMatrix = assemble(mesh, [interior], [quadTri, quadTri]) 8 # This should be zero except at boundary DOFs, but it won't be.
Listing 5. A patch test for the suitability of an element for the biharmonic equation.
1 @pointwiseEval(ctyl, barycentricCoordinate=(0.5, 0.5)) 2 def morleyDof(c: ctyl, u: field(cty, R, euclideanDerivative=True)): 3 return hodge(u(1))(c.E(c.tangentVector(0))) 4 Morley = FE(2, Pure(Simplex(2), 2), [vertexEval, morleyDof])
Listing 6. The Morley DOFs demonstrate three key aspects of our system. First, we offer sophisticated tensor algebra such as the Hodge star to compute gradient normals. Second, we are disciplined about how vectors and derivatives interact with meshes/physical space: euclideanDerivative = True means that derivative values live in Euclidean space as opposed to the tangent space, ensuring the quantity is defined uniquely per edge. In contrast, the Laplace operator uses a tangent space which is defined uniquely per cell. Similarly, listing 5, uses a normal vector because we want to measure a quantity that is computed differently per edge-cell relationship. Third, our tensor algebra is disciplined in its interpretation of different spaces, preventing various mistakes: the tangent vector must be embedded into Euclidean space via c.E before the derivative, defined in Euclidean space, uses it.
for all in our quadratic Lagrange space. We can generate this quantity in our system as a sparse matrix (though we simplify since third derivatives are zero). To do this (listing 5), we must integrate on all cell boundaries and take the difference of values computed for the same DOF on different boundaries.
Since derivatives of quadratic Lagrange functions are discontinuous, this test will fail. However, the structure of the test shows us how similar quadratic functions could succeed. The Morley element, implemented in listing 6, is the minimal element that satisfies listing 5.
2.2.2 The Biharmonic Equation and Boundary Conditions In listing 1, we eliminated boundary conditions from the system around line 24. Despite the simplicity of this, no system that we know of has consistent support for elimination methods on more complex FEs. In particular, the complexity lies in determining if an elimination method is feasible (if in the weak formulation has a nice form). (Listing 1:line 15 only does the right thing when all DOFs defined on the boundary exactly correspond to the boundary condition).
Returning to the biharmonic equation, we can use the weak formulation to identify what the basis functions in must actually do. For the biharmonic equation, if we want to use the naive weak formulation, we must ensure that
for all . And to actually eliminate the DOFs, we need that if then
iff or . This is almost tautological, but the key point is that we can use our system to extract by building the above operators just as we could use it to analyze the smoothness of elements for a problem. We could also use the above operators to implement Nitsche's method, an alternative for cases where elimination methods fail [Benzaken et al. 2024]. Given the importance of boundary conditions though, we do offer a wrapper, really a simple elaboration on the above ideas, to apply boundary conditions as an alternative to using the system raw: given a mesh, an FE, a BC, and potentially a right hand side for a BC (), we offer a variety of utilities to check if elimination methods can work or to utilize alternatives such as pointwise constraints. These utilities along with our patch test and more complex elements allows us to build a more complete robust biharmonic solver from the framework of the basic Laplace solver.
3 Background
Abstractly, our goal is to automate the labor of building discretized operators with FEMs. Naively, our goal requires that we figure out how to write down bases of functions across arbitrary meshes. However, FEMs already reduce this work through two steps: first, they stitch together many local bases defined on many mesh entities (section 3.4), and, second, they somehow describe each local basis in terms of a reference basis (section 3.3). Unfortunately, the second step is a tricky informal idea at present: we must still somehow specify the basis at each mesh element. Thus, we will start (in section 3.1) by developing mathematical machinery to write down bases efficiently and exactly across many mesh elements. In particular, we will recall linear algebra that allows for primal and dual vectors (contra vs covariant) and we will understand how these notions respond to changes of coordinates. With this machinery, we can mathematically state (definition 3.11) what it means to write "every single basis in terms of a reference basis". One of our chief contributions is to solve this problem (section 6) for finite element bases specified via a language of coordinate independent linear algebra (section 5). But to even state the problem, we must start with linear algebra and how we can write tensors efficiently and exactly.
3.1 Writing Down Tensors
Given a point on the surface of the sphere , consider the cotangent space, . Roughly speaking, is the space of vectors that could be for any scalar function . A vector in the co-tangent space can be described as a list of numbers only after some contortion to pick a basis. Alternatively, without a choice of basis or any information about the co-tangent space, we can refer to vectors in the co-tangent space by taking the derivative of scalar functions at a point . The definition of the co-tangent space lends itself to a natural and rather specific way of writing down vectors, but the modifier co hints at a germ of generality.
Collin et al.
The cotangent space works because derivatives at a point are defined via: where is linear in . This is to say that where is the vector space of linear functions from a vector space to a vector space and where is the standard tangent space at . We have just used the dual space, which is defined as follows: for a vector space , the dual space is .
We can often more easily write down vectors in the dual space than in the primal space . Consider the space of functions from a set to a vector space . In the case , absent structure on , a function/vector in requires a table of information, . For each , the point-evaluation functional is a simple example of a vector in . This is an example, not a characterization of all dual vectors: other linear functionals, such as integral moments on suitable function spaces, need not be evaluations at a single point. We can generalize this pattern to a class of bases that allow us to compromise between the array prospective of Euclidean space and coordinate free vectors that are easy to write down:
Definition 3.1 (Primal and Dual Basis). Given a finite-dimensional vector space with a basis , we say that , a basis for is a dual basis for if . We call the primal basis to . Together, and are a primal-dual basis pair.
The main point of this definition is that the dual basis is easy to write down and yields an array representation for the primal space (via the primal basis) that is easy to understand (via the dual basis).
Another clue that the derivative of a scalar function is a dual vector is the chain rule: . The co-vector, , is said to transform covariantly because the change of basis map, , is used instead of the inverse (contravariance). A simpler definition is that dual vectors are covariant and primal vectors are contravariant. This definition naturally extends when we consider how to write down tensors instead of just vectors. When we make such an extension, we are now considering how we can write down linear maps such as or as arrays or other objects.
We are used to writing down linear maps as arrays of numbers and we understand that this is the result of a choice of basis. However, it is not just any basis as given some some contortion is required to use bases for V and W. We introduce this contortion via the sharp map:
Definition 3.2 (Sharp, Flat). Suppose, and are a primal-dual basis pair for a vector space . Then they define a sharp isomorphism between and :
We denote the inverse of the sharp mapping as . The sharp map is determined by the choice of either dual or primal basis. If the space is an inner product space with inner product and is an orthogonal basis in the inner product, then that sharp map can also be written
Now, given a basis for and for , the array for is ; the contortion lies in the flat map. Really, we should have picked a dual basis for ; this is because the linear map is one part covariant and one part contravariant. To capture this and to also model higher order tensors found in many applications (e.g., stress strain relationships in elasticity, differential forms, high order derivatives), we introduce tensor products.
In our discussion here, we first seek to convey that tensor products are a coordinate free formalism that captures a wide variety of mathematical objects with explicit co and contravariance. See [Dummit and Foote 2004; Lee 2012] for a more detailed discussion on tensor products.
Example 3.1 (Tensor Product). We consider the space of linear maps , the space of bilinear maps , and the tensor product space . We restrict ourselves to finite dimensional spaces. We fix arbitrary bases for , and . We emphasize that the following holds for arbitrary choices of base and that all definitions do not actually depend on bases:
(1) The space has a basis . Further, is a bilinear map from and to . The space is contravariant in and .
(2) The space is isomorphic to the space via the invertible mapping:
The space is covariant in V and contravariant in W.
(3) The space is isomorphic to the space via the invertible mapping:
The space is covariant in both V and W.
These ideas can naturally be extended to tensor products of more than two spaces.
Now we move to the next part of our discussion: tensor products provide a way to write down many coordinate independent objects and to represent them in sensible bases. We start by noting a general rule for writing tensor products in bases: we use dual bases for the contravariant components and primal bases for the covariant components. In the case of , this suggests that we should use a basis in the space , but on the other hand the standard dual basis for this space would be in . Tensor products are defined ultimately so that
where the isomorphism is unique (compared to the non-unique sharp map). The force of this is that we can write down coordinate independent dual vectors for a tensor product space via writing coordinate independent multi-linear maps (which is much easier to do). For example, the trace of a matrix is coordinate independent because it can be written as a coordinate independent vector in via . Similarly, symmetry is preserved under change of basis because we can write: . This is actually using a more general rule that any linear map on a tensor product space corresponds to a multi-linear map in a way that preserves coordinate independence of definitions. This leads to our final definition, of critical importance to section 3.3, which returns to the change of basis in the chain rule.
Definition 3.3 ( Tensor Space, Adjoint, Pullback). Suppose is a finite-dimensional vector space. Then is a tensor space. Suppose we have another finite dimensional space with an isomorphism . The adjoint of is a map given by . The pullback is a linear map in , defined by the following rule and extended linearly:
(13)
One can check that this definition reproduces the contravariant change of basis for vectors, the covariant one for tensors, and the mixed rule for matrices/linear maps. The pullback can be extended to operate on tensor fields, functions taking values in tensor spaces, which is the definition we utilize to reason about elements:
Definition 3.4 (Pullback and Pushforward). Let and be surfaces. Let have an inverse . Let and let . The pullback along is a mapping in given by
The pushforward along T is a mapping in given by
The superscript star denotes pullback on fields; its pointwise action uses the tensor pullback defined above, extending the adjoint on covectors. The subscript star denotes the induced pushforward on dual functionals. We abbreviate by and by .
3.2 Reference Space and World Space
Like many paradigms for simulation, FEMs utilize reference space and world spaces. The reference space is where calculations occur in a standard domain and the world space is where actual physical models live. This distinction will be core to how we reason about finite elements. For now, we narrow the notions of reference and world space to a simpler class of known objects.
Definition 3.5 (Simplex, Entity, Standard Entity). In this paper, we restrict mesh entities to simplices. An abstract simplex is a finite nonempty set of vertices with faces , where is the power set of . Ordered by , it is a partially ordered set, or poset: inclusion is reflexive, antisymmetric, and transitive. A simplex of topological dimension has vertices. Its standard entity labels these vertices by ; these are abstract labels, not coordinates on the real line. An extension to other cell types would require a corresponding standard face structure for each type.
The utility of the above definition is that it is discrete and closer to general definitions where entities are subsets of posets. Though for simplicity in this work we limit ourselves to affine simplices, large portions can be generalized to curved and more complex polyhedra. We now need two notions of dimension for entities:
Definition 3.6 (Topological Dimension, Geometric Dimension). The topological dimension of a simplex is . An entity is said to be geometric if the vertices are all members of where is at least the topological dimension. The number here is the geometric dimension of an entity. We refer to these as tdim and gdim.
Our reference spaces will typically be standardized geometric entities and they will relate to world space through affine maps that we call parametrizations or charts (in honor of differential geometric terminology).
Definition 3.7 (Geometric Standard Entities). For a simplex of topological dimension , the vertices of a geometric standard entity are given by where are the standard basis vectors.
We can now define our parameterizations:
Definition 3.8 (Chart). A chart is a triple where for are two geometric entities and is an injective affine map from to and is a bijection from the vertices of to the vertices of .
These give us our notion of a reference space and our notion of a world space. Much of this work could be extended to allow F to be a polynomial mapping, allowing for general quads and hexes.
3.3 The Mathematical Definition of a Finite Element
Before providing the definition of a FE and illuminating the resulting computational issues, especially those relating to transforming elements, we recast the linear Lagrange element on a triangle. The two key properties of the linear Lagrange basis functions are:
(1) The basis functions are affine functions on the triangle, i.e., the vector space of affine functions defined on a triangle .
(2) Each basis function corresponds to a triangle vertex, , so that if , then .
We can recast this definition by means of a dual basis. This may seem circuitous. Why not just define a primal basis, the functions , directly? Consider our triangle, K and the linear Lagrange basis functions again. Depending on the coordinates of our triangle, may have all different sorts of arbitrary coefficients. However, consider the following dual basis functions: . These these dual basis functions just say “the value at each of the vertices,” which is a simple, coordinate-independent concept. Finding the coefficients of the primal basis functions then reduces to solving n linear systems:
where is some arbitrary basis for the function space (e.g., monomials or Legendre polynomials). Note as a consequence of eq. (16), that . Some readers may recognize the matrix as a generalized Vandermonde matrix [Trefethen 2019].
The key step in the above exercise is that we no longer write down the primal basis explicitly, but we instead write down the dual basis. This has a few key advantages: the mathematical theory works mostly on the dual basis, the dual basis functions make the
Collin et al.
interaction between neighboring triangles easier to reason about, interpolation methods come for free via the dual basis, and the dual basis is easier to write down. Thus the mathematical definition centers the dual basis:
Definition 3.9 (Finite Element). A finite element consists of
(1) , the domain of the element (e.g. a triangle, quad, hex, tetrahedron),
(2) a vector space of values (e.g., real numbers or vectors )
(3) is a finite dimensional vector space of functions from to (usually some class of polynomial functions)
(4) is a dual basis for (e.g., point evaluations)
This definition dates back to Ciarlet [Ciarlet 2002] and variations of it have been reproduced in many FEM textbooks [Braess 2007; Brenner and Scott 2008; Gatto 2022; Logg et al. 2012]. Typically a diagram is used to depict a given FE, representing various dual basis functions via glyphs (such as dots and circles) as we do in fig. 3.
These diagrams raise a critical issue in the definition: we have instantiated this FE on a particular set , but our definition should be coordinate free and independent of . Moreover, as practitioners will have anticipated, we want to instantiate a FE on arbitrary . And if we simply use the recipe of using eq. (16) to find basis functions for many different , we suffer from cubic, , scaling in solutions to eq. (16), not to mention the sub-optimal performance qualities of matrix inverses. To avoid this issue, we observe that a single formula, dependent on , might capture many different related FEs on different sets . To see how this might work, we return to the linear Lagrange element on a triangle.
Throughout the transformation discussion, maps the reference domain to the physical domain. Let be the unit reference triangle and be some arbitrary non-degenerate physical triangle, related to via an injective affine map . Suppose we are given two finite elements, for where are the affine functions on and consists of evaluations at corresponding vertices. Let be the primal basis corresponding to . With the formula for Lagrange interpolating polynomials on a triangle, we can verify that if is an injective affine map and is the primal basis corresponding to , then . We use for the coefficients that combine mapped reference basis functions into physical basis function ; its rows index physical basis functions and its columns index reference basis functions. In particular, if we consider the pullback map on scalar functions , given by , we can see that it is linear and its matrix representation in the bases and is the identity matrix, i.e.,
The consequence of eq. (17) is that any computation on the primal basis corresponding to an arbitrary can be done in terms of and , avoiding the need to actually find for each cell. This possibility is referred to as affine equivalence [Ciarlet 2002]:
Definition 3.10 (Affine Equivalence for Scalar-Valued Elements). Two finite elements for are affine equivalent under an injective affine map if maps each reference nodal basis function to its corresponding physical nodal basis function. In our convention, .
However, many FEs are not affine equivalent, and so other notions of equivalence have been developed, including affine-interpolation equivalence for the Hermite element [Ciarlet 2002] and compatible nodal completion equivalent for the Morley and Argyris elements [Kirby 2018]. We do not deeply investigate these notions here, but the key idea is that the basis-transformation matrix in eq. (17) need not be the identity matrix but now takes some other forms, possibly non-linearly dependent on the map and/or . We retain this symbol and reference-to-physical direction throughout; the corresponding pullback of physical fields is , while maps reference fields to the physical domain. In particular, for the Morley element, the basis-transformation matrix was computed by [Kirby 2018]; in our convention it is as follows:
Example 3.2 (Morley Basis-Transformation Matrix). Let be the unit reference triangle, a non-degenerate physical triangle, and affine with . Number corresponding vertices 1, 2, 3 and let edge be opposite vertex . Orient each unit tangent from the lower-numbered endpoint to the higher-numbered endpoint, and obtain its unit normal by a clockwise quarter turn. Write these vectors as on and on , and let be the physical edge length. Define
Order the six DOFs as vertex values followed by normal derivatives at edge midpoints, on both triangles. Then
Kirby uses the opposite geometric map , with . Thus our is Kirby's , with normals before tangents. The matrix inside the brackets is his nodal matrix ; the transpose is essential because our is his basis matrix . With reference basis and physical basis , we have . This matrix from eq. (18) again lets us compute with the Morley element basis functions on an arbitrary triangle by only computing the matrix and the Morley element basis functions on a single reference triangle.
At present, these matrices are computed by hand, as in [Aznaran et al. 2023; Groelj and Knez 2021; Kirby 2018; Kirby and Mitchell 2019; Sky et al. 2023]. One of the core aspects of our system is that we will compute these automatically from a software specification of definition 3.9. Naturally, some of these formulas are available in papers, but there are several other virtues to automation. First, for an unknown element, a formula is not already available. Second, as we will describe in the next section, the formula is not enough. The formula must be integrated into an FE code with global function spaces, which is a finicky task that requires awareness of the various conventions and methods a given code employs. Third, the first two reasons compound: exploring new elements requires changing other aspects of the system in subtle ways, and changing the system might require one to revisit and change existing formulas. To facilitate rapid exploration of FEMs, we need to automate the discovery of the relevant formula in the context of an expressive system for other aspects of FEs.
With this motivation and background in hand, we can now formally state the core problem that we will solve in section 6. We are interested in finding formulas for the primal basis functions of a class of FEs so that the primal basis functions depend (linearly) on a fixed FE and (non-linearly though ideally at cost at most ) on a transformation . We can now formally define the object that we will compute in section 6.
Definition 3.11 (Transformation of a Finite Element). Fix a finite element . Suppose we have a collection of sets that are diffeomorphic to via a mapping . Suppose further that we have a collection of finite elements indexed by . Let be the primal basis for . Let be the primal basis for . For each , we seek a matrix , with physical basis functions indexing rows and reference basis functions indexing columns, such that
This is the same basis-transformation convention as eq. (17). In the usual convention of multiplying column vectors of coefficients, the matrix of is . If the pullback is an isomorphism, the coefficient matrix of is . Further, this means the primal basis for the target element can be written as:
Here acts on tensor values; for scalar fields this factor is the identity.
Ultimately our system will compute this from a software implementation of the mathematical definition of a FE. Our system uses eq. (20) as the formula for primal basis functions on elements. Based on our discussion of pullbacks, we can now anticipate some core challenges. First, to even state the problem in software, we must specify elements simultaneously across all possible domains. This is a key language design problem. Second, the above formulation assumes that , which in general does not need to be the case. Thus, mapping P does not obviously exist in many cases. Third, even if it does exist, P might be a complex symbolic object, especially because pullbacks depend polynomially on derivatives and inverse matrices turn polynomials into large complex rational functions. We return to this in section 6 and for now move on to the other big challenge of using FEs: the global FE space and operations on it.
3.4 The Mathematical Definition of Global Finite Element Spaces and Associated Operations

Fig. 3. Examples of finite elements depicted graphically via their dual basis functions. This figure was inspired by graphical depictions going back to the Ciarlet definition of the finite element, but especially those in [Logg et al. 2012].
An FE defines a local space of functions on individual mesh elements. Now we seek to construct a global FE space, a space of functions defined on the whole (global) mesh. Like the individual FEs, this construction will consist of a domain, a space of functions, and a dual basis. Returning to the linear Lagrange example from section 3.3, the

primal bases of the corresponding global space are the well-known linear hat functions, one for each vertex in the mesh.
A hat function associated to the vertex v matches a primal basis function in each local linear Lagrange FE space on a triangle incident to the vertex. However, the hat function is not simply the sum of these local functions, as this would result in over-counting values on the shared edges between triangles. The problem of how to handle boundaries between elements also arises

when we seek to describe spaces of discontinuous functions, whose values at such boundaries are ill-defined. For instance, this occurs when modeling fractures, creases, or interfaces between different materials.
We need a few auxiliary notations from topology in order to talk coherently about the boundary vs. interior of our elements. We write to mean the closure of the set , and to mean the interior of the set . We say that a set is regular closed if .
Collin et al.
Definition 3.12 (Restriction of Functions). Suppose is a regular closed set and is a vector space. Given such that is continuous and bounded on , then , the restriction of to , is the unique continuous extension of to .
A key application of this concept is the construction of discontinuous functions: consider two triangles sharing a vertex , as well as a function defined on . If is discontinuous at , then we can evaluate and at to get two distinct values. This allows us to have two different DOFs at and thus to construct global FE spaces that include discontinuous functions. We can transpose the preceding construction to

extend local dual functions back to operating on the global space.
Definition 3.13 (Extension of Dual Functions). Suppose is a regular closed set and is a vector space. Given a , the extension to is a dual function defined via for all . More concisely, . Hence is dual (a.k.a. adjoint) to .
Given some point evaluation of a vertex on a mesh, , then for a triangle with , is now not just a point evaluation, but a more complex object: it is the limit of all point evaluations as they approach the vertex. Thus, as emphasized above the extension of a dual function by different elements yields different dual functions on the global domain. These are the dual functions to which DOFs are most naively associated. Every graphics programmer is familiar with this phenomenon as it applies to texture coordinates, or mesh normals that vary according to triangle, not merely according to vertex.
This machinery is sufficient to define what we call a broken global FE space, which models a fully discontinuous space.
Definition 3.14 (Broken Global Finite Element Space). Let be a domain meshed by a finite collection of elements , each a regular closed subset of and forming a partition of in the sense that and if . Furthermore, let be the FEs associated to each . Then define
(1) a global space of piecewise functions
(2) a global set of dual function so that .
We call the broken global finite element space associated to a collection of finite elements.
Note that the union of local dual basis functions, (2), in the above construction is disjoint. We have exactly one global dual function for each local dual function on each element. Further note that the construction of P given above is intuitively accurate, but requires tricky functional analysis to specify precisely .
The broken space does not yet allow us to produce our hat functions. Intuitively, we still need to ensure that all the DOFs corresponding to point evaluation at the same vertex evaluate to the same value for all functions in . To do this, we must group or equate DOFs to construct the global FE space. We accomplish this via an equivalence relationship on the global broken degrees of freedom.
Definition 3.15 (Global Finite Element Space). Suppose we have a collection of finite elements that form a broken global finite element space . Further suppose is an equivalence relation on such that basis functions from the same element are not made equivalent: in other words, for some and , then . Then we can define via
and we can define
The global finite element space is then .
We make two observations. First, a good choice of equivalence relationship can sometimes be generated via the space of continuous functions, :
This requires that all dual basis functions are well defined on functions in . In the FE literature, equivalence relations are used implicitly by way of a choice of function space. Second, although is technically a set of equivalence classes, the construction of as a quotient allows us to use any set of representatives of the classes as a dual basis for .
As an initial application of the above machinery of global FE spaces, we can define a notion of interpolation. Traditionally, interpolation uses a set of points and a corresponding set of measurements . Interpolation seeks to find a function that satisfies . For FEs, we can replace the pairs with dual basis functions, , and values for these dual basis functions, . However, we are not often given a set of values as actual numbers. Instead, we often are given some other function , not necessarily in the FE space, that we use to compute the , which then defines a function that approximates .
Definition 3.16 (Well Defined, Finite Element Interpolation). Let be a global finite element space. Let be such that for all , is well defined, which is to say that for all , . Then the interpolation of into the global finite element space is a function given by
Let us consider an example of the issue that occurs. Consider a mesh of the interval [0, 2] consisting of two sub-intervals [0, 1] and [1, 2]. Even if the local function spaces consist of affine functions, P as constructed above does not specify the value
of for ; it can be arbitrarily modified. This problem occurs in much of functional analysis and is resolved by drawing functions from Lebesgue spaces, such as . These spaces technically consist of equivalence classes of functions, rather than individual functions. This is almost entirely a distraction from any of our development here, so we choose to not needlessly complicate our presentation further.
FE interpolation lets one approximate a wide variety of functions with FE functions. Practically, interpolation allows one to get data into the system in a consistent way. In particular, if some FEM converges at an order with some given FE, then interpolating incoming data will often not disrupt this order of convergence.²
FE interpolation also reveals another fundamental challenge of using complex FE global spaces (beyond the correct software implementation of the above definitions and their usage to build global operators/sparse matrices): FE interpolation requires that the equivalence classes of DOFs are well defined but sometimes they are actually multi-valued. As a simple example, interpolating from a discontinuous linear Lagrange space to a continuous one does not make sense in the above definition. In DEC, this problem is often encountered when converting between edge, vertex, and face fields as one can't interpolate between these and must use global Hodge star like objects. For our system to support more general FEMs, we must systematically handle how quantities derived from finite element spaces are sometimes multi-valued and how this renders some computations ill-defined. As it turns out, our system will systematically provide warnings when such problems emerge and this mechanism will be at the heart of how our system supports all the different ways one might want to use functions defined in global finite element spaces (e.g., operator assembly, residuals, interpolation).
4 Related Work
4.1 Finite Elements in Graphics
FEMs are a standard part of the toolkit of computer graphics, especially piece-wise linear FEs. The piecewise linear discretization of the Laplacian operator appears ubiquitously in computer graphics in the form of the cotangent Laplacian [Meyer et al. 2003; Pinkall and Polthier 1993]. Moreover, piece-wise linear Lagrange FEs are used to simulate fluids, simulate solids, simulate fluid structure interaction, mesh objects, render objects, smooth meshes, perform 4D variations on these themes, and more [Alliez et al. 2003; Bargteil et al. 2007; Clausen et al. 2013; Gruber and Aulisa 2020; Irving et al. 2007; Jakob et al. 2010; Kazhdan and Hoppe 2013; Shi et al. 2025; Sin et al. 2013; Smith et al. 2018].
In several subfields of computer graphics, alternatives to piece-wise linear Lagrange FEs are under consideration due to various problem specific needs. The primary alternatives under consideration are higher-order Lagrange elements or similar constructions for squares and hexahedra (such as B-splines) [Longva et al. 2020; Mezger et al. 2008; Schneider et al. 2019, 2022]. Most notably, higher-order Lagrange elements (typically not beyond cubic) have been employed to deal with locking phenomena in elasticity problems [Bargteil and Cohen 2014; Fernández-Fernández et al. 2025; Longva et al. 2020; Weber et al. 2015]. In elasticity in particular, more exotic elements have been used specifically to deal with many phenomena [Bargteil and Cohen 2014; Frâncu et al. 2021; Rémillard and Kry 2013]. In fluids in particular, B-Spline constructions have been employed as FEs, mainly to allow for smoother bases [Cao et al.
2022] though [Nabizadeh et al. 2024] also employs a scheme similar to some FEEC elements. Moreover, spline bases have a long history in fluids/continuum simulation as a discretization in FEM-like components of particle/grid type simulations [Fu et al. 2017; Hu et al. 2018; Jiang et al. 2016]. A few works have directly or potentially indirectly³ utilized something like lower order discontinuous Lagrange elements [Chen et al. 2018; Edwards and Bridson 2014; English and Bridson 2008; Kaufmann et al. 2009a]. Finally, the lower-order nonlinear Lagrange elements have been employed in a variety of other problems, such as meshing and surface deformation [Le et al. 2023; Ling et al. 2015]. Beyond higher order Lagrange, a few have used the FEEC elements (mainly the Whitney elements via subdivision representations) and their relatives (Crouzeix-Raviart), especially when dealing with the structure of harmonic functions [Brandt et al. 2018; Custers and Vaxman 2020; Desbrun et al. 2006; English and Bridson 2008; Huang et al. 2011; Jacobson et al. 2010; Stein et al. 2020; Wang et al. 2006]. In the latter case, the elements are always of the lowest orders. Much more rarely, authors have used elements that we cannot find implemented elsewhere, such as the Fraeijts de Veubeke's element [Boyé et al. 2012]. The same work also uses Morley's element but does not provide any related details on its usage. Lastly, we should also note that a many works have considered basis functions built from fundamental solutions to PDEs, complex geometrical features, complex higher order sub-cell/multiscale constructions, similar to various extended or enriched finite element schemes [Chen et al. 2019; Hafner et al. 2019; Kaufmann et al. 2009b; Kharevych et al. 2009; Koschier et al. 2017; Martin et al. 2008]; we consider these and many other approaches as potential future work as they are often built on top of FEM pipelines.
4.2 Automation for the Finite Element
In this section, we survey the related work with respect to the ability of other FE software to use definition 3.9 of an FE automatically and parametrically. Outside of providing basis function values, several other aspects of using FEs have been partially automated in a few libraries. The systems that support non-affine equivalent elements support using their DOFs to perform interpolation or to enforce BCs to varying degrees, though in all cases the support is partial [Gangl et al. 2020; Gustafsson and McBain 2020; Kirby and Mitchell 2019; Porrmann 2022; Renard and Poulios 2020]. Similarly, some of these systems make assumptions on the mesh to make certain types of FEs work [Homolya and Ham 2016] while others, mainly FEniCS via the Basix library for basis functions, allow users to specify how basis functions are impacted by generators of symmetry groups [Scroggs et al. 2022]. Lastly, Marsden et al. [2023] proposed extending Ciarlet's definition with information about continuity across shared mesh entities and structured DOF representations. FUSE [Marsden 2026] provides a unified, serialisable element representation, with DOFs expressed through kernels, integral pairings over entities, and group actions. Its generation of DOF families through group actions serves several roles, including one closely related to our topological
²In some systems, e.g., Firedrake/FEniCS, inappropriate representations of DOFs have led to interpolation changing the order of convergence. Here is a recent example of this problem: https://github.com/gridap/Gridap.jl/pull/1048.
³Indirect usage is possible for discontinuous elements because they often show up through tricks to break connections between elements or to model discontinuous geometries (e.g., periodic geometries involve a discontinuous parameterization). However, it is difficult to tease out the exact relationship.
12 • Collin et al.
enumeration (paragraph 5.2.4.3): both expand compact DOF specifications across entities. Our enumeration does this by matching pointwise expressions with topologically compatible charts and fields, whereas FUSE uses group actions to express cell symmetries and their action on DOFs. Among the systems discussed here, FUSE is the closest related work to our element-specification language.
For an element whose physical-cell transformation is not already supplied by a library, implementing the element has traditionally required the developer to derive and encode that transformation. For elements with known transformation formulas, this may mean implementing an existing result; for others, it requires a new derivation establishing some version of definition 3.10 or eq. (17).
For example, Symfem constructs finite element bases symbolically [Scroggs 2021]. Scroggs and Wells [2026], part of the FEniCSx effort [Baratta et al. 2023] and related to Symfem, automates DOF transformations when the element can be written on a general domain and when the transformation can be decomposed block-wise based on the topological sub-entities of the reference element. Their algorithm, like ours, directly attacks eq. (17), but under an assumption of a block-wise sparsity pattern found in elements that are affine equivalent under appropriate pushforward, mainly the FEEC families. Their transformations may produce a nicer formula for some of these while we believe ours would probably work on a larger class of elements. Further, at the level of the specification language, Symfem currently doesn't build all simplicial elements on arbitrary affine geometries, so the infrastructure for the problem is not yet fully present there.
After promulgation of aspects of this work at PDESoft 2024 [Collin et al. 2024] and documentation of its mathematical and algorithmic foundations in our 2025 thesis [Collin 2025], we presented further aspects of this work at PDESoft 2026 [Collin 2026]. To our knowledge, related generic transformation work in FIAT/FInAT began in July 2026 [Brubeck 2026]. Section 6.2 of the thesis develops the two-stage Vandermonde construction and recursive block inversion; its Appendix A develops the dual-basis-cover construction and support analysis. Appendix A of this paper gives the cover factorization and its algorithmic consequences. The FIAT/FInAT implementation [FIAT/FInAT developers 2026a] uses constructions closely related to those developed in our thesis and presented here: weighted derivative representations of DOFs (theorem 6.1.1 and appendix A); generalized Vandermonde matrices (section 6.2 and eq. (26)); support-based block algorithms (section 6.2.3, paragraph 6.2.4.2, and appendix A); and simplification using pullback structure (sections 5.1.3 and 5.1.4 and paragraph 5.2.4.2; see also our related Grassmann work [Collin et al. 2026]). Its public development notebook also discusses the construction and support-based block elimination [FIAT/FInAT developers 2026b]. FIAT/FInAT integrates these methods into its established element infrastructure for affine simplices and supported physical-node conventions [FIAT/FInAT developers 2026a].
Before generic transformation automation, libraries supporting non-affine equivalent elements (definition 3.10) allowed developers to supply geometry-dependent matrix representations of the pull-back. Examples include Firedrake, FEniCS, NGSolve, Dune, scikit-fem, and GetFEM [Gangl et al. 2020; Gustafsson and McBain 2020; Kirby and Mitchell 2019; Porrmann 2022; Renard and Poulios 2020; Schöberl 2014]. These libraries offer a wide variety of FEs, including
Firedrake's support for generally mapped elements and macroelements [Brubeck and Farrell 2024; Brubeck and Kirby 2025; Brubeck et al. 2025; Ham et al. 2023; Kirby and Mitchell 2019]. FIAT, a foundation for this line of work and a library used in Firedrake and originally FEniCS, automatically generates reference basis functions for a wide variety of DOFs, polynomial spaces, and domains. Earlier FInAT work supplies element-specific transformations and other symbolic data needed for generally mapped elements [Ham et al. 2025; Kirby 2004, 2018; Kirby and Mitchell 2019; Rathgeber et al. 2016].
Other FEM systems provide different balances of built-in element families, weak-form interfaces, and specialized operators [Anderson et al. 2021; Arndt et al. 2021; Baratta et al. 2023; Dedner et al. 2012; Fischer et al. 2022; Hecht 2012; Jasak et al. 2007; Maas et al. 2012; Moxey et al. 2020; Shadid et al. 1996; Tonks et al. 2012]. Supporting a predefined element family or parametrizing a variational form does not by itself make transformation generation, interpolation, and boundary-condition routines parametric over a new mathematical element specification.
Our focus is to express DOFs in IPTEM and use the same compiler for element transformations and variational forms, including the generation and structured inversion of geometry-dependent Vandermonde matrices, as well as the parametric use of elements in interpolation, boundary-condition enforcement, and assembly. These routines operate on the resulting element representation, so they adapt to the element specification.
4.3 Automation for Other Aspects of the Finite Element Method
Outside of the FE itself, many other aspects of the FEM have been somewhat automated, often via DSLs. Discussions of meshing software are not germane to our purposes, but the specification of weak formulations is heavily related to our enterprise.
Essentially three approaches have emerged to allow users of FEM software to specify their problems. First, systems such as PolyFEM, Vega, or nekRS offer parameterized PDEs that users can configure with expressions for fixed tensors or BCs, meshes, or other parameters [Fischer et al. 2022; Schneider et al. 2019; Sin et al. 2013]. Second, systems such as MFEM, Trixi.jl, and Nektar++ offer libraries of operators that can be combined to specify the variational formulation of a PDE [Anderson et al. 2021; Moxey et al. 2020; Ranocha et al. 2023]. These systems sometimes also expose internal constructs for building such operators, such as element loops and tools to represent specific components of an operator; packages such as deal.i2 and MFEM exemplify this approach [Andrej et al. 2024; Arndt et al. 2021; Kronbichler and Kormann 2012]. Third, several systems such as Firedrake, FEniCS, and Dune rely on the Unified Form Language, a DSL for specifying weak forms or energies as expressions [Alnæs et al. 2014; Dedner et al. 2012; Logg et al. 2012; Rathgeber et al. 2016]. Within computer graphics, SymX is closet cousin of these, as it has a DSL for energies that it can minimize [Fernández-Fernández et al. 2025]. Some packages such as Gridap.jl [Badia and Verdugo 2020; Verdugo and Badia 2022] or LibCEED [Abdelfattah et al. 2023; Brown et al. 2021] operate potentially between the second and third approaches, via novel ways of expressing and decomposing finite element assembly loops that utilize compiler technologies to achieve varying advantages.
Form languages are the line of work closest to our own as the specification form is similar to the specification of elements, but they are not used this way. Form language compilers produce quadrature loops, which are heavily optimized for performance, as opposed to symbolic outputs that can be used to compute pullback matrices [Alnæs and Mardal 2010; Homolya et al. 2017; Kirby and Logg 2006; Logg et al. 2012]. As a minor example of this, when users wanted to use FEEC elements in form compilers, form compilers had to be modified to deal with pullbacks associated with FEEC elements as opposed to symbolically deducing such pullbacks [Rognes et al. 2010]. However, we note that form compilers have other symbolic capabilities such as various forms of automatic differentiation [Alnæs et al. 2014; Farrell et al. 2013; Paganini and Wechsung 2021], the ability to perform various automated optimizations [Bergbauer et al. 2025; Homolya et al. 2017; Kempf et al. 2020; Russell and Kelly 2013] (and this is not to mention a lot of compiler work aimed at the performance of FEM systems in general), and the ability to express many highly specialized time-steppers and preconditions [Farrell et al. 2021a; Gibson et al. 2020; Kirby and Mitchell 2018; Ølgaard et al. 2009]. A particularly valuable contribution is automatic sum factorization for high-order elements, enabled by FinAT's explicit representation of tensor-product structure and TSFC's exploitation of that structure in Firedrake [Homolya et al. 2017]. This reduces the computational complexity of assembly, making it an important consideration in performance comparisons with ElementForge, which does not currently implement sum factorization.
At this time, we do not pursue this higher-level work, but we do produce a form language (the same language we use to specify elements). Our form language inherits some advantages and disadvantages from a non-specialized form language: for example, our language can be more concise for many forms that operate on high-level tensor expressions, especially those involving exterior calculus, but our language can also be more verbose as we do not build in specialized constructs for form differentiation, mixed methods, or for discontinuous Galerkin methods.
4.4 Less Well-Known Finite Elements
We highlight the many FEs that appear in the literature, briefly commenting on their various utilities. For example, there are many families of FEs that offer various forms of continuity [Argyris et al. 1968; Bell 1969; Ciarlet 1978; Hu et al. 2021; Hu and Zhang 2014; Li et al. 2022; Wang and Xu 2012; Wu and Xu 2018]. Sometimes FEs are defined because they allow elegant and correct solutions to certain problems [Arnold and Awanou 2013; Arnold and Walker 2020; Arnold and Winther 2002; Cockburn and Fu 2017; Guzmán and Neilan 2018; Tai and Winther 2006]. Some FEs offer superior convergence speeds or conditioning properties over easier to use options [Ainsworth and Jiang 2022; Ciarlet Jr. et al. 2017; Gillette et al. 2019; Guzmán et al. 2011; Karniadakis and Sherwin 1999; Kronbichler et al. 2019; Nigam and Phillips 2010] or sometimes they offer highly efficient code for the same convergence [Bernardi and Raugel 1985; Buffa and Christiansen 2005; Chan and Warburton 2016a,b;
Kirby 2011]. Some FEs are uniquely suited for certain applications using some portion of the above properties [Arf and Simeon 2021; Arnold et al. 2014; Arnold and Walker 2020; Arnold and Winther 2002; Cockburn and Fu 2017; Cockburn and Qiu 2014; Mardal et al. 2002; Matthies and Tobiska 2005; Neunteufel 2021; Regge 1961]. We believe that ElementForge can implement most of these elements with the exception of the small minority of elements relying on rational function spaces and NURBS/Spline type constructions. We do require an extension for piecewise polynomial spaces in the element space, but these are known to be simple. Further, projects such as tIGAr [Kamensky 2021, 2023] has shown how to extend code generation approaches such as FEniCS to isogeometric analysis, which we believe we could adapt to our system with non-trivial effort.
5 Software Representation of DOFs and Operators:
Integrated Pointwise Tensor Expressions on Manifolds
We capture both DOFs and operators via a new language for Integrated Pointwise Tensor Expressions on Manifolds (IPTEM). The IPTEM language balances the expression of DOFs/operators against both succinctness and automation. Our IPTEM languages facilitate a succinct yet expressive representation that can be manipulated automatically to produce simple formulas for use in FEM code.
We introduce our IPTEM language and compiler in stages, each of which introduces a novel language and novel compilation algorithm. The languages are tensor expressions (section 5.1), pointwise tensor expressions on manifolds (section 5.2), abbreviated PTEM, and, finally, integrated pointwise tensor expressions on manifolds, resulting in IPTEM (section 5.3). We organize section 5 in this order. Each language addition has an associated compilation algorithm and together they amount to a single compiler. The composition of these compilers is depicted in listing 7. Notably, the organization of the compiler runs contrary to that of the languages, going from PTEM to tensors to integrals. The rest of our implementation sections utilize the overall compiler depicted in listing 7 as a black-box to generate code for Vandermonde matrices (section 6.2.2) and for the local parts of global FEM code (section 7.2 and appendix C.0.3).
5.1 Tensor Expressions: Tensors, Tensor Spaces, Basis
Our system balances succinctly expressing tensors against our need for the automatic generation of simple formulas. Along the lines of section 3.1, our system achieves this balance by utilizing the idea of coordinate independence. We introduce a grammar for tensor expressions (fig. 4) that only allows coordinate independent concepts, leaving the choice of basis (fig. 6) to automation and optimization via compiler algorithms. We do not fully elucidate the formal aspects of this language as these are the subject of another work, which describes a similar language in fully formal terms. [Collin et al. 2026].
5.1.1 Grammar and Semantics for Tensor Expressions
We clarify the mathematical meaning of the terms in fig. 4. In what follows, we follow the grammar: we examine each space, s, and some associated tensors, e, in turn, defining inner products recursively as a running class of examples. Through these examples, we show that terms are coordinate independent yet expressive. We also introduce syntactic
Collin et al.
1 matchTy = dict[PTEMargument, Union[Chart,Field]] 2 (See section 5.2.3 and paragraph 5.2.1.1) 3 iptemTensorTy = Tuple[Tensor, Basis, dict[Tuple[str, Basis], Formula]] 4 (See section 5.1.1, section 5.1.3, and section 5.1.2) 5 def iptemCompiler(iptems: List[IPTEM], ( See section 5.3) 6 charts: List[Chart], ( See paragraph 5.2.1.1) 7 fieldArgs: dict[Argument, List[Field]], ( See paragraph 5.2.1.1) 8 evaluateIntegral: bool (See section 5.3.1) 9 ) -> DataFrame: (See fig. 8) 10 # PTEM Phase: (See section 5.2) 11 iptemMatches : dict[IPTEM, List[matchTy]] = {} 12 for iptem in iptems: 13 iptemMatches[iptem] = topologicalEnumerate(iptem.ptem, charts, fieldArgs) (See paragraph 5.2.4.3 and fig. 8) 14 15 iptemTensors: dict[Tuple[IPTEM, matchTy], iptemTensorTy] = {} 16 for (iptem, matches) in iptemMatches: 17 for m in matches: 18 iptemTensors[(iptem, m)] = singleCompilation(m) (See paragraph 5.2.4.2) 19 # Tensor Compiler Phase: (See section 5.1.1) 20 ptemFormulas: dict[Tuple[IPTEM, matchTy], Formula] = {} 21 for (key, (tensor, basis, env)) in iptemTensors: 22 ptemFormulas[key] = representTensor(tensor, basis, env) (See section 5.1.4) 23 # Integrals/Reductions phase: (See section 5.3) 24 iptemFormulas: dict[Tuple[IPTEM, matchTy], Formula] = {} 25 for ((iptem, m), Formula) in ptemFormulas: 26 iptemFormulas[iptem, m] = applyIntegration(iptem.integral, m, formula, evaluateIntegral) (See section 5.3.1) 27 table = applyReductions(iptemFormulas) (See section 5.3.2) 28 # Table has columns for IPTEM, IPTEM arguments, and Formula 29 return table
Listing 7. Architecture of the IPTEM compiler. At the bottom language level, we introduce a compiler from tensor expressions to formula, simple array programs described in section 5.1.2, that represent the expression in an input basis (section 5.1.4). We can treat this level as a computer algebra system compiler hybrid that other levels query. This operates in the middle of our overall IPTEM compiler (in listing 7: line 22). To get to the point where we can compile tensor expressions to formula, we must manage PTEMs, the middle language level, and translate them to situations that our tensor compiler can handle (section 5.2.4 and line 10 - line 18). We do this in two phases. We call the first phase topological enumeration (paragraph 5.2.4.3 and line 13) and the second phase single compilation (paragraph 5.2.4.2, line 18). Topological enumeration enumerates the different ways a PTEM can be matched to input data (fields and charts - see section 5.2.1) and the second phase converts a PTEM to a tensor expression given a matching of PTEM to input data. At the top language level, we can add integration and reduction of PTEMs, but in our overall compilation algorithm we handle integration and reduction last (line 24-line 29) via two post-processing phases. First, our compiler generates code for integrating formulas produced from PTEMs matched to input data (section 5.3.1 and line 26). Second, our compiler generates code to combine formulas for various IPTEM together based on reductions across shared chart and field argument matches (section 5.3.2 and line 27). Particular attention to the relationship between topological enumeration and reductions is given in fig. 8 as it is critical to how we solve problems emerging from multi-valued computation in FEM code (see section 3.4).
sugar, which is present in our implementation as a Python EDSL. Here, v is a DSL object representing a vector space, with methods such as v.inner; an annotation v: v declares a symbolic vector in that space. These annotations are interpreted by the DSL rather than as ordinary Python class hints. The @linear decorator constructs a symbolic multilinear map from the function, so the result supports
tensor operations such as reshape. For space objects, v | w denotes the direct sum , while denotes the tensor product ; the former is not Python's union-type notation.
(1) The first space in fig. 4 is R, which is associated to the operations/vectors available in every vector space: Zero, +, scalar multiplication via ×, and specific scalars (noted by c in the grammar). Scalar multiplication provides an inner product for this space.
(2) Given a space V, fig. 4 allows for the dual space (see section 3.1). The dual space is closely associated to the sharp map (definition 3.2), Abstract, and Eval. For two tensor expressions (corresponding to tensors and ), we use Eval to produce a scalar via Eval( ), representing . We can abbreviate this as . Similarly, we can write for . Since spaces in our grammar are inner product spaces, this sharp, just like evaluation, does not reference specific coordinates (see (9)). To express the inner product, we introduce multi-linear evaluation, Eval( ) for evaluating the first n linear arguments of some e. We also support partial evaluation: Eval( ) where indicates which argument of e will be supplied . Finally, we can produce expressions representing vector in using abstract: given an e representing a vector in the space V and an inner product on on V, represented with Inner(V), we can write
Abstract(tx₀, V, R, Inner(V)(e, tx₀))
which should be read as mapping a variable representing a value in the space denoted via V to a value in the space denoted via R via an expression. The expression evaluates the inner product on V on an input variable and e. Since evaluating the inner product is linear, this represents a value in . We can use abstraction and multi-linear evaluation to define an inner product on :
Abstract([tx₀, tx₁], [Dual(V), Dual(V)], R, Inner(V)(tx₀, tx₁))
We could translate this into our Python syntax:
@linear # Abstract def f(tx0: Dual(V), tx1: Dual(V)) -> R: return V.inner(tx0.sharp(), tx1.sharp())
(3) To characterize linear and multi-linear maps, we utilize tensor products (example 3.1) as a coordinate independent representation. Tensor product tensor expressions can be constructed with , but also via Abstract and any node that provides a multi-linear map. For example, the inner product of represents a bilinear map, denoted with . The reshape map can be used to convert this to a map on via Reshape(Inner(V), [0,1], 0), as in (12). The integer arguments in Reshape and Eval handle the case of a more general tensor product space. Suppose we have a tensor product of dual spaces and other spaces. The integers for Eval and Reshape allow one to access the dual spaces. The last integer in Reshape places a reshaped space in the spaces. Finally, we note that given a and with associated inner products, we can define an inner product on V⊗W. To hint at our Python EDSL, we show this one in Python syntax:
1 @linear # Abstract 2 def f(v: V, w: W, vp: V, wp: W) -> R: 3 return V.inner(v, vp) * W.inner(w, wp) 4 inner = f.reshape([0,1], 0).reshape([1,2], 1)
(4) Given two vector spaces expressions V and W, we have a direct sum V⊕W. This allows the representation of () and a vector in might be written as . The operations Project and Embed allow us to extract an entry from a direct sum or to create a direct sum with a specific entry. By conflating Project with indexing, we have a Pythonic way to write the inner product:
1 @linear # Abstract 2 def inner(x: V | W, y: V | W) -> R: 3 return V.inner(x[0], y[0]) + W.inner(x[1], y[1])
With this addition, our language starts to resemble a NumPy like language that respects co- and contra-variance and utilizes coordinate free quantities.
(5) The final four spaces of the grammar all utilize the same idea. Given a linear map , we can factor into the kernel and co(mplement)-kernel as well as into image and co(mplement)-image. Our final four spaces provide exactly these with some additional metadata. We can indicate if is injective and/or surjective via properties (prop), as these sometimes simplify these spaces. These spaces allow our tensor expression language to express a surprisingly wide variety of mathematical concepts. For example, symmetric tensors found in elasticity can be expressed using the kernel of the anti-symmetrization map and the exterior algebra can be expressed using the co-image of the symmetrization map. Also, the tangent space can be expressed as the image of the derivative of a parameterization/chart at a point. The operator Embed allows us to embed vectors from these subspaces into their ambient spaces, leading to simple definitions of inner products via those on or .
1 @linear 2 def inner(x: Kernel(L, V), y: Kernel(L, V)) -> R: 3 return V.inner(x.embed(V), y.embed(V))
The operator Project allows us to enter these spaces and we do not support indexing for it. Lastly, we encode the first isomorphism theorem in our language: users can access the induced mapping from the co-kernel to the image with the Restrict mapping and the inverse via Inverse.
| tx | tensor variable |
|---|---|
| n | constant integer |
| b | constant boolean |
| f | Non-Linear Function |
| s ::= R | Real Numbers |
| s* | Dual Space |
| s₀⊗ s₁ | Tensor Product |
| s₀⊕ s₁ | Direct Sum |
| Kernel(e, s₀?, s₁?, prop) | Kernel |
| Image(e, s₀?, s₁?, prop) | Image |
| Colmage(e, s₀?, s₁?, prop) | Co-Image |
| CoKernel(e, s₀?, s₁?, prop) | Co-Kernel |
| prop ::= Injective | Surjective | Bjective | Linear Map Properties |
| e ::= tx | Tensor variable name |
| c | Constant real number |
| Zero(s) | Zero of a space |
| e₀ + e₁ | Addition of Tensors |
| e₀ × e₁ | Scaling of Tensors |
| e# | Sharp operation |
| e₀⊗ e₁ | Tensor Product |
| Eval(e₀, (n₀, ...)), e₁, ...) | Evaluation |
| Abstract((tx₀, ...), (s₀, ...)), e, s?) | Multi-Linear Function |
| Reshape(e, (n₀, ..., nₖ), n) | Universal Property of Tensors |
| Inner(s) | Inner Product of s |
| e₀⊕ e₁ | Direct Sum |
| Project(s₀, s₁, n?) | Projection |
| Embed(s₀, s₁, n?) | Embedding |
| Inverse(e) | Inverse |
| Restrict(e) | Restriction |
| NonLinear(f, e) | Black-box evaluation |
Fig. 4. A Grammar to Describe Tensor Expressions and Tensor Spaces.
As a final note on expressiveness, we can recover arbitrary Einstein index notation from this language, but we still need other operations on tensors in various mathematical models, necessitating an extensible escape hatch in the NonLinear term. The escape hatch is intended for non-linear scalar functions such as cos or √ as these often appear in weak formulations.
5.1.2 Formulas In this paper, a formula is a straight-line array program: a sequence of intermediate assignments followed by a returned array. Formulas are the target language of our tensor expression compiler, with syntax given in fig. 5. However, formulas as a representation of programs constrain Array entries to be rational functions (rf) (in the intermediate variables of the program). Critically, formulas constrain arrays to enable symbolic manipulation via manipulation of rational functions. Consequently, we have two notions of simplicity. First, we have the degree of the rational functions, a natural number for the polynomial degree of the numerator and a natural number for the polynomial degree of the denominator, in terms of the inputs to the formula (which is potentially infinite due to non-linear functions). This roughly captures the simplicity of the Vandermonde matrix of the Morley element (example 3.2). Moreover, this captures the literal simplicity of evaluating a formula. The degree and the number of variables allows one to bound the evaluation cost. Second, we have the degree of the rational function outputs in terms of all intermediates, which is necessarily finite. This second notion captures our ability to manipulate formulas with polynomial manipulation routines (e.g., from Sympy) to structurally simplify formulas. Our compiler for tensor expressions prioritizes
⁴sometimes the symmetric tensors in elasticity are considered to be symmetric tensors of anti-symmetric tensors, which we can also model with this ⁵The former definition is not the coordinate free definition of the tangent space, but it is defined independently of basis once the derivative at a point is supplied. In other words, the linear algebra is still coordinate independent. ⁶the inverse can be used on other mappings but might fall back on the first isomorphism and projection
16 • Collin et al.
| sh | constant nat tuple | |
|---|---|---|
| av | array variable | |
| f | External Function | |
| en | Einsum string | |
| rf | ::= c | Constant Real Number |
| av[sh] | Array Variable Access | |
| rf₀ + rf₁ | Sum | |
| rf₀ × rf₁ | Product | |
| rf₀ / rf₁ | Division | |
| ar | ::= Array((rf₀, ..., sh)) | Rational Function Array |
| stmt | ::= av₀ = Einsum(en, av₁, ...) | Einsum |
| av₀ = Inv(av₁) | Inverse | |
| (av₀, av₁) = QR(av₂) | QR | |
| (av₀, av₁, av₂) = SVD(av₃) | SVD | |
| (av₀, ..., av_N) = f(av_N+1 ...) | Black-Box Evaluation | |
| av₀ = ar | Array Definition | |
| return(ar) | Array Return | |
| formula | ::= (av₀, ..., av_N) ↔ (stmt₀, ..., stmt_N) | Formula |
Fig. 5. A grammar to describe formulas, code that computes arrays that represent a tensor expression in a given basis.
the first notion unless a formula becomes too big to manipulate in some context (e.g., symbolic inversion of a large dense symbolic matrix).
5.1.3 Bases Given a well formed⁷ tensor expression in fig. 4, the expression will have a clear mathematical meaning. However, we cannot assign the expression to a formula in fig. 5 unless we select bases. We introduce our basis language in fig. 6. A basis simply specifies a list of tensor expressions and the grammar mostly mirrors the structure of the tensor space grammar. For example, we note that every space has a corresponding standard basis, which is orthonormal in the inner product described in section 5.1.1. Here, we only discuss the last two basis constructions, which are crucial for our compiler and constitute a useful but confusing contrast.
For any of the four subspaces that depend on a linear function (e.g., the kernel), we can use a ProjectedBasis to project a basis to the subspace. Practically, these can be used in formulas via SVD or QR though such bases are not unique in all cases⁸. Furthermore, a critical alternative exists. Mainly, if a linear map is injective⁹, then the image and co-kernel have special basis constructions via ImageBasis. Suppose we have another basis (representing a basis for ). We have ImageBasis(, Image(F, Injective)) (representing the basis for given by ). Via use of Inverse and Restrict, we have a similar basis for CoKernel. The distinction between ProjectedBasis and ImageBasis can model the difference between an immersed inner product for a tangent space (i.e., a surface in Euclidean space uses the Euclidean inner product) vs. an inner product induced by the parameterization of a surface. The former choice is the correct one for mathematical modeling, but the latter is easier to compute with. Our compiler can simplify away
| b | ::= {1} | Scalar Basis |
|---|---|---|
| RawBasis(e₀, ..., ) | Basis of tensors | |
| DualBasis(b₀) | Dual Basis | |
| PrimalBasis(b₀) | Primal Basis | |
| b₀ ⊗ b₁ | Tensor Product | |
| b₀ ⊕ b₁ | Direct Sum | |
| ProjectedBasis(b₀, b₁, s) | Projection Basis | |
| ImageBasis(b₀, s) | Image Basis |
Fig. 6. A grammar to describe bases for tensor spaces.
transformations by recognizing when an ImageBasis does not need to be converted to a ProjectedBasis to represent a tensor (or vice-versa).
5.1.4 Formula Generation We now sketch our compiler, which produces a formula representing a given tensor in a given basis. And we study some examples that show how the separation between tensor and basis enables automatic derivation of simple formulas for FEM.
We implement our compiler via two mutually recursive functions, depicted in fig. 7a, and a helper function to access the standard orthonormal basis of a space. These functions carry around an environment to handle variables bound in functions and to handle externally defined representations of variables. Our compiler, representTensor, recursively de-structures a tensor and a basis to produce a formula via various builtIn rules. We provide a sample rule in fig. 7b. As we see in fig. 7b, when representTensor encounters a tensor that can't be represented in a basis due to a mismatch between the basis structure and tensor structure, then representTensor uses the standard basis and calls changeOfBasis to put the result in the desired basis. This ensures termination¹⁰ as the standard basis always allows for the rules in representTensor to work without a change of basis.
We implement both functions via lists of rules for various tensor and basis combinations. We discuss a few rules and an example to understand how coordinate independence buys us useful automation. In fig. 7, we see rules for inner product, evaluation, and tensor product. Change of basis rules are similar so we defer examples to appendix B. By contrasting the rules for inner product and evaluation, we can learn a core lesson: since our system has some freedom of basis choice in the evaluation rule, our system can use these to find simpler representations. In particular, the inner product rule must convert to a particular basis whereas the evaluation rule just needs a primal and dual relationship between them. In fig. 7e, the first two scenarios show the consequence of this: we see that in the first scenario a change of basis is required, leading to a symbolic output, while in the second it can be avoided, leading to a simple numerical output. Though mathematically we don't actually get to pick between these two scenarios as a final output, we might get to pick as some intermediate path. Of course, our choice of intermediate path must be offset later, but our third scenario shows how the path still practically impacts formulas, especially given rules such as the tensor product rule. The third scenario is mathematically equivalent to the second one, but we have erased the basis structure and placed it into the resulting formula. Unless one can reliably detect on symbolic formulas, we lose
⁷We don't go into this detail here, but obviously we need to exclude various expressions that are without meaning (e.g., non-match arguments, sharp of a non-dual space, etc).
⁸For injective maps, both are unique up to ordering. In general though, we do not care that these are not unique as we simply need a basis to be consistently chosen. Since we need to make a consistent choice, we do need a unique basis to realize the linear map in, which is why require two basis arguments for ProjectedBasis.
⁹Note that charts give us injective linear maps
¹⁰up to user defined bases with no conversion to the standard basis the much simpler numerical representation. The key point is that though our compiler can't change the mathematical answer with an intermediate basis, our compiler can make symbolic computation more reasonable by picking and tracking bases. Though we could feasibly detect with Sympy for small matrices, tensor products could produce rather larger matrices (e.g., 6 by 6, which generically has a huge determinant expression) where in contrast the freedom in the tensor product rule could allow us to use simpler representations. Since the tensor product is coordinate independent, we can sometimes use whatever basis is best for the sub-terms, avoiding symbolic coordinate operations until we need to and retaining the basis structure to try to ease these
The core point again is that our compiler can avoid a symbolic explosion through picking bases that result in simpler expressions and by tracking bases to avoid having to do hard and expensive symbolic math.
5.2 Pointwise Tensor Expressions on Manifolds (PTEM)
Pointwise expressions are of the form where F only has tensor operations, x is a point, u is some field, Du is the derivative, and is geometric information such as a tangent vector. (The expression is pointwise because it depends on not or .) Due to the geometric nature of these expressions, we call them pointwise tensor expressions on manifolds (PTEM). For the purposes of automating FEM, we seek a succinct representation of pointwise expressions that allows us to translate into a pure tensor expression so we can utilize our tensor compiler. Our tensor compiler can exploit the exact numerical representation of geometric information and fields poses an incredible burden on users.
To keep PTEM succinct for users while preserving automation with our tensor compiler, we embrace more automation. In particular, PTEM uses chart and field types (section 5.2.1) as placeholders for concrete charts and fields. Upstream automation (section 7.2, section 6.2.2, and appendix C.0.3) supplies matching charts and fields (paragraph 5.2.1.1) through the interfaces in listing 7. Users will not ever write the fields and geometries mentioned in this section; they will write corresponding types (paragraph 5.2.1.2) to write pointwise expressions (section 5.2.3) that our compiler will automatically match (paragraph 5.2.4.3) with actual charts and fields (paragraph 5.2.1.1) to produce tensor expressions (paragraph 5.2.4.2). We call our compiler's process of matching PTEM with charts and fields topological enumeration (paragraph 5.2.4.3) and we call the final production of a tensor expression from a match, single compilation (paragraph 5.2.4.2). To use the previous section as a metaphor, pointwise expressions with field/geometry types are tensor expressions, fields/geometries are bases, and the tensor expressions derived from their combinations are formulas.
Env = dict[Tuple[str, Basis], Formula] def representTensor(tensor: TensorExpr, basis: Optional[Basis], env: Optional[Env]) -> Tuple[Formula, Basis]: def changeOfBasis(basis: str, basis: dict[Basis, env: Optional[Env]]) -> Tuple[Formula, Formula]: def standardBasis(space: Space, env: Optional[Env]) -> Basis:
(a) Core Compiler Functions
def innerRule(t1: TensorExpr, t2: TensorExpr, basis: Optional[Basis], env: Env) -> Tuple[Formula, Basis]: (f1, _) = representTensor(t1, standardBasis(spaceOf(t1), env)) # Result in std basis. (f2, _) = representTensor(t1, standardBasis(spaceOf(t1), env)) if basis is None or isStandardBasis(basis): # make formula that dots formulas, symbolically. return (f1.dot(f2), standardBasis(R)) else: (fpre, prebasis) = innerRule(t1, t2, standardBasis(R), env) (fromStandard, _) = changeOfBasis(basis, prebasis) return (fromStandard @ fpre, basis)
(b) Inner Product Rule
def simpleEvalRule(t1: TensorExpr, t2: TensorExpr, basis: Optional[Basis], env: Env) -> Tuple[Formula, Basis]: if basis is None: (f1, b1) = representTensor(t1, None, env) # pick simple formula (f2, b2) = representTensor(t2, None, env) if isPrimalDual(b1, b2): return (f1.dot(f2), standardBasis(R)) else: # there are many options here # we show one (f1p, _) = representTensor(t1, DualBasis(b2), env) return (f1p.dot(f2), standardBasis(R)) else: match basis: case Dual(b1) * b2: (f1, _) = representTensor(t1, b1, env) (f2, _) = representTensor(t2, b2, env) return (f1.dot(f2), standardBasis(R)) case _: recurse = simpleEvalRule(t1, t2, None) (fromBasis, _) = changeOfBasis(basis, recurse[1]) return (fromStandard @ recurse[8], basis)
(c) Evaluation Rule
def tensorProdRule(t1: TensorExpr, t2: TensorExpr, basis: Optional[Basis], env: Env) -> Tuple[Formula, Basis]: if basis is None: (f1, b1) = representTensor(t1, None, env) # pick simple formula (f2, b2) = representTensor(t2, None, env) return (f1.oprod(f2), b1 * b2) else: match basis: case b1 * b2: # tensor product (f1, _) = representTensor(t1, b1, env) (f2, _) = representTensor(t2, b2, env) return (f1.oprod(f2), b1 * b2) case _: (f1, b1) = representTensor(t1, None, env) (f2, b2) = representTensor(t2, None, env) (fromProd, _) = changeOfBasis(basis, b1 * b2) return (fromProd @ (f1.oprod(f2)), basis)
(d) Tensor Product Rule
import sympy as sp env = EmptyEnv() env[(**p), DualBasis(standardBasis(R3)) * standardBasis(R3))] = sp.Matrix(**p) img = Image(Var(**p), R3, R3, Bijection)
Scenario 1:
env[(**a), standardBasis(Dual(img))] = np.array([1, 0]) env[(**b), imagebasis(standardBasis(R*3), img)) = np.array([1, 0]) ret = representTensor(Var(**a})(Var(**b)), None, env) assert ret[8] == F[0,0]
Scenario 2:
env[(**ap), DualBasis(imagebasis(standardBasis(R3), img))] = np.array([1, 0]) env[(**bp), imagebasis(standardBasis(R3), img)) = np.array([1, 0]) ret = representTensor(Var(**ap})(Var(**bp)), None, env) assert ret[8] == 1.0
Scenario 3:
env[(**ap), DualBasis(ProjectedBasis(standardBasis(R3), standardBasis(R3), img)) = f.inverse() @ np.array([1, 0]) ret = representTensor(Var(**ap})(Var(**bp)), None, env) assert ret[8] == f.inverse() @ F[0,0]
(e) Sketch of possible scenarios, showing how simpler symbolic intermediates could result from greater freedom of choice in bases.
Fig. 7. Example compilation rule with an example illustrating the different structures of the rules.
Through this design, we also solve another problem raised in section 3.4: fields are multi-valued so some computation is multi-valued, which must be carefully handled in FEM codes. However, our process of topological enumeration actually finds all combinations of inputs where the output is a single well defined value. Thus,
If the symbolically simpler basis is not an option, our change of basis operations use basis structures similarly. Our only innovation with change of basis rules (compared to representation rules) is we compute both directions at the same time to better exploit the basis structure (e.g., a change of basis between two tensor products of bases can be inverted by inverting the constituent change bases, evading a larger matrix inverse). See appendix B.
18 • Collin et al.
as will be shown in fig. 8, our automation to evade cumbersome specification of geometries and fields will actually solve higher level problems and simplify the specification of high level FEM computations.
In this section, we work from the ground up: we start with charts and fields, move to PTEM, and then discuss single compilation, and the finally topological enumeration.
5.2.1 Charts and Fields: Types and Values
We detail both charts and fields as the external interface (types) and the internal interface (values).
5.2.1.1 Values: Internal Interface Our compiler and system internally think of a chart as just an affine map with some metadata (definition 3.8), but the matrix and vector are replaced with tensor expressions, which are allowed to potentially depend on inputs such as vertices. Though charts can just use the general formula for an affine map induced by sets of vertices, we generally want our tensor compiler to use more specific information where possible. The internal interface for fields, depicted in listing 8, is similarly straightforward: given a position with a reference position and world position with respect to some chart, we can sample the field and its derivatives in some basis. We note that just like the vertices in the chart, the field can be sampled at a formula for a point. Both of these interfaces make patching general or specific fields/charts into the tensor compiler easy, but users should not have to construct such objects. Our PTEM compiler just needs these interfaces to (1) provide the necessary data to our tensor expression compiler and (2) to track charts and fields internally so we can automatically reason about how to combine them with pointwise expressions.
class Chart:
inputs: List[Tuple[str, Basis]] # e.g. vertex symbols
A: TensorExpr
b: TensorExpr
inputTopType: TopType
# omitting topology/geometry of domain/image
class Field(Protocol):
type: FieldType
chart: Chart # where is the field defined
def sample(refPoint: Tuple[Formula, Basis],
worldPoint: Tuple[Formula, Basis],
chart: Chart,
derivatives: int,
basis: Optional[Basis] = None) -> Tuple[Formula, basis]:
...
Listing 8. Field interface for pointwise expressions.
5.2.1.2 Types: External Interface Users utilize types in our pointwise expressions, depicted in fig. 10. For topological types, the entities that we consider (definition 3.5) leads to a simple grammar for our types. Using this grammar, users can pick out subsets of the set of affine maps that correspond to parameterization of entities of a given topological type:
Definition 5.1 (Aff, Conv). Let Aff be the set of all charts. The set Aff(t) for a topological type t from our grammar is the set of charts whose domain corresponds to the given topological type t. These are the charts given by $(S_0, S_1, F)$ (see definition 3.8) where
$S_0$ has topological type $t$. Given a chart $c = (S_0, S_1, F) \in \text{Aff}(t)$, we let $\text{Conv}(c)$ be the convex hull of the images under $F$ of the vertices of $S_0$; this is the domain that the chart parametrizes.
Our system includes two context-dependent placeholders in chart types: the largest charts available on a mesh and charts of the types found on the boundary of a mesh. These are eliminated internally.
For field types, users specify a domain (defaults to TopChart), a range (defaults to R), and a choice of Euclidean or tangential derivatives (defaults to Tangential). The range is a tensor space that depends only on the chart type, allowing for the use of spaces that depend on the given type (e.g., TangentSpace). Finally, a property indicates if a derivative is taken in the tangent space or a Euclidean space.¹² This models derivatives defined multiply vs. singly on shared mesh entities/internal boundaries (Recall listing 6 and section 3.4).
5.2.2 Ordering of types We partially order topological types via $\text{Simplex}(d) \leq \text{Simplex}(d')$ iff $d \leq d'$. With just simplifies, we technically have a total order, but we have an intuitive purpose for this order: one type is less than another iff an entity of the former type can always be embedded via a chart into a sub-entity of another. If we added more general entities, such as rectangles or hexes, our intuition renders these incomparable to a triangle. Hence, we call this a partial order.
5.2.3 Grammar for Pointwise Tensor Expressions on Manifolds (PTEM): We supply a grammar for pointwise tensor expressions on manifolds in fig. 9. The grammar is minimal, focusing on the core geometric interface and the separation between types and arguments. Our actual implementation for example contains a wide variety of primitives from exterior algebra, but these are easy extensions because our language is implemented via tracing[Frostig et al. 2018] in a Python EDSL. See appendix G for details.
The grammar has two components that go into the pointwise tensor expression: arguments and expressions. Arguments bind names to types and expressions extend tensor expressions with concepts that provide data from the arguments (e.g., we can get a field value from a field argument). Our system also supports default arguments (see appendix F). The expressions should be understood to modify the standard tensor expression grammar with special values, including tangent vectors, the current position $x$, derivatives of expressions with respect to $x$, and field access. Further, since we give access to the spaces of arguments via an extension to tensor spaces, we also give access to inner products of the tangent space (the metric). The pointwise tensor expressions themselves combine linear and non-linear arguments (the first and second groups), an optional output field type, and a tensor expression value that depends only on the arguments to the expression.
### 5.2.4 Semantics, Single Compilation, and Topological Enumeration of PTEM
5.2.4.1 Semantics of PTEM Semantically, PTEM define an expression parametrically over charts. To see this and its complexities, we step through PTEM as defining a function of the incoming charts
¹²Practically, this is the difference between a field defined on $N \subset \mathbb{R}^k$ taking values in a tensor space $V$ having a first derivative in $\mathcal{T}_x N^\star \otimes V$ vs $(\mathbb{R}^k)^\star \otimes V$.
(A) Graphical and tabular representations of a triangle's topology:

<table border=1><tr><td>Entity</td><td>Entity Type</td></tr><tr><td>$V_{0}$</td><td>Vertex</td></tr><tr><td>$V_{1}$</td><td>Vertex</td></tr><tr><td>$V_{2}$</td><td>Vertex</td></tr><tr><td>$E_{0}$</td><td>Edge</td></tr><tr><td>$E_{1}$</td><td>Edge</td></tr><tr><td>$E_{2}$</td><td>Edge</td></tr><tr><td>$T_{0}$</td><td>Triangle</td></tr></table>
(C) Graphical and tabular representations of an input field defined on a triangle:

(B) Graphical and tabular representations of input IPTEMs:

<table border=1><tr><td>IPTEM</td><td>Chart Type Of Output And Input Field</td></tr><tr><td>Evaluation At Vertex</td><td>Vertex</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>Edge</td></tr></table>
(D) Graphical and tabular representations of input fields defined on triangle edges:

(E) Set, Graphical, and Tabular Interpretations Of Topological Enumeration of IPTEM:
<table border=1><tr><td>IPTEM</td><td>Output Domain</td><td>Input Domain</td><td>Field</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{0}$</td><td>$T_{0}$</td><td>U</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{1}$</td><td>$T_{0}$</td><td>U</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{2}$</td><td>$T_{0}$</td><td>U</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{0}$</td><td>$T_{0}$</td><td>U</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{1}$</td><td>$T_{0}$</td><td>U</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{2}$</td><td>$T_{0}$</td><td>U</td></tr></table>

<table border=1><tr><td>IPTEM</td><td>Output Domain</td><td>Input Domain</td><td>Field</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{0}$</td><td>$E_{0}$</td><td>$w_{0}$</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{0}$</td><td>$E_{1}$</td><td>$w_{1}$</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{1}$</td><td>$E_{0}$</td><td>$w_{0}$</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{1}$</td><td>$E_{2}$</td><td>$w_{2}$</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{2}$</td><td>$E_{2}$</td><td>$w_{2}$</td></tr><tr><td>Evaluation At Vertex</td><td>$V_{2}$</td><td>$E_{1}$</td><td>$w_{1}$</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{0}$</td><td>$E_{0}$</td><td>$w_{0}$</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{1}$</td><td>$E_{1}$</td><td>$w_{1}$</td></tr><tr><td>Evaluation At Edge Midpoint</td><td>$E_{2}$</td><td>$E_{2}$</td><td>$w_{2}$</td></tr></table>
Fig. 8. On a triangle topology (A), we have two groups of field inputs, (C) and (D), and we have one group of IPTEMs (B). By changing the field inputs, we have two different topological enumeration calculations, depicted graphically with unions and joins in (E). The first reproduces quadratic Lagrange elements while the second produces a rule to transfer edge fields to a quadratic Lagrange element, up to a resolution of discontinuities at vertices. The inputs and outputs are represented tabularly too.
20 • Collin et al.
<table><tr><td>cv</td><td></td><td>Chart Variable</td></tr><tr><td>fv</td><td></td><td>Field Variable</td></tr><tr><td>n</td><td></td><td>Constant Natural</td></tr><tr><td rowspan="3">s</td><td>∪ =</td><td>TangentSpace(cv)</td><td>Tangent Space</td></tr><tr><td>|</td><td>EuclideanSpace(cv)</td><td>Euclidean Space</td></tr><tr><td>|</td><td>spaceOf(e)</td><td>An Expression's Space</td></tr><tr><td rowspan="7">e</td><td>∪ =</td><td>TangentVector(cv, n?)</td><td>Tangent Vector</td></tr><tr><td>|</td><td>CoTangentVector(cv, n?)</td><td>Co-Tangent Vector</td></tr><tr><td>|</td><td>NormalVector(cv, cv?, n?)</td><td>Normal Vector (in)</td></tr><tr><td>|</td><td>CoNormalVector(cv, cv?, n?)</td><td>Co-Normal Vector (in)</td></tr><tr><td>|</td><td>X()</td><td>Point x</td></tr><tr><td>|</td><td>FieldAccess(fv, n?)</td><td>Field at x</td></tr><tr><td>|</td><td>D(e)</td><td>Derivative w.r.t. x</td></tr><tr><td>arg</td><td>::=</td><td>cv : chartTy | fv : fieldTy</td></tr><tr><td>args</td><td>::=</td><td>(arg_0, ..., arg_N)</td></tr><tr><td>PTEM</td><td>::=</td><td>Pointwise(arg_s0, arg_s1, fieldTy?, e)</td><td>Pointwise Expression</td></tr></table>
Fig. 9. A grammar to describe pointwise tensor expressions on manifolds, operating on tensor fields.
<table><tr><td>tdim</td><td colspan="3">Topological Dimension</td></tr><tr><td rowspan="2">dervType</td><td>::=</td><td>Euclidean</td><td>$\mathbb{R}^n$</td></tr><tr><td>|</td><td>Tangential</td><td>$\mathcal{T}_x$</td></tr><tr><td>topType</td><td>::=</td><td>Simplex (tdim)</td><td>Simplex</td></tr><tr><td rowspan="4">chartTy</td><td>::=</td><td>TopChart</td><td>Largest Chart(s)</td></tr><tr><td>|</td><td>BoundaryChart</td><td>Boundary Charts</td></tr><tr><td>|</td><td>Chart(topType_0)</td><td>Fixed Top Type</td></tr><tr><td></td><td></td><td></td></tr><tr><td rowspan="2">s</td><td>∪ =</td><td>TangentSpace(chartTy)</td><td>Tangent Space</td></tr><tr><td>|</td><td>EuclideanSpace(chartTy)</td><td>Euclidean Space</td></tr><tr><td>fieldTy</td><td>::=</td><td>field(chartTy?, s?, derivType?)</td><td>Field Type</td></tr></table>
Fig. 10. A grammar to express types in pointwise expressions.
and fields, the values of paragraph 5.2.1.1, leading to (22). Let us consider a PTEM with $M$ chart arguments with topological types $ty_i$ and $N$ field arguments, each associated to another chart argument with topological type $fty_i$. There may also be an output field with type $fty_0$. We see immediately that we must provide at least $M$ charts of the associated types to the PTEM. We can't immediately supply fields because these depend on spaces that depend on more charts. Each chart argument of a field argument parametrizes the range of the field via a tensor space of the field arguments$^{13}$, roughly as $R_i: \text{Aff}(fty_i) \to \text{Vect}^{14}$ for $i = 1, \ldots, N$. We may also have a tensor space for the output parametric on some chart: $R_0: \text{Aff}(fty_0) \to \text{Vect}$. These define the field output spaces or the input spaces to the PTEM. Thus, we must first supply charts for all the input fields and then we can supply fields that map from the given charts to the derived vector spaces. Finally, we also need the point in $\mathbb{R}^d$.^{15} With all these ingredients we can provide the
signature for the ways that we can interpret an IPTEM:
$$
\begin{aligned}(c_1,\ldots,c_M): \times_{i=1}^M \text{Aff}(ty_i) &\mapsto (fc_0, fc_1,\ldots,fc_N): \times_{i=0}^N \text{Aff}(fty_i) \\ &\mapsto (f_1,\ldots,f_N): \times_{i=1}^N C^\infty(\text{Conv}(fc_i), R_i(fc_i)) \\ &\mapsto (x): \mathbb{R}^d \to R_0(fc_0). \end{aligned} \tag{22}
$$
Our system can compile PTEM to a program with the above signature. Though pragmatically, (22) suggests a large breadth of what a single PTEM expresses: many calculations over many combinations of geometries, fields, and points. Really, our compilation system compiles a PTEM to a collection of tensor expressions that represent (22) given different combinations of a given set of chart and field values (as in listing 7). In other words, the PTEM compiler will be given a PTEM and some charts/fields to produce tensor expressions that correspond to $(x): \mathbb{R}^d \mapsto R_0(fc_0)$ for every reasonable way to plug the charts and fields into eq. (22). Though, of course, by supplying very general chart and field (which listing 8 allows for), we can completely recover (22).
Our PTEM compiler will operate in stages based on (22). For the first two groups of arguments, the charts drawn from Aff, our compiler must resolve all the valid/useful combinations of arguments, which we do via topological enumeration (paragraph 5.2.4.3). For the next groups of arguments, our compiler has determined the geometric settings and our compiler now tries to produce nice tensor expressions, which we do via single compilation (paragraph 5.2.4.2).
5.2.4.2 Single Compilation (listing 7:line 18) refers to the second half of eq. (22): given a suitable pairing charts and fields to PTEM arguments, our system compiles a given PTEM to a tensor expression in the output space that depends on a position in space (parametrized with a reference and world space position) as well as any other variables used in chart, space, and field definitions. Single compilation is mostly mechanical, consisting mostly of substitutions, symbolic differentiation, change of coordinates, and other bookkeeping for the tensor compiler. First, given that the charts supply spaces, our compiler replaces place holder tensor spaces and expressions such as tangent space with a definition depending on the chart. In cases where a supplied chart is larger than the type associated to a field or when a supplied field used a Euclidean (Tangent) space where a type used a Tangent (Euclidean) space, our compiler may also modify expressions with pullbacks$^{16}$ (definition 3.3) to correct the mismatch. Second, similar to many expression based languages, our language can be symbolically differentiated, which our compiler performs to remove all derivatives except as directly applied to field inputs. Third, our compiler rewrites all field expressions in terms of a query to reference and world space coordinates and then fields are queried via the field interface to replace field accesses with tensor expressions. At this point, our pointwise tensor expression is just a tensor expression with dependencies on a point input and other variables that defined charts and fields. Fourth, our tensor compiler needs a basis for input spaces, output spaces, and intermediate ones; our compiler can build these with field/chart
$^{13}$plus some number of derivatives via $\oplus$
$^{14}$the collection of all vector spaces.
$^{15}$When charts are supplied, they must all have a common geometric dimension $d$ for this to make sense.
$^{16}$Technically, our definition of the pullback does not exactly achieve this purpose. Using our tensor expression language, we can recursively define a generalize pullback given base cases for certain primal and dual spaces. If our base cases use the project and embedding maps to/from (co)tangent spaces, we yield a generalize pullback suitable for correcting between tangent and Euclidean space inputs.
queries/metadata except for the basis of the output space. For a real valued DOF this is not a hard choice, but for more general spaces our compiler defaults to a standard basis that is orthonormal in the inner product of the space. This can be considered part of more general bookkeeping done throughout single compilation: as our compiler lowers geometry and fields down to tensor expressions, our compiler introduces values coming from charts and fields, meaning our compiler must track the introduction of new terms and their corresponding representations in formulas and bases for the tensor compiler.
5.2.4.3 Topological Enumeration Via eq. (22), we raise three potential problems with using the PTEM grammar. First, an expression might not make sense if the domains of some functions don't overlap (e.g., $u(x) * v(x)$ requires $u$ and $v$ to share some domain.) Second, as we have already noted, users should not have to explicitly pair fields and charts to PTEM, which is potentially a lot of complex information in eq. (22). Third, we note that the pairing of fields/geometries with PTEMs in different ways is often at the core of multi-valued functions: if multiple fields or charts are possible options for a PTEM in context (a vertex sampling edge fields for example), then there may be multiple distinct values for some computation. We address these three issues with topological enumeration (listing 7-line 13), which proves itself to be a useful bit of automation.
Topological enumeration finds all the "topologically valid" ways to match a PTEM's arguments to a concrete collection of charts and fields. By valid, we mean an approximation to the rule that pointwise calculations mean that all fields should share a common domain. We formally defined validity:
Definition 5.2 (Topological Validity of PTEM Arguments). Suppose we have a PTEM with $N$ field arguments and $M$ chart arguments. Thus we have $N$ topological types $fty_i$ for the fields and $M$ topological types $ty_i$ for the charts. We further suppose a topological type associated to the output $fty_0$. Suppose we assign to each $ty_i$ an entity of the corresponding type $S_i$. For each $fty_i$, we assign an entity $FS_i$ of type greater than or equal to $fty_i$ except for $i = 0$ where equality must hold. (These entities will come from the ranges of charts.) Then such an assignment is valid if
(1) There is an entity $FS_I$ such that $\cap_{i=1}^N FS_i \supseteq FS_I \supseteq FS_0$.
(2) If $ty_i \leq ty_{i'}$, $S_i \subseteq S_{i'}$.
(3) If any $ty_i = fty_0$, $S_i = FS_0$.
Recall that we defined a partial order on topological types in section 5.2.2.
The content of this definition is that the pointwise combination of fields and geometric information is uniquely defined on a unique output domain, $FS_0$. Our compiler implements topological enumeration by enumerating all combinations and keeping only those that satisfy definition 5.2. This definition resolves our first conceptual issue by default, but to see that this also resolves the latter two we consider some examples.
To make topological enumeration less abstract, we work through two examples in fig. 8 using both graphical and table based vocabularies. In particular, what is remarkable is that topological enumeration reproduces key patterns in FEM codes, revealing them to
be part of fundamental patterns of pointwise manipulations. Thus by computing definition 5.2 to implement topological enumeration, our compiler rediscovers these patterns automatically.
In one scenario of fig. 8, the combination of different entities of a triangle and different IPTEMs with a single triangle field reproduces quadratic Lagrange elements. Our definition of validity allows us to reproduce all elements in fig. 3 by just changing the IPTEM inputs to fig. 8. Thus, users do not need to explicitly manage a geometry and its consequences when writing down elements. And the automation is quite simple: our compiler simply pairs the chart types with charts of the same or greater types and then filters for when the criteria of topological validity are met.
In the other scenario of fig. 8, we see that the multi-valued character of moving from edge fields to a triangle field is highlighted by the results of topological enumeration. Our tabular representation of the output of topological enumeration for this example indicates this issue by grouping entries that have the same IPTEM and domain. This shows the utility of this bit of automation: the compiler can detect when multi-valued quantities emerge by looking for such groupings and then the user needs to supply a resolution. If a user uses quadratic Lagrange DOFs on an edge field, then the resulting calculation can't become the pattern in the first table of (E) in fig. 8, a proper set of quadratic Lagrange DOFs, unless the user specified how to combine the grouped rows. We describe how to supply a resolution in section 5.3.
## 5.3 IPTEM: Integration and Reductions
In fig. 11, we augment PTEM with integration and reductions (to handle multiple values induced by topological enumeration though we also gain more expressive capacity in this freedom). Both of these additions are succinct and affect a small almost post-processing change to the overall pipeline (listing 7).
5.3.1 Integration In fig. 11, we provide integration. Integrations are simply a chart type to integrate over. Point evaluation is also provided under integration as a barycentric coordinates on a specific topological type.
Integration modifies the PTEM compilation algorithm only as a post-processing step because our compiler implements all integrals via quadrature that can integrate $d$ degree polynomials exactly$^{17}$. All other pre-steps remain unchanged (e.g., topological enumeration's output type is the integral type and the optional new storage chart type for the IPTEM can participate as another topological type.)
Our compiler integrates via quadrature rules. For a given chart $c$ with a domain that we assume is numeric, a quadrature rule gives us points $x_i$ and weights $w_i$. With these, we can evaluate the integral of a formula $F$ via something like
$$
\sum w_i |\det Dc(x_i)| F(x_i, c(x_i), \ldots).
$$
In some cases (section 6.1), our compiler symbolically computes this sum by substituting quadrature points into formulas, summing them together, and simplifying with Sympy (in particular if we are computing Vandermonde matrices or if all the formula's return values happen to be numeric), but for other purposes (section 7) our compiler places this sum into generated code. Consumers of
$^{17}$For product simplices, it is a product of degrees
22 • Collin et al.
our compiler must specify this choice (listing 7). However, all of this requires someone to choose a quadrature degree $d$, which is potentially error prone and not ergonomic. Ideally, users only think about the quadrature degree if there is not an obvious choice.
5.3.1.1 Quadrature Degree Estimation: Given a formula acting on inputs that all have some polynomial dependence on the point $x$, our compiler can estimate the polynomial dependence of the output of the formula on the point. To do so is fairly trivial for any formulas that are polynomial$^{18}$. For non-polynomial functions, our compiler relies on one important simplification or just fails: for 0 degree dependence, non-linear functions still have 0 degree dependence. This simplification means that formulas for all operators and DOFs can determine quadrature degrees automatically on affine geometries. When quadrature estimation fails, users at a higher level on the interface must specify the polynomial dependence of some inputs or simply specify the quadrature degree. We note that this analysis can be interpreted via a simple lattice [Cousot and Cousot 1977]: $\mathbb{N} \cup \{\infty\}$.
5.3.2 Reductions In fig. 11, we also provide reductions, which our compiler applies to the topological enumeration of IPTEMs. In particular, reductions should be considered as reductions on the tabular representations of the topological enumeration of IPTEMs (see fig. 8). Later, they will also apply to the global FEM problem (see section 7.3)
Reductions are specified via two mechanisms. First, we need a reduction operation, such as arbitrary choice, average, or sum. Second, we need to pick columns to reduce over, which we can do so by selecting arguments to a pointwise expression and then sub-selecting charts/fields and local/global. For local, these sub-selections occur on the output of topological enumeration. By sub-selecting to reduce over charts (fields), we reduce together rows (interpretations) that are the same up to the chart (field) used in a given augment. These sub-selections allow for surprisingly flexibility, such as a DOF defined on the entire boundary of a cell via reducing over boundary integration charts. Our compiler implements these at the local level through simple group-by operations on the output of topological enumeration (listing 7:line 24).
The integration mechanism chooses the default reduction. If a point evaluation is used, we reduce over fields via a choiceAllEq, which will warn us if a point evaluation is ill-defined due to multiple and non-equal choices at runtime. Thus, topological enumeration and reduction provide a flexible solution to the problem of partially defined finite element interpolations (see definition 3.16). If an integration is used, we use sum reductions over fields. These create the desired results for most DOFs (typically point evaluations) and operators (typically integrals). In this work, we only need to overriding system defaults when we specify integral FEEC DOFs (see section 8.1.2)
## 5.4 Miscellaneous Aspects
For clarity of discussion, we have left out three important aspects of our system. However, since these are actually quite critical for the implementation, we have included them in appendices. These
<table><tr><td colspan="2">bc</td><td>Barycentric Coord.</td></tr><tr><td>integ</td><td>=</td><td>PointEval(topType, bc)<br>Integral(chartTy)</td><td>Point Evaluation<br>Integral</td></tr><tr><td>op</td><td>=</td><td>Min | Max | Sum<br>Difference | Avg<br>choice | choiceAllEq</td></tr><tr><td>over</td><td>=</td><td>LocalChart | LocalField<br>GlobalChart | GlobalField<br>Chart | Basis | ALL</td></tr><tr><td>reduction</td><td>::=</td><td>Argument(n, op, over)</td></tr><tr><td>reductions</td><td>::=</td><td>(reduction<sub>0</sub>, ...)</td></tr><tr><td>Store</td><td>::=</td><td>Default | chartTy</td></tr><tr><td>IPTEM</td><td>::=</td><td>IPTX(PTEM, integ, reductions, Store)</td></tr></table>
Fig. 11. A grammar to describe integrated pointwise tensor expressions with reductions.
are permutations of mesh entities (appendix E), default arguments to IPTEM (appendix F), and additional syntax/library content for IPTEMs (appendix G). Though these issues first emerge in this section, these aspects actually impact content in section 6 up to section 8. We organize them in terms of how they impact other sections and suggest consulting them if further understanding is required.
## 6 Software Representation of Finite Elements
We can now provide a software specification of finite elements via the machinery of the previous section. Further, we solve the problem posed by definition 3.11, the core obstacle to automatically using finite elements. We provide our specification in section 6.1 and solve definition 3.11 in section 6.2. Finally, in section 6.3, we detail our specification of the function spaces in finite elements, as these do not emerge as easily as other components from our pre-existing machinery.
### 6.1 Overall Specification
Our software definition (listing 9) of an FE naturally mirrors definition 3.9, but our definition is carefully constructed to balance expressing many elements against the automatic generation of formulas, specifically via the problem specified in definition 3.11.
class FiniteElement:
V: TopType # Domain
P: PSpace # Polynomial Space
Sigma: Sequence[IPTEM] # Dofs
Listing 9. Interface for constructing finite elements. The topological type represents the possible domain sets (e.g., triangles). The polynomial space represents polynomial spaces parameterized by the domain. The list of IPTEM represents the degrees of freedom, also parameterized by the domain. Note that the value space is in the polynomial space.
Our construct contains two familiar objects that represent classes of objects parametrized by a domain: a topological type for the domain and a list of IPTEMs for the dual basis functions. While our infrastructure for IPTEM handles many of the problems of representing many dual basis functions and generating formulas for them on
$^{18}$This does require some plumbing, which leads to polynomial degrees being attached to field inputs so this information can be attached to inputs to formulas.
symbolic domains $^{19}$, we must resolve similar problems for spaces of functions. In particular, two function spaces defined similarly on two domains are unlikely to be isomorphic via pullback, which makes computing the Vandermonde matrix impossible or symbolically messy. To understand our representation of classes of polynomial function spaces for FEs (PSpace), we first detail a software interface and algorithms for using the finite element, solving definition 3.11. Then we can discuss the requirements on PSpace in section 6.3. To just solve definition 3.11, we leave the polynomial space to an interface for now.
6.1.1 PSpace Interface In listing 10, we provide our interface to polynomial spaces parametrized by domains. At the core, the interface is simple and similar to that for fields (listing 8): on a given domain, a given set of points, and a given basis, our compiler can sample some unknown basis of functions and its derivatives. The main purpose of this interface is to provide fields as arguments to our compiler (listing 7: line 7), which is why we also include a maximum polynomial degree.
1 class PSpace:
2 def tabulateChart(self, chart: Chart, derivatives: int, refPoints: NDArray, basis: Optional[Basis] = None) -> Tuple[Formula, Basis]: ...
3 def valueSpace(self, chart: Chart) -> Space: ...
4 def dim(self) -> int: ...
5 def maxDegree(self) -> int: ...
6 def asFields(self, chart: Chart) -> List[Fields]: ...
7 def validChartTypes(self) -> List[ChartType]: ...
Listing 10. Interface that local spaces, PSpaces, must provide.
### 6.2 Inverse Vandermonde Formula Generation
We now solve definition 3.11 up to the details of the space representation. We depict the overall algorithm in listing 11. The algorithm consumes an FE, a reference chart, and a symbolic world space domain given by a chart. The algorithm conducts some validity checks (section 6.2.1), checking that the symbolic chart maps from the range of the reference chart and that the FE type checks. Then the algorithm constructs a Vandermonde matrix (section 6.2.2) and uses this to construct basis functions that can be used on the symbolic chart, exploiting that $v_{ref}$ is numerical. Then using the Vandermonde algorithm again, the algorithm can construct a symbolic Vandermonde matrix from the symbolic chart and the reference function basis functions pulled back to the symbolic world space. Then, a symbolic inversion routine (section 6.2.3) exploits the expected structure of this matrix to produce a formula representing the inverse. The symbolic output matrix provides the symbolic Vandermonde matrix problem (definition 3.11), expressing the FE basis functions on the symbolic domain in terms of the reference domain. We prove the correctness of this approach up to an assumption on the space (section 6.2.4). Paragraph 6.2.4.2 summarizes the matrix structure; appendix A gives the dual-basis-cover factorization that separates reference sampling, coordinate changes, and physical DOF weights. This suggests an alternative algorithm that factorizes the Vandermonde matrix using DOF blocks corresponding to mesh entities, ordered according to the dependencies between those blocks. The
factorization explains a guaranteed part of the matrix's sparsity, while symbolic construction and simplification can reveal further zeros.
1 def vandermondeInverse(dofs: FiniteElement, refChart: Chart, symbolicChart: Chart) -> Formula:
2 checkValid(refChart, symbolicChart, dofs)
3 refVander = vandermondeAlgo(dofs.Sigma, refChart, dofs.space.asFields(refChart))
4 VRef = refVander.asNumericArray()
5 assert VRef.dtype == np.float64
6 vanderInv = np.linalg.inv(VRef)
7 assert vanderInv.shape == (dofs.P.dim(), dofs.P.dim())
8 refFieldsOnSymbolic = vanderInv.T.dot(dofs.space.asFields(symbolicChart))
9 symbolicVander = vandermondeAlgo(dofs.Sigma, symbolicChart, refFieldsOnSymbolic)
10 symbolicVanderInv = symbolicInverse(symbolicVander)
11 return symbolicVanderInv
Listing 11. Overall algorithm for Vandermonde inverse calculation.
6.2.1 Validity For a finite element, $E = \text{FiniteElement}(V, P, \text{Sigma})$ to be valid, the DOFs must consume elements of $E.P$. valueSpace() and must not use any chart types larger than the chart type $E.V$. Similarly, the chart type $E.V$ must be in $E.P$. validChartTypes(). And naturally the DOFs must all be linear in a single non-default argument. The function checkValid checks all of this and further checks that the two chart inputs are compatible: they must both map between domains of type $E.V$ and the range of the reference space chart should be the domain of the symbolic chart.
6.2.2 Vandermonde Algorithm The Vandermonde Algorithm is the compilation procedure for a list of IPTEM. The function vandermondeAlgo (dofs, chart, fields) runs our IPTEM compiler (listing 7) with the following arguments: the IPTEMs are the DOFs, the charts are chart plus charts for every sub-entity of the chart's world space, the fields are the fields of the polynomial space, and all quadrature sums are symbolically simplified. We note that our construction of DOFs on a given polynomial space emerges naturally out of our compilation procedure (see fig. 8). The result will be a matrix that is the number of topologically enumerated DOFs $^{20}$ by the dimension of the polynomial space.
6.2.3 Symbolic Inversion Our second Vandermonde matrix is symbolic, meaning the formula returns an array of rational functions, potentially depending on other statements. However, we expect that that this matrix will be roughly block triangular. We will recursively exploit the Schur complement to invert such a matrix:
$$
\begin{pmatrix}A&0\\ C&D\end{pmatrix}^{-1}=\begin{pmatrix}A^{-1}&0\\ -D^{-1}CA^{-1}&D^{-1}\end{pmatrix}. \tag{23}
$$
A sketch of the algorithm is depicted in listing 12. The algorithm directly inverts small matrices. The algorithm tries to find a choice for A and C that maximizes the size of the zero block. Then the algorithm recurses on the blocks and recombines them with a triple matrix multiply. We isolate this as a separate function as we want to control symbolic complexity here. Our compiler introduces intermediates for non-zeros in the triple matrix multiplication if a rational function entry has a denominator with degree larger than one. Additionally, when performing the triple matrix multiply or
$^{19}$In particular, we can supply charts with symbolic variables in their definitions when we compile IPTEMs
$^{20}$Note that the actual DOFs are defined via topological enumeration.
Collin et al.
def symbolicInverse(V: Formula) -> Formula:
(mat, stmts) = V
N = mat.shape[0]
if N <= 6: # largest reasonable symbolic inverse
(matInv, stmtsp) = directSymbolicInverse(mat, stmts)
# Depending on the complexity of rational functions, we might introduce intermediate variables
return Formula(matInv, stmtsp)
else:
(blockP, blockQ) = choosePQ(mat)
A = mat[0:blockP, :][:, 0:blockQ]
B = mat[0:blockP, :][:, blockQ:]
D = mat[blockP:, :][:, blockQ:]
C = mat[blockP:, :][:, 0:blockQ]
assert allSymbolicZero(B)
(Ainv, AinvStmts) = symbolicInverse(Formula(A))
(Dinv, DinvStmts) = symbolicInverse(Formula(D))
(schur, schurStmts) = tripleMatMul(Dinv, C, Ainv)
matInv = bmat[[Ainv, np.zeros(blockP, blockQ)], [-schur, Dinv]]
return Formula(matInv, stmts + AinvStmts + DinvStmts + schurStmts)
Listing 12. Symbolic Inverse Algorithm
the base case inversion, we use Sympy to attempt to cancel fractions and detect structurally zero values as much as possible. The actual implementation features two other tricks: (1) we check for diagonal matrices and (2) we have an environment variable to determine when to time out and use a direct inverse (we do not need this for any of our results). We include this latter trick for the case where an element does not yield a reasonable symbolic Vandermonde matrix so we can fall back to a horribly inefficient option - numerically inverting the Vandermonde C matrix for each cell, with a warning to tell the users that this is going to happen. Inverting such Vandermonde-like matrices per cell is an established practice for some methods where this is the case - such as in polygonal FEMs or virtual element methods, though it comes with performance and numerical problems that typically lie outside the realm of standard FEM [Perumal 2018; Sutton 2016].
6.2.4 Correctness We now establish what the inverse Vandermonde algorithm in listing 11 computes and the conditions on the function spaces under which it is correct. We need some intermediate results relating pullbacks (definition 3.3) and primal dual basis pairs (definition 3.1).
Proposition 6.1. Let $E := (K, V, P, \Sigma)$ and $E' = (K', V', P', \Sigma')$ be finite elements where $V$ and $V'$ are subspaces of $\mathcal{T}(K)^{(p,q)}$ and $\mathcal{T}(K')^{(p,q)}$ respectively. Let $T \in C^1(K, K')$ have an inverse in $C^1(K', K)$. The pullback and pushforward maps satisfy the inverse identities:
(1) $T_{\star} \circ T_{-\star} = Id$ on dual functionals over $K'$,
(2) $T^{\star} \circ T^{-\star} = Id$ on fields over K.
Further, if $(T^{-\star})|_{P}$ is an isomorphism onto $P'$, then
(1) $T_{\star}|_{P^{\star}}$ is an isomorphism onto $(P')^{\star}$.
(2) For any $\phi \in P^{\star}$ and any $f \in P$,
$$
T_{\star}(\phi)((T^{-\star})(f))=\phi(f). \tag{24}
$$
This says the pushforward is analogous to an inverse transpose of a pullback.
(3) Given any primal-dual basis pair $(\{f_a\}, \{\phi_b\})$ for $P$ (i.e., $\phi_b(f_a) = \delta_{ab}$), we have that $(\{T^{-\star}f_a\}, \{T_{\star}\phi_b\})$ is a primal-dual basis pair for $P'$.
(4) Similarly, for any primal-dual basis pair $(\{f'_a\}, \{\phi'_b\})$ for $P'$ (i.e., $\phi'_b(f'_a) = \delta_{ab}$), we have that $(\{T^\star f'_a\}, \{T_{-\star} \phi'_b\})$ is a primal-dual basis pair for $P$.
PROOF. The field pullbacks along T and $T^{-1}$ are inverse. By definition of pushforward,
$$
(T_{\star}\phi)(T^{-\star}f)=\phi(T^{\star}T^{-\star}f)=\phi(f).
$$
The same calculation with T and $T^{-1}$ exchanged gives the inverse identity on dual functionals. Under the stated isomorphism of polynomial spaces, these maps restrict to inverse maps on their dual spaces. Applying the displayed pairing identity to each primal-dual basis pair preserves the primal-dual basis relations, proving the remaining assertions.
Our core result, theorem 6.1.1, is our ability to solve definition 3.11. This result closely mirrors our algorithm and provides the main condition on the spaces. As we prove it, we will indicate how steps of the proof refer back to listing 11.
Theorem 6.1.1. Assume the conditions of proposition 6.1. Let $\Sigma = \{\phi_b\}$ and $\Sigma' = \{\phi'_b\}$. Let $\{f_b\}$ and $\{f'_b\}$ be the associated primal bases. Further, suppose
(1) $T_{|P}^{-\star}$ is an isomorphism onto $P'$.
(2) There exist points $x_{b,q} \in K$ and tensor valued rational functions $w_{b,q}$ such that for any $f' \in P'$,
$$
\phi_{b}^{\prime}(f^{\prime})=\sum_{q}w_{b,q}(x_{b,q},T(x_{b,q}),D T(x_{b,q}))((T^{\star}f^{\prime})(x_{b,q}),(T^{\star}D f^{\prime})(x_{b,q}),\ldots).
$$
This usually boils down to the existence of a quadrature rule for integrating polynomial functions on K. Further, we wish to stress that this condition just aims to model rational dependency on geometry in the sort of DOFs that we see and could be varied quite a bit.
Then there exists a matrix P of shape $|\Sigma'| \times |\Sigma|$ (physical basis rows, reference basis columns) such that
(1) $P_{b'b}$ is a rational function in the values $\{DT(x_{a,q}), x_{a,q}, T(x_{a,q})\}$ over all DOF indices a and quadrature indices q,
(2) P transforms the mapped reference basis into the physical nodal basis, or equivalently
$$
(T^{\star})(f_{b^{\prime}})=\sum_{b}\mathsf{P}_{b^{\prime}b}f_{b}. \tag{25}
$$
Recall that this is eq. (19) in definition 3.11.
PROOF. By the assumed isomorphism, a computable basis for $P'$ is the image of the reference primal basis under $T^{-\star}$. We call this basis $f_b^T := (T^{-\star})(f_b)$. (We construct $f_b$ via Line 3 and $f_b^T$ via Line 8). Because of proposition 6.1, we also have a corresponding dual basis $\phi_b^T := T_{\star}(\phi_b)$. Evaluate physical DOFs on this mapped reference basis to form a generalized Vandermonde matrix, with physical DOFs indexing rows and reference basis functions indexing columns:
$$
\mathsf{C}_{b^{\prime}b}:=\left(T_{-\star}\phi_{b^{\prime}}^{\prime}\right)(f_{b})=\phi_{b^{\prime}}^{\prime}(f_{b}^{T}). \tag{26}
$$
Equivalently, $\phi'_b' = \sum_b C_{b'b} \phi'_b^T$ on $P'$.
Listing 11, line 9, computes this matrix.
Writing $f'_i = \sum_j P_{ij} f_j^T$ and applying $\phi'_k$ gives
$$
\delta_{k i}=\sum_{j}\mathrm{C}_{k j}\mathrm{P}_{i j}=(\mathrm{C P}^{T})_{k i}.
$$
Both sets are bases of the same space, so C is square and invertible. Therefore
$$
\mathrm{P}=\mathrm{C}^{-T}. \tag{27}
$$
Thus, the inverse transpose combines mapped reference basis functions into physical basis functions. (Listing 11: line 10 returns $C^{-1}$; its columns contain the coefficients of individual physical basis functions. Transposing it gives the row convention used for $P$.) Applying $T^*$ to the basis identity and using $T^*\boldsymbol{f}_b^T = \boldsymbol{f}_b$ proves eq. (25). In coefficient-vector convention, $T^*$ is represented by $P^T = C^{-1}$ and $T^{-*}$ by $C$.
By the definition of pullback, we observe that for $y = T(x)$, $f_{b'}^{T}(y)$ is a polynomial in the coefficients $DT(x)$, $y$, and $DT^{-1}(y)$. By the conditions of the theorem, $\phi_{b}'$ will evaluate $f_{b'}^{T}$ at points $\{T(x_{bq})\}$ and will weight each value by a rational function in $(x_{b,q})$, $T(x_{b,q})$, and $DT(x_{b,q})$. Thus, each entry of C is a rational function $\{x_{b,q}, DT(x_{b,q}), T(x_{b,q})\}$. Since the inverse of a matrix of rational functions is a matrix of rational functions, this completes the proof.
The core extra step is that $T^{-*}|_{P}$ is an isomorphism onto $P'$. We can weaken this if we are willing to weaken the results to just eq. (25): we just need an isomorphism from $T^{-*}(P)$ to $P'$, but the relationship of this isomorphism to T might cost us rational function like-formulas and our precise relationship to the pullback. Ideally, $T^{-*}(P) = P'$, but if not we only need some correction as a function of T that might make our formulas more complex and our code more expensive and ugly. Thus, our representation of function spaces must provide a way to work with these two possibilities. We discuss this in section 6.3 after two additional matters.
6.2.4.1 Relation to prior work We note that a key difference between our methods here and those employed by hand in [Kirby 2018] is that our methods operate on $P(K', V')^*$ rather than $C^k(K', V')^*$; in [Kirby 2018], certain definitions $^{21}$ to facilitate manipulations of DOFs by hand arise out of concerns about DOFs' behaviors as objects in $C^k(K', V')^*$ whereas we avoid this at the cost of having to use $f_b$ explicitly to manipulate objects in $P(K', V')^*$. In particular, we note that the Morley DOFs on a physical element cannot be expressed as linear combinations of push-forwarded DOFs if we consider them as objects in $C^k(K', V')^*$, but this is the case for the Morley DOFs as objects in $P(K', V')^*$. The approach in [Kirby 2018] is easier for hand calculation, but harder for automation.
6.2.4.2 Structure of Vandermonde Matrices Appendix A proves C = HFG (theorem A.1.1) and explains the contribution of each factor: H combines physical derivative samples into DOFs, F applies local coordinate changes, and G tabulates reference basis derivatives. For corresponding affine covers, F is block diagonal by point and derivative order, while G can be precomputed on the fixed reference
<table border=1><tr><td colspan="2">d</td><td>Polynomial degree</td></tr><tr><td>IPTEMS</td><td>:= (IPTEM $_{0}$, ...)</td><td>IPTEM List</td></tr><tr><td rowspan="2">deg</td><td>:= Deg(d)</td><td>Pure degree</td></tr><tr><td>:= Range(deg $_{0}$, deg $_{1}$)</td><td>Range of degrees</td></tr><tr><td rowspan="6">P</td><td>:= Pure(topType, deg, s)</td><td>Tensor Space Polynomials</td></tr><tr><td>Sum(P $_{0}$, ...)</td><td>Direct Sum</td></tr><tr><td>Kernel(P $_{0}$, IPTEMS)</td><td>Kernel</td></tr><tr><td>IKernel(IPTEMS, P $_{0}$)</td><td>Invariant Kernel</td></tr><tr><td>BKernel(IPTEMS $_{0}$, IPTEMS $_{1}$, P $_{0}$)</td><td>Kernel in a given basis</td></tr></table>
Fig. 12. A grammar to describe collections of polynomial spaces, indexed by charts.
element. The factors expose which reference DOFs can contribute to each physical DOF. Their dependency pattern gives a useful lower bound on the sparsity of C by certifying zeros and explaining their origin. Running the construction with symbolic simplification can reveal a more precise pattern, including cancellations between H and F. This pattern can suggest an ordering for the recursive inversion routine. The alternative algorithm in appendix A constructs C from these factors and then solves for $P^{T}$. It separates reusable reference data from symbolic geometry calculations. Its limitation is that constructing F independently of H does not exploit how the DOFs' contractions can simplify the pullbacks. Our implemented construction compiles the complete DOF expressions using the coordinate-independent tensor and basis machinery in sections 5.1.3 and 5.1.4, also developed in our Grassmann work [Collin et al. 2026]. This machinery can avoid unnecessary basis conversions and simplify pullbacks in the context of the contractions that use them; in the factorization, these simplifications exploit the relationship between H and F.
### 6.3 Specification of Polynomial Spaces
Our system must allow users to specify polynomial spaces such that the following two requirements are easy to satisfy automatically:
(1) provide a tabulate function as in the interface depicted in listing 10, ideally providing simple output formula,
(2) ensure that two polynomial spaces P and $P'$ instantiated at two different isomorphic domains K and $K'$ are isomorphic under pullback or that there is some known mapping from $T^{-*}(P)$ to $P'$ dependent on T, allowing theorem 6.1.1.
However, as system designers, we have a third requirement: our polynomial grammar must be expressive enough to capture a wide variety of polynomial spaces. We had to balance the first and third against the second.
We provide a grammar for polynomial spaces in fig. 12. Polynomial degrees come in two $^{22}$ kinds: up to and including a given degree and a range of degrees. Degrees, along with spaces that depend on a given topType (like in fieldTy), parametrize tensor valued polynomial spaces, denoted with Pure. Naturally, we can define the direct sum of polynomial spaces, but we gain a great deal more expressiveness by allowing users to specify polynomial
$^{21}$Mainly compatible nodal completion, which is a stronger and harder to construct facility than our dual basis cover (definition A.1 in appendix A).
$^{22}$If we added hexes or quads, we would add a third type: products of degrees.
26 • Collin et al.
spaces as kernels of DOFs. We provide three options to vary the pain of computing an isomorphism from $T^{-*}(P)$ to $P'$ in the case of kernels.
(1) a kernel of a collection of DOFs, requiring the kernel to be computed via an SVD or QR in the code,
(2) a kernel of a collection of DOFs that we promise is invariant, as a hack,
(3) an effective intermediate (due to the second use of compatible nodal completions in [Kirby 2018]) wherein a second super space $P_0$ is supplied along with a corresponding dual basis $\mathrm{IPTEM}_1 \supset \mathrm{IPTEM}_0$; the idea is that our compiler can transform the space with the element defined with $P_0$ and $\mathrm{IPTEM}_0$ and then extract the space $\cap_{\phi \in (\mathrm{IPTEM}_1 - \mathrm{IPTEM}_0)} \ker \phi$.
Lastly, we note that the range degree construct is actually not affine invariant and is transformed via the middle case, as we mainly intend this as a useful hack. Our compiler can implement tabulate by recursion on the grammar and we can inductively argue that our second property is satisfied through this interface. For both issues, we handle the base case, Pure polynomial spaces of a given degree, via orthogonal polynomials, as in [Kirby 2004].
## 7 Global FEM Data and Computation
Our global interface provides a wide variety of FEM computations parametrically over elements. However, as we saw in section 2, not all combinations of PDEs/elements result in reasonable solutions so we can't preserve a user's intention to solve a given PDE if they change an element. At a more basic level, a truly parametric interface must deal with intentions, such as interpolation (definition 3.16), where changing the element may lead to undefined quantities. Moreover, many much more basic computations make no sense when users change elements: a manipulation of an interpolation matrix produced by a quadratic Lagrange element might make no sense for a linear Lagrange element. To achieve an expressive parametric interface, we seek to ensure a more fundamental property: if a users write a computation using just components of the system, then the computation is always discretely meaningful even if they might not be meaningful in a continuous sense. We believe this insurance will at least promote truly parametric FEM code. In contrast, the state of the art simply either completely fails on or silently allows potentially undefined quantities. $^{23}$
To achieve an expressive global parametric interface, we limit our interface to a small collection of consistently meaningful discrete objects and operations with a highly structured automated connection to elements. In particular, we replace the standard easy to abuse outputs of FEM computations, sparse and dense tensors, with our novel structured output, a single valued assembled object (SVAO). SVAOs summarize many types of computation (e.g., boundary integrals, interior integrals, integrals, interpolation, boundary identification), shrinking the number of frontend objects. In particular, users create SVAOs by interpreting a collection of IPTEM on a mesh given inputs such as FEM bases: assembly (mesh: Mesh, iptems: List[IPTEM], linearArgs: List[MeshField | MeshFields], nonLinearArgs: dict[str, MeshField | MeshFields]) -> SVAO: Users only use elements to either construct
SVAOs through assembly or to extract components from SVAOs, limiting the interface between elements and global code to code that our system automatically generates for each element on demand. Thus, we build an interface that is parametric in the sense that users don't have to write new code if an element is changed for the old code to run and be meaningful in a discrete sense, though it might not achieve the desired PDE solution. Further, our interface will use few operations and objects, and, our interface will resolve problems around multi-valued computation, such as in definition 3.16.
In the following, we will develop the machinery to define SVAOs and assembly (section 7.1). To define assembly in section 7.1.4, we will heavily leverage our semantics for IPTEMs (section 5.2.4), especially topological enumeration (paragraph 5.2.4.3) as assembly can be considered as a sort of mesh wide topological enumeration. We limit an implementation discussion to ensuring a parametric interface (section 7.2), leaving many details to an appendix (appendix C). Finally, in section 7.3, we will discuss other well defined discrete operations that we combine with SVAO and assembly to express FEM computations in a parametric consistently discretely meaningful manner, leading to an overall workflow fully described in appendix D.2.
### 7.1 SVAOs and other global objects
To define SVAOs and their assembly, we need to build the other objects in our system first. Precise definitions of these objects (meshes/sections in section 7.1.1 global field(s) in section 7.1.2, and IPTEMs in section 7.1.3) help us ensure that SVAOs are always discretely meaningful. We describe everything with succinct mathematical expressions that are not too far from the implementations.
7.1.1 Mesh and Data On Meshes Mathematically, our global meshes are posets with a regularity condition that makes them meshes of entities.
Definition 7.1 (Mesh). Let $V \subset P(\mathbb{R}^n)$ be the vertices of a mesh topology. Let $F \subset P(V)$ be a poset under $\subseteq$, called the set of faces. Here, face includes entities of every dimension, such as vertices, edges, triangles, and tetrahedra; it is not restricted to two-dimensional entities. Then $(V, F)$ is a mesh if
(1) For every $v \in V$, $\{v\} \in F$,
(2) and if for every $f \in F$, $F_f := \{f' \in F: f' \subseteq f\}$, a subposet of $P(V)$, is isomorphic as a poset to a standard entity (definition 3.5),
(3) The sets $^{24}$ $\{\mathrm{Conv}(f): f \in F, \nexists f' f \subset f'\}$ have disjoint interiors.
A triangle mesh is a running example: the definition makes its vertices and edges explicit alongside its triangles. The same definition applies to simple meshes in other dimensions. We leave discussion of permutations/orientations of mesh entities to appendix E.
Data on meshes must be laid out or associated with mesh entities. Sections, like meshes, have a regularity condition, which we model by requiring a schema for storing data on meshes. Users do not need
$^{23}$e.g., Firedrake as of writing does not allow interpolation into spaces such as Hermite or Argyris even when it might be well defined.
$^{24}$we use convex hull to refer to the geometric entities; some additional machinery could remove this, but it is simple enough here.
to write these as they can be inferred from IPTEM (see section 7.1.3). Note, in this definition, we rely on topological types and their order as in section 5.2.2:
Definition 7.2 ($\mathcal{T}$, Schema for data on a mesh). Let $L$ be an abstract set of labels (e.g. IPTEMs). Let $\mathcal{T}$ be the collection of all topology types (fig. 10). A function $f: L \to \mathcal{T}^2$ is a schema for a mesh if for all $l \in L$ then $(t_1, t_2) = f(l)$ satisfies $t_1 \leq t_2$.
We can interpret schema as placing data on the edges of the mesh $\subset$ relationship. We consider two examples of schema. For linear Lagrange, our schema might map the single point evaluation to vertices: $L_0 = \{\text{vertexeval}\}$, $f_0(\text{vertexeval}) = (\text{Simplex}(0), \text{Simplex}(0))$. The two entries describe the entity carrying the datum and the containing entity in whose context it is defined. For vertex evaluation these are the same vertex, so both entries are zero-dimensional. We might store the normal to an edge within a triangle with $L_1 = \{\text{edgenormal}\}$, $f_1(\text{edgenormal}) = (\text{Simplex}(1), \text{Simplex}(2))$ because edge normals might not agree between two triangles that share an edge. Sections simply describe data on a mesh that satisfies a given schema.
Definition 7.3 (Ty, Section). Let $\mathcal{T}$ be the set of topology types and let $L$ be an abstract set of labels. Further, let $f: L \to \mathcal{T}^2$ be a schema. If $(V, F)$ is a mesh, let $\text{Ty}: F \to \mathcal{T}$ be a mapping from faces to the topology types corresponding to the standard entities a given face is isomorphic to. A $\text{section} S_{V,F,f}$ is the set $S_{V,F,f} := \{(l, h, g): l \in L, h \in F, g \in F, h \subset g, (t_1, t_2) = (f(l)), \text{Ty}(h) = t_1, \text{Ty}(g) = t_2\}$.
Returning to our previous examples, $S_{V,F,f_0}$ is isomorphic to the set of linear Lagrange DOFs with $|S_{V,F,f_0}| = |V|$. Similarly, $|S_{V,F,f_1}| = 3 * |T|$ where $T$ is the set of triangles. A bijection from a section $S_{V,F,f}$ to $\mathbb{N}$ would be a numbering for DOFs.
7.1.2 Global Fields Here, a field is a function assigning scalar or tensor values over mesh entities, not an algebraic field such as $\mathbb{R}$ or $\mathbb{C}$. Since our fields are often functions in finite element spaces or otherwise multi-valued across mesh entities (definition 3.14), we must use care to model this as a discrete object on a mesh. This starts with modeling vector spaces broken across a mesh.
Definition 7.4 (Mesh Vector Space). Given a topological type $T$ and a mesh $(V, F)$, a mesh vector space is a sequence of vector spaces $R_t$ for all $t \in F$ with $\text{Ty}(t) = T$.
We note that definition 7.4 is a more discrete notion of a fiber bundle (see [Lee 2012]) in differential geometry. The key example of this is the tangent space defined per triangle on a discrete mesh, but we could consider many examples implied by fig. 9 and fig. 4. We can now define our notion of fields:
Definition 7.5 (Mesh Field). Suppose $(V, F)$ is a mesh and $T$ is a topology type. Suppose we have a corresponding mesh vector space $R_t$. A mesh field is a collection of $C^\infty$ functions, $h_t: \text{Conv}(t) \to R_t$.
A mesh field can be thought of as a discrete analogue to a function from a manifold to a bundle. A mesh field could model a function in a global finite element space, but it could also model a more generic object that we can sample when restricted to entities of a mesh (as in definition 3.12). For example, a mesh field could model
a single linear Lagrange basis function or its gradient, which is discontinuous across triangles but $C^\infty$ within them. Moreover, definition 7.5 accounts for situations such as a Python function (for example $(x, y) \mapsto xy$) defining a smooth function on the entire mesh.
While a field represents a single function or vector in a FEM like space, we will sometimes provide an entire basis or collection of fields on a mesh to build operators/SVAO. We model this with the following definition.
Definition 7.6 (Sectioned Mesh Field Sequence). Suppose $(V, F)$ is a mesh, $f: L \to \mathcal{T}^2$ is a schema, and $S_{V,F,f}$ is a section. Suppose $T$ is a topology type greater than or equal to any in $f(L)$. Suppose we have a corresponding mesh vector space $R_t$. A sectioned mesh field sequence is a sequence of $C^\infty$ functions $g_{l,h,g,t}\colon \text{Conv}(t) \to R_t$ indexed by $(l, h, g, t) \in L \times F^3$ with $(l, h, g) \in S_{S,F,f}$, $\text{Ty}(t) = T$, and $g \subseteq t$.
We can think of these as a more computational counterpart to definition 3.14. Combining elements over $t$ reproduces our construction of global FEM spaces (definition 3.15) from local FEM spaces (definition 3.14). In this way, integration and storage topology types associated to an IPTEM (fig. 11) implicitly and automatically define the equivalence of DOFs used to make a FEM space (definition 3.15). Returning to our linear Lagrange example, the restrictions of the basis functions to each incident triangle defines a section mesh field sequence. If we had the linear Lagrange basis function $\phi_v$ for every vertex in the mesh, then $g_{\text{vertexeval},h,g,t} = \phi_v|_{t}$ for $t$ a triangle ($T = \text{Simplex}(2)$) with $h = g = v \in t$.
7.1.3 IPTEM as Global Computations We now reuse IPTEM as a specification. Following (22) in section 5.2.4, we interpret IPTEM as operator parametrized by suitable mesh entities.
Definition 7.7 (IPTEM on meshes). Suppose we have an IPTEM with a topological type $T_I$ for an integration domain, a topological type $T_O$ for output with $T_I \leq T_O$, $N$ topological types for field arguments, $f t y_i$ and $M$ for chart arguments, $t y_i$. Suppose for $1 \leq i \leq N$, we have a collection of mesh spaces, $R_{f t y_i,i}$. Suppose we have a finite dimensional vector space $V$. An IPTEM is a function
$$
I(c_1,\ldots,c_M,f_O,f_I,f_1,\ldots,f_N):
$$
$$
\times_{i=1}^{M} \operatorname{Aff}(t y_i) \times \operatorname{Aff}(T_I) \times \operatorname{Aff}(T_O) \times_{i=1}^{N+1} \operatorname{Aff}(f t y_i) \to
$$
$$
\mathcal{F}(\times_{i=1}^{N} C^\infty(\operatorname{Conv}(f_i), R_{f_i,i}), V)
$$
that takes the form
$$
\begin{align*}(c_1,\ldots,c_M,f_O,f_I,f_1,\ldots,f_N)&\mapsto(g_1,\ldots,g_N)\\&\mapsto\int_{\operatorname{Conv}(f_I)} F_{c_1,\ldots,c_M,f_O,f_1,\ldots,f_N}(g_0,\ldots,g_N)dx\end{align*}
$$
for some suitably typed $F$. To understand this, we recall our discussion of (22): given some geometries, we take functions defined on parameterizations of various geometries and compute an integral on one of these geometries. Further, the integrand depends pointwise on the functions, the parameterizations, and derivatives of functions.
Collin et al.
This definition models the compilation of an IPTEM on a particular set of mesh entities modulo local reductions (see fig. 11 and fig. 9). We observe that many good examples for this, such as the linear Lagrange DOF or Laplace operator, can be drawn from section 2. Assembly mirrors topological enumeration (paragraph 5.2.4.3) as assembly essentially interprets definition 7.7 wherever possible just as we did for eq. (22) in section 5.2.4.
7.1.4 SVAO and Global Assembly We now have all the ingredients to define SVAOs, semantically, and as a sparse array. Moreover, we argue that SVAOs are necessarily discretely meaningful, emerging from well-defined discrete IPTEM operators and bases/global fields that are known to be well behaved in specific combinations of mesh entities. In particular, mesh fields/bases combined with IPTEM allow us to easily see where computations are not multi-valued. Thus, to produce all the possible well defined computations from an IPTEM (or a collection of IPTEMs with the compatible field arguments) and some input fields/bases, we simply pair IPTEMs with the data from fields in all possible ways that are well defined and not zero.
We now show how to do this mathematically to define assembly and a SVAO. Our system implements these two definitions, so most users need to understand their meaning but do not need the implementation details; extending or debugging the system may require those details. Suppose we have some IPTEMs $IS = \{I_0, \ldots, I_Q\}$. This allows us to define a schema $f_{IS}$ from their integration and storage topological types. Each of these has $N$ field arguments and $M$ chart arguments $^{25}$ We supply a mesh $(V, F)$. Finally we provide $N$ input Section Mesh Field Sequences $^{26}$, $g_1, \ldots, g_N$, with schema $f_k$, topological types $T_k$, sections $S_{V,F,f_k}$ for $k = 1, \ldots, N$. We now have the ingredients for a call to assembly to produce a SVAO. A SVAO is a sparse tensor with dimensions for
(1) The output section $S_{V,F,f_{IS}}$.
(2) For each $i = 1, \ldots, M$, a dimension for F corresponding to a chart argument.
(3) For each $i = 1, \ldots, N$, a pair of dimensions for $S_{V,F,f_k}$ and $F$, representing a basis function and the domain from which the basis function was sampled. For mesh fields, we only include $F$.
The SVAO stores all valid, in the sense of definition 5.2, non-zero combinations of fields specified by the inputs, entities specified by the mesh, and IPTEMs. Our assembly routine produces a SVAO from the call:
$$
S=\mathrm{assembly}((V,F),\{I_{0},\ldots,I_{Q}\},g_{1},\ldots,g_{N}) \tag{28}
$$
where
$$
\begin{aligned}&S_{(l_{0},h_{0},g_{0}),c_{1},\ldots,c_{M},((l_{1},h_{1},g_{1}),t_{1}),\ldots((l_{N},h_{N},g_{N}),t_{N})}\\ &=l_{0}(c_{1},\ldots,c_{M},g_{1},((l_{1},h_{1},g_{1}),t_{1}),\ldots,g_{N},((l_{N},h_{N},g_{N}),t_{N}))\\ \end{aligned} \tag{29}
$$
if $g_k \subset t_k$ and $\mathrm{T}(t_k) = T_k$ for all $k$, $(l_0, h_0, g_0) \in S_{V,F,f_{IS}}$, and $(l_k, h_k, g_k) \in S_{V,F,f_k}$ for all $k$, and $(c_1, \ldots, c_M, h_0, g_0, t_1, \ldots, t_N)$ are a topologically valid assignment (definition 5.2) for $l_0$, which is one of the IPTEM. We observe that each entry of this array is well
defined/singly valued: the IPTEM is a single valued function on a given region and the input fields have been restricted to some region where they are $C^{\infty}$. On the other hand, we also compute all possible entries that could be well defined in this sense by using the validity definition: for each domain we must integrate on, we consider all possible ways we restrict fields to produce structurally non-zero well-defined values. For our mesh field or section mesh fields on our conforming meshes, this is always the basis functions with supports that could intersect on the integration domain.
We consider an example to explain this. Suppose we had an IPTEM for the Laplace operator, $l_{\Delta}$, as in listing 1. Our schema would be $f_{\Delta}(l_{\Delta}) = (\text{Simplex}(2), \text{Simplex}(2))$, which our system would automatically infer from the IPTEM code. The section $S_{V,F,f_{\Delta}}$, which would be computed as part of assembly, would represent a Laplace operator per triangle. Let $g_1 = g_2$ be section mesh field sequences corresponding to linear Lagrange basis functions, which are both sampled on triangles. Users would specify this with an element from section 6.1. Then our SAVO assembly can be written
$$
\begin{aligned}S_{(l_{\Delta},t_{0},t_{0})},&((\operatorname{vertexeval},v,v),t_{0}),((\operatorname{vertexeval},v^{\prime},v^{\prime}),t_{0})\\&=l_{\Delta}\big(g_{\operatorname{vertexeval},v,v,t_{0}},g_{\operatorname{vertexeval},v^{\prime},v^{\prime},t_{0}}\big)\end{aligned}
$$
for all triangles $t_0$ and vertices $v, v' \in t_0$. This is a typical abstraction $^{27}$ of the cotangent Laplacian assembly algorithm with just a constant factor more book keeping. SVAO assembly arrives at this from the general definition in (29) via two elements of the definition. First, via definition 5.2, we sample the triangle defined basis functions on the same triangle where they are integrated. Second, we get that $v, v' \in t_0$ due to the definition of section mesh field sequences.
Reproducing assembly of a FEM matrix is not the only point though; our definition also reproduces operations such as interpolation (definition 3.16), operations to mark boundaries, and more. We recall interpolation in particular though because we recall that it is only partially defined due to multi-valued computation. Our definition of assembly resolves this problem by computing all possible single-valued versions of a computation and then allowing users to resolve the problem in a way of their choosing via SVAO operations described in section 7.3.
### 7.2 Implementation Aspects
We describe code generation for assembly in appendix C. In particular, we describe interfaces to objects such as sectioned mesh field sequences that allow us to generate code. Here, we wish to note two things to emphasize the parametric aspects of our system.
First, the design of SVAO and the implementation make plugging elements into assembly easy. In particular, in appendix C.0.2, we note that the infrastructure of the previous sections does most of the heavy lifting. For example, schema to define global element numbering emerge naturally from our definition of IPTEMs with integration and storage topological types. In our implementation, users need not think about the difference between an element and a global basis as our assembly routine recognizes the element and automatically does the wrapping via our infrastructure. And our
$^{25}$for simplicity, we don't represent this here, but this can actually be allowed to vary.
$^{26}$the more general of the two options
$^{27}$the reduction across triangles is accomplished via an interface in section 7.3 wrapping does the job of defining a sort of global tabulation function for a section mesh field sequence (listing 29) that knows to generate code via Vandermonde matrix inversion as in section 6.2.
Second, our implementation heavily uses the infrastructure of section 5 just as our implementation of elements does. Both directly call listing 7 for the local code. We patch this local code through symbolic charts whose formula stand in for data extracted from mesh data structures at runtime. See appendix C.0.3 for more information.
### 7.3 Operations on Global Objects
With SVAO, we can now discuss the entire global interface. In particular, we can now introduce a small number of additional operations that allow us to chain together assembly operations to express many FEM operations. The overall workflow is discussed in appendix D.2. All the objects and operations described here are discretely well defined so users can use them with SVAO to make discretely well defined pipelines. All operations work discretely on SVAOs in a coherent easy to understand/NumPy-like manner.
We do need two more objects, sub-sections and sub-meshes, but these can be understood essentially as masks on the original objects. $^{28}$ With these, we have all our objects: mesh, IPTEM, SVAO, mesh field, and sectioned mesh field sequence, section, sub-mesh, sub-sections. Our operations are four NumPy-like operations (reduction, slice, set-slice, and where), and seven simple specific operations (propagation, submersion, asMask, asInput, asDenseVector, asScipyMatrix, and asScalar). Signatures for all operations are provided (in appendix D), but we describe the two categories roughly below. Our eight objects and eleven operations constitute our user interface modulo all the tools to write IPTEM. If users stick to this interface, code will remain discretely well defined as elements change; however, users can also just access underlying arrays if they really need to.
Our NumPy-like operations all utilize the idea that SVAO is still an array, but whose dimensions and entries have specific meaning. (These operations are precisely enumerated in appendix D.1.) By keeping the meanings of the entries and dimensions in mind, we believe this interface forces code that computes well defined quantities. For example, to slice a SVAO, users must pair dimensions that are sections with sub-sections and dimensions that are mesh facets with sub-meshes. We used these in our initial example, listing 1, to implement boundary conditions. Dual to this, the where operation behaves like-NumPy where but the output object will be a subsection for section dimensions, sub-meshes for facet dimensions, or even IPTEM for labels. The where operation can be used to implement more sophisticated methods for identifying boundary entities or boundary DOFs. The where operation combined with assembly is critical to extracting boundary DOFs to implement elimination methods as illustrated in section 2.2.2. Lastly, reductions behave just like NumPy-reductions, but they can be specialized per IPTEM label of the output section, allowing complex default global reductions to be applied in many cases. For reductions in particular, we note that the defaults inherited from IPTEM are nice as they allow users to
not think about the many dimensions of SVAO if they just need to reduce away all dimensions but two section dimensions to get an operator as a matrix or vector or scalar.
Besides these NumPy operations, we provide a few more specific operations. Four of these are simple: we offer the ability to use default reductions to attempt to convert a SVAO to a mesh field, dense vector, scipy sparse matrix, or scalar. In other words, a short cut to apply a reduction and extract the data. The defaults for global reductions are encoded into IPTEM (See fig. 11). For sub-sections and sub-meshes, we have three other operations starting with using the sub sets directly as a mask for array programming. Sub-meshes can always be propagated to a sub-section by simply finding all section elements associated to a sub-mesh (e.g., as in listing 1:line 15) while sub-sections can be submersed back into the mesh if a sub-section is an injection into the mesh. These two methods also support more robust boundary condition elimination as in section 2.2.2. Precise definition for sub-objects and operations between them are provided in appendix D.3.
## 8 Evaluation
To evaluate our system, we construct several applications of interest to computer graphics where we can utilize a variety of elements: a biharmonic smoothing energy, a Hodge Decomposition, and a Stokes flow. For each application and relevant element, we validate the application via convergence plots and we also supply a simplistic analysis of some of the trade-offs between elements. Thus, these applications demonstrate the potential utility of changing elements to computer graphics applications. In some cases, these results are known, though they have never been achieved in a truly automated fashion and are not widely available to the graphics community.
To evaluate how our system achieves the above, we conduct three experiments to show that:
(1) Our system can specify FEs concisely compared to other systems, in large part due to our automatic capabilities.
(2) Our system can specify FEs in a malleable manner: the code required to implement new elements given the infrastructure of old elements is small, so the code to vary elements is small.
(3) Our system's automation does not cost us when it comes to the FE transformation theory - the code generated by our system require roughly the same work as compared to the transformation theory deduced by hand.
Through the variety of applications, we hope to demonstrate that our system is sufficiently expressive to specify most elements that are available in the world. Finally, we note that all of our applications provide evidence for the claim that our system is parametric over the definition of the element. With the exception of the mixed method for the biharmonic applications, we did not need to change our program to change to another valid element for any of these applications. For the biharmonic application, we did explore some changes to the weak formulation for the sake of exploring trade-offs, but we did not need to do so. In other systems, this would not be the case due to the need to develop the element or the need to work out how interpolation or boundary conditions work for different elements.
$^{28}$though a sub-mesh must be a sub-poset so not any mask is valid, which is why internally we need a subset of a mesh that can be completed to a proper sub-mesh.
Collin et al.
### 8.1 Applications
#### 8.1.1 Biharmonic Energies
8.1.1.1 Problem Setup Fourth-order problems are a central motivator for the development of scalar elements beyond the Lagrange element. The model fourth-order problem is the biharmonic equation:
$$
\Delta^{2}u=f. \tag{30}
$$
The biharmonic equation emerges in many contexts, and we study several of them representing geometry processing and simulation concerns. Our contexts include a variety of BCs, including Dirichlet conditions (also sometimes referred to as Dirichlet & Neumann):
$$
u|_{\partial\Omega}=h\mathrm{a n d}\frac{\partial u}{\partial n}=g \tag{31}
$$
for some given scalar functions $h, g$. In simulation contexts, these are sometimes known as clamped plate BCs. Simulation contexts also utilize a form of BC given by
$$
\frac{\partial u}{\partial n}=g\mathrm{a n d}\frac{\partial\Delta u}{\partial n}=h. \tag{32}
$$
However, we also study the natural BCs, which occur in smoothing applications [Stein et al. 2018, 2020]:
$$
n H_{u}n=0\mathrm{a n d}\frac{\partial\Delta u}{\partial n}+\frac{\partial u}{\partial n t n}=0 \tag{33}
$$
where t is a vector tangent to the boundary. In smoothing applications, we also see interpolation constraints:
$$
u(x_{i})=f_{i} \tag{34}
$$
where $x_i \in \Omega$ (typically vertices of the mesh) and $f_i \in \mathbb{R}$.
Finally, any of these BCs could be combined with a biharmonic eigenvalue problem:
$$
\Delta^{2}u=\lambda u. \tag{35}
$$
For example, the solution to the eigenvalue problem under the Dirichlet conditions provides the vibrational modes of a surface clamped at its boundaries.
8.1.1.2 Operators Using our system, we implement the following operators to represent the biharmonic equation. We use a Hessian-Hessian inner product for the equation
$$
a_{H}(u,v):=\int_{\Omega}(H_{u},H_{v}). \tag{36}
$$
Naturally, for the right hand side or the eigenvalue problem, we need a mass operator:
$$
m(u,v)=\int_{\Omega}u v. \tag{37}
$$
To implement various BCs variationally (Neumann or Dirichlet via Nitsche's method [Benzaken et al. 2024]), we utilize terms from the following operator:
$$
a_{B}(u,v):=\int_{\partial\Omega}v\frac{\partial\Delta u}{\partial n}+\int_{\partial\Omega}\frac{\partial v}{\partial n}\Delta u+\int_{\partial\Omega}u v+\int_{\partial\Omega}\frac{\partial u}{\partial n}\frac{\partial v}{\partial n}. \tag{38}
$$
For natural BCs in smoothing, we do not need operators to enforce them. To enforce point constraints, we need linear operators that correspond to point evaluation at a fixed set of points $\{x_i\}_{i=1}^N$:
$$
P(u)=(u(x_{1}),\ldots,u(x_{N}))\in\mathbb{R}^{N}. \tag{39}
$$
Also, to validate the BCs numerically $^{29}$, it is useful to have the following non-linear operator:
$$
e_{B}(u)=\int_{\partial\Omega}(n H_{u}n)^{2}+(\frac{\partial\Delta u}{\partial n}+\frac{\partial u}{\partial n t n})^{2}. \tag{40}
$$
Similarly, to check if an element is valid to use for a biharmonic problem on a given mesh (some unconditionally work, but others do not), it is useful to consider the patch test operator that operates on the interior edges $\cup e_i \subset \Omega$ with the notation that $K_{0,i}$ and $K_{1,i}$ are the two cells that include $e_i$:
$$
t(u,v)=\sum_{i}\int_{e_{i}}(\nabla u|_{K_{0,i}}-\nabla u|_{K_{1,i}})\cdot v. \tag{41}
$$
If $v$ is drawn from discontinuous piecewise linear functions defined the set of edges, then $t \equiv 0$ when $u$ is drawn from a given global finite element space is a necessary condition to use an element to solve a biharmonic problem.
Since we wish to compare to prior work, mainly [Stein et al. 2019, 2018], we need operators to implement a mixed method for the biharmonic equation. These come from the Laplace equation, except for smoothing, where we need a few additional operators, including an inner product on matrix-valued functions that represent Hessians and an integration of the divergence of a matrix against the gradient of a scalar function:
$$
a_{\mathrm{D i v}},\nabla\left(\Lambda,u\right)=\int_{\Omega}\nabla\cdot\Lambda\cdot\nabla u. \tag{42}
$$
8.1.1.3 Elements We use the following elements on this problem: affine Lagrange, Morley, Hermite, Bell, Argyris. For the purpose of later analysis, we provide code. The Lagrange element in our system is:
1 cty0, sty2 = ChartType(0), SimpleType(2)
2 @pointwiseEval(cty0, barycentricCoordinate=0.0)
3 def vertexEval(u: field(cty0, R)):
4 return u(0)
5 LagrangeTri = EF.FE(2, Pure(sty2,1), [vertexEval])
Listing 13. Affine Lagrange DOFs
The Morley element uses quadratic polynomials, the affine Lagrange DOFs, and evaluations of the gradient normal at midpoints. We note that the normal direction is computed with a global Hodge star on Euclidean space to ensure the value is consistent on edges examined from different cells:
1 cty1 = ChartType(1) # On objects of dimension 1
2 @pointwiseEval(cty1, barycentricCoordinate=(0.5, 0.5)
3 def morleyDof(c: cty1, u: field(cty1, R, euclideanDerivative=True)):
4 return hodge(u(1)), dot(c.E(c.tangentVector(0)))
5 Morley = EF.FE(2, Pure(sty2,2), [vertexEval, morleyDof])
Listing 14. Morley DOFs
Hermite DOFs are cubic and use Lagrange DOFs plus edge gradients and a center evaluation.
1 fld = field(cty0, R, euclideanDerivative=True)
2 @pointwiseEval(cty0, barycentricCoordinate=0.0)
3 def xDervDof(u: fld):
4 return u(1)[0]
5 @pointwiseEval(cty0, barycentricCoordinate=0.0)
6 def yDervDof(u: fld):
$^{29}$As a minor note, we used this to provide the first numerical validation of the BC offered in [Stein et al. 2018]
```r
7 return u(1)[1]
8 cty2 = ChartType(2)
9 @pointwiseEval(cty2, barycentricCoordinate=(1/3, 1/3, 1/3))
10 def centerDof(u: field(cty2, R)):
11 return u(0)
12 HermiteDofs = EF.FE(2, Pure(sty2, 2), [vertexEval, xDervDof, yDervDof, centerDof])
Listing 15. Hermite DOFs
The Argyris DOFs utilize the Hermite gradient DOFs plus the Morley DOFs and three additional Hessian DOFs per vertex:
1 fld = field(cty0, R, euclideanDerivative=True)
2 @pointwiseEval(cty0, barycentricCoordinate=0.0)
3 def xxDervDof(u: fld):
4 return u(2)[0,0]
5 @pointwiseEval(cty0, barycentricCoordinate=0.0)
6 def yyDervDof(u: fld):
7 return u(2)[1,1]
8 @pointwiseEval(cty0, barycentricCoordinate=0.0)
9 def xyDervDof(u: fld):
10 return u(2)[0,1]
11
12 ArgyrisDof = EF.FE(2, Pure(sty2, 5), [vertexEval, xDervDof, yDervDof, morleyDof, xxDervDof, yyDervDof, xyDervDof])
Listing 16. Argyris DOFs
Finally, the Bell DOFs use the Argyris DOFs except the Morley DOFs. Instead, the Bell space consists in quintic polynomials whose normal gradients are cubic polynomials on each edges. To enforce this, we add Morley-like DOF that use the Legendre DOFs to the space:
1 @pointwiseIntegral(cty1)
2 def bellSpaceDof(c: cty1,
3 u: field(cty1, R, euclideanDerivative=True),
4 v: field(cty1, R) = legendreDofs(5).basisFunction(4)):
5 return u(1).dot(c.normalVector(0)) * v(0)
6 dofsList = [vertexEval, xDervDof, yDervDof, xxDervDof, yyDervDof, xyDervDof]
7 BellDofs = EF.FE(2, BKernel(Pure(sty, 5), dofsList, dofsList + [bellSpaceDof]), dofsList)
Listing 17. Bell DOFs
The Legendre DOFs are just L2 duals of the monomials:
1 def legendreDofs(deg: int):
2 dofs = []
3 for d in range(deg + 1):
4 @pointwiseIntegral(cty1)
5 def legendreDof(c: cty1, u: field(cty1, R)):
6 return (c.x*td) * u(0)
7 dofs.append(legendreDof)
8 return EF.FE(1, Pure(Simplex(1), deg), dofs)
Listing 18. Legendre DOFs
8.1.1.4 Validation To validate our system, we provide a convergence study on a model problem: the biharmonic equation with homogeneous Dirichlet BCs on the unit square. We use the analytical solution . We compared the mixed method from [Stein et al. 2019, 2018] to an implementation using the operators in (36) and (37) with boundaries enforced by querying our system for the nodes corresponding to the Dirichlet BCs. This amounts to a few lower level calls made automatically in the system to the last two terms of the operator in (38) (similar to listing 5). By comparing to other literature [Pormann 2022], we have validated that the DOFs selected for the BCs are correct. Since our particular

Fig. 13. Convergence data for fig. 14. We enforce boundary conditions via either mixed methods, elimination methods, or Nitsche's method. Observe that we come close to the expected convergence rates in all cases. For higher order elements, achieving exact convergence rates is difficult due to already low errors at initial sizes. Additionally, the parameter choices in Nitsche's method can impact observed convergence rates.
variation of the Argyris and Bell elements only supports BCs on certain types of meshes (compare to [Ferraro et al. 2010; Gräßle 2022]), we also provide convergence data for a Nitsche method formulation [Benzaken et al. 2024] that utilizes all of the terms in (38). The results are depicted in fig. 14 and fig. 13. The results validate the system, as convergence is in line with theoretical predictions.
To validate the system on a more realistic mesh, we provide the first six eigenvectors of the Hessian operator with natural BCs, allowing a visual comparison with [Stein et al. 2018]. To make the comparison possible here, we also provide the first six eigenvectors via the mixed method described in [Stein et al. 2018]. The results in fig. 15 show that the first six eigenvectors have roughly the expected structure on a more complex mesh. We also include Hermite elements in this example to show that they provide visually reasonable results, although they do not pass the patch test and do not converge on meshes used in our convergence validation.
8.1.1.5 Trade-Offs Our convergence results are the start of our discussion of trade-offs. Examining fig. 14, we observe that Morley might improve the error, reaching the correct shape earlier than the Lagrange element, but the visual suffers due to discontinuity. Argyris
Collin et al.

Fig. 14. Solutions to the Biharmonic equation on the square with different elements, meshes, and BC enforcement methods. All are visualized on refined meshes according to polynomial degree. See fig. 13 for convergence data. These visually validate our convergence results and indicate trade offs between the elements.
in contrast reaches a visually pleasing and accurate solution much earlier. However, we observe that this does not hold if we enforce boundary conditions variationally as opposed to an elimination method. Morley can always use elimination methods for Dirichlet BCs while Mixed Lagrange can only use homogeneous BCs and Argyris can only use elimination BCs on certain meshes. Since the visual benefits of Argyris can be harmed by boundary condition enforcement, we plan to seek alternatives with better boundary condition properties. Similarly, we ought to search for techniques to post-process discontinuous Morley (e.g. [Collin et al. 2019; Mirzargar et al. 2015]) that produce continuous visually pleasing solutions with comparable error properties and boundary value preservation.
To further visually motivate our discussion of the trade-offs between elements for Biharmonic problems, we consider the interpolation problems from [Stein et al. 2018]. We replicate the mixed method described in [Stein et al. 2018] and utilize a direct method via (36) with four elements: Morley, Hermite, Bell, and Argyris. We apply all methods to a low-resolution mesh (210 elements). We note that constructing a low-resolution mesh that worked on the mixed method was a struggle, as the mixed method fails when two edges of a triangle are on the boundary ("ears"). In contrast, the Morley, Bell, and Argyris elements are valid on any conforming meshes for this problem. The results are depicted in fig. 16, where all are visualized by evaluating the solution at each vertex (so all solutions are still rendered as linear functions). Visually, we see that distortions due

Fig. 15. The first six eigenfunction of the Hessian energy operator with natural boundary conditions [Stein et al. 2018]. All pass rough visual muster, though Morley and Lagrange have kinks in the less refined belly regions of the third eigenvector. We also observe that the Hermite element may seem different from the rest, which is plausible, as Hermite elements fail the patch test. We do not include Argyris as it is visually indistinguishable from Bell.
to low poly count disappear as we use higher-order elements. What is striking about this result is that via various machine-independent metrics, several higher-order elements were cheaper: they used fewer DOFs per element and thus required smaller sparse matrices. Of course, this is just one problem; the results are much more striking than the standard convergence results in fig. 14; there, the cost calculation might be more complex, especially if we explore variations of BCs. There are many vicissitudes to explore, but to tease and conserve space, we summarize some trade-offs between elements for biharmonic problems in table 1.
8.1.2 Hodge Decomposition
8.1.2.1 Problem Setup We assume the language of exterior calculus for this section (see [Wang et al. 2023]) up to the Hodge Decomposition. For information on how exterior calculus primitives are expressed in our system, see appendix G.
Definition 8.1 (Hodge Decomposition). Suppose is an manifold without boundary. Let be a form with . The Hodge decomposition of is a triple of forms, , such that
(1) ,
(2) and .
If has boundary, then the Hodge decomposition is a tuple of forms, such that
(1) ,
(2) and ,
(3) and .
Table 1. A table of various trade-offs between elements. The first three rows give the number of DOFs used per triangle to solve certain types of problems. Then come rows indicating which formulations are supported (e.g., mixed methods, naive forms, IPO). The next three rows concern enforcement of boundary conditions. Transform NNZ is the number of non-zeros in the transform matrix.
| Trade Off/Element | Lagrange 1 | Lagrange 2 | Lagrange 3 | Morley | Hermite V1 | Bell | Argyris |
|---|---|---|---|---|---|---|---|
| DOFs Per Tri | 3 | 6 | 10 | 6 | 10 | 18 | 21 |
| DOFs Per Tri BiLaplice | 6 | 12 | 10 | 6 | 10 | 18 | 21 |
| DOFs Per Tri Hessian | 15 | 30 | 10 | 6 | 10 | 18 | 21 |
| Supported Form | Mixed | Mixed | IPM | Naive | Sometimes | All | All |
| Elimination BCs | Homogeneous | Homogeneous | Homogeneous | Yes | Sometimes | Sometimes | Sometimes |
| Supports Nitsche | No | No | Yes | Yes | Yes | Yes | Yes |
| Transform NNZ | 3 | 6 | 10 | 12 | 16 | 45 | 63 |
| Continuity | Complex | at vertices | |||||
| Ideal Convergence Rate | Unknown | ||||||
| Convergence Defects | Yes | Unknown | Unknown | None | Yes | None | None |
All, but naive depends on the geometry. Depends on geometry Only u = 0, but not Minimal element that passes the patch test. (Mixed, IPM (interior penalty method) Naive). General case is unknown.
g Fails on mesh with corners h Fails patch test on some meshes

Fig. 16. Biharmonic interpolation on a low resolution mesh with different elements. All functions were rendered as affine on refined meshes of the appropriate polynomial degree (see fig. 17). Observe that the head of the cat is improved by the cheaper quadratic Morley, though discontinuities are introduced. Hermite fixes the head of the cat, but the tail and bottom regions are less accurate compared to Bell. Argyris does not improve much on Bell for the additional cost.

Fig. 17. Upsampled (higher order) render meshes contrasted with function solutions plotted on the mesh without upsampling. Compared to fig. 16 and we see that the visual benefits of higher order elements compared to the mixed method are partially realized without more expensive rendering technologies.
Collin et al.
Further variations on these decompositions are available when more complex varieties of BCs are used [Zhao et al. 2019], but we stick to the standard variations. Computing the Hodge decomposition has many applications, most notably as a primitive for solving many PDEs in fluids and electromagnetics [Bhatia et al. 2013]. Additionally, the operators used to define the Hodge decomposition are at the core of vector field design problems [Leopardi and Stern 2016].
8.1.2.2 Operators Traditionally, each Hodge decomposition amounts to the solution of two vector Poisson equations and two vector Poisson eigenvalue problems. The Poisson equations allow us to compute the and terms while the eigenvalue problems allow us to compute by projecting to the null space of the two vector Poisson equations. Further, we need two differential operators to set up the right hand side of these equations () and two of the same differential operators to process the results to form and . A recent example of such an approach is [Su et al. 2024a]. However, this involves a huge array of operators because for each choice of and , a variety of differential operators might be involved. We will avoid this complexity by simply specifying the operators involved using only and the inner product on forms. We need only four operators that operate on pairs of either two forms, or and forms, or two forms:
With the right choice of element, the BCs are Dirichlet or natural. Next, we need to use and pointwise to set up the right hand sides. Since the first four are similar, we provide code for :
def ddoperator(formDeg: int, cell: int): fld = field(ChartType(cell), Lambda(formDeg, cell)) @pointwiseIntegral(ChartType(cell)) def mdd(u: fld, v: fld): return antiSymmeterize(u(1)).dot(antiSymmeterize(v(1))) return mdd
Listing 19. Example operator for FEEC
We also provide an example with :
def deltaOperator(formDeg: int, cell: int): fld = field(ChartType(cell), Lambda(formDeg, cell)) fldp = field(ChartType(cell), Lambda(formDeg - 1, cell)) @pointwise(ChartType(cell)) def delta(u: fld) -> fldp: return hodge(antiSymmetrize(D(hodge(u(0)))) return delta
Listing 20. Implementation of a pointwise delta operator.
8.1.2.3 Elements Just as with operators, there are elements for different choices of and . Also as with operators, these can be succinctly unified into a few choices, parametrized by dimension of the space/surface , form degree , polynomial degree , Hodge duality , and trim . These elements are labeled , , , . Together these capture Lagrange elements, discontinuous Lagrange elements, Nedelec (type one and two) (face and edge) elements, Brezzi-Douglas-Marini elements, and Raviart Thomas elements. Since we do not need the last two here, we will not discuss them here beyond providing their spaces, but they only require about 10-20 more lines of code.
We first describe these mathematically. To describe the spaces, we need the Koszul operator (see [Arnold 2019]) and also the space of homogeneous polynomials (all terms have the same degree except 0) . The latter gives rise to the space of homogeneous polynomial form spaces .
(1) , the space of degree polynomial valued forms on the tangent space of .
(2) , the degree forms plus the kernel of the Koszul derivative on the homogeneous polynomial degree forms. These are the so called trimmed spaces.
(3) , the space of forms represented via Hodge stars of forms. The idea of this spaces is to model normal components as opposed to tangential components.
(4) , similar to the above but using trimmed spaces.
For each of these elements, the DOFs can be defined via mutual recursion. The base case is the Lagrange elements, which we will discuss in the Stokes section. We can define the DOFs on k forms and simplifies f of dimension d using forms of smaller degree defined on smaller simplices:
(1) : for every face , let be a basis for . The DOFs are
for all and all valid i.
(2) : for every face , let be a basis for . The DOFs are
for all and all valid i.
These DOFs capture the tangential components with forms; DOFs for the latter two spaces would capture the orthogonal complements of the tangent space. (Practically, the first two favor Dirichlet BCs on , while the latter two favor Dirichlet BCs on ). The trimmed spaces provide smaller, more economical versions that are harder to interpret; in particular, the trimmed spaces allow users to approximate forms of different orders to the same order of accuracy [Arnold 2019].
We provide code to capture all of these cases in stages. First, we provide the DOFs to define the Koszul space.
1 def koszulDofs(formDeg: int, degree: int, dim: int):
2 evals = []
3 dsf = filter(
4 lambda x: sum(x) == degree + 1,
5 product(*[range(degree + 2) for _ in range(dim)]),
6 )
7 for ds in dsf1:
8 for k in range(int(binom(dim, formDegree - 1))):
9 @P.pointwiseIntegrate(CellType(dim))
10 def koszul_eval(c: ChartType(dim), f: field(dim, Lambda(
11 formDegree, dim)):
12 x = c.P(c.x)
13 xx = np.prod[[c.x[j] ** ds[j] for j in (range(dim))])
14 r = interiorEval(f(0), [0], [x])
15 return (
16 r[(k,)] * xx (See paragraph G.0.0.5)
17 )
18 evals.append(koszul_eval)
19 return evals
Listing 21. Implementation of Koszul DOFs.
We define the Koszul DOFs to isolate the kernel of the Koszul operator. We do this by testing the Koszul operator with every relevant monomial and form component. Then, we can define our spaces:
1 def freeSpace(formDeg: int, degree: int, dim: int, trim: bool):
2 if not trim:
3 return Pure(Simplex(dim), degree, Lambda(formDeg, dim))
4 dim)
5 else:
6 Prm1 = freeSpace(formDeg, max(degree - 1, 0), dim, trim)
7 if formDegree == 0 or formDegree == dim:
8 return Prm1
9 kdofs = koszulDofs(formDegree, degree, dim)
10 return Prm1 + IKernel(kdofs, Pure(Simplex(dim), degree, minDegree =degree))
Listing 22. Implementation of FEEC spaces, utilizing Koszul DOFs for the Koszul space.
Finally, we can define our elements modulo a few lines of code to specify the base cases:
1 def feeC(formDeg: int, degree: int, dim: int, trim: bool):
2 if formDeg == 0:
3 return langrangeDofs(dim, degree if not trim else degree - 1)
4 assert dim >= formDeg >= 0 and degree >= 0
5 space = feeSpace(formDeg, degree, dim, hodge, trim)
6 md = min(dim, formDegree + degree - 1)
7 evals = []
8 for j in range(formDegree, md + 1):
9 ct = ChartType(j)
10 field = field(ct, Lambda(formDegree, ct))
11 recDegree = degree - j + formDegree - 1 if trim else degree - j + formDegree
12 recDofs = feeC(j, recDegree, j - formDegree, trim=not trim)
13 for basisFunc in recDofs:
14 @P.pointwiseIntegrate(ct, reduction=choice)
15 def form_eval(u: field, v: recDofs.field() = basisFunc):
16 return hodge(wedge([u(0), v(0)])))
17 evals.append(form_eval)
18 return EF.FE(dim, space, evals)
Listing 23. Implementation of FEEC elements.
For our base case, we must also provide arbitrary order Lagrange DOFs. We provide these in the Stokes section.
8.1.2.4 Validation
We use two problems to validate our solvers and provide convergence data. We refer to the first as the annulus solution and the second as the cylinder solution. See appendix H for details. For both cases, we must utilize the theory of variational crimes to temper the validation experiments; we should not expect
convergence higher than second order because we are using a linear approximation of the geometry [Holst and Stern 2012]. For analytical data, we quickly achieve this if we consider convergence for , , and the total harmonic part, . We provide convergence plots in fig. 18. For the individual harmonic components, our results differ by geometry. For the annulus, we achieve results identical to the total harmonic component. For the convergence in the cylinder scenario, we need a further proviso. In particular, for and , we achieve results comparable to the total harmonic component, but we do not achieve convergence for . Literature on convergence in the surface scenario of individual components of the algorithm is sparse, and most articles on the decomposition do not perform this analysis, sometimes reporting a difficulty in the convergence of the individual components of the harmonic part of the decomposition [Poelke 2017; Poelke and Polthier 2016; Su et al. 2024a,b; Tong et al. 2003; Zhao et al. 2019]. This might be a Babuška paradox type situation [Davini 2003], but it might also be that the convergence in the theory applies to the PDEs but not the classic Hodge decomposition algorithms.
We checked that each component has the correct angle with an interpolation of the true solution (zero to machine precision). These indicate that the elements and solvers are sound, but the steps to produce the five term Hodge decomposition (as found in many places in the literature) are not sound. Despite this though, we do produce equally visually satisfying solutions for all components (fig. 19) that are indistinguishable from the true solutions. Further, the intermediate mesh resolutions of our convergence study provide a starting point for the discussion of trade-offs between elements. We provide the results for for several mesh resolutions and elements in fig. 20. These results show that higher order elements provide advantages with respect to visual anomalies on low resolution meshes.
8.1.2.5 Trade-offs
The trade-offs for higher order representations of forms have been noted throughout the literature [Boksebeld and Vaxman 2022; Custers and Vaxman 2020; Desbrun et al. 2006; Wang et al. 2006], including applications such as vector field design, parameterization (fixed boundary, seamless), vector heat methods, and solutions to fluid equations. In each of these, the story is roughly the same: higher-order elements provide smoother and more accurate solutions that benefit downstream applications at the expense of implementation pains and computational costs. We can provide another data point by computing one of the zero eigenvectors of the Hodge Laplacian on a low resolution mesh. We compare this to a higher resolution mesh and low order element scenario in fig. 21. We follow [Boksebeld and Vaxman 2022] in this comparison. We note that not only are there visual distortions due to the lower order elements (jumps in color), but that the topology of the vector field is not accurately represented: the lowest orders do not capture the critical point in the center of the field and heavily distort the flow along the lines of the coarse geometry.
8.1.3 Stokes Flow
8.1.3.1 Problem Setup
Let or and . Suppose we have a forcing function and a viscosity parameter . The Stokes equations seek a velocity field and a pressure field such
Collin et al.

Fig. 18. Convergence plots for five different elements on two different geometries for the and total harmonic components of the Hodge Decomposition. We omit as it is similar to the total harmonic component. The theory of variational crimes indicates these are the correct results, validating our implementation and demonstrating the difficulty of a convergence advantage for analytical solutions via higher order exterior calculus methods.

Fig. 19. Higher order and resolution solutions for the Hodge decomposition in both scenarios. Visual results show the correct vector field topologies and no visual anomalies.

Fig. 20. Visual results for produced by the convergence study. Except for the first column of the cylinders study where the method fails catastrophically, we have labeled regions visual anomalies with dashed lines. Though the pattern is not completely robust due to the – elements, the last two components of the element complex control how coarse a mesh can be without obvious visual anomalies.

Fig. 21. Zero eigenvectors of the Hodge Laplacian on a low-resolution mesh with a variety of elements and a comparison to a lower order element on a highly refined mesh (282 vertices vs. 29,000 vertices). Observe that the labeled critical point location drifts.
that
and
We are primarily interested in no-slip BCs and other proscribed time-varying velocities:
or
for some . We additionally enforce that the pressure is mean zero, i.e., for all time .
We are primarily interested in the contrast between cases where and where h is the characteristic edge length of the mesh. The former resembles the case of a fluid like water while the latter resembles the case of a superfluid.
8.1.3.2 Operators and Time Stepping The standard weak formulation for stationary stokes is to find a u and p such that for all and :
We considered implicit Euler and Crank Nicholson time stepping. For a time step size and a , we solve for at time in terms of and at time via finding and such that
holds for all . Since the resulting discrete system is a saddle point system, we must be careful with the solver. For all purposes in this section, we get away with PETSc' GMRES with LU (via MUM MPS) as a pre-conditioner [Amestoy et al. 2019, 2001; Balay et al. 2019].
8.1.3.3 Elements We follow the element choices offered in the experiments in [Linke and Rebholz 2019], including various pairings of Lagrange elements (Taylor-Hood and Scott-Vogelius), mini elements, and Crouzeix-Raviart elements. The Taylor-Hood (TH) element is simply the use of a k-degree vector Lagrange element for the velocity space and a k-1-degree scalar Lagrange element
for the pressure space. This requires a more general bit of code for the Lagrange element, which we provide here; this version allows for Lagrange elements on arbitrary Euclidean-like spaces and for discontinuous spaces:
def lagrangeDofs(dim: int, degree: int, space = P.R, dg: bool = False): PSpace = Pure(Simplex(dim), degree, space) dofs = [] for dim in range(dim + 1): for point in equispacedBarycentric(dim, degree, boundary=False): for vector in stdEuclideanBasis(space): @pointwiseEval(ChatType(dim), barycentricCoordinate=point, storeAt=dimp if not dg else dim) def dof(u: field(ChatType(dim), space)): return u(0).dot(vector) dofs.append(dof) return Dofs(PSpace, dofs)
Listing 24. Tensor Lagrange Elements
Scott-Vogelius (SV) can be characterized as a Taylor-Hood element where the pressure space is discontinuous, but this characterization is facile due to the circumstances under which the element works. In particular, the SV element requires that there are no singular vertices (vertices incident to edges that all lie on two lines (or three planes)) and so the SV element is sometimes phrased as TH with discontinuous pressure on a barycentrically refined or macro triangle/tetrahedral meshes [Farrell et al. 2021b; Guzmán and Scott 2019; Linke et al. 2008; Vacek and Sváček 2024]. In the future, we will model with these explicit macro elements, but for now we model this by just refining the mesh barycentrically. A bubble element is a Lagrange element where we include extra basis functions that are zero on the boundary of the geometry. The mini element on a d-dimensional space uses linear Lagrange for the pressure and the sum of linear Lagrange plus a d-degree bubble element for the velocity. We can define a mini space similarly:
def mini(dim: int, degree: int, bdegree: int, space = P.R, dg: bool = False): assert bdegree > degree and bdegree >= dim + 1 idofs = [] ndofs = [] dofs = [] for dim in range(dim + 1): for point in equispacedBarycentric(dim, bdegree, boundary=False): for vector in stdEuclideanBasis(space): @pointwiseEval(ChatType(dim), barycentricCoordinate=point, storeAt=dimp if not dg else dim) def dof(u: field(ChatType(dim), space)): return u(0).dot(vector) if dim == dimp: idofs.append(dof) else: ndofs.append(dof) PSpace = Pure(Simplex(dim), degree, space) + IKernel(ndofs, Pure(Simplex(dim), bdegree, space)) return Dofs(PSpace, lagrangeDofs(dim, degree, space).dofs + idofs)
Listing 25. Mini Elements
Finally, we do not bother with the CR element as it is very similar to the Lagrange element.
8.1.3.4 Validation and Trade-Offs We set up two analytical problems to test our solver, which is sufficient to reveal a trade-off. In particular, we follow [Linke and Rebholz 2019] to show that cheaper
38 • Collin et al.
elements (fewer DOFs) tend to be non-robust to low viscosities, sometimes inducing locking behaviors similar to those found in elasticity simulation.
In two dimensions, we consider analytical velocities and pressures given by
and
In three dimensions, we consider
and
We use these to construct a forcing function according to the Stokes equations and solve until time 0.01 in ten time steps on the unit square or unit cube. We enforce Dirichlet conditions on the velocity while for the pressure we require that . We do this for and . We use the Taylor-Hood elements and the Scott-Vogelius elements at order . In 2D, we use Crank-Nicolson time stepping with whereas in 3D we used Euler. Convergence results for velocities and pressures in 2D/3D are plotted in fig. 22. We immediately observe that the convergence in velocity of the Taylor-Hood elements is massively impacted by lowering the viscosity while Scott-Vogelius is not impacted. Interestingly, we observe that the pressure convergence is not impacted. As it turns out in the analysis of [Linke and Rebholz 2019], as viscosity gets smaller, the error in velocity becomes dominated by the error in the gradient of pressure if an element is not discretely divergence free in a specific sense. This theory is borne out in the velocity and pressure plots in fig. 22, noting that convergence of a gradient is typically an order lower than convergence of the function.
Finally, to show that this difference can produce visually striking results, we set up a simulation on the Bob mesh. We start from zero initial conditions. We add inflow at the top of a head that looks like
and an outflow that looks like
We assume a force due to gravity. We compute 200 time steps starting at t = 0 and ending at t = 0.2. We compare the mini element to the Scott-Vogelius element of order k = 3. We note that the former uses 12 velocity DOFs per element while the latter uses 60. We again contrast the behavior for vs .
The results are seen in fig. 23. When , both simulations show reasonable results. We observe that for Scott-Vogelius, the simulation changes dramatically with , which is expected. When is small, the fluid responds slowly to nearby changes in velocity so the inflow and outflows are slow to spread to the inner regions of the geometry. For Scott-Vogelius, we can plainly see that away from the inflow/outflow, the fluid is mainly responding to gravity. However, for the mini element, changing has little qualitative impact. This is a convergence failure and a non-intuitive example of locking.

Fig. 22. 2D/3D Convergence results for velocity and pressure of a stokes simulation using two different elements and two different viscosities. Note that the TH elements consistently underperformed velocity convergence in the low viscosity regime whereas both methods are comparable in the normal regime. Also note that pressure convergence is not impacted.

Fig. 23. Stream lines, seeded in the head, derived from the flow of our stokes simulation at the last time step with different elements and viscosities. We contrast the impact of changing viscosities ( vs ) on two different elements. The Scott Vogelius element correct accounts for the low viscosity whereas the mini element does not. In particular, the low viscosity at low pressure means that the fluid should move mainly due to gravity rather than inflow/outflow velocity, which is manifestly true for Scott-Vogelius but not for the Mini Element. Both produce plausible results for normal viscosity.
8.2 Claim: Finite elements are specified concisely due to automation
See table 2. In particular, we show that we are able to dramatically improve on the SOTA for specifying FEs within systems capable of assembling FE matrices. We do not compare against systems like the symbolic finite elements library as not all of their specifications (e.g., Morley) can be used on multiple domains [Scroggs 2021]. Moreover, our improvements in lines of code come from two of our automations. First, our efforts to automatically deduce transformations by simplifying formulas and symbolically inverting matrices represents non-trivial portions of code counts for many elements. Not only does this portion represent a non-trivial number of lines, but these lines are hard to produce, requiring manual mathematical reasoning. Second, our efforts to build a high-level language for IPTEMs, open in particular to the automation of topological enumeration, also dramatically reduce the lines of code for all elements. This is best shown for Lagrange and FEEC elements: though the transformation is trivial, we still make the specification smaller by relying on topological enumeration and our high-level language for tensor expressions.
8.2.1 Claim: The automation produces optimal implementations of the finite element transformation theory. In [Kirby 2018], a key measure of the cost of using a more complex element is the number of non-zeros in the transformation. Our automations and saved lines of code would not be as useful if the transformations were considerably more expensive. We compare the number of symbolic non-zeros to assess the sparsity of the generated transformations. These counts do not measure compilation, assembly, or solve time; wall-clock comparisons remain necessary to assess runtime performance. We
| Element | ElementForge SLOC | FinAT/FIAT SLOC (Transform) | |
|---|---|---|---|
| Morley | ~10 | 84 | (31) |
| Hermite | ~17 | 88 | (23) |
| Argyris | ~31 | 221 | (117) |
| Bell | ~44 | 138 | (63) |
| (Nédéc (first kind)) + (DG Volume Lagrange) + (Nédéc (second kind)) | ~46 | 534 | (0) |
| Lagrange | ~10 | 80 | (0) |
| Mini | ~17 | 28 | (0) |
Table 2. SLOC to specify all the elements used in our experiments and available in both ElementForge and FinAT, currently the most comprehensive practical system for using different FEs. Note that for our system, Nédéc (first kind), DG Volume Lagrange, and Nédéc (second kind) all share an implementation and so do BDM, so we group these together. If we added at most 10 to 20 lines of code we could also do Raviart-Thomas and Brezzi-Douglas-Marini, which combined require around 200 lines of code in FIAT. This and other variants on FEEC elements could make interesting additional case studies for table 4.
| Element | Transformation NNZ |
|---|---|
| Morley | 12 |
| Hermite | 16 |
| Argyris | 81 |
| Bell | 42 |
| (RT + Nédéc (first kind) + DG Volume Lagrange) + (BDM + Nédéc (second kind)) | O(N) |
| Lagrange | O(N) |
| Mini | O(N) |
Table 3. Transformation DOFs
do this in table 3, where we find that we have the number of non-zeros in matrices computed by hand in the literature. Additionally, this shows that our inversion procedure does not default to a matrix inverse: ElementForge enables the inverse to be computed more like a formula and with the optimal sparsity pattern visible at compile time.
8.3 Claim: Finite element specifications and usage are malleable
To evaluate malleability, we ask: how many extra lines of code are required to change elements? First, to literally add the element in the two simulations where the code changes, we find that the number of lines of code is modest (table 4 and table 5). Similarly, in the case of the FEEC elements, we have a much more succinct implementation, especially for trimmed elements where we more directly translate the math than compared to other systems [Kirby 2004]. Second, we ask how much do programs change when we change elements? The answer is that they do not unless an element requires a different formulation (e.g., the mixed Lagrange method in the biharmonic equation). Compared to other systems, our advantage here lies in our construction of the front end; no other systems that we know of support interpolation into elements such as Hermite, Morley, or Argyris³⁰, but this naturally emerges in our front end. Similarly, ElementForge supports direct enforcement of Dirichlet BCs when possible on these spaces, whereas that is typically a special case in other systems [Pormann 2022].
³⁰See https://www.firedrakeproject.org/interpolation.html
40 • Collin et al.
| Element | Additional LOC |
| Morley | 4 |
| Hermite | 11 |
| Argyris | 11 |
| Bell | 13 |
Table 4. Extra LOCs for biharmonic elements against affine Lagrange
| Element | Additional LOC |
| Mini | 10 |
| CR | 1 |
Table 5. Extra LOCs for Stokes elements against general Lagrange
AI Use Disclosure
The original implementation was written before our use of AI agents. We are now reimplementing the software with AI agents in preparation for public release. We acknowledge the use of generative AI tools in the following ways: creating and reformatting figures, editing text, reformatting tables and listings, literature searches and citation checks, drafting and revising manuscript text, drafting and checking mathematical exposition, general latex debugging, producing scripts to organize data output from our system into a format suitable for bulk processing via Paraview or Matplotlib, producing scripts to control Paraview and Matplotlib on the output data in bulk, and producing scripts to perform bulk operations in Adobe Illustrator.
Acknowledgments
Theadora Fields Collin acknowledges the support of the NSF Graduate Research Fellowship Program. This material is based upon work supported by the Department of Energy, National Nuclear Security Administration under Award Number DE-NA0004266. Further, we graciously acknowledged the support of Intel and NSF PPoSS Grant CCF-2217064; DARPA PROWESS Award HR0011-23-C-0101, NSF SHF Grant CCF-2107244, DoE PSAAP Center DE-NA0003965, DoE SciDAC-5 DE-SC0023116, DARPA SBIR HR001123C0139, DoE DE-NA0004266. Oded Stein is generously supported by a gift from Adobe Inc and graciously acknowledges the support of the NSF award No. 2335493. We acknowledge the support of the following individuals in developing these ideas and also in some cases editing this manuscript: Sofia Chandler-Freed, Eleanor Mast, Ridgway L. Scott, Gordon Kindlmann, David Ham, Robert Kirby (Baylor), Manya Bansal, Caleb Kim, Jaeyeon Won, Mit Kotak, Sina Nabizadeh, Christopher McNally, Jesse Michel, Willow Ahrens, Richard Sollee, Filippo Carloni, Francesco Peverelli, Robert L Van Heyningen, Jaime Peraire, Cuong Nguyen, and many more.
References
Ahmad Abdelfattah, Valeria Barra, Natalie Beams, Jed Brown, Jean-Sylvain Camier, Veselin Dobrev, Yohann Dudouit, Leila Ghaffari, Sebastian Grimberg, Tzancio Kolev, David Medina, Will Pazner, Thilina Ratnayaka, Rezgar Shakeri, Jeremy L Thompson, Stanimire Tomov, and James Wright III. 2023. libCEED User Manual. Zenodo. https://doi.org/10.5281/ZENODO.4302736
Mark Ainsworth and Shuai Jiang. 2022. A Systematic Approach to Constructing Preconditioners for the hp-Version Mass Matrix on Unstructured and Hybrid Finite Element Meshes. SIAM Journal on Scientific Computing 44, 2 (2022), A901–A934. https://doi.org/10.1137/20M1382519
Pierre Alliez, David Cohen-Steiner, Olivier Devillers, Bruno Lévy, and Mathieu Desbrun. 2003. Anisotropic polygonal remeshing. ACM Transactions on Graphics 22, 3 (July 2003), 485–493. https://doi.org/10.1145/882262.882296
Martin Sandve Alnaes and Kent-André Mardal. 2010. On the Efficiency of Symbolic Computations Combined with Code Generation for Finite Element Methods. ACM Trans. Math. Softw. 37, 1, Article 6 (01 2010), 26 pages. https://doi.org/10.1145/1644001.1644007
Martin S. Alnaes, Anders Logg, Kristian B. Olgaard, Marie E. Rognes, and Garth N. Wells. 2014. Unified form language: A domain-specific language for weak formulations of partial differential equations. ACM Trans. Math. Software 40, 2 (February 2014), 1–37. https://doi.org/10.1145/2566630
P.R. Amestoy, A. Buttari, J.-Y. L'Excellent, and T. Mary. 2019. Performance and Scalability of the Block Low-Rank Multifrontal Factorization on Multicore Architectures. ACM Trans. Math. Software 45 (2019), 2:1–2:26. Issue 1.
P.R. Amestoy, I. S. Duff, J. Koster, and J.-Y. L'Excellent. 2001. A Fully Asynchronous Multifrontal Solver Using Distributed Dynamic Scheduling. SIAM J. Matrix Anal. Appl. 23, 1 (2001), 15–41.
R. Anderson, J. Andrej, A. Barker, J. Bramwell, J.-S. Camier, J. Cerveny, V. Dobrev, Y. Dudouit, A. Fisher, Tz. Kolev, W. Pazner, M. Stowell, V. Tomov, I. Akkerman, J. Dahm, D. Medina, and S. Zampini. 2021. MFEM: A Modular Finite Element Methods Library. Computers & Mathematics with Applications 81 (2021), 42–74. https://doi.org/10.1016/j.camwa.2020.06.009
Julian Andrej, Nabil Atallah, Jan-Phillip Bäcker, Jean-Sylvain Camier, Dylan Copeland, Veselin Dobrev, Yohann Dudouit, Tobias Duswald, Brendan Keith, Dohyun Kim, et al. 2024. High-performance finite elements with MFEM. The International Journal of High Performance Computing Applications 38, 5 (2024), 447–467.
Jason Ansel, Edward Yang, Horace He, Natalia Gimelshein, Animesh Jain, Michael Voznesensky, Bin Bao, Peter Bell, David Berard, Evgeni Burovski, Geeta Chauhan, Anjali Chourdia, Will Constable, Alban Desmaison, Zachary DeVito, Elias Ellison, Will Feng, Jiong Gong, Michael Gschwind, Brian Hirsh, Sherlock Huang, Kshitjee Kalambarkar, Laurent Kirsch, Michael Lazos, Mario Lezcano, Yanbo Liang, Jason Liang, Yinghai Lu, C. K. Luk, Bert Maher, Yunjie Pan, Christian Puhrsch, Matthias Reso, Mark Saroufim, Marcos Yukio Siraichi, Helen Suk, Shunting Zhang, Michael Suo, Phil Tillet, Xu Zhao, Eikan Wang, Keren Zhou, Richard Zou, Xiaodong Wang, Ajit Mathews, William Wen, Gregory Chanan, Peng Wu, and Soumith Chintala. 2024. PyTorch 2: Faster Machine Learning Through Dynamic Python Bytecode Transformation and Graph Compilation. In Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2 (La Jolla, CA, USA) (ASPLOS '24). Association for Computing Machinery, New York, NY, USA, 929–947. https://doi.org/10.1145/3620665.3640366
Jeremias Arf and Bernd Simeon. 2021. Structure-Preserving Discretization of the Hessian Complex Based on Spline Spaces. arXiv:2109.05293 [cs, math]
J. H. Argyris, I. Fried, and D. W. Scharpf. 1968. The TUBA Family of Plate Elements for the Matrix Displacement Method. The Aeronautical Journal 72, 692 (August 1968), 701–709.
Daniel Arndt, Wolfgang Bangerth, Denis Davydov, Timo Heister, Luca Heltai, Martin Kronbichler, Matthias Maier, Jean-Paul Pelteter, Bruno Turcksin, and David Wells. 2021. The dealII finite element library: Design, features, and insights. Computers and Mathematics with Applications 81 (January 2021), 407–422. https://doi.org/10.1016/j.camwa.2020.02.022
Douglas Arnold and Gerard Awanou. 2013. Finite Element Differential Forms on Cubical Meshes. Math. Comp. 83, 288 (October 2013), 1551–1570. https://doi.org/10.1090/s0025-5718-2013-02783-4
Douglas Arnold, Richard Falk, and Ragnar Winther. 2010. Finite element exterior calculus: from Hodge theory to numerical stability. Bull. Amer. Math. Soc. 47, 2 (January 2010), 281–354. https://doi.org/10.1090/s0273-0979-10-01278-4
Douglas N Arnold. 2019. Finite Element Exterior Calculus. Society for Industrial & Applied Mathematics, New York, NY.
Douglas N. Arnold, Gerard Awanou, and Ragnar Winther. 2014. Nonconforming Tetrahedral Mixed Finite Elements FOR Elasticity. Mathematical Models and Methods in Applied Sciences 24, 04 (April 2014), 783–796. https://doi.org/10.1142/S021820251350067X
Douglas N. Arnold and Shawn W. Walker. 2020. The Hellan-Herrmann-Johnson Method with Curved Elements. SIAM J. Numer. Anal. 58, 5 (Jan. 2020), 2829–2855. https://doi.org/10.1137/19m1288723
Douglas N. Arnold and Ragnar Winther. 2002. Mixed Finite Elements for Elasticity. Numer. Math. 92, 3 (September 2002), 401–419.
Francis R. A. Aznaran, Patrick E. Farrell, and Robert C. Kirby. 2023. Transformations for Piola-mapped elements. The SMAI Journal of computational mathematics 8 (July 2023), 399–437. https://doi.org/10.5802/smai-jcm.91
Santiago Badia and Francesc Verdugo. 2020. Gridap: An extensible Finite Element toolbox in Julia. Journal of Open Source Software 5, 52 (2020), 2520. https://doi.org/10.21105/joss.02520
Satish Balay, Shrirang Abhyankar, Mark Adams, Jed Brown, Peter Brune, Kris Buschelman, Lisandro Dalcin, Alp Dener, Victor Eijkhout, William Gropp, et al. 2019. PETSc users manual. Argonne National Laboratory.
Igor A Baratta, Joseph P Dean, Jorgen S Dokken, Michal Habera, Jack S Hale, Chris N Richardson, Marie E Rognes, Matthew W Scroggs, Nathan Sime, and Garth N Wells. 2023. DOLFINx: the next generation FEniCS problem solving environment. Zenodo preprint, version 1. https://doi.org/10.5281/zenodo.10447666
Adam W Bargteil and Elaine Cohen. 2014. Animation of deformable bodies with quadratic Bézier finite elements. ACM Transactions on Graphics (TOG) 33, 3 (2014), 1–10.
Adam W. Bargteil, Chris Wojtan, Jessica K. Hodgins, and Greg Turk. 2007. A Finite Element Method for Animating Large Viscoplastic Flow. ACM Trans. Graph. 26, 3 (07 2007), 16–es. https://doi.org/10.1145/1276377.1276397
Kolbein Bell. 1969. A refined triangular plate bending finite element. Internat. J. Numer. Methods Engrg. 1, 1 (1969), 101–122. https://doi.org/10.1002/nme.1620010108
Joseph Benzaken, John A. Evans, and Rasmus Tamstorf. 2024. Constructing Nitsche's Method for Variational Problems. Archives of Computational Methods in Engineering 31, 4 (April 2024), 1867–1896. https://doi.org/10.1007/s11831-023-09953-6
Maximilian Bergbauer, Peter Munch, Wolfgang A. Wall, and Martin Kronbichler. 2025. High-Performance Matrix-Free Unfitted Finite Element Operator Evaluation. SIAM Journal on Scientific Computing 47, 3 (May 2025), B665–B689. https://doi.org/10.1137/24m1653689
Christine Bernardi and Geneviève Raugel. 1985. Analysis of some finite elements for the Stokes problem. Math. Comp. 44, 169 (1985), 71–79. https://doi.org/10.1090/s0025-5718-1985-0771031-7
H. Bhatia, G. Norgard, V. Pascucci, and Peer-Timo Bremer. 2013. The Helmholtz-Hodge Decomposition—a Survey. IEEE Transactions on Visualization and Computer Graphics 19, 8 (August 2013), 1386–1404. https://doi.org/10.1109/tvcg.2012.316
Iwan Boksebeld and Amir Vaxman. 2022. High-Order Directional Fields. ACM Transactions on Graphics 41, 6 (November 2022), 1–17. https://doi.org/10.1145/3550454.3555455
Simon Boyé, Pascal Barla, and Gael Guennebaud. 2012. A Vectorial Solver for Free-Form Vector Gradients. ACM Trans. Graph. 31, 6, Article 173 (11 2012), 9 pages. https://doi.org/10.1145/2366145.2366192
James Bradbury, Roy Frostig, Peter Hawkins, Matthew James Johnson, Chris Leary, Dougal Maclaurin, George Necula, Adam Paszke, Jake VanderPlas, Skye Wanderman-Milne, and Qiao Zhang. 2018. JAX: composable transformations of Python+NumPy programs. Google. http://github.com/jax-ml/jax
Dietrich Braess. 2007. Finite Elements: Theory, Fast Solvers, and Applications in Solid Mechanics. Cambridge University Press, Cambridge, England. https://doi.org/10.1017/cb9780511618635
Christopher Brandt, Leonardo Scandolo, Elmar Eismann, and Klaus Hildebrandt. 2018. Modeling N-Symmetry Vector Fields Using Higher-Order Energies. ACM Trans. Graph. 37, 2, Article 18 (03 2018), 18 pages. https://doi.org/10.1145/3177750
Susanne C. Brenner and L. Ridgway Scott. 2008. The Mathematical Theory of Finite Element Methods. Springer New York, New York City, NY. https://doi.org/10.1007/978-0-387-75934-0
Jed Brown, Ahmad Abdelfattah, Valeria Barra, Natalie Beams, Jean-Sylvain Camier, Veselin Dobrev, Yohann Dudouit, Leila Ghaffari, Tzancio Kolev, David Medina, et al. 2021. libCCEED: Fast algebra for high-order element-based discretizations. Journal of Open Source Software 6, 6 (2021), 2945.
Pablo D. Brubeck. 2026. Automate Zany Basis Transformations, Starting with Morley. FIAT/FinAT source repository, commit 8b2006eb. https://github.com/firedrakeproject/fiat/commit/8b2006eb2260cd02a283a4db0ed528a8b2312c Commit dated 13 July 2026.
Pablo D Brubeck and Patrick E Farrell. 2024. Multigrid solvers for the de Rham complex with optimal complexity in polynomial degree. SIAM Journal on Scientific Computing 46, 3 (2024), A1549–A1573.
Pablo D Brubeck and Robert C Kirby. 2025. FIAT: enabling classical and modern macroelements. arXiv:2501.14599 https://arxiv.org/abs/2501.14599
Pablo D Brubeck, Robert C Kirby, Fabian Laakmann, and Lawrence Mitchell. 2025. FIAT: improving performance and accuracy for high-order finite elements. ACM Trans. Math. Software 51, 3, Article 21 (2025). https://doi.org/10.1145/3748816 arXiv:2408.03565 Preprint first posted in 2024.
Annalisa Buffa and Snorre H. Christiansen. 2005. A Dual Finite Element Complex on the Barycentric Refinement. Comptes Rendus Mathematique 340, 6 (March 2005), 461–464. https://doi.org/10.1016/j.crma.2004.12.022
Yadi Cao, Yunuo Chen, Minchen Li, Yin Yang, Xinxin Zhang, Mridul Anjanayea, and Chenfanjiang Fan. 2022. An Efficient B-Spline Lagrangian/Eulerian Method for Compressible Flow, Shock Waves, and Fracturing Solids. ACM Trans. Graph. 41, 5, Article 169 (05 2022), 13 pages. https://doi.org/10.1145/3519595
Jesse Chan and T. Warburton. 2016a. Orthogonal Bases for Vertex-Mapped Pyramids. SIAM Journal on Scientific Computing 38, 2 (January 2016), A1146–A1170.
Jesse Chan and T. Warburton. 2016b. A Short Note on a Bernstein-Bezier Basis for the Pyramid. SIAM Journal on Scientific Computing 38, 4 (January 2016), A2162–A2172.
Jiong Chen, Hujun Bao, Tianyu Wang, Mathieu Desbrun, and Jin Huang. 2018. Numerical coarsening using discontinuous shape functions. ACM Transactions on Graphics (TOG) 37, 4 (2018), 1–12.
Jiong Chen, Max Budninskiy, Houman Owhadi, Hujun Bao, Jin Huang, and Mathieu Desbrun. 2019. Material-adapted refinable basis functions for elasticity simulation. ACM Transactions on Graphics (TOG) 38, 6 (2019), 1–15.
Philippe G. Ciarlet. 1978. Interpolation error estimates for the reduced Hsieh-Clough-Tocher triangle. Math. Comp. 32, 142 (1978), 335–344. https://doi.org/10.1090/s0025-5718-1978-0482249-1
Philippe G. Ciarlet. 2002. Finite Element Method for Elliptic Problems. Society for Industrial and Applied Mathematics, USA.
Patrick Ciarlet Jr., Charles F. Dunkl, and Stefan A. Sauter. 2017. A Family of Crouzeix-Raviart Finite Elements in 3D. arXiv:1703.03224 [math]
Pascal Clausen, Martin Wicke, Jonathan R. Shewchuk, and James F. O'Brien. 2013. Simulating Liquids and Solid-Liquid Interactions with Lagrangian Meshes. ACM Trans. Graph. 32, 2, Article 17 (04 2013), 15 pages. https://doi.org/10.1145/2451236.2451243
Bernardo Cockburn and Guosheng Fu. 2017. A Systematic Construction of Finite Element Commuting Exact Sequences. SIAM J. Numer. Anal. 55, 4 (Jan. 2017), 1650–1688. https://doi.org/10.1137/16m1073352
Bernardo Cockburn and Wei Feng Qiu. 2014. Commuting diagrams for the TNT elements on cubes. Math. Comp. 83 (2014), 603–633. https://doi.org/10.1090/S0025-5718-2013-02729-9
Teodoro Collin, Gordon Kindlmann, and L. Ridgway Scott. 2019. An Adaptive Savitsky-Golay Filter for Smoothing Finite Element Computation. arXiv:1911.00790
Theadora Fields Collin. 2025. Automated Finite Elements. S.M. thesis. Massachusetts Institute of Technology. https://hdl.handle.net/1721.1/164593
Theadora Fields Collin. 2026. Intermediate Abstractions for Global Finite Elements. Presentation at PDESoft 2026, TU Wien, Austria. https://pdesoft2026.conf.tuwien.ac.at/program/13 July 2026. Conference program.
Theadora Fields Collin, Gilbert Bernstein, Oded Stein, and Saman Amarasinghe. 2026. Grassmann: The Coordinate-Independent Linear Algebra Programming Language. (2026). Manuscript.
Theadora Fields Collin, Oded Stein, Gilbert Bernstein, and Saman Amarasinghe. 2024. A Programming Language for Coordinate Free Linear Algebra. Presentation at PDEsoft 2024, Cambridge, UK. https://2024.pdesoft.org/talks/a-programming-language-for-coordinate-free-linear-algebra/ 1 July 2024. Conference abstract and program.
Patrick Cousot and Radhia Cousot. 1977. Abstract interpretation: a unified lattice model for static analysis of programs by construction or approximation of fixpoints. In Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages. 238–252.
Bram Custers and Amir Vaxman. 2020. Subdivision Directional Fields. ACM Trans. Graph. 39, 2, Article 11 (02 2020), 20 pages. https://doi.org/10.1145/3375659
Cesare Davini. 2003. Gaussian Curvature and Babuska's Paradox in the Theory of Plates. Springer Milan, Milan, Italy, 67–87. https://doi.org/10.1007/978-88-470-2231-7_6
Andreas Dedner, Robert Klöfkorn, Martin Nolte, and Mario Ohlberger. 2012. Dune-Fem: A General Purpose Discretization Toolbox for Parallel and Adaptive Scientific Computing. Springer Berlin Heidelberg, Berlin, Germany, 17–31. https://doi.org/10.1007/978-3-642-28589-9_2
Mathieu Desbrun, Eva Kanso, and Yiying Tong. 2006. Discrete Differential Forms for Computational Modeling. In ACM SIGGRAPH 2006 Courses (Boston, Massachusetts) (SIGGRAPH '06). Association for Computing Machinery, New York, NY, USA, 39–54. https://doi.org/10.1145/1185657.1185665
David Steven Dummit and Richard M Foote. 2004. Abstract algebra, 3rd edition. John Wiley & Sons, Nashville, TN.
Essex Edwards and Robert Bridson. 2014. Detailed water with coarse grids: Combining surface meshes and adaptive discontinuous galerkin. ACM Transactions on Graphics (TOG) 33, 4 (2014), 1–9.
Elliot English and Robert Bridson. 2008. Animating Developable Surfaces Using Nonconforming Elements. ACM Trans. Graph. 27, 3 (08 2008), 1–5. https://doi.org/10.1145/1360612.1360665
P. E. Farrell, D. A. Ham, S. W. Funke, and M. E. Rognes. 2013. Automated Derivation of the Adjoint of High-Level Transient Finite Element Programs. SIAM Journal on Scientific Computing 35, 4 (January 2013), C369–C393. https://doi.org/10.1137/120873558
Patrick E. Farrell, Robert C. Kirby, and Jorge Marchena-Menéndez. 2021a. Irkoms: Automating Runge-Kutta Time-Stepping for Finite Element Methods. ACM Trans. Math. Softw. 47, 4, Article 30 (09 2021), 26 pages. https://doi.org/10.1145/3466168
Patrick E Farrell, Lawrence Mitchell, L Ridgway Scott, and Florian Wechsung. 2021b. A Reynolds-robust preconditioner for the Scott-Vogelius discretization of the stationary incompressible Navier-Stokes equations. The SMAJ journal of computational mathematics 7 (2021), 75–96.
José Antonio Fernández-Fernández, Fabian Löschner, Lukas Westhofen, Andreas Longva, and Jan Bender. 2025. Symx: Energy-based simulation from symbolic expressions. ACM Transactions on Graphics 45, 1 (2025), 1–19.
NM Ferraro, SC Jardin, and X Luo. 2010. Essential boundary conditions with straight C1 finite elements in curved domains. Technical Report. Princeton Plasma Physics Lab.
42 • Collin et al.
FIAT/FInAT developers. 2026a. Physically Mapped Elements and the Automatic Basis Transformation. Source code, revision 6d156383. https://github.com/firedrakeproject/fiat/blob/6d15638307aa3b2990bbc6fcb0d4794aa3be90/finat/physically_mapped.py Implementation merged in pull request 259, 28 October 2026.
FIAT/FInAT developers. 2026b. Zany Transformation Development Notebook. Historical repository file zany_claude.md, revision c29035c3. https://github.com/firedrakeproject/fiat/blob/c29035c3493a14f3a330f74205b715a680a69b3/zany_claude.md Includes the discussion of support and block elimination in lines 675–727.
Paul Fischer, Stefan Kerkemeier, Misun Min, Yu-Hsiang Lan, Malachi Phillips, Thilina Rathnayake, Elia Merzari, Ananias Tomboulides, Ali Karakus, Noel Chalmers, and Tim Warburton. 2022. NekRS, a GPU-accelerated spectral element Navier–Stokes solver. Parallel Comput. 114 (December 2022), 102982. https://doi.org/10.1016/j.parco.2022.102982
Mihai Francu, Arni Asgeirsson, Kenny Erleben, and Mads J. L. Rønnow. 2021. Locking-Proof Tetrahedra. ACM Transactions on Graphics 40, 2 (April 2021), 1–17. https://doi.org/10.1145/3444949
Roy Frostig, Matthew James Johnson, and Chris Leary. 2018. Compiling machine learning programs via high-level tracing. In SysML conference 2018. https://cs.stanford.edu/~rfrostig/pubs/jax-mlsys2018.pdf
Chuyuan Fu, Qi Guo, Theodore Gast, Chenfanfu Jiang, and Joseph Teran. 2017. A polynomial particle-in-cell method. ACM Transactions on Graphics 36, 6 (Nov. 2017), 1–12. https://doi.org/10.1145/3130800.3130878
Yoshihiko Futamura. 1999. Partial Evaluation of Computation Process-An Approach to a Compiler-Compiler. Higher-Order and Symbolic Computation 12, 4 (Dec. 1999), 381–391. https://doi.org/10.1023/a:1010095604496
Peter Gangl, Kevin Sturm, Michael Neunteufel, and Joachim Schöberl. 2020. Fully and Semi-Automated Shape Differentiation in NGSolve. arXiv:2004.06783
Paolo Gatto. 2022. Mathematical Foundations of Finite Elements and Iterative Solvers. Society for Industrial and Applied Mathematics, Philadelphia, PA. https://doi.org/10.1137/1.9781611977097
Thomas H. Gibson, Lawrence Mitchell, David A. Ham, and Colin J. Cotter. 2020. Slate: extending Firedrake's domain-specific abstraction to hybridized solvers for geoscience and beyond. Geoscientific Model Development 13, 2 (February 2020), 735–761. https://doi.org/10.5194/gmd-13-735-2020
Andrew Gillette, Tyler Kloeckorn, and Victoria Sanders. 2019. Computational Serendipity and Tensor Product Finite Element Differential Forms. The SMAI journal of computational mathematics 5 (March 2019), 1–21.
Benedikt Gräfle. 2022. Optimal multilevel adaptive FEM for the Argyris element. Computer Methods in Applied Mechanics and Engineering 399 (September 2022), 115352. https://doi.org/10.1016/j.cma.2022.115352
Jan Grošelj and Marjeta Knez. 2021. A construction of edge B-spline functions for a C1 polynomial spline on two triangles and its application to Argyris type splines. Computers & Mathematics with Applications 99 (2021), 329–344.
Anthony Gruber and Eugenio Aulisa. 2020. Computational P-Willmore Flow with Conformal Penalty. ACM Trans. Graph. 39, 5, Article 161 (08 2020), 16 pages. https://doi.org/10.1145/3369387
Tom Gustafsson and G. McBain. 2020. Scikit-Fem: A Python Package for Finite Element Assembly. Journal of Open Source Software 5, 52 (August 2020), 2369. https://doi.org/10.21105/joss.02369
Johnny Guzmán and Michael Neilan. 2018. Inf-Sup Stable Finite Elements on Barycentric Refinements Producing Divergence-Free Approximations in Arbitrary Dimensions. SIAM J. Numer. Anal. 56, 5 (January 2018), 2826–2844. https://doi.org/10.1137/17M1153467
Johnny Guzmán and L Ridgway Scott. 2019. The Scott-Vogelius finite elements revisited. Math. Comp. 88, 316 (2019), 515–529.
Johnny Guzmán, Dmitriy Leykekhman, and Michael Neilan. 2011. A family of non-conforming elements and the analysis of Nitsche's method for a singularly perturbed fourth order problem. Calcolo 49, 2 (Sept. 2011), 95–125. https://doi.org/10.1007/s10092-011-0047-8
Christian Hafner, Christian Schumacher, Espen Knoop, Thomas Auzinger, Bernd Bickel, and Moritz Bächer. 2019. X-CAD: optimizing CAD models with extended finite elements. ACM Transactions on Graphics (TOG) 38, 6 (2019), 1–15.
D Ham, M Homolya, M Lange, R Kirby, and L Mitchell. 2025. FlnAT/FlnAT: a smarter library of finite elements. https://zenodo.org/doi/10.5281/zenodo.597531
David A Ham, Paul HJ Kelly, Lawrence Mitchell, Colin J Cotter, Robert C Kirby, Koki Sagiyama, Nacime Bouziani, Sophia Vorderwuelbecke, Thomas J Gregory, Jack Betteridge, et al. 2023. Firedrake user manual.
F. Hecht. 2012. New development in freefem++. Journal of Numerical Mathematics 20, 3–4 (January 2012), 251–266. https://doi.org/10.1515/jnum-2012-0013
Michael Holst and Ari Stern. 2012. Geometric Variational Crimes: Hilbert Complexes, Finite Element Exterior Calculus, and Problems on Hypersurfaces. Foundations of Computational Mathematics 12, 3 (April 2012), 263–293. https://doi.org/10.1007/s10208-012-9119-7
Miklós Homolya and David A Ham. 2016. A parallel edge orientation algorithm for quadrilateral meshes. SIAM Journal on Scientific Computing 38, 5 (2016), 548–561.
Miklós Homolya, Robert C Kirby, and David A Ham. 2017. Exposing and exploiting structure: optimal code generation for high-order finite element methods. arXiv:1711.02473 https://arxiv.org/abs/1711.02473
Jun Hu, Ting Lin, and Qingyu Wu. 2021. A Construction of Conforming Finite Element Spaces in Any Dimension. arXiv:2103.14924 [cs, math]
Jun Hu and Shangyou Zhang. 2014. The Minimal Conforming Finite Element Spaces on Rectangular Grids. Math. Comp. 84, 292 (August 2014), 563–579.
Yuanning Hu, Yu Fang, Ziheng Ge, Ziyin Qu, Yixin Zhu, Andre Pradhana, and Chenfanfu Jiang. 2018. A moving least squares material point method with displacement discontinuity and two-way rigid body coupling. ACM Transactions on Graphics (TOG) 37, 4 (2018), 1–14.
Jin Huang, Yiying Tong, Hongyu Wei, and Hujun Bao. 2011. Boundary Aligned Smooth 3D Cross-Frame Field. ACM Trans. Graph. 30, 6 (12 2011), 1–8. https://doi.org/10.1145/2070781.2024177
Hughes. 2000. The Finite Element Method. Dover Publications, Mineola, NY.
Geoffrey Irving, Craig Schroeder, and Ronald Fedikw. 2007. Volume Conserving Finite Element Simulations of Deformable Models. ACM Trans. Graph. 26, 3 (07 2007), 13–es. https://doi.org/10.1145/1276377.1276394
Alec Jacobson, Elif Tosun, Olga Sorkine, and Denis Zorin. 2010. Mixed Finite Elements for Variational Surface Modeling. Computer Graphics Forum 29, 5 (July 2010), 1565–1574. https://doi.org/10.1111/j.1467-8659.2010.01765.x
Wenzel Jakob, Adam Arbree, Jonathan T. Moon, Kavita Bala, and Steve Marschner. 2010. A Radiative Transfer Framework for Rendering Materials with Anisotropic Structure. ACM Trans. Graph. 29, 4, Article 53 (07 2010), 13 pages. https://doi.org/10.1145/1778765.1778790
Hrvojje Jasak, Aleksandar Jemcov, Zeljko Tukovic, et al. 2007. OpenFOAM: A C++ library for complex physics simulations.
Chenfanfu Jiang, Craig Schroeder, Joseph Teran, Alexey Stomakhin, and Andrew Selle. 2016. The material point method for simulating continuum materials. In Acm siggraph 2016 courses. 1–52.
David Kamensky. 2021. Open-source immersogeometric analysis of fluid–structure interaction using FEniCS and IGAr. Computers and Mathematics with Applications 81 (Jan. 2021), 634–648. https://doi.org/10.1016/j.camwa.2020.01.023
David Kamensky. 2023. Code Generation for Isogeometric and Immersed Analysis: A Review of Methods and Applications. Springer International Publishing, Cham, 191–221. https://doi.org/10.1007/978-3-031-36942-1_7
George Karniadakis and Spencer J. Sherwin. 1999. Spectral/Hp Element Methods for CFD. Oxford University Press, New York.
Peter Kaufmann, Sebastian Martin, Mario Botsch, Eitan Grinspun, and Markus Gross. 2009b. Enrichment textures for detailed cutting of shells. In ACM SIGGRAPH 2009 Papers (New Orleans, Louisiana) (SIGGRAPH '09). Association for Computing Machinery, New York, NY, USA, Article 50, 10 pages. https://doi.org/10.1145/1576246.1531356
Peter Kaufmann, Sebastian Martin, Mario Botsch, and Markus Gross. 2009a. Flexible simulation of deformable models using discontinuous Galerkin FEM. Graphical Models 71, 4 (2009), 153–167.
Michael Kazhdan and Hugues Hoppe. 2013. Screened Poisson Surface Reconstruction. ACM Trans. Graph. 32, 3, Article 29 (07 2013), 13 pages. https://doi.org/10.1145/2487228.2487237
Dominic Kempf, René Heß, Steffen Müthing, and Peter Bastian. 2020. Automatic Code Generation for High-performance Discontinuous Galerkin Methods on Modern Architectures. ACM Trans. Math. Software 47, 1 (December 2020), 1–31. https://doi.org/10.1145/3424144
Lily Kharevych, Patrick Mullen, Houman Owhadi, and Mathieu Desbrun. 2009. Numerical coarsening of inhomogeneous elastic materials. ACM Transactions on graphics (TOG) 28, 3 (2009), 1–8.
Robert C. Kirby. 2004. Algorithm 839: FIAT, a New Paradigm for Computing Finite Element Basis Functions. ACM Trans. Math. Softw. 30, 4 (12 2004), 502–516. https://doi.org/10.1145/1039813.1039820
Robert C. Kirby. 2011. Fast simplicial Finite Element Algorithms Using Bernstein Polynomials. Numer. Math. 117, 4 (April 2011), 631–652.
Robert C. Kirby. 2018. A General Approach to Transforming Finite Elements. The SMAI journal of computational mathematics 4 (April 2018), 197–224.
Robert C. Kirby and Anders Logg. 2006. A Compiler for Variational Forms. ACM Trans. Math. Softw. 32, 3 (09 2006), 417–444. https://doi.org/10.1145/1163641.1163644
Robert C. Kirby and Lawrence Mitchell. 2018. Solver Composition Across the PDE/-Linear Algebra Barrier. SIAM Journal on Scientific Computing 40, 1 (January 2018), C76–C98. https://doi.org/10.1137/17m1133208
Robert C. Kirby and Lawrence Mitchell. 2019. Code Generation for Generally Mapped Finite Elements. ACM Trans. Math. Software 45, 4 (December 2019), 1–23. https://doi.org/10.1145/3361745
Dan Koschier, Jan Bender, and Nils Thuerey. 2017. Robust extended finite elements for complex cutting of deformables. ACM Transactions on Graphics (TOG) 36, 4 (2017), 1–13.
Martin Kronbichler and Katharina Kormann. 2012. A generic interface for parallel cell-based finite element operator application. Computers & Fluids 63 (2012), 135–147.
Martin Kronbichler, Katharina Kormann, Niklas Fehn, Peter Munch, and Julius Witte. 2019. A Hermite-like Basis for Faster Matrix-Free Evaluation of Interior Penalty Discontinuous Galerkin Operators. arXiv:1907.08492 [cs, math]
Qiqin Le, Yitong Deng, Jiamu Bu, Bo Zhu, and Tao Du. 2023. Second-Order Finite Elements for Deformable Surfaces. In SIGGRAPH Asia 2023 Conference Papers (, Sydney, NSW, Australia). (SA '23) Association for Computing Machinery, New York, NY, USA, Article 113, 10 pages. https://doi.org/10.1145/3610548.3618186
John M. Lee. 2012. Introduction to Smooth Manifolds. Springer New York, New York City, NY. https://doi.org/10.1007/978-1-4419-9982-5
Paul Leopardi and Ari Stern. 2016. The abstract Hodge-Dirac operator and its stable discretization. SIAM J. Numer. Anal. 54, 6 (2016), 3258–3279.
Dan Li, Chunmei Wang, and Junping Wang. 2022. Weak Galerkin methods based Morley elements on general polytopal partitions. arXiv:2210.17518
Ruotian Ling, Jin Huang, Bert Jüttler, Feng Sun, Hujun Bao, and Wenping Wang. 2015. Spectral Quadrangulation with Feature Curve Alignment and Element Size Control. ACM Trans. Graph. 34, 1, Article 11 (12 2015), 11 pages. https://doi.org/10.1145/2653476
Alexander Linke, Gunar Matthies, and Lutz Tobiska. 2008. Non-nested multi-grid solvers for mixed divergence-free Scott-Vogelius discretizations. Computing 83, 2 (2008), 87–107.
Alexander Linke and Leo G. Rebholz. 2019. Pressure-induced locking in mixed methods for time-dependent Navier-Stokes equations. J. Comput. Phys. 388 (July 2019), 350–356. https://doi.org/10.1016/j.jcp.2019.03.010
Anders Logg, Kent-Andre Mardal, and Garth Wells (Eds.). 2012. Automated solution of differential equations by the finite element method: The FEniCS Book. Lecture Notes in Computational Science and Engineering, Vol. 84. Springer, Berlin, Germany. https://doi.org/10.1007/978-3-642-23099-8
Andreas Longva, Fabian Löschner, Tassilo Kugelstadt, José Antonio Fernández-Fernández, and Jan Bender. 2020. Higher-Order Finite Elements for Embedded Simulation. ACM Trans. Graph. 39, 6, Article 181 (11 2020), 14 pages. https://doi.org/10.1145/3414685.3417853
Steve A. Maas, Benjamin J. Ellis, Gerard A. Ateshian, and Jeffrey A. Weiss. 2012. FEBio: Finite Elements for Biomechanics. Journal of Biomechanical Engineering 134, 1 (January 2012), 011005. https://doi.org/10.1115/1.4005694
Kent Andre Mardal, Xue-Cheng Tai, and Ragnar Winther. 2002. A Robust Finite Element Method for Darcy-Stokes Flow. SIAM J. Numer. Anal. 40, 5 (January 2002), 1605–1631.
India Marsden. 2026. firedrakeproject/fuse: 2026.8.1. Zenodo. Software release. https://doi.org/10.5281/zenodo.21931355 Version 2026.8.1, released 14 August 2026.
India Marsden, David A. Ham, and Patrick E. Farrell. 2023. Redefining the Finite Element with Implementation in Mind. FEniCS 2023, Book of Abstracts, p. 17. https://fenicsproject.org/assets/extra/fenics2023/BookOfAbstracts.pdf Conference abstract, Pula (Cagliari), Italy, 14–16 June 2023.
Sebastian Martin, Peter Kaufmann, Mario Botsch, Martin Wicke, and Markus Gross. 2008. Polyhedral finite elements using harmonic basis functions. In Computer graphics forum, Vol. 27. Wiley Online Library, 1521–1529.
Gunar Matthies and Lutz Tobiska. 2005. Inf-Sup Stable Non-Conforming Finite Elements of Arbitrary Order on Triangles. Numer. Math. 102, 2 (December 2005), 293–309.
Mark Meyer, Mathieu Desbrun, Peter Schröder, and Alan H. Barr. 2003. Discrete Differential-Geometry Operators for Triangulated 2-Manifolds. In Visualization and Mathematics III, Hans-Christian Hege and Konrad Polthier (Eds.). Springer Berlin Heidelberg, Berlin, Heidelberg, 35–57.
Johannes Mezger, Bernhard Thomaszewski, Simon Pabst, and Wolfgang Straßer. 2008. Interactive physically-based shape editing. In Proceedings of the 2008 ACM symposium on Solid and physical modeling. 79–89.
Mahsa Mirzargar, Jennifer K. Ryan, and Robert M. Kirby. 2015. Smoothness-Increasing Accuracy-Conservering (SIAC) Filtering and Quasi-Interpolation: A Unified View. Journal of Scientific Computing 67, 1 (Aug. 2015), 237–261. https://doi.org/10.1007/s10915-015-0081-9
David Moxey, Chris D. Cantwell, Yan Bao, Andrea Cassinelli, Giacomo Castiglioni, Sehun Chun, Emilia Juda, Ehsan Kazemi, Kilian Lackhove, Julian Marcon, Gianmarco Mengaldo, Douglas Serson, Michael Turner, Hui Xu, Joaquim Peiró, Robert M. Kirby, and Spencer J. Sherwin. 2020. Nektar++: Enhancing the capability and application of high-fidelity spectral element methods. Computer Physics Communications 249 (April 2020), 107110. https://doi.org/10.1016/j.cpc.2019.107110
Mohammad Sina Nabizadeh, Ritoban Roy-Chowdhury, Hang Yin, Ravi Ramamoorthi, and Albert Chern. 2024. Fluid Implicit Particles on Coadjoint Orbits. ACM Trans. Graph. 43, 6, Article 270 (Nov. 2024), 38 pages. https://doi.org/10.1145/3687970
Michael Neunteufel. 2021. Mixed Finite Element Methods For Nonlinear Continuum Mechanics And Shells. Ph. D. Dissertation. TU Wien.
Nilima Nigam and Joel Phillips. 2010. High-Order Finite Elements on Pyramids: Approximation Spaces, Unisolvency and Exactness. arXiv:math/0610206
Kristian B Ølgaard, Anders Logg, and Garth N Wells. 2009. Automated code generation for discontinuous Galerkin methods. SIAM Journal on Scientific Computing 31, 2 (2009), 849–864.
Alberto Paganini and Florian Wechsung. 2021. Fireshape: a shape optimization toolbox for Firedrake. Structural and Multidisciplinary Optimization 63, 5 (February 2021), 2553–2569. https://doi.org/10.1007/s00158-020-02813-y
Logah Perumal. 2018. A Brief Review on Polygonal/Polyhedral Finite Element Methods. Mathematical Problems in Engineering 2018, 1 (2018), 5792372. https://doi.org/10.1155/2018/5792372
Ulrich Pinkall and Konrad Polthier. 1993. Computing Discrete Minimal Surfaces and Their Conjugates. Exp. Math. 2 (1993), 15–36. https://api.semanticscholar.org/CorpusID:10068306
Konstantin Poelke. 2017. Hodge-type decompositions for piecewise constant vector fields on simplicial surfaces and solids with boundary. Ph.D. Dissertation. FU Berlin.
Konstantin Poelke and Konrad Polthier. 2016. Boundary-aware hodge decompositions for piecewise constant vector fields. Computer-Aided Design 78 (September 2016), 126–136. https://doi.org/10.1016/j.cad.2016.05.004
Maik Pormann. 2022. C1 Finite Elements for Dune. Master's thesis. TU Dresden.
Hendrik Ranocha, Michael Schlotte-Lakemper, Jesse Chan, Andrés M. Rueda-Ramírez, Andrew R. Winters, Florian Hindenland, and Gregory J. Gasser. 2023. Efficient Implementation of Modern Entropy Stable and Kinetic Energy Preserving Discontinuous Galerkin Methods for Conservation Laws. ACM Trans. Math. Software 49, 4 (Dec. 2023), 1–30. https://doi.org/10.1145/3625559
Florian Rathgeber, David A. Ham, Lawrence Mitchell, Michael Lange, Fabio Luporini, Andrew T. T. Mcrae, Georgehe-Teodor Bercea, Graham R. Markall, and Paul H. J. Kelly. 2016. Firedrake: Automating the Finite Element Method by Composing Abstractions. ACM Trans. Math. Softw. 43, 3, Article 24 (12 2016), 27 pages. https://doi.org/10.1145/2998441
Tullio Regge. 1961. General relativity without coordinates. Il Nuovo Cimento 19, 3 (1961), 558–571. https://doi.org/10.1007/BF02733251
Olivier Rémillard and Paul G. Kry. 2013. Embedded Thin Shells for Wrinkle Simulation. ACM Trans. Graph. 32, 4, Article 50 (07 2013), 8 pages. https://doi.org/10.1145/2461912.2462018
Yves Renard and Konstantinos Poulios. 2020. GetFEM: Automated FE Modeling of Multiphysics Problems Based on a Generic Weak Form Language. ACM Trans. Math. Software 47, 1 (December 2020), 1–31. https://doi.org/10.1145/3412849
Marie E. Rognes, Robert C. Kirby, and Anders Logg. 2010. Efficient Assembly of H(div) and H(curl) Conforming Finite Elements. SIAM Journal on Scientific Computing 31, 6 (2010), 4130–4151. https://doi.org/10.1137/08073901X
Francis P Russell and Paul HJ Kelly. 2013. Optimized code generation for finite element local assembly using symbolic manipulation. ACM Transactions on Mathematical Software (TOMS) 39, 4 (2013), 1–29.
Teseo Schneider, Jérémie Dumas, Xifeng Gao, Mario Botsch, Daniele Panozzo, and Denis Zorin. 2019. Poly-Spline Finite-Element Method. ACM Trans. Graph. 38, 3, Article 19 (03 2019), 16 pages. https://doi.org/10.1145/3313797
Teseo Schneider, Yixin Hu, Xifeng Gao, Jérémie Dumas, Denis Zorin, and Daniele Panozzo. 2022. A Large-Scale Comparison of Tetrahedral and Hexahedral Elements for Solving Elliptic PDEs with the Finite Element Method. ACM Trans. Graph. 41, 3, Article 23 (03 2022), 14 pages. https://doi.org/10.1145/3508372
Joachim Schöberl. 2014. C++ 11 implementation of finite elements in NGSolve. Institute for analysis and scientific computing, Vienna University of Technology 30 (2014).
Matthew Scroggs. 2021. Symfem: a symbolic finite element definition library. Journal of Open Source Software 6, 4 (August 2021), 3556. https://doi.org/10.21105/joss.03556
Matthew W. Scroggs. 2023. DefElement: an encyclopedia of finite element definitions. Poster presented at FEniCS 2023, Cagliari, Italy. https://doi.org/10.6084/m9.figshare.23294939.v1
Matthew W. Scroggs, Jørgen S. Dokken, Chris N. Richardson, and Garth N. Wells. 2022. Construction of Arbitrary Order Finite Element Degree-of-Freedom Maps on Polygonal and Polyhedral Cell Meshes. ACM Trans. Math. Softw. 48, 2, Article 18 (05 2022), 23 pages. https://doi.org/10.1145/3524456
Matthew W. Scroggs and Garth N. Wells. 2026. Algorithm XXXX: Computation of Finite Element Degree-of-Freedom Transformation Matrices. https://doi.org/10.48550/arXiv:2607.08172 arXiv:2607.08172 [math.NA] Version 1, 9 July 2026.
J.N. Shadid, H.K. Moffat, S.A. Hutchinson, G.L. Hennigan, K.D. Devine, and A.G. Salinger. 1996. MP Salsa: a finite element computer program for reacting flow problems. Part 1-theoretical development. Office of Scientific and Technical Information (OSTI), Oak Ridge, TN. https://doi.org/10.2172/237399
Alvin Shi, Haomiao Wu, and Theodore Kim. 2025. Hyper-Dimensional Deformation Simulation. In Proceedings of the Special Interest Group on Computer Graphics and Interactive Techniques Conference Conference Papers. 1–11.
Fun Shing Sin, Daniel Schroeder, and Jernej Barbić. 2013. Vega: non-linear FEM deformable object simulator. In Computer Graphics Forum, Vol. 32. Wiley Online Library, 36–48.
Collin et al.
Adam Sky, Michael Neunteufel, Jack S. Hale, and Andreas Zilian. 2023. A Reissner-Mindlin plate formulation using symmetric Hu-Zhang elements via polytopal transformations. Computer Methods in Applied Mechanics and Engineering 416 (November 2023), 116291. https://doi.org/10.1016/j.cma.2023.116291
Breannan Smith, Fernando De Goes, and Theodore Kim. 2018. Stable Neo-Hookean Flesh Simulation. ACM Trans. Graph. 37, 2, Article 12 (03 2018), 15 pages. https://doi.org/10.1145/3180491
Oded Stein, Eitan Grinspun, Alec Jacobson, and Max Wardetzky. 2019. A mixed finite element method with piecewise linear elements for the biharmonic equation on surfaces. https://doi.org/10.48550/ARXIV.1911.08029
Oded Stein, Eitan Grinspun, Max Wardetzky, and Alec Jacobson. 2018. Natural Boundary Conditions for Smoothing in Geometry Processing. ACM Transactions on Graphics 37, 2 (April 2018), 1–13. https://doi.org/10.1145/3186564
Oded Stein, Alec Jacobson, Max Wardetzky, and Eitan Grinspun. 2020. A Smoothness Energy without Boundary Distortion for Curved Surfaces. ACM Transactions on Graphics 39, 3 (March 2020), 1–17. https://doi.org/10.1145/3377406
Zhe Su, Yiying Tong, and Guowei Wei. 2024a. Hodge decomposition of vector fields in Cartesian grids. In SIGGRAPH Asia 2024 Conference Papers (SA 24). ACM, New York City, NY, 1–10. https://doi.org/10.1145/3680528.3687602
Zhe Su, Yiying Tong, and Guo-Wei Wei. 2024b. Topology-preserving Hodge Decomposition in the Eulerian Representation. arXiv:2408.14356
Tianjiao Sun, Lawrence Mitchell, Kaushik Kulkarni, Andreas Klöckner, David A Ham, and Paul HJ Kelly. 2020. A study of vectorization for matrix-free finite element methods. The International Journal of High Performance Computing Applications 34, 6 (July 2020), 629–644. https://doi.org/10.1177/1094342020945005
Oliver J. Sutton. 2016. The virtual element method in 50 lines of MATLAB. Numerical Algorithms 75, 4 (December 2016), 1141–1159. https://doi.org/10.1007/s11075-016-0235-3
Xue-Cheng Tai and Ragnar Winther. 2006. A Discrete de Rham Complex with Enhanced Smoothness. CALCOLO 43, 4 (December 2006), 287–306.
Yiying Tong, Santiago Lombeyda, Anil N Hirani, and Mathieu Desbrun. 2003. Discrete multiscale vector field decomposition. ACM transactions on graphics (TOG) 22, 3 (2003), 445–452.
Michael R. Tonks, Derek Gaston, Paul C. Millett, David Andrs, and Paul Talbot. 2012. An object-oriented finite element framework for multiphysics phase field simulations. Computational Materials Science 51, 1 (January 2012), 20–29. https://doi.org/10.1016/j.commatsci.2011.07.028
Lloyd N. Trefethen. 2019. Approximation Theory and Approximation Practice, Extended Edition. Society for Industrial and Applied Mathematics, Philadelphia, PA. https://doi.org/10.1137/1.9781611975949
K. Vacek and P. Sváček. 2024. Finite Element Approximation of Fluid Structure Interaction Using Taylor-Hood and Scott-Vogelius Elements. In Topical Problems of Fluid Mechanics 2024 (TPFM). Institute of Thermomechanics of the Czech Academy of Sciences; CTU in Prague Faculty of Mech. Engineering Dept. Tech. Mathematics, Prague, Czech Republic, 232–239. https://doi.10.14311/tpfm.2024.031
Francese Verdugo and Santiago Badia. 2022. The software design of Gridap: a finite element package based on the Julia JIT compiler. Computer Physics Communications 276 (2022), 108341.
Ke Wang, Weiwei, Yiying Tong, Mathieu Desbrun, and Peter Schröder. 2006. Edge Subdivision Schemes and the Construction of Smooth Vector Fields. ACM Trans. Graph. 25, 3 (07 2006), 1041–1048. https://doi.org/10.1145/1141911.1141991
Ming Wang and Jinchao Xu. 2012. Minimal Finite Element Spaces for 2m-Th-Order Partial Differential Equations in . Math. Comp. 82, 281 (June 2012), 25–43.
Stephanie Wang, Mohammad Sina Nabizadeh, and Albert Chern. 2023. Exterior Calculus in Graphics: Course Notes for a SIGGRAPH 2023 Course. In ACM SIGGRAPH 2023 Courses (Los Angeles, California) (SIGGRAPH '23). Association for Computing Machinery, New York, NY, USA, Article 8, 126 pages. https://doi.org/10.1145/3587423.3595525
Daniel Weber, Johannes Mueller-Roemer, Christian Altenhofen, André Stork, and Dieter Fellner. 2015. Deformation simulation using cubic finite elements and efficient p-multigrid methods. Computers & graphics 53 (2015), 185–195.
Sergei Winitzki. 2010. Linear Algebra Via Exterior Products. Lulu.com, Barking, England.
Shuonan Wu and Jinchao Xu. 2018. Nonconforming Finite Element Spaces for 2m-Th Order Partial Differential Equations on . Math. Comp. 82, 281 (June 2012), 25–43.
Comp. 88, 316 (May 2018), 531–551. https://doi.org/10.1090/mcom/3361
Rundong Zhao, Mathieu Desbrun, Guo-Wei Wei, and Yiying Tong. 2019. 3D hodge decompositions of edge- and face-based vector fields. ACM Transactions on Graphics 38, 6 (November 2019), 1–13. https://doi.org/10.1145/3355089.3356546
A Alternative Analysis of Finite Element Transformations
We factor the generalized Vandermonde matrix of eq. (26) to separate local DOFs, coordinate changes, and the reference basis. This gives an alternative construction of the symbolic matrix in section 6.2
and identifies structure that the inversion routine in section 6.2.3 can exploit. With , the factorization is , and the basis transformation remains .
Definition A.1 (Dual Basis Cover). Suppose is a finite element. Choose a basis for each tensor power of the tangent space used by the derivatives, and a basis of covectors on V. A derivative-evaluation functional has the form
where and . A dual basis cover is a finite collection of these functionals whose restrictions span and which includes all derivative and value components at each point and derivative order it uses. The collection may be redundant.
For the affine charts used here, the chain rule maps a complete block of derivatives at a physical point to derivatives of the same order at its reference preimage. Corresponding covers can therefore be constructed from the evaluation or quadrature points used by the DOFs. Quadrature representations must be exact on the finite element space for the identities below to hold exactly. For non-affine maps, lower derivative orders may also be needed.
Theorem A.1.1 (Factorization through dual basis covers). Assume the isomorphism condition of theorem 6.1.1. Let and be physical and reference dual basis covers. Choose matrices , , and satisfying
Then the matrices defined in eqs. (26) and (27) satisfy
PROOF. The spanning properties of the covers and the fact that is a basis ensure that the three representations exist. Applying to the first identity and substituting the other two gives
Evaluate this identity on reference basis function . Since , the result is
The relation from eq. (27) completes the proof.
H: physical DOF weights. Each row of H combines physical derivative samples into one physical DOF. It contains evaluation or quadrature weights, contractions with normals or tangents, and any integration measure factors in the DOF specification. This is essentially a representation of a DOF in terms of samples that are easy to pushforward, but the coefficients dependent on the geometry. Thus H exposes the local sampling pattern without constructing physical nodal basis functions.
F: local coordinate changes. For corresponding complete derivative blocks under an affine map, F is block diagonal by evaluation point and derivative order: These blocks depend on the Jacobian, its inverse, and the tensor transformation of the field values. For scalar first derivatives in Cartesian coordinates, the block is ; scalar value blocks are identities. This component is the change of coordinates via pullbacks.
G: reference sampling and polynomial identities. The entries are directly computable as
For fixed reference points and component bases, G is geometry-independent and can be precomputed once, using the reference basis already constructed in listing 11. It records dependencies among the possibly redundant samples on P. A derivative sample can depend on several reference DOFs, so G need not be sparse merely because each sample is local. Its zero pattern must come from evaluating or analyzing the reference basis.
Consequences for sparsity and inversion. The product is read from right to left: G samples the reference basis, F converts those samples to physical components, and H combines them into physical DOFs. A sufficient condition for is that for every pair . Thus the nonzero patterns of the factors give a conservative dependency pattern for C: an upper bound on its possible nonzero entries, or equivalently a lower bound on its sparsity in the sense of guaranteed zeros. This is a useful structural guarantee that explains why those entries vanish. Running the construction and symbolically simplifying HF and HFG can reveal a more precise sparsity pattern by exposing cancellations that the factor patterns alone do not capture.
If an ordering gives a block lower-triangular C with invertible diagonal blocks, then is block lower triangular and is block upper triangular.
An alternative construction algorithm. The factorization suggests the following organization of the computation:
(1) Construct corresponding covers from the DOF samples, completing derivative and value components. On the fixed reference element, tabulate G and establish its zeros symbolically or from exact reference data, rather than from floating-point roundoff alone.
(2) Compile H from the physical DOF specifications and build the local blocks of F from the symbolic map. Reuse each transformed sample wherever it occurs in multiple DOFs.
(3) Assemble C = HFG by contracting these blocks with the precomputed reference data. Use the factor patterns to skip known zeros, then simplify the remaining entries and identify any valid block-triangular ordering.
(4) Solve symbolically, using the recursive block procedure of section 6.2.3 where applicable. Return to match listing 11, or transpose it to obtain the paper's basis matrix P.
This constructs the same matrix as directly evaluating every physical DOF on every mapped reference basis function, but this directly exposes a useful conservative sparsity pattern.
A limitation of this organization is that it constructs the pullback blocks in F independently of how the DOFs use them through H. Both factors depend on the same geometry, and the contractions in H can simplify or cancel transformations in F. Constructing the complete blocks of F can therefore introduce intermediate expressions that disappear in HF. Simplification in step 3 can recover these cancellations, but only after those expressions have been constructed. Our implemented route compiles the complete DOF expressions using the coordinate-independent tensor and basis machinery of sections 5.1.3 and 5.1.4 and our related Grassmann work [Collin et al. 2026], allowing the pullbacks to be simplified in the context of their use. The factorization remains useful for explaining and bounding sparsity, even when constructing its factors separately is not the best way to generate the formulas.
B Sample Change Of Basis Rules
We now sketch our implementation for changeOfBasis (basisSrc: Basis, basisDst: Basis, env: Optional[Env]) -> Tuple[Formula, Formula]: We implement this with rules to convert every function to and from the standard basis: toStandardBasis (basis: Basis, env: Optional[Env]) -> Tuple[Formula, Formula]: A critical example of such a rule is the rule for converting a dual basis to the standard basis:
def dualToStandard(basis: Basis, env: Optional[Env]) => Tuple[Formula, Formula]: space = spaceOfBasis(basis) stdBasis = standardBasis(space) if basis == stdBasis: return (eyeFormula(space), eyeFormula(space)) else: primalOf = basis.primal (to, from) = toStandardBasis(primalOf, env) return (from.T, to.T)
Listing 26. A rule convert the dual basis of a space to the standard basis of that space.
This rule shows the virtue of our design: since we already have the inverse on hand, we can avoid recomputing or losing some clever way to do so. For example, a raw basis requires a recursive call to our representation function and an inverse:
def rawToStandard(basis: Basis, env: Optional[Env]) -> Tuple[Formula, Formula]: space = spaceOfBasis(basis) stdBasis = standardBasis(space) # raw basis can't be std basis vectorsOfBasis = basis.vectors formulas = [representTensor(vec, stdBasis, env) for vec in vectorsOfBasis] # make a formula that produced a formula for np.hstack on the formulas from = hstackFormula(formulas) # make a formula that produces the inverse of the output of the previous formula: to = inverseFormula(from) return (from, to)
Listing 27. A rule convert the dual basis of a space to the standard basis of that space.
Other rules such as image basis or primal bases can also require inverses or other symbolic additions in formulas. Some rules like the tensor product though are quiet obvious and nice:
def prodToStandard(basis: Basis, env: Optional[Env]) -> Tuple[Formula, Formula]:
Collin et al.
space = spaceOfBasis(basis)
stdBasis = standardBasis(space)
if basis == stdBasis:
return (eyeFormula(space), eyeFormula(space))
else:
productends = basis.bases
tos = []
froms = []
for b in productends:
(to, from) = toStandardBasis(b, env)
tos.append(to)
froms.append(from)
# kronocker product of inverse is inverse of productands:
return (kronFormula(tos), kronFormula(froms))
Listing 28. A rule convert the tensor product of a space to the standard basis of that space.
C Implementation Aspects of SVAO and assembly
We now sketch an interface for the field/basis input and an implementation for assembly. We show assembly is parametric over elements in a practical way by sketching how to implement the section mesh field sequence with an element.
C.0.1 (Sectioned) Mesh Field (Sequence) Interface A sketch of our interfaces is in listing 29. To satisfy the preconditions of both definitions (definition 7.5 and definition 7.6), we supply the requires topological type and specification of the mesh vector space with a field type (line 1) as well as a schema (line 40). To facilitate quadrature degree estimation in assembly, the interface optionally supplies the degree of the field outputs as a function of the degree of the inputs (line 5). To satisfy the actual functions available in both definitions, we have a tabulation function (line 42 and line 29). The tabulation function takes care to understand because it operates symbolically i.e, it generates code that performs the functionality of the numerical version. We present the numerical version first. The tabulation function in numerical mode (line 7) consumes positions in a chart (world and reference space), a chart given numerically, a number of requested derivatives, the specification of the mesh entity corresponding to the chart as well as any mesh entities contained therein, and a desired basis for the output values. The tabulation function can also consume global arrays or functions that might be needed to define the field or sequence of fields. For a sectioned mesh field, the tabulation function returns a collection of outputs indexed to the parts of the section relating to the queried mesh entity (line 31). The numerical version essentially satisfies the practical existence of the functions available on some mesh entity. The symbolic version of tabulate can be understood as a staging or symbolic execution [Futamura 1999] of the numerical version: the symbolic version is simply the numerical one that runs on symbolic inputs to produce symbolic outputs. For example, the array inputs and outputs to the numerical tabulate are replaced with formulas while the mesh entities will be replaced with symbols for mesh entities in the context that the mesh field is used, mainly assembly.
1 class CoreData:
2 field: fieldType
3 topType: TopologicalType
4
5 def degree(x: int | Tuple[int, ...]) -> Optional[int | Tuple[int, ...]]: ...
6
7 class NumericFieldQuery:
8 refPoints: NDArray
9 worldPoints: NDArray
10 chart: Tuple[NDArray, NDArray],
11 derivativise: int,
12 meshEntity: MeshEntity,
13 subMeshEntities: List[MeshEntities],
14 basis: Optional[Basis] = None
15 context: dict[str, Array | Any] = {}
16
17 class SymbolicFieldQuery:
18 refPoints: Formula
19 # as before but symbolic variables
20
21 class MeshField:
22 # compile time data:
23 core: CoreData
24 basis: Optional[SectionedMeshField]
25 # runtime data:
26 sectionData: Optional[Tuple[Section, Array]]
27 globalData: dict[str, Array | Any ]
28
29 def tabulate(query: NumericFieldQuery | SymbolicFieldQuery) -> Tuple[NDArray | Formula, Basis]: ...
30
31 class BasisOut:
32 commonFormulas: List[Tuple[str, Formula]]
33 sectionedOut: dict[Tuple[Any, MeshEntity, MeshEntity], NDArray | Formula]
34 basis: Basis
35
36 class SectionedMeshField:
37 # compile time data:
38 core: CoreData
39 L: List[Any]
40 schema: dict[Any, Tuple[TopologicalType, TopologicalType]]
41
42 def tabulate(query: NumericFieldQuery | SymbolicFieldQuery) -> BasisOut: ...
Listing 29. Data provided by a global field at code generation time.
C.0.2 Elements and Sectioned Mesh Field Sequences To be usable, an element simply needs to implement a sectioned mesh field sequence, which is almost trivial to do automatically with our current infrastructure. The primary topological type comes directly from the underlying domain of the element while the field and degree comes directly from the polynomial space. The schema can be created by direct inspect of the DOFs/IPTEMs as they define and their integration and output types define the schema. Finally, tabulate can be implemented by using the polynomial space to tabulate values on the reference space and then by using the Vandermonde matrix to transform those values to values for the DOFs on the given chart.
C.0.3 Assembly Code Generation Our assembly function generates code for given a combination of mesh class, IPTEMs, and global fields (modulo runtime data). The generated assembly function uses arrays associated to meshes and fields to build a tensor, the SVAO. Our assembly function caches the generated function and figures out how to wire runtime data (e.g. arrays of vertices or arrays for mesh relationships) into function arguments. We sketch the code generation of the function, which reuses our existing infrastructure, mainly the compilation of IPTEM. We sketch our code generation as five phases: preparation for multiple compilation, multiple compilation, analysis of multiple compilation, code generation, and meta data recording.
the topological types involved
(1) Preparation for IPTEM compilation: Based on the IPTEM, we build a system of charts and fields that models the execution of parts of (29). In particular, we determine the largest integration chart and generate all charts within that chart; this similar to the first stage of vandermonde matrix construction (listing 11). Then for every field with a chart smaller than the largest integration chart, we introduce another symbolic chart to model neighboring geometries that a field could be sampled from. Each field input is then associated to at most two charts; we make up to two symbolic field inputs (listing 8) that are placeholders to record how the fields from different charts are used.
(2) IPTEM Compilation: IPTEMs are paired with all the generated charts and fields to produce formulas. Local reductions are applied. We make sure the integrals are compiled as loops and not evaluated. We just use the compiler of section 5, specifically listing 7.
(3) Analysis of IPTEM Compilation Based on the resulting formula, we can extract a wide variety of meta-data to generate our code. In particular, we can use the place holder fields to figure out how to query input fields i.e., at what points, geometries (one within the largest integration chart or one outside), and derivatives. We can also construct a schema for the output section and check if there are multiple values for any outputs. Finally, we can determine based on the used charts and fields that mesh/section queries/relationships are needed.
(4) Code Generation: The inner most loop of our generated code are the multiply compiled IPTEMs. The function that assembly runs is built out around from them. We sketch this structure in listing 30. First, these are lifted to operate on incoming groups of basis functions (line 17 - line 19). Second, these are lifted to operate on particular geometric entities, which means place them within an outer loop over all integration charts and possibly inner loops from intersecting geometries on other charts (line 10 - line 17). Within these loops, appropriate geometric information must be constructed to supply charts and then queries to fields must be created using the tabulate interface (lines 11, 12, 15 and 16). After the IPTEMs and within the geometric loops, the values of the IPTEMs must be added to the COO values and the compile times schema should be used to create appropriately ordered indices from queries to runtime meshes/sections (line 20-line 22). Finally, global arguments from meshes/fields/sections complete the function, modulo some metadata that allows meshes/fields to be unpacked for these (line 6).
(5) Meta Data: Global reduction information is not used in the assembly function; instead, the global reduction is attached to the SVAO output as a default reduction. The output section is another global argument, but the schema metadata for the output section is used in the function that calls the generated code to construction a section if one is not present already.
3 4 5 6
meshVertices, meshRelationships, nTopCell, inputFieldSections, inputFieldArrays, inputFieldOtherArgs,
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
) -> Tuple[Array, Array]: # BC00 coo_indices = [] coo_vals = []
for topCell in range(nTopCell): # Setup geometry for topCell and subcells # Setup fields at quadrature points on this cell for otherCell1 in ...: for otherCell2 in ...: # Setup fields at quadrature points # Setup geometry for otherCells for dof0 in ...: for dof1 in ...: vals = # IPTEM quadrature loops indices = ... coo_vals.append(vals) coo_indices.append(indices)
Return all blocks of values and indices
Listing 30. A visual depiction of how the various intermediate outputs of our global code generation process are stitched together to produce a global kernel function.
D Details on Global Operations
D.1 SVAO Operations
We now outline the interface to each operation in turn. For reductions, we support reduction over the non-specified axes and the reduction can be chosen up to indices from the specified axes. The defaults are inferred from the IPTEM's default reductions, which can be overridden in the global case (see fig. 11). Via the metadata for reductions and IPTEMs included, we support (when possible) automatic conversion to a global field (e.g., for interpolation) or automatic conversion to a scalar or dense vector or sparse matrix. The interfaces are summarized in listing 31. Slicing functionality is similar to slicing in NumPy except that dimensions are sliced with our global constructions: sub-sections, sub-meshes, list of IPTEM, or indices for local linear inputs. Slicing can simply extract a slice, but the non-zeros of a slice can also be set. As a convenience, we offer an option to set the diagonal over two axes, useful for boundary conditions. Slicing is detailed in listing 32. Finally, we offer a where-functionality that allows us to construct subsections, sub-meshes or just lists of indices. The interface is detailed in listing 33. As a final addendum, we note that users can extract the output section and dimension information, which is how we expect users to get such information. This is detailed in listing 34.
1 # Reduction optionally using indices and/or the number of non-zeros in the reduction region. 2 Reducer = Callable[[NDArray], NDArray] | Callable[[int, NDArray], NDArray] | Callable[[NDArray, NDArray], NDArray] | Callable[[int, NDArray, NDArray], NDArray] 3 4 def reduce(ao: AssemblyOutput, axes: Optional[List[str]] = None, reducer: Optional[Reducer] = None) -> AssemblyOutput: ... 5 def asScalar(ao: AssemblyOutput) -> Optional[float]: ... 6 def asDenseVector(ao: AssemblyOutput) -> Optional[NDArray]: ... 7 def asScipySparseMatrix(ao : AssemblyOutput, format: str = "coo") -> AssemblyOutput: ...
Listing 31. Reduction Interfaces
1 def assemble(outSectionArrays, 2 meshTopologyArrays,
48 • Collin et al.

Fig. 24. Overall Global Work Flow
2 sliceIndex = List[IPTEM] | SubSection | SubMesh | NDArray | IPTEM | int
3
4 def slice(ao: AssemblyOutput, dimensions: List[str], subsets: List[sliceIndex]) -> AssemblyOutput
5
6 Setter = Zero | flat | Callable[[NDArray, NDArray, NDArray], NDArray] | AssemblyOutput
7 # The second to last option takes slice indices, current values of the slice, and the non-zeros of the slice.
8 # The last option must have been sliced on the appropriate dimensions with the same subsets.
9
10 def setSlice(ao: AssemblyOutput, dimensions: List[str], subsets: List[sliceIndex], setter: Setter = Zero) -> AssemblyOutput: ...
11
12 def setDiagonal(ao: AssemblyOutput, dimension1: str, dimension2: str, subset1: sliceIndex, subset2: sliceIndex, val: float | NDArray) -> AssemblyOutput: ...
Listing 32. Slice Interfaces
1 sliceIndex = List[IPTEM] | SubSection | SubMesh | NDArray | IPTEM | int
2
3 FilterTy = allZero | allNonZero | Callable[[int, NDArray, NDArray], bool]
4
5 def where(ao: AssemblyOutput, filter: Optional[FilterTy] = None) -> sliceIndex: ...
Listing 33. Where Interfaces
1 def shape(ao: AssemblyOutput, dim: str) -> int: ...
2
3 def outSection(ao: AssemblyOutput) -> Section: ...
Listing 34. Metadata Interfaces
D.2 Overall User Workflow
We depict an overall user workflow in fig. 24. As stated previously, the idea is to start with a few bespoke objects and then use IPTEMs and assembly to progressively build others that various post-processing operations convert to more objects to build or post-process further global objects. In this version, we also suggest how this would interact with a full pipeline, involving solvers and other external user code.
D.3 Sub-Meshes and Sub-Sections
Meshes and sections have subsets, representing sub meshes (including boundaries) and subspaces. These are simple to define and our main focus is on constructing subsets, as this is where our generality shines.
Definition D.1 (Sub-Mesh). Given a mesh , a sub-mesh is simply some other mesh with and .
We note that this is differently from simply a subset of mesh:
Definition D.2 (Mesh Subset). Given a mesh , a mesh subset is simply a subset .
For sections, sub-sections are like mesh subsets:
Definition D.3 (Sub-Section). Suppose we have a mesh and a schema , generating a section . A sub-section is simply a subset of .
Sub-sections and sub-meshes can be constructed in a variety of ways, showcasing how various global aspects of the system come together. We depict the situation in fig. 25. Sub-meshes and sub-sections can be constructed from external data or the special case of the topological boundary constructed from the relationships between mesh entities. Critically, a sub-mesh can be propagated to a sub-section:
Definition D.4 (Propagation). Given a sub-mesh and a section , the propagation of the sub-mesh to a sub-section is given by
This simply extracts the portion of the section where the entities are on the sub-mesh; this captures the usual boundary basis functions of an FE space. However, critically, we can also go the other way sometimes. If we have a schema where is injective, then any section over can be converted into a sub-mesh.
Definition D.5 (Submersion). Given a subset of a section where is injective, we can define a subset mesh via first defining a subset via:
and then we can define a sub-mesh as the smallest mesh such that . We call this sub-mesh a submersion.
This little bit of topological ingenuity allows all sorts of data to be transported to sub-meshes, such as using Lagrange elements to identify a boundary. Finally, assembled outputs with a given section can be used with a predicate to filter a section or sub-section, via a where constructed to be discussed in appendix D.1. Additionally, we note that subsections and sub-meshes can be trivially combined with boolean operations, including and/or/complement, as they are simply masks. We now proceed to discuss the assembled outputs, the runtime output of generated code, which can be used to create these sub-meshes via filtering or global fields using reductions. We will see that these can also be sliced and filtered via sub-meshes and subsections, facilitating the construction of many algorithms, such as elimination of boundary DOFs.
Extensible Programmatic Specification of Finite Element Methods • 49

Fig. 25. Mechanisms for constructing sub-meshes and sub-sections
E Permutations and FEM
By permutations, we mean permutations of vertices in a mesh. Reasoning about permutations is a core issue in mesh data structures. In the FEM literature, [Scroggs et al. 2022] gave the most concise explanation for the impact of permutations of mesh data on the implementation of elements. We summarize here and our solution is a programmatic version of their solution.
E.0.0.1 Core Problem Suppose we have two triangles , each parametrized in terms of a reference triangle via maps . The edge, can be parametrized in terms of a reference edge in either triangle: . Both reference edges admit parameterization , which leads to two different parameterizations of the via . Since our computations are not parameterization invariant, this choice matters and so can lead to inconsistent results. For example, a DOF computed with an edge integral might depending on the choice of .
E.0.0.2 Core Solution Thankfully, there is a third parameterization of : since our vertices are globally ordered, we can pick a . This is a global orientation for . Further, based on the ordering of the vertices in , we can compute so that . These are local orientations. We need to adjust everything we do by to ensure we get correct answers. Thankfully, we do have one useful identity to help adjust some calculations: . Thus, for some calculations, we can ignore the permutation and adjust later based on the local orientations. Since there are finitely many options for local orientations, this amounts to computing and applying a finite list of corrections to some calculations.
E.0.0.3 Outline We divide the rest of this section into infrastructure for modeling permutations in our system and then the applications of actual corrections to ensure correct results. Though this work is an appendix, we wish to stress that it was where most of the bugs occurred.
E.1 Modeling Permutations
We now sketch the infrastructure to model permutations in our system.
E.1.0.1 Permutations, Topological Types, and Charts We must characterize permutations and how they relate to charts to solve the above problem. We first consider permutations of an object of a given topological type. Our grammar for topological types (fig. 10) limits the types of permutations we need to consider. Given a Simplex(), we obviously need to consider all permutations of the vertices . Given a Product(), we can consider the symmetries of each as . We can also see that there are ways to arrange these. This leads to a semi-direct product of with . One can check this reproduces the group as a semi-direct product of with . Thus, the inductive structure of our topological types induces a structure for the permutations. Given a chart (definition 3.8), we add meta-data to encode if we wish to permute the vertices of in terms of an element of the permutation group of the associated topological type.
E.1.0.2 Permutations and IPTEM Compilation Given an IPTEM, we can compute all the chart/topological types that it depends on. This follow immediately from the grammar (fig. 9 and fig. 11). Thus, when we compile IPTEMs, we can optionally supply a permutation for each chart input.
E.1.0.3 Permutations and Meshes Our meshes (definition 7.1) store a global ordering on vertices . Given any with , we have an ordering of the vertices of in induced by the isomorphism from to the standard entity (definition 7.1). The orientation of in is the permutation of the vertices ordered according to that puts them into their global order. Our meshes by default store the orientations of all entities with respect to the top level entities. We can compute the others on demand.
E.2 Applying Permutations
We now sketch the infrastructure to apply permutations in our system.
E.2.0.1 Permutations and Elements We follow [Scroggs et al. 2022] when we modify elements to deal with permutations. When we tabulate basis function values or compute Vandermonde matrices, we don't permute vertices. These interfaces don't care about permutations and we assume the ordering induced by whatever charts are passed in. Instead we separately apply a correction for permutations that allows those calculations to still occur symbolic once per reference element. We use the infrastructure of section 6 and the above to compute the corrections.
Orientation corrections are computed once per element as a mapping from DOFs and potential permutations of entities in a reference element to rows of an adjustment matrix that adjust the DOFs in terms of other other DOFs. To compute the corrections, for each DOF/IPTEM, we pre-compute how different combinations of permutations impact the DOF in terms of other DOF: following our infrastructure in section 6, we compute (numerically) Vandermonde matrices for every combination of permutations of charts of the reference element that a DOF depends on and extract the results.
50 • Collin et al.
We note that in cases where the topological type representing the domain of an element is not the top level element in a mesh, we must also consider permutations of this and that these must be propagated to the polynomial space. This is accounted or because our field protocol (listing 8) takes charts to define the geometries. Since we are computing Vandermonde, we note that this is close to computing pullback matrices on permutation adjustments, but that this logic does not hold when permutations of multiple mesh entities impact a DOF. A better way to think about computing correction is this: we figure out how to write a basis function given certain permutation assumptions as a linear combination of other basis functions on the reference element. This is the classic interpretation of Vandermonde matrices.
E.2.0.2 Permutations and Assembly Permutations impact our general assembly code generation (appendix C.0.3) in two ways. First, when we generate code to query elements, our implementation of listing 29 for elements must use the pre-computed permutation information to adjust sample basis function values. Second, when we setup geometries in listing 30, we must actually setup reference geometries and geometries permuted according to global orientations. The reference geometries and permutation meta-data go to sampled fields while the IPTEMs are assembled using the permuted geometries/charts. In essence, when we sample fields, we expect to adjust them after doing reference calculations but when we actually compute an IPTEM we wish to do so in world space directly and so we just directly adjust the vertices that we patch in.
F IPTEM Default Arguments
Our pointwise tensor expressions and integrated pointwise tensor expressions can have default arguments. Default arguments non-trivially aid the specification of elements, but they do requiring handling across multiple levels of our system. The advantages can be seen through section 8.1.1 and section 8.1.2. In both, element specifications are simplified via a recursive specification of basis functions wherein new DOF depend on primal basis functions, which we represent by allowing elements to provide access to the kth basis function and allowing this basis function to be supplied as a default argument. In the case of section 8.1.1, a true specification of the DOFs requires some way to use average characteristic length : derivative DOFs must be weighted by this quantity in massive simulations as otherwise the condition number of the mass matrix varies too much with the mesh. We handle this with default arguments too: we can expression this quantity via a few simple integrated pointwise tensor expressions that use each other as default arguments. We find this to be quite elegant: a quantity that is typically built in to other systems can emerge naturally. On the other hand, this does require some plumbing.
F.0.0.1 Interface Our external interface is a simple modification to fig. 9: field arguments can have defaults. The default can be another IPTEM (a zero degree field whose integration and output types allow the implementation of listing 8 given appropriate charts). The default can also be anything that implements listing 8. For example,
we extend elements to provide an implementation of listing 8 given a request for a kth basis function; internally, they simply generate the code/formulas they would to be sampled on a given chart in assembly and then extract the kth row from this.
F.0.0.2 IPTEM Compilation To handle default arguments, IPTEM compilation does not require much modification. Moreover, the simplest approach is the best: we simply compile PTEM ignoring default arguments, treating them as unknown variables, and then query the fields for formulas to substitute in when we integrate. This does require some book keeping for quadrature points, bases, and charts. This path works for reasoning about elements: generating Vandermonde matrices, reference space tabulations of field values, and generating permutation matrices. Additionally, we can optionally postpone the query and substitution step so that global assembly can treat default arguments slightly differently.
F.0.0.3 Global Assembly Global assembly handles default arguments mostly with plumbing.
Global assembly must handle default arguments that appear in DOFs used to define a space as well in the IPTEM representing operators. Thus, global assembly code generation must gather all the default arguments at the start of compilation. Global assembly handles the two types of default arguments separately. For fields, global assembly just needs some additional bookkeeping to query the fields and substitute the code in before the necessary calculations. Thus global assembly just uses the IPTEM compilation path with additional bookkeeping. For IPTEM arguments, global assembly acts recursively: global assembly generates code to assemble IPTEMs that are default arguments, applies the default reductions (including global ones), and then supplies the reduced SAVO for the IPTEMs as mesh fields. To do this, global assembly code gen simply leaves the default arguments as non-linear input arguments and then at runtime global assembly provides default arguments assembled constructed by calling global assembly recursively. By handling IPTEM defaults via a runtime and code gen separation, IPTEM defaults can cached between assembly calls.
G Additional IPTEM syntax in Python
In our introduction to tensor expressions (fig. 4 and the examples (section 2), we slowly introduced a Python embedding of our language for IPTEMs. We now gather some of the details that might be unclear, in terms of semantics and implementation. There are several topics like this that we gather here: tracing, indexing operations, data inside charts, and exterior calculus.
G.0.0.1 Tracing We utilize tracing [Frostig et al. 2018] to implement our DSL. Tracing, most notably utilized in Jax[Bradbury et al. 2018] and PyTorch [Ansel et al. 2024], is a technique to embed a DSL in a language. In short, ordinary code is used to produce AST for a DSL by running the code on specialized tracing values whose operations are overloaded to produce AST instead of normal program values. We utilize this technique with decorators such as @pointwise OR @pointwiseEval OR @pointwiseIntegral. These use Python's inspect functionality to find the field and chart types, construct appropriate field and chart tracing values, and run the function on these tracing values to extract an appropriate IPTEM expression.
Characteristic mesh length is the ratio of a triangle volume to permitter; the average of this quantity means that at an edge or vertex we average the characteristic length incident to an entity
To make our system more flexible, we could retrace under certain circumstances, such as different Euclidean dimensions, so that users could specialize IPTEMs to these circumstances.
G.0.0.2 (I)PTEM meta data such as reductions, integration, and storage To actually construct (I)PTEMs, we provide three decorators: @pointwise, @pointwiseEval, and @pointwiseIntegral. Consequently, these decorators must also supply metadata in fig. 11 and fig. 9. We supply integration domains and barycentric coordinates directly to the decorator as required arguments. For reductions, we offer a variety of keyword arguments and further array of defaults. In particular, reductions are assumed to be applied over charts by default unless overridden and reductions can be supplied via the built-in one or via python code conforming to the interface used in global reductions (). Finally, storage can be overridden via a simple keyword argument to the decorator, storeAt=ChartType.
G.0.0.3 PTEM: Chart interface Our extensions to the tensor expression language in fig. 9 are reflected in a more Pythonic way in the implementation. In particular, chart values expose methods, c. CT, c. T, c. Rk for the tangent space, cotangent space, and Euclidean space. As a convince, we also provide c.P and c.E to project or embed between (co)tangent and (co)Euclidean spaces. Thanks to tracing these can stand into both as conveniences. The chart also exposes c. tangentVector, c. cotangentVector, c. normalVector, and c. conormalVector. These match up to fig. 9 by having the first chart value being c. Similarly, the spatial position, X, is attached to any chart argument, via c.x. Lastly, we support chartOf as a utility for any tensor expression in an (I)PTEM that provides the unique chart associated to an expression if it exists; this avoids unnecessary chart arguments.
G.0.0.4 PTEM: Field interface Our expression of fields suffers a bit in the Python interface. Via fig. 9, we have a field at the point x via field access and we have derivatives. With a field argument f, we support field access with some number of derivatives via with k = 0 being the plain value. We also unadorned or for a derivative as well as for general tensor expressions including .
G.0.0.5 Indexing Operations and other overloads Within our Pythonic embedding of the IPTEM language, we allow indexing of tensors to take on several meanings. We aim to balance a coordinate independent representation with convenience. For example, for any vector in a space built purely from direct sums, tensor products, dual spaces, and Euclidean spaces, our system allows standard indexing because such spaces in oru system always operate in an inner product that is the dot Euclidean dot product. On the other hand, for other spaces, we do not allow the standard Pythonic syntax for indexing of tensors. Instead, for all other indexing, we only support non-standard indexing of the form for a fixed integer ; our system allows this as a hack to access the coefficient of some tensor in th standard basis entry. We would like to remove this in our system and only use it for constructions like the Koszul null space specification (line 19) where we need DOFs that together zero a whole tensor. We believe we can remove this by allowing more generalized DOFs that output tensors, but we decided that having this hack might be convenient if one really needs it. This would also
simplify away the need for stdEuclideanBasis (space), an iterator over vectors forming the standard basis for a space built purely from direct sums, tensor products, dual spaces, and Euclidean spaces.
In addition to indexing, we overload the standard Pythonic binary operations as much as possible. We support + as sum, * as tensor product for spaces, vectors, and basis, | as direct sum for spaces, vectors, and basis. We also allow ** for tensor power and ^ for direct sum power.
G.0.0.6 Exterior Calculus Since exterior calculus is fundamental to many types of physical modeling [Wang et al. 2023], we provide users with helpers to make using it easy. Since we use tracing to implement our DSL, these are nothing more than Python functions that construct tensor expressions that can be used in IPTEMs. And these functions are quite simple since it is not hard to embed them. First, we define Symmeterize (v), which implements tensor symmetrization for a tensor v in a tensor product space. Due to tracing, we can pattern match on the space of v to construct the correct expression. With this, we can define Lambda (formDeg, ct=None, space=None) as the Kernel of Symmeterize (v) where v is assumed to be in either a given space or the cotangent space of a chart of a given chart or chart type. Then, antiSymmeterize (v) is simply the projection to the kernel of the symmetrization map determined by the space of v. Like with Symmeterize, we can define Wedge (v1,v2,...) via taking their tensor product, flattening the product with reshape and then applying antiSymmeterize to the result. For associativity of forms to hold, tracing must be used to find the involved form degrees and insert a correction factor (see [Winitzki 2010] for details). We can also define interiorEval for values in a Lambda space of a dual space via Embed to expose the dual space, Eval, and finally antiSymmeterize i.e. Project. Finally, the Hodge start can be implemented by inverting the maps and and then defining . The way to think of this is that so given a particular x, we gain a vector and we wish to finds its image in . Using Inverse and Abstract makes this possible up to two important details that tracing allows us to patch up: the standard inner product on k forms induced by our language is the desired inner product up a scaling factor involving the factorials of the k forms (requiring us to detect the form degree and insert them) and the volume form must be specified in terms of the corrected form inner product. Again, we follow [Winitzki 2010] in this development of forms.
H Analytical Solutions for the Hodge Decomposition
First, we consider a flat annulus of outer radius 2 and inner radius 1. We decompose the vector field:
The analytical form of the Hodge decomposition is known. Set and . Then we can write the decomposition via
52 • Collin et al.
and
and
and
and finally,
Second, we consider a cylinder of radius 1 and height 1. We further specify that this is a manifold with a metric inherited from . To write this down with clarity, we use two bits of notation. We utilize cylindrical coordinates, , and Cartesian, , simultaneously. We also utilize an orthonormal frame for the tangent space via
and
Then the vector field
has a decomposition as follows:
and
and
and
and finally we can infer eta from the rest.
I Software Release
Several components of our software stack are publicly available:
-
polyarray, an intermediate representation combining symbolic and numerical array computations: https://github.com/wraith1995/polyarray.
-
PyAB (PyArrayBackend), an array intermediate representation with NumPy and PyTorch code generation: https://github.com/wraith1995/PyArrayBackend.
-
Grassmann, a Python-embedded language for coordinate-free linear and multilinear algebra that compiles to array code: https://github.com/wraith1995/Grassmann.
We are working on preparing the remaining components of ElementForge for public release.