Skip to content

Commit

Permalink
hex: allow for Real function space (#3549)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksagiyam authored May 8, 2024
1 parent 815bc4b commit d058083
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ def check_element(element, top=True):
If the element is illegal.
"""
if element.cell.cellname() == "hexahedron" and \
element.family() not in ["Q", "DQ"]:
raise NotImplementedError("Currently can only use 'Q' and/or 'DQ' elements on hexahedral meshes, not", element.family())
element.family() not in ["Q", "DQ", "Real"]:
raise NotImplementedError("Currently can only use 'Q', 'DQ', and/or 'Real' elements on hexahedral meshes, not", element.family())
if type(element) in (finat.ufl.BrokenElement, finat.ufl.RestrictedElement,
finat.ufl.HDivElement, finat.ufl.HCurlElement):
inner = (element._element, )
Expand Down
14 changes: 14 additions & 0 deletions tests/regression/test_real_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,17 @@ def test_real_interpolate():
R = FunctionSpace(mesh, "R", 0)
a_int = assemble(interpolate(Constant(1.0), R))
assert np.allclose(float(a_int), 1.0)


def test_real_space_hex():
mesh = BoxMesh(2, 1, 1, 2., 1., 1., hexahedral=True)
DG = FunctionSpace(mesh, "DQ", 0)
R = FunctionSpace(mesh, "R", 0)
dg = Function(DG).assign(1.)
r = Function(R).assign(1.)
val = assemble(r * dx)
assert abs(val - 2.) < 1.e-14
val = assemble(inner(dg, TestFunction(R)) * dx)
assert np.allclose(val.dat.data_ro, [2.])
val = assemble(inner(r, TestFunction(DG)) * dx)
assert np.allclose(val.dat.data, [1., 1.])

0 comments on commit d058083

Please sign in to comment.