Skip to content

Creating a FunctionSpace with a MixedElement without a MeshSequence #464

Description

@pbrubeck

With recent API changes it is no longer possible to create a FunctionSpace with a MixedElement without a MeshSequence. We should consider automating the construction of the MeshSequence if a standard Mesh is provided to mantain backwards-compatibility.

import ufl
import finat.ufl
cell = ufl.triangle
domain = ufl.Mesh(finat.ufl.VectorElement(finat.ufl.FiniteElement("Lagrange", cell, 1)))

V = finat.ufl.VectorElement(finat.ufl.FiniteElement("Lagrange", cell, 2))
Q = finat.ufl.FiniteElement("Lagrange", cell, 1)
Z = V * Q

# This works in ufl main
mixed_mesh = ufl.MeshSequence([domain]*len(Z.sub_elements))
space = ufl.FunctionSpace(mixed_mesh, Z)

# This works in ufl release, but throws an error in ufl main
space = ufl.FunctionSpace(domain, Z)

The error we get in main is

----> 1 space = ufl.FunctionSpace(domain, Z)

File /scratch/brubeckmarti/firedrake-venv/src/ufl/ufl/functionspace.py:57, in BaseFunctionSpace.__init__(self, domain, element, label)
     55 else:
     56     if element.cell != domain_cell:
---> 57         raise ValueError("Non-matching cell of finite element and domain.")
     58 if not domain.can_make_function_space(element):
     59     raise ValueError(f"Mismatching domain ({domain}) and element ({element}).")

ValueError: Non-matching cell of finite element and domain.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions