Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend VectorFunctionSpace to custom elements #2576

Merged
merged 14 commits into from
Mar 16, 2023
19 changes: 14 additions & 5 deletions python/dolfinx/fem/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,21 @@ def tabulate_dof_coordinates(self) -> npt.NDArray[np.float64]:
return self._cpp_object.tabulate_dof_coordinates()


def VectorFunctionSpace(mesh: Mesh, element: typing.Union[ElementMetaData, typing.Tuple[str, int]],
dim=None) -> FunctionSpace:
def VectorFunctionSpace(
mesh: Mesh,
pierricmora marked this conversation as resolved.
Show resolved Hide resolved
element: typing.Union[basix.ufl_wrapper._BasixElementBase,
ElementMetaData, typing.Tuple[str, int]],
dim=None) -> FunctionSpace:
"""Create vector finite element (composition of scalar elements) function space."""
e = ElementMetaData(*element)
ufl_element = basix.ufl_wrapper.create_vector_element(e.family, mesh.ufl_cell().cellname(), e.degree,
dim=dim, gdim=mesh.geometry.dim)
if isinstance(element, basix.ufl_wrapper._BasixElementBase):
pierricmora marked this conversation as resolved.
Show resolved Hide resolved
e = element
ufl_element = basix.ufl_wrapper.create_vector_element(e.family(), e.cell_type, e.degree(),
e.lagrange_variant, e.dpc_variant, e.discontinuous,
dim=dim, gdim=mesh.geometry.dim)
else:
e = ElementMetaData(*element)
mscroggs marked this conversation as resolved.
Show resolved Hide resolved
ufl_element = basix.ufl_wrapper.create_vector_element(e.family, mesh.ufl_cell().cellname(), e.degree,
mscroggs marked this conversation as resolved.
Show resolved Hide resolved
dim=dim, gdim=mesh.geometry.dim)
return FunctionSpace(mesh, ufl_element)


Expand Down