Skip to content

Commit 7920b02

Browse files
authored
Merge pull request #173 from firedrakeproject/pbrubeck/merge-release
Merge release into master
2 parents db4a062 + 6b99cf5 commit 7920b02

File tree

12 files changed

+61
-55
lines changed

12 files changed

+61
-55
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
release.conf export-ignore
21
bitbucket-pipelines.yml export-ignore
32
.gitignore export-ignore
43
.gitattributes export-ignore

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: github pages
33
on:
44
push:
55
branches:
6-
- master
6+
- main
77

88
jobs:
99
build_docs:

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: FIAT CI
77
on:
88
push:
99
branches:
10-
- master
10+
- main
1111
pull_request:
1212

1313
jobs:

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ For more information, visit http://www.fenicsproject.org
2020
:target: https://github.com/FEniCS/fiat/actions?query=workflow%3A%22FIAT+CI%22
2121
:alt: Build Status
2222

23-
.. image:: https://coveralls.io/repos/github/FEniCS/fiat/badge.svg?branch=master
24-
:target: https://coveralls.io/github/FEniCS/fiat?branch=master
23+
.. image:: https://coveralls.io/repos/github/FEniCS/fiat/badge.svg?branch=main
24+
:target: https://coveralls.io/github/FEniCS/fiat?branch=main
2525
:alt: Coverage Status
2626

2727
.. image:: https://readthedocs.org/projects/fenics-fiat/badge/?version=latest

finat/element_factory.py

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,18 @@ def convert_finiteelement(element, **kwargs):
157157

158158
codim = 1 if element.family() == "Boundary Quadrature" else 0
159159
return finat.make_quadrature_element(cell, degree, scheme, codim), set()
160-
lmbda = supported_elements[element.family()]
161-
if element.family() == "Real" and element.cell.cellname() in {"quadrilateral", "hexahedron"}:
162-
lmbda = None
163-
element = finat.ufl.FiniteElement("DQ", element.cell, 0)
164-
if lmbda is None:
160+
161+
make_finat_element = supported_elements[element.family()]
162+
163+
if element.cell.cellname() in {"quadrilateral", "hexahedron"}:
164+
# Reconstruct Real and Bernstein on tensor product cells
165+
if element.family() == "Real":
166+
make_finat_element = None
167+
element = finat.ufl.FiniteElement("DQ", element.cell, 0)
168+
elif element.family() == "Bernstein":
169+
make_finat_element = None
170+
171+
if make_finat_element is None:
165172
if element.cell.cellname() == "quadrilateral":
166173
# Handle quadrilateral short names like RTCF and RTCE.
167174
element = element.reconstruct(cell=quadrilateral_tpc)
@@ -174,49 +181,51 @@ def convert_finiteelement(element, **kwargs):
174181
finat_elem, deps = _create_element(element, **kwargs)
175182
return finat.FlattenedDimensions(finat_elem), deps
176183

184+
deps = set()
177185
finat_kwargs = {}
178186
kind = element.variant()
179187
if kind is None:
180188
kind = 'spectral' # default variant
181189

182190
if element.family() == "Lagrange":
183191
if kind in ['spectral', 'mimetic']:
184-
lmbda = finat.GaussLobattoLegendre
192+
make_finat_element = finat.GaussLobattoLegendre
185193
elif element.cell.cellname() == "interval" and kind in cg_interval_variants:
186-
lmbda = cg_interval_variants[kind]
194+
make_finat_element = cg_interval_variants[kind]
187195
elif any(map(kind.startswith, ['integral', 'demkowicz', 'fdm'])):
188-
lmbda = finat.IntegratedLegendre
196+
make_finat_element = finat.IntegratedLegendre
189197
finat_kwargs["variant"] = kind
190198
elif kind in ['mgd', 'feec', 'qb', 'mse']:
191-
degree = element.degree()
192-
shift_axes = kwargs["shift_axes"]
193-
restriction = kwargs["restriction"]
199+
make_finat_element = finat.RuntimeTabulated
200+
finat_kwargs["variant"] = kind
201+
finat_kwargs["shift_axes"] = kwargs["shift_axes"]
202+
finat_kwargs["restriction"] = kwargs["restriction"]
194203
deps = {"shift_axes", "restriction"}
195-
return finat.RuntimeTabulated(cell, degree, variant=kind, shift_axes=shift_axes, restriction=restriction), deps
196204
else:
197205
# Let FIAT handle the general case
198-
lmbda = finat.Lagrange
206+
make_finat_element = finat.Lagrange
199207
finat_kwargs["variant"] = kind
200208

201209
elif element.family() in ["Discontinuous Lagrange", "Discontinuous Lagrange L2"]:
202210
if kind == 'spectral':
203-
lmbda = finat.GaussLegendre
211+
make_finat_element = finat.GaussLegendre
204212
elif kind == 'mimetic':
205-
lmbda = finat.Histopolation
213+
make_finat_element = finat.Histopolation
206214
elif element.cell.cellname() == "interval" and kind in dg_interval_variants:
207-
lmbda = dg_interval_variants[kind]
215+
make_finat_element = dg_interval_variants[kind]
208216
elif any(map(kind.startswith, ['integral', 'demkowicz', 'fdm'])):
209-
lmbda = finat.Legendre
217+
make_finat_element = finat.Legendre
210218
finat_kwargs["variant"] = kind
211219
elif kind in ['mgd', 'feec', 'qb', 'mse']:
212-
degree = element.degree()
213-
shift_axes = kwargs["shift_axes"]
214-
restriction = kwargs["restriction"]
220+
make_finat_element = finat.RuntimeTabulated
221+
finat_kwargs["variant"] = kind
222+
finat_kwargs["shift_axes"] = kwargs["shift_axes"]
223+
finat_kwargs["restriction"] = kwargs["restriction"]
224+
finat_kwargs["continuous"] = False
215225
deps = {"shift_axes", "restriction"}
216-
return finat.RuntimeTabulated(cell, degree, variant=kind, shift_axes=shift_axes, restriction=restriction, continuous=False), deps
217226
else:
218227
# Let FIAT handle the general case
219-
lmbda = finat.DiscontinuousLagrange
228+
make_finat_element = finat.DiscontinuousLagrange
220229
finat_kwargs["variant"] = kind
221230

222231
elif element.family() in {"HDiv Trace", "Bubble", "FacetBubble"}:
@@ -225,7 +234,7 @@ def convert_finiteelement(element, **kwargs):
225234
elif element.variant() is not None:
226235
finat_kwargs["variant"] = element.variant()
227236

228-
return lmbda(cell, element.degree(), **finat_kwargs), set()
237+
return make_finat_element(cell, element.degree(), **finat_kwargs), deps
229238

230239

231240
# Element modifiers and compound element types

finat/ufl/elementlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def show_elements():
152152
register_alias("Lob",
153153
lambda family, dim, order, degree: ("Gauss-Lobatto-Legendre", order))
154154

155-
register_element("Bernstein", None, 0, H1, "identity", (1, None), simplices)
155+
register_element("Bernstein", None, 0, H1, "identity", (1, None), any_cell)
156156

157157

158158
# Let Nedelec H(div) elements be aliases to BDMs/RTs

finat/ufl/finiteelement.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,10 @@ def __new__(cls,
9494
return EnrichedElement(HCurl(TensorProductElement(Qc_elt, Id_elt, cell=cell)),
9595
HCurl(TensorProductElement(Qd_elt, Ic_elt, cell=cell)))
9696

97-
elif family == "Q":
98-
return TensorProductElement(*[FiniteElement("CG", c, degree, variant=variant)
97+
elif family in {"Q", "Bernstein"}:
98+
if family == "Q":
99+
family = "CG"
100+
return TensorProductElement(*[FiniteElement(family, c, degree, variant=variant)
99101
for c in cell.sub_cells()],
100102
cell=cell)
101103

gem/gem.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""
1616

1717
from abc import ABCMeta
18-
from itertools import chain
18+
from itertools import chain, repeat
1919
from functools import reduce
2020
from operator import attrgetter
2121
from numbers import Integral, Number
@@ -972,7 +972,7 @@ class Delta(Scalar, Terminal):
972972
def __new__(cls, i, j, dtype=None):
973973
if isinstance(i, tuple) and isinstance(j, tuple):
974974
# Handle multiindices
975-
return Product(*map(Delta, i, j))
975+
return Product(*map(Delta, i, j, repeat(dtype)))
976976
assert isinstance(i, IndexBase)
977977
assert isinstance(j, IndexBase)
978978

@@ -984,26 +984,18 @@ def __new__(cls, i, j, dtype=None):
984984
if isinstance(i, Integral) and isinstance(j, Integral):
985985
return one if i == j else Zero()
986986

987-
if isinstance(i, Integral):
988-
return Indexed(Literal(numpy.eye(j.extent)[i]), (j,))
989-
990-
if isinstance(j, Integral):
991-
return Indexed(Literal(numpy.eye(i.extent)[j]), (i,))
992-
993987
self = super(Delta, cls).__new__(cls)
994988
self.i = i
995989
self.j = j
996990
# Set up free indices
997-
free_indices = []
998-
for index in (i, j):
999-
if isinstance(index, Index):
1000-
free_indices.append(index)
1001-
elif isinstance(index, VariableIndex):
1002-
raise NotImplementedError("Can not make Delta with VariableIndex")
991+
free_indices = [index for index in (i, j) if isinstance(index, Index)]
1003992
self.free_indices = tuple(unique(free_indices))
1004993
self._dtype = dtype
1005994
return self
1006995

996+
def reconstruct(self, *args):
997+
return Delta(*args, dtype=self.dtype)
998+
1007999

10081000
class Inverse(Node):
10091001
"""The inverse of a square matrix."""

gem/optimise.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ def child(expression):
246246
children = remove_componenttensors([Indexed(e, multiindex) for e in expressions])
247247
return ComponentTensor(_select_expression(children, index), multiindex)
248248

249+
if types == {Delta}:
250+
if all(e.i == k and e.j == expr.j for k, e in enumerate(expressions)):
251+
return expr.reconstruct(index, expr.j)
252+
elif all(e.j == k and e.i == expr.i for k, e in enumerate(expressions)):
253+
return expr.reconstruct(expr.i, index)
254+
249255
if len(types) == 1:
250256
cls, = types
251257
if cls.__front__ or cls.__back__:

release.conf

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)