The matrices appearing in (23), (24), and (25) can be calculated analytically in each triangle and accumulated on the triangle vertices. The matrices have a simple form locally in each triangle. In each triangle, introduce a local numbering of the vertices labeled in a counter clockwise order. The side segments are labeled by their opposite vertex,
and so on in cyclic order, or
where the permutation symbol if the values of the indices are in ascending order or a cyclic permutation, = -1, if the indices are in descending order or a cyclic permutation, or = 0, if any two indices have the same value.
The triangle area is given by
The basis functions can be expressed as
To calculate the matrices, we need integrals of basis functions over the triangle, which are
The contribution to the mass matrix from a single triangle, is
To calculate the stiffness matrix and Poisson bracket tensor, we need the gradients of the basis functions, which are constant in each triangle, and from (28) are given by
This immediately yields the the contribution to the stiffness matrix from a single triangle,
The contribution in a triangle to the Poisson bracket tensor is given by
which is independent of
The local matrices are assembled globally by summing the contribution of each triangle which shares a given vertex i.
It is convenient to consider a diagonalized form of the mass matrix. The lumped mass matrix is formed by subtracting all the off diagonal matrix elements in each row and adding them to the diagonal,
where a(i) is the label of a triangle having vertex i. Its value, from (29), is one third the area of the triangles surrounding the vertex.
Using the lumped mass, the finite element discretization is equivalent to a finite volume discretization, where the control volumes are constructed by joining the barycenters of the triangles (average of the vertex positions) to the midpoints of the triangle edges.