This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Why "Cellname mismatch between domains with same label"?

0 votes

I do not understand why I receive the error message in the title when I try to run the following code

from dolfin import *
mesh = UnitCubeMesh(10, 10, 10)
V = FunctionSpace(mesh, 'CG', 1)
W = V*V
x = Expression('x[0]', cell='triangle')
y = Expression('x[1]', cell='triangle')
z = Expression('x[2]', cell='triangle')
Ar11 = x*x
Ar12 = x*y
Ar13 = x*z
Ar22 = y*y
Ar23 = y*z
Ar33 = z*z
Ar = as_matrix(((Ar11, Ar12, Ar13), (Ar12, Ar22, Ar23), (Ar13, Ar23, Ar33)))
(u_r, u_i) = TrialFunctions(W)
(v_r, v_i) = TestFunctions(W)
a_r = inner(Ar*grad(u_r), grad(v_r))*dx

asked Mar 1, 2015 by jacopo.lanzoni FEniCS Novice (160 points)

1 Answer

0 votes

Hi, with UnitCubeMesh the cell of your Trial/Test functions is 'tetrahedron', while you make the cell of the expression to be 'triangle'. Hence the mismatch. The fix is

x = Expression('x[0]', cell='tetrahedron')
y = Expression('x[1]', cell='tetrahedron')
z = Expression('x[2]', cell='tetrahedron')
answered Mar 1, 2015 by MiroK FEniCS Expert (80,920 points)

Oh, thanks. This is what happens when you try to transform some script for 2D into one for 3D on a Sunday...

...