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

mixed spaces over different meshes

+1 vote

Hi,
I have a basic question related to the old one of http://fenicsproject.org/qa/1216/linear-dependent-basis-function-on-fenics-formulations.
I can not understand the relationship of global functions of two different meshes on
the assembled system matrix. The code below illustrates my point.

from dolfin import *

mesh1 = UnitIntervalMesh(4)
mesh2 = UnitIntervalMesh(2)

V1 = FunctionSpace(mesh1, "CG", 2)    # 9 Lagrange global functions of degree 2
V2 = FunctionSpace(mesh2, "CG", 1)    # 3 Lagrange global functions of degree 1

V = V1 * V2

(u1, u2) = TrialFunctions(V)
v1 = TestFunction(V1)

a =  (inner(grad(u1), grad(v1)) * dx) + (inner(grad(u2), grad(v1)) * dx) 
A = assemble(a)

V1_dofs = V.sub(0).collapse(mesh1)[1].values()
V2_dofs = V.sub(1).collapse(mesh2)[1].values()

print 'V1 dofs = ', V1_dofs
print 'V2 dofs = ', V2_dofs

print 'A = ', A.array()

I would expect to find three V2 dofs associated with the functions of space V2. Mesh2 has
only 3 nodes. But there are five V2 dofs = [4, 2, 6, 9, 13]. There is no problem with
V1 dofs = [0, 1, 3, 5, 7, 8, 10, 11, 12]. There are 5 mesh nodes and
the midpoints of its elements. The assembled system matrix don't have 12 columns. I can t
understand it. Any help will be appreciated.
Thanks for availability.

asked May 15, 2014 by Andre Machado FEniCS User (1,040 points)
edited May 24, 2014 by Andre Machado

Please try to use the proper formatting. You have then a better chance to obtain an answer.

1 Answer

+3 votes

As far as I know you cannot have a mixed space of function spaces defined on different meshes. There mistake should have been captured, though, so looks to me like a bug. Please correct me if I'm wrong?

answered May 21, 2014 by mikael-mortensen FEniCS Expert (29,340 points)

Mikael, thank you for the feedback. Is not possible to do this with nested meshes / hierarchically related Function spaces? I am not completely convinced that it is impossible.
Any help about this dofs relations would be appreciated.

This is from line 483 of site-packages/functions/functionspace.py:

    #if not all(V.mesh() == spaces[0].mesh() for V in spaces):
    #    cpp.dolfin_error("functionspace.py", "Nonmatching meshes for mixed function space: " \
    #              + str([V.mesh() for V in spaces]))

Don't know why it's commented out. Uncommented it would catch your effort to create a mixed space with two different meshes. You could post a question on why on the fenics mailinglist or report a bug (that your mixed space is created) on bitbucket.

Using FEniCS >= 1.5 and this multimesh or mshr functionalities
is possible to assemble a form a over two distict meshes
(hierarquicaly related)?

...