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

coefficient ordering in MixedFunctionSpace

+2 votes
Q = FunctionSpace(mesh,'CG',1)
M = MixedFunctionSpace([Q,Q,Q])
u_mixed = Function(M)
s0 = M.sub(0).dim()

Are u_mixed.vector()[0:s0] the coefficients of the subfunction u_mixed[0]?

asked Jul 18, 2013 by chaffra FEniCS User (1,830 points)

2 Answers

+1 vote
 
Best answer

You cannot make any assumption as to the ordering of dofs in a Function vector.

answered Jul 19, 2013 by Garth N. Wells FEniCS Expert (35,930 points)
selected Jul 20, 2013 by Jan Blechta

Actually you can but you should not!

+1 vote
u_mixed = interpolate(Constant((1.,2.,3.)), M)
u_mixed.vector().array()

produces output

array([ 1.,  2.,  3.,  1.,  2.,  3.,  1.,  2.,  3.,  1.,  2.,  3.,  1.,
    2.,  3.,  1.,  2.,  3.,  1.,  2.,  3.,  1.,  2.,  3.,  1.,  2.,  3.])

so answer is no.

If you're trying to handle somehow assignment to subfunction then note that the issue is now in progress. Also note that standard way of handling assignment to subfunction is for now projection or interpolation. If you want to fiddle directly with DOFs, use helper functions in M.dofmap().

answered Jul 18, 2013 by Jan Blechta FEniCS Expert (51,420 points)
...