Skip to content

Commit cfb647b

Browse files
committed
Define P1 with trivial Vandermonde matrix
1 parent 7920b02 commit cfb647b

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

FIAT/expansions.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def dubiner_recurrence(dim, n, order, ref_pts, Jinv, scale, variant=None):
8181
raise ValueError("Higher order derivatives not supported")
8282
if variant not in [None, "bubble", "dual"]:
8383
raise ValueError(f"Invalid variant {variant}")
84-
8584
if variant == "bubble":
8685
scale = -scale
8786

@@ -94,9 +93,10 @@ def dubiner_recurrence(dim, n, order, ref_pts, Jinv, scale, variant=None):
9493

9594
pad_dim = dim + 2
9695
dX = pad_jacobian(Jinv, pad_dim)
97-
phi[0] = sum((ref_pts[i] - ref_pts[i] for i in range(dim)), scale)
96+
97+
phi[0] = sum((ref_pts[i] * 0 for i in range(dim)), scale)
9898
if dphi is not None:
99-
dphi[0] = (phi[0] - phi[0]) * dX[0]
99+
dphi[0] = (phi[0] * 0) * dX[0]
100100
if ddphi is not None:
101101
ddphi[0] = outer(dphi[0], dX[0])
102102
if dim == 0 or n == 0:
@@ -127,29 +127,32 @@ def dubiner_recurrence(dim, n, order, ref_pts, Jinv, scale, variant=None):
127127
a = 0.5 * (alpha + beta) + 1.0
128128
b = 0.5 * (alpha - beta)
129129

130-
factor = a * fa - b * fb
131-
phi[inext] = factor * phi[icur]
130+
fcur = a * fa - b * fb
131+
phi[inext] = fcur * phi[icur]
132132
if dphi is not None:
133-
dfactor = a * dfa - b * dfb
134-
dphi[inext] = factor * dphi[icur] + phi[icur] * dfactor
133+
dfcur = a * dfa - b * dfb
134+
dphi[inext] = fcur * dphi[icur] + phi[icur] * dfcur
135135
if ddphi is not None:
136-
ddphi[inext] = factor * ddphi[icur] + sym_outer(dphi[icur], dfactor)
136+
ddphi[inext] = fcur * ddphi[icur] + sym_outer(dphi[icur], dfcur)
137137

138138
# general i by recurrence
139139
for i in range(1, n - sum(sub_index)):
140140
iprev, icur, inext = icur, inext, idx(*sub_index, i + 1)
141141
a, b, c = coefficients(alpha, beta, i)
142-
factor = a * fa - b * fb
143-
phi[inext] = factor * phi[icur] - c * (fc * phi[iprev])
142+
fcur = a * fa - b * fb
143+
fprev = -c * fc
144+
phi[inext] = fcur * phi[icur] + fprev * phi[iprev]
144145
if dphi is None:
145146
continue
146-
dfactor = a * dfa - b * dfb
147-
dphi[inext] = (factor * dphi[icur] + phi[icur] * dfactor -
148-
c * (fc * dphi[iprev] + phi[iprev] * dfc))
147+
dfcur = a * dfa - b * dfb
148+
dfprev = -c * dfc
149+
dphi[inext] = (fcur * dphi[icur] + phi[icur] * dfcur +
150+
fprev * dphi[iprev] + phi[iprev] * dfprev)
149151
if ddphi is None:
150152
continue
151-
ddphi[inext] = (factor * ddphi[icur] + sym_outer(dphi[icur], dfactor) -
152-
c * (fc * ddphi[iprev] + sym_outer(dphi[iprev], dfc) + phi[iprev] * ddfc))
153+
ddfcur = -c * ddfc
154+
ddphi[inext] = (fcur * ddphi[icur] + sym_outer(dphi[icur], dfcur) +
155+
fprev * ddphi[iprev] + sym_outer(dphi[iprev], dfcur) + phi[iprev] * ddfcur)
153156

154157
# normalize
155158
d = codim + 1
@@ -159,9 +162,10 @@ def dubiner_recurrence(dim, n, order, ref_pts, Jinv, scale, variant=None):
159162
if variant is not None:
160163
p = index[-1] + shift
161164
alpha = 2 * (sum(index[:-1]) + d * shift) - 1
162-
norm2 = (0.5 + d) / d
163165
if p > 0 and p + alpha > 0:
164-
norm2 *= (p + alpha) * (2*p + alpha) / p
166+
norm2 = (2*d+1) * (p + alpha) * (2*p + alpha) / (2*d*p)
167+
else:
168+
norm2 = 1.0
165169
else:
166170
norm2 = (2*sum(index) + d) / d
167171
scale = math.sqrt(norm2)
@@ -183,9 +187,9 @@ def C0_basis(dim, n, tabulations):
183187
# Recover facet bubbles
184188
for phi in tabulations:
185189
icur = 0
186-
phi[icur] *= -1
187190
for inext in range(1, dim+1):
188-
phi[icur] -= phi[inext]
191+
phi[icur] += phi[inext]
192+
phi[icur] *= -1
189193
if dim == 2:
190194
for i in range(2, n+1):
191195
phi[idx(0, i)] -= phi[idx(1, i-1)]

FIAT/lagrange.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ def __init__(self, ref_el, degree, variant="equispaced", sort_entities=False):
8383
points = get_lagrange_points(dual)
8484
poly_set = LagrangePolynomialSet(ref_el, points)
8585
else:
86-
poly_variant = "bubble" if ref_el.is_macrocell() else None
87-
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree, variant=poly_variant)
86+
poly_set = polynomial_set.ONPolynomialSet(ref_el, degree, variant="bubble", scale=1)
8887
formdegree = 0 # 0-form
8988
super().__init__(poly_set, dual, degree, formdegree)

0 commit comments

Comments
 (0)