Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions finat/quadrature.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from FIAT.reference_element import LINE, QUADRILATERAL, TENSORPRODUCT
from gem.utils import safe_repr

from finat.point_set import GaussLegendrePointSet, KMVPointSet, PointSet, TensorPointSet
from finat.point_set import (GaussLegendrePointSet, GaussLobattoLegendrePointSet,
KMVPointSet, PointSet, TensorPointSet)


def make_quadrature(ref_el, degree, scheme="default"):
Expand Down Expand Up @@ -43,7 +44,13 @@ def make_quadrature(ref_el, degree, scheme="default"):
if degree < 0:
raise ValueError("Need positive degree, not %d" % degree)

if ref_el.get_shape() == LINE and not ref_el.is_macrocell():
if scheme.lower() in {"kmv", "lump"}:
fiat_rule = fiat_scheme(ref_el, degree, "KMV")
if ref_el.get_shape() == LINE:
point_set = GaussLobattoLegendrePointSet(fiat_rule.get_points())
else:
point_set = KMVPointSet(fiat_rule.get_points())
elif ref_el.get_shape() == LINE and not ref_el.is_macrocell():
# FIAT uses Gauss-Legendre line quadature, however, since we
# symbolically label it as such, we wish not to risk attaching
# the wrong label in case FIAT changes. So we explicitly ask
Expand All @@ -53,10 +60,7 @@ def make_quadrature(ref_el, degree, scheme="default"):
point_set = GaussLegendrePointSet(fiat_rule.get_points())
else:
fiat_rule = fiat_scheme(ref_el, degree, scheme)
if scheme.lower() == "kmv":
point_set = KMVPointSet(fiat_rule.get_points())
else:
point_set = PointSet(fiat_rule.get_points())
point_set = PointSet(fiat_rule.get_points())

return QuadratureRule(point_set, fiat_rule.get_weights(), ref_el=ref_el, io_ornt_map_tuple=fiat_rule._intrinsic_orientation_permutation_map_tuple)

Expand Down
11 changes: 10 additions & 1 deletion finat/ufl/elementlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,15 @@ def canonical_element_description(family, cell, order, form_degree):
raise ValueError(f"Invalid value rank {value_rank}.")

embedded_degree = order
if any(bubble in family for bubble in ("Guzman-Neilan", "Bernardi-Raugel")):
if family == "Kong-Mulder-Veldhuizen":
if order == 1:
bump = 0
elif tdim == 2 and order < 5:
bump = 1
else:
bump = 2
embedded_degree += bump
elif any(bubble in family for bubble in ("Guzman-Neilan", "Bernardi-Raugel")):
embedded_degree = tdim

return family, short_name, order, reference_value_shape, sobolev_space, mapping, embedded_degree
11 changes: 11 additions & 0 deletions test/finat/test_create_finat_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ def test_quadrilateral_variant_spectral_dq_l2():
assert isinstance(element.product.factors[1], finat.GaussLegendre)


@pytest.mark.parametrize("cell, degree",
[(ufl.triangle, p) for p in range(1, 7)]
+ [(ufl.tetrahedron, p) for p in range(1, 4)])
def test_kmv(cell, degree):
ufl_element = finat.ufl.FiniteElement('KMV', cell, degree)
finat_element = create_element(ufl_element)
assert ufl_element.degree() == degree
assert ufl_element.embedded_superdegree == finat_element.degree
assert (finat_element.degree > degree) or (degree == 1)


def test_cache_hit(ufl_element):
A = create_element(ufl_element)
B = create_element(ufl_element)
Expand Down
Loading