Unify LagrangeSimplexFiniteElement across dimensions
- Mar 31, 2025
-
-
Carsten Gräser authored
The implementation supports arbitrary order, but the test is only implemented for order up to 2.
-
Carsten Gräser authored
We can implement arbitrary order derivatives by a simple recursion. Notice that the effort grows exponentially with the total order because the number of terms from the product rule is 2^totalOrder. Furthermore the stack-storage grows linearly with the dynamic total order. Hence we need to use a dynamic-to-static switch using an explicit enumeration of the supported static derivative orders. Since derivatives of order >k are zero, the number of these cases is known at compile time.
-
Carsten Gräser authored
Instead of evaluating the barycentric factors during the loop over the Lagrange nodes, it is simpler and more efficient to do this once in advance. This also adds the prcisice formula for the basis functions to the doxygen documentation.
-
Carsten Gräser authored
The `LagrangeSimplexFiniteElement` contains 5 different code paths to implement the basis and its derivatives: * A special implementation for order 0 in any dimension. * A special implementation for order 1 in any dimension. * An implementation for any order in dimension 1. * An implementation for any order in dimension 2. * An implementation for any order in dimension 3. There are good reasons for the first two special cases. Unfortunately the ones for dim=1,2,3 are all implemented differently for no good reason (except history) makes the code hard to read and understand. This patch unifies the latter three implementations. While there are still three branches, there is a very simple common structure making the now making the code much simpler to understand. The unified implementation basically follows the former `evaluateFunction()` implementation of the 3d case: 1. Rescale the simplex by `k` such that Lagrange points have integer coordinates. 2. Transform to barycentric coordinates in the scaled simplex. 3. Loop over Lagrange points in lexicographic order. 4. Compute basis functions as products of univariate Lagrange-polynomials wrt. barycentric coordinates. This approach is now also used for `evaluateJacobian()` and first order derivatives in `partial()` extending the support of the latter to dim=1 and dim=2. For now the special implementation of second order partial derivatives in 2d is kept, but could be updated accordingly.
-