Unsupported Operand for FunctionSpace Type

Hello ! I am trying to simulate waves for an online course and am receiving an unsupported operand error for the FunctionSpace type.

 44 # Define function spaces and functions
 45 Q = FunctionSpace(mesh, "CG", 1);
 46 W = Q * Q;
 47 h = CellSize(mesh);
 48 (p, q) = TestFunctions(W);

Would someone be able to help me sort out this error ?

TypeError: unsupported operand type(s) for *: 'FunctionSpace' and 'FunctionSpace'

It seems like you want to define a mixed function space. Here is the right way to do it:

Element1 = FiniteElement("CG", mesh.ufl_cell(), 1)
Element2 = FiniteElement("CG", mesh.ufl_cell(), 1)

# Define the mixed element
W_elem = MixedElement([Element1, Element2])

# Define the mixed function space
W = FunctionSpace(mesh, W_elem)
1 Like

Thanks so much ! I think I might have been using some outdated reference material.