Getting error running tutorial stokes equations


257
views
0
6 months ago by
Hi guys,

When I try to run the example at https://fenicsproject.org/olddocs/dolfin/1.6.0/python/demo/documented/stokes-iterative/python/documentation.html

I get the error

line 53, in <module>
W = V * Q
TypeError: unsupported operand type(s) for *: 'FunctionSpace' and 'FunctionSpace'

the code in that line is
# Load mesh
mesh = UnitCubeMesh(16, 16, 16)

# Define function spaces
V = VectorFunctionSpace(mesh, "CG", 2)
Q = FunctionSpace(mesh, "CG", 1)
W = V * Q​

Thank you very much!!!
Community: FEniCS Project

2 Answers


2
6 months ago by
In newer versions, you need to create a MixedElement first, then create a FunctionSpace from that element.  For example, the following runs without error for me in 2017.2:

from fenics import *

# Load mesh
mesh = UnitCubeMesh(16, 16, 16)

# Define function spaces
VE = VectorElement("CG",mesh.ufl_cell(),2)
QE = FiniteElement("CG",mesh.ufl_cell(),1)
VQE = MixedElement([VE,QE])
W = FunctionSpace(mesh,VQE)
​
Thank you so mush for your answer,

I updated to 2017.2.0 an it is working with your suggestion.
written 6 months ago by Ruben Gonzalez  
1
6 months ago by
Use MixedFunctionSpace. May be this will help you.
from fenics import *
# Load mesh
mesh = UnitCubeMesh(16, 16, 16)

# Define function spaces
V = VectorFunctionSpace(mesh, "CG", 1)
Q = FunctionSpace(mesh, "CG", 1)
W = MixedFunctionSpace([V,Q])
Thank you very much for your answer, but it is still not working.

I'm using fenics version 2017.1.0
written 6 months ago by Ruben Gonzalez  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »