KMV element uesd in FEnicsX

Hi, everyone,

I want to use the “KMV( Kong–Mulder–Veldhuizen)” element in fenicsx. However, it seems not to work. I wonder if the FenicsX could support this element.

Thx

import ufl
import numpy

from mpi4py import MPI
from petsc4py import PETSc

from dolfinx import mesh, fem, io, nls, log

def q(u):
    return 1 + u**2

domain = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
x = ufl.SpatialCoordinate(domain)
u_ufl = 1 + x[0] + 2*x[1]
f = - ufl.div(q(u_ufl)*ufl.grad(u_ufl))

element = ufl.FiniteElement("KMV", domain.ufl_cell(), 2)

V = fem.FunctionSpace(domain, element)

ValueError: Unknown element family: Kong-Mulder-Veldhuizen with cell type triangle

You could implement them using the definitions at: DefElement: Kong–Mulder–Veldhuizen
as a custom element, as explained in:
Creating a custom element — Basix 0.4.3.0 documentation
and
Defining conforming Crouzeix–Raviart elements — Basix 0.4.3.0 documentation

Thank you very much, dokken.
I have already tested the Variants of Lagrange elements, as the Variants of Lagrange elements. but there is some issue with it.

import basix
import numpy as np
from basix import ElementFamily, CellType, LagrangeVariant, LatticeType

lagrange = basix.create_element(
    ElementFamily.P, CellType.triangle, 15, LagrangeVariant.equispaced)
points = basix.create_lattice(
    CellType.triangle, 50, LatticeType.equispaced, True)
tab = lagrange.tabulate(0, points)[0]
print(max(np.sum(np.abs(tab), axis=0)))

gll2 = basix.create_element(
    ElementFamily.P, CellType.triangle, 15, LagrangeVariant.gll_isaac)
print(max(np.sum(np.abs(gll2.tabulate(0, points)[0]), axis=0)))

from mpi4py import MPI
from dolfinx import mesh
domain = mesh.create_unit_square(MPI.COMM_WORLD, 15, 15)

from dolfinx.fem import FunctionSpace
V = FunctionSpace(domain, gll2)

TypeError                                 Traceback (most recent call last)
Input In [12], in <cell line: 2>()
      1 from dolfinx.fem import FunctionSpace
----> 2 V = FunctionSpace(domain, gll2)

File /usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/function.py:440, in FunctionSpace.__init__(self, mesh, element, cppV, form_compiler_params, jit_params)
    438     super().__init__(mesh.ufl_domain(), element)
    439 else:
--> 440     e = ElementMetaData(*element)
    441     ufl_element = ufl.FiniteElement(e.family, mesh.ufl_cell(), e.degree)
    442     super().__init__(mesh.ufl_domain(), ufl_element)

TypeError: dolfinx.fem.function.ElementMetaData() argument after * must be an iterable, not basix._basixcpp.FiniteElement

could you please help me to check it? Thx

Hi, dokken,

I added one code e = basix.ufl_wrapper.BasixElement(gll2). It works. Thx