Skip to content

Commit

Permalink
Remove jit options from function-space as we no longer generate code. (
Browse files Browse the repository at this point in the history
…#3529)

* Remove jit options from function-space as we no longer generate code.
Remove commented out code from create_dolfinx_element

* Set dtype in single element test case (for basix element). Picked up in: https://github.com/FEniCS/ffcx/actions/runs/11973090647/job/33381299505?pr=730

* remove more comments and form compiler options

* Paramterize test
  • Loading branch information
jorgensd authored Nov 22, 2024
1 parent 13bc37f commit ceefabb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
15 changes: 1 addition & 14 deletions python/dolfinx/fem/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,24 +583,18 @@ def _create_dolfinx_element(
else:
basix_e = ufl_e.basix_element._e
bs = ufl_e.reference_value_shape if ufl_e.block_size > 1 else None
# bs = [ufl_e.block_size] if ufl_e.block_size > 1 else None
# print(bs, ufl_e.reference_value_shape)
return CppElement(basix_e, bs, ufl_e.is_symmetric)


def functionspace(
mesh: Mesh,
element: typing.Union[ufl.FiniteElementBase, ElementMetaData, tuple[str, int, tuple, bool]],
form_compiler_options: typing.Optional[dict[str, typing.Any]] = None,
jit_options: typing.Optional[dict[str, typing.Any]] = None,
) -> FunctionSpace:
"""Create a finite element function space.
Args:
mesh: Mesh that space is defined on.
element: Finite element description.
form_compiler_options: Options passed to the form compiler.
jit_options: Options controlling just-in-time compilation.
Returns:
A function space.
Expand All @@ -619,14 +613,7 @@ def functionspace(
if ufl_e.cell != mesh.ufl_domain().ufl_cell():
raise ValueError("Non-matching UFL cell and mesh cell shapes.")

# ufl_space = ufl.FunctionSpace(mesh.ufl_domain(), ufl_e)
# value_shape = ufl_space.value_shape

# Compile dofmap and element and create DOLFINx objects
if form_compiler_options is None:
form_compiler_options = dict()
form_compiler_options["scalar_type"] = dtype

# Create DOLFINx objects
cpp_element = _create_dolfinx_element(mesh.topology.cell_type, ufl_e, dtype)
cpp_dofmap = _cpp.fem.create_dofmap(mesh.comm, mesh.topology._cpp_object, cpp_element)

Expand Down
11 changes: 6 additions & 5 deletions python/test/unit/fem/test_mixed_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ def test_element_product(d1, d2):
assert np.isclose(A.squared_norm(), B.squared_norm())


def test_single_element_in_mixed_element():
@pytest.mark.parametrize("rtype", [np.float32, np.float64])
def test_single_element_in_mixed_element(rtype):
"""Check that a mixed element with a single element is equivalent to a single element."""
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 3)
el = element("Lagrange", mesh.basix_cell(), 3)
mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 10, 3, dtype=rtype)
el = element("Lagrange", mesh.basix_cell(), 3, dtype=rtype)
me = mixed_element([el])
V = dolfinx.fem.functionspace(mesh, me)
assert V.num_sub_spaces == 1
Expand All @@ -113,9 +114,9 @@ def test_single_element_in_mixed_element():
def f(x):
return x[0] ** 2 + x[1] ** 2

u = dolfinx.fem.Function(V)
u = dolfinx.fem.Function(V, dtype=rtype)
u.sub(0).interpolate(f)
w = dolfinx.fem.Function(W)
w = dolfinx.fem.Function(W, dtype=rtype)
w.interpolate(f)
np.testing.assert_allclose(u.x.array, w.x.array)

Expand Down

0 comments on commit ceefabb

Please sign in to comment.