Skip to content

Commit

Permalink
Use ONPolynomialSet for equispaced Lagrange
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Nov 10, 2023
1 parent f628a01 commit ae09667
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions FIAT/lagrange.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@

from FIAT import finite_element, polynomial_set, dual_set, functional
from FIAT.orientation_utils import make_entity_permutations_simplex
from FIAT.barycentric_interpolation import LagrangePolynomialSet
from FIAT.reference_element import LINE


class LagrangeDualSet(dual_set.DualSet):
"""The dual basis for Lagrange elements. This class works for
simplices of any dimension. Nodes are point evaluation at
equispaced points."""

def __init__(self, ref_el, degree, variant=None):
def __init__(self, ref_el, degree, variant="equispaced"):
entity_ids = {}
nodes = []
entity_permutations = {}
Expand Down Expand Up @@ -44,8 +46,18 @@ def __init__(self, ref_el, degree, variant=None):
class Lagrange(finite_element.CiarletElement):
"""The Lagrange finite element. It is what it is."""

def __init__(self, ref_el, degree):
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
dual = LagrangeDualSet(ref_el, degree)
def __init__(self, ref_el, degree, variant="equispaced"):
dual = LagrangeDualSet(ref_el, degree, variant=variant)
if ref_el.shape == LINE and variant != "equispaced":
# In 1D we can use the primal basis as the expansion set,
# avoiding any round-off coming from a basis transformation
points = []
for node in dual.nodes:
# Assert singleton point for each node.
pt, = node.get_point_dict().keys()
points.append(pt)
poly_set = LagrangePolynomialSet(ref_el, points)
else:
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree)
formdegree = 0 # 0-form
super(Lagrange, self).__init__(poly_set, dual, degree, formdegree)

0 comments on commit ae09667

Please sign in to comment.