Skip to content

Commit 9d80ddc

Browse files
committed
Remove entity permutations for non-Lagrange elements
1 parent d8383ae commit 9d80ddc

3 files changed

Lines changed: 16 additions & 34 deletions

File tree

FIAT/fdm_element.py

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
from FIAT import dual_set, finite_element, functional, quadrature
1313
from FIAT.barycentric_interpolation import LagrangePolynomialSet
14-
from FIAT.hierarchical import IntegratedLegendre
15-
from FIAT.orientation_utils import make_entity_permutations_simplex
14+
from FIAT.polynomial_set import ONPolynomialSet
1615
from FIAT.P0 import P0Dual
1716
from FIAT.reference_element import LINE
1817

@@ -48,15 +47,17 @@ class FDMDual(dual_set.DualSet):
4847
def __init__(self, ref_el, degree, bc_order=1, formdegree=0, orthogonalize=False):
4948
# Define the generalized eigenproblem on a reference element
5049
embedded_degree = degree + formdegree
51-
embedded = IntegratedLegendre(ref_el, embedded_degree)
52-
edim = embedded.space_dimension()
53-
self.embedded = embedded
50+
P = ONPolynomialSet(ref_el, embedded_degree, variant="bubble")
51+
Pdim = len(P)
52+
# Apply even / odd reordering on edge bubbles
53+
P = P.take([0, 1, *range(2, Pdim, 2), *range(3, Pdim, 2)])
54+
self.poly_set = P
5455

5556
vertices = ref_el.get_vertices()
5657
if bc_order == 1 and formdegree == 0:
57-
rule = quadrature.GaussLobattoLegendreQuadratureLineRule(ref_el, edim+1)
58+
rule = quadrature.GaussLobattoLegendreQuadratureLineRule(ref_el, Pdim+1)
5859
else:
59-
rule = quadrature.GaussLegendreQuadratureLineRule(ref_el, edim)
60+
rule = quadrature.GaussLegendreQuadratureLineRule(ref_el, Pdim)
6061
self.rule = rule
6162

6263
solve_eig = sym_eig
@@ -65,21 +66,21 @@ def __init__(self, ref_el, degree, bc_order=1, formdegree=0, orthogonalize=False
6566

6667
# Tabulate the BC nodes
6768
if bc_order == 0:
68-
C = numpy.empty((0, edim), "d")
69+
C = numpy.empty((0, Pdim), "d")
6970
else:
70-
constraints = embedded.tabulate(bc_order-1, vertices)
71+
constraints = P.tabulate(vertices, bc_order-1)
7172
C = numpy.transpose(numpy.column_stack(list(constraints.values())))
7273
bdof = slice(None, C.shape[0])
7374
idof = slice(C.shape[0], None)
7475

7576
# Tabulate the basis that splits the DOFs into interior and bcs
76-
E = numpy.eye(edim)
77+
E = numpy.eye(Pdim)
7778
E[bdof, idof] = -C[:, idof]
7879
E[bdof, :] = numpy.linalg.solve(C[:, bdof], E[bdof, :])
7980

8081
# Assemble the constrained Galerkin matrices on the reference cell
8182
k = max(1, bc_order)
82-
phi = embedded.tabulate(k, rule.get_points())
83+
phi = P.tabulate(rule.get_points(), k)
8384
wts = rule.get_weights()
8485
E0 = numpy.dot(E.T, phi[(0, )])
8586
Ek = numpy.dot(E.T, phi[(k, )])
@@ -131,16 +132,10 @@ def __init__(self, ref_el, degree, bc_order=1, formdegree=0, orthogonalize=False
131132
if len(bc_nodes) > 0:
132133
entity_ids = {0: {0: [0], 1: [1]},
133134
1: {0: list(range(2, degree+1))}}
134-
entity_permutations = {}
135-
entity_permutations[0] = {0: {0: [0]}, 1: {0: [0]}}
136-
entity_permutations[1] = {0: make_entity_permutations_simplex(1, degree - 1)}
137135
else:
138136
entity_ids = {0: {0: [], 1: []},
139137
1: {0: list(range(0, degree+1))}}
140-
entity_permutations = {}
141-
entity_permutations[0] = {0: {0: []}, 1: {0: []}}
142-
entity_permutations[1] = {0: make_entity_permutations_simplex(1, degree + 1)}
143-
super().__init__(nodes, ref_el, entity_ids, entity_permutations)
138+
super().__init__(nodes, ref_el, entity_ids)
144139

145140

146141
class FDMFiniteElement(finite_element.CiarletElement):
@@ -167,7 +162,7 @@ def __init__(self, ref_el, degree):
167162
dual = FDMDual(ref_el, degree, bc_order=self._bc_order,
168163
formdegree=self._formdegree, orthogonalize=self._orthogonalize)
169164
if self._formdegree == 0:
170-
poly_set = dual.embedded.poly_set
165+
poly_set = dual.poly_set
171166
else:
172167
lr = quadrature.GaussLegendreQuadratureLineRule(ref_el, degree+1)
173168
poly_set = LagrangePolynomialSet(ref_el, lr.get_points())

FIAT/hierarchical.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from FIAT import finite_element, dual_set, functional, P0
1212
from FIAT.reference_element import symmetric_simplex
13-
from FIAT.orientation_utils import make_entity_permutations_simplex
1413
from FIAT.quadrature import FacetQuadratureRule
1514
from FIAT.quadrature_schemes import create_quadrature
1615
from FIAT.polynomial_set import ONPolynomialSet, make_bubbles
@@ -35,14 +34,11 @@ class LegendreDual(dual_set.DualSet):
3534
def __init__(self, ref_el, degree, codim=0):
3635
nodes = []
3736
entity_ids = {}
38-
entity_permutations = {}
3937

4038
sd = ref_el.get_spatial_dimension()
4139
top = ref_el.get_topology()
4240
for dim in sorted(top):
4341
npoints = degree + 1 if dim == sd - codim else 0
44-
perms = make_entity_permutations_simplex(dim, npoints)
45-
entity_permutations[dim] = {}
4642
entity_ids[dim] = {}
4743
if npoints == 0:
4844
for entity in sorted(top[dim]):
@@ -59,9 +55,8 @@ def __init__(self, ref_el, degree, codim=0):
5955
Q_facet = FacetQuadratureRule(ref_el, dim, entity, Q_ref)
6056
nodes.extend(functional.IntegralMoment(ref_el, Q_facet, phi) for phi in phis)
6157
entity_ids[dim][entity] = list(range(cur, len(nodes)))
62-
entity_permutations[dim][entity] = perms
6358

64-
super().__init__(nodes, ref_el, entity_ids, entity_permutations)
59+
super().__init__(nodes, ref_el, entity_ids)
6560

6661

6762
class Legendre(finite_element.CiarletElement):

FIAT/polynomial_set.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -294,15 +294,7 @@ def make_bubbles(ref_el, degree, codim=0, shape=(), scale="L2 piola"):
294294
entity_ids = expansions.polynomial_entity_ids(ref_el, degree, continuity="C0")
295295
sd = ref_el.get_spatial_dimension()
296296
dim = sd - codim
297-
if dim == 1:
298-
# Apply even / odd reordering on edge bubbles
299-
indices = []
300-
for entity in entity_ids[dim]:
301-
ids = entity_ids[dim][entity]
302-
indices.extend(ids[::2])
303-
indices.extend(ids[1::2])
304-
else:
305-
indices = list(chain(*entity_ids[dim].values()))
297+
indices = list(chain(*entity_ids[dim].values()))
306298

307299
if shape != ():
308300
ncomp = numpy.prod(shape)

0 commit comments

Comments
 (0)