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

Manipulate the indexing of Mixed Function Space

+1 vote

Hello,

Before the recent removal of the 'MixedFunctionSpace', I had the following code:

V = VectorFunctionSpace(mesh, "CG",lagrange_order)
ME = MixedFunctionSpace([V,V,V])
v = TestFunctions(ME)
u = TrialFunctions(ME)

before the update, v had the following index structure:

v[0][0]
v[0][1]
v[1][0]
v[1][1]
v[2][0]
v[2][1]

So now, I created a Mixed Function Space using a VectorElement as follows:

V = VectorElement("Lagrange", mesh.ufl_cell(), lagrange_order, dim=2)
ME = FunctionSpace(mesh,V*V*V)
v = TestFunctions(ME)
u = TrialFunctions(ME)

But then after the update, it shows the following:

v[0][0]
v[0][1]
v[0][2]
v[0][3]
v[1][0]
v[1][1]

Which is a problem as all my expressions relied on explicitly calling the indices with the old structure.

Is there a way to customize the MixedFunctionSpace indexing?

asked Jan 9, 2017 by plastic_beach FEniCS Novice (190 points)

1 Answer

+3 votes
 
Best answer

Hi, the space needs to be defined in a different way. Consider

from dolfin import *

mesh = UnitSquareMesh(10, 10)
V = VectorElement("Lagrange", mesh.ufl_cell(), 1, dim=2)

ME = FunctionSpace(mesh, V*V*V)
for i in range(ME.num_sub_spaces()): print ME.sub(i).num_sub_spaces()
print

ME = FunctionSpace(mesh, MixedElement([V, V, V]))
for i in range(ME.num_sub_spaces()): print ME.sub(i).num_sub_spaces() 
answered Jan 9, 2017 by MiroK FEniCS Expert (80,920 points)
selected Jan 10, 2017 by plastic_beach

It worked. Thanks a lot MiroK

...