P1isoP2 elements

Is it possible to implement “P1isoP2” elements in fenicsx, where one has a mixed element on a grid and a refined version of that same grid?

I’m interested in trying this in the context of solving the Navier-Stokes equations, with linear elements for the pressure on a regular triangular grid, and linear elements for velocity on a refined triangulation. My naïve approach using two meshes didn’t get very far:

mesh = create_unit_square(MPI.COMM_WORLD, h//2, h//2, CellType.triangle)
mesh_refined = create_unit_square(MPI.COMM_WORLD, h, h, CellType.triangle)

P2v = ufl.VectorElement("P", mesh.ufl_cell(), 1)
P1 = ufl.FiniteElement("P", mesh_refined.ufl_cell(), 1)
TH = ufl.MixedElement([P2v, P1])
W = fem.FunctionSpace(mesh_refined, TH)

Which leads to odd but not surprising errors when attempting to construct the forms:

TypeError: '<' not supported between instances of 'Mesh' and 'Mesh'

Hello,

I don’t think this is possible yet, but it may be possible in the (quite distant) future once we’ve looked at supporting macro elements (eg Guzmán-Neilan elements).

Hello,
Are there any advances on the topic ?

P1 iso P2 elements are now supported, you can create them with:

import basix
import basix.ufl

element = basix.ufl.element(basix.ElementFamily.iso, basix.CellType.triangle, 1)

mesh = create_unit_square(MPI.COMM_WORLD, 10, 10, CellType.triangle)
W = fem.FunctionSpace(mesh, element)
2 Likes

Hi,
Thank you for your answer, I didn’t know this was available. However in addition to the velocity I would need to define tensors on the same refined grid which would be of order 0. I tried to pass 0 as order in your code but I got an error “Cannot create a continuous order 0 Lagrange basis function”. It seems that it forces the elements to be continuous. Is there any workaround ?

This should work:

element = basix.ufl.element(basix.ElementFamily.P, basix.CellType.triangle, 0, discontinuous=true)
2 Likes

Did you mean basix.ElementFamily.iso ?

Also this does not provide a tensor but only a scalar, I wanted to plug this into ufl.TensorElement but the family name ‘iso’ does not exist (that’s actually why I thought it was not implemented). I thought using “ufl.finiteelement.elementlist.register_element” would solve the problem but depending on the order of the element, the sobolev space varies from H1 to L2, but the basix family name remains ‘iso’, so I can’t register both order 1 and order 0 in the same script. Did I miss anything ?

ufl.TensorElement and ufl.finiteelement.elementlist.register_element are deprecated and will be removed in the next UFL release, so we recommend moving away from using these.

The functions in basix.ufl should be able to do everything that you used to do with these. You can create a tensor element by passing a shape into the element function, for example:

element = basix.ufl.element(
    basix.ElementFamily.P, basix.CellType.triangle, 0,
    discontinuous=true, shape=(2, 2))

There’s no need to use an iso element here as it would be the same as a DP0 element

1 Like

Okay thank you ! In that case I guess that ufl.VectorElement should also be replaced by something like

vector = basix.ufl.element(
basix.ElementFamily.iso,basic.CellType.triangle,1,shape=(2,))

?
Concerning the use of basix.ElementFamily.iso, I don’t understand why this is the same as basix.ElementFamily.P when the degree is 0. For me the latter designates the use of Lagrange elements, so if we consider the order 0 this makes only one degree of freedom per triangle. What I want is Lagrange elements of order 0 but on the refined grid, so this makes 3 degrees of freedom per triangle on the coarse mesh. Is there any way to get that ?

Yes, that’s exactly how to create a vector element.

In Basix, the basis functions of an iso element are always continuous across the boundaries between edges on the fine mesh (that are not edges in the coarse mesh), so there’s currently no way to make this element. I’ve opened an issue for this: Add discontinuous iso element · Issue #794 · FEniCS/basix · GitHub

Yes.
I’ll let @mscroggs comment on the other part of the question.

1 Like

Okay I see, thank you