from ufl.finiteelement import FiniteElement, MixedElement
(Pdb) from ufl import Cell, pullback, sobolevspace
(Pdb) pullback = pullback.identity_pullback
(Pdb) sobolev_space_H1 = sobolevspace.H1
(Pdb) sobolev_space_L2 = sobolevspace.L2
(Pdb) mixed_element = MixedElement([element_u, element_p])
(Pdb) cell_name = "tetrahedron" # Use "triangle" for 2D meshes
(Pdb) cell = Cell(cell_name)
(Pdb) element_u = FiniteElement(
... family="Lagrange",
... cell=cell,
... degree=2,
... reference_value_shape=vector_shape,
... pullback=pullback,
... sobolev_space=sobolev_space_H1
... )
(Pdb) element_p = FiniteElement(
... family="Lagrange",
... cell=cell,
... degree=1,
... reference_value_shape=scalar_shape,
... pullback=pullback,
... sobolev_space=sobolev_space_L2
... )
(Pdb) mixed_element = MixedElement([element_u, element_p])
(Pdb) W = fem.functionspace(mesh, mixed_element)
*** AttributeError: 'MixedElement' object has no attribute 'is_mixed'
(Pdb) mixed_element.__class__.__mro__
(<class 'ufl.finiteelement.MixedElement'>, <class 'ufl.finiteelement.FiniteElement'>, <class 'ufl.finiteelement.AbstractFiniteElement'>, <class 'abc.ABC'>, <class 'object'>)
(Pdb) dolfinx.__version__
'0.9.0'
(Pdb) ufl.__version__
'2024.2.0'
(Pdb)
You are not supposed to use elements directly from ufl in dolfinx 0.8 and 0.9.
See for instance
and
1 Like
This has also been covered in:
http://jsdokken.com/FEniCS-workshop/src/unified_form_language/ufl_elements.html#the-finite-element
1 Like