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

vector() method with 1.5.0 version

0 votes

Hi,
I have some problems with the vector() method in the new release 1.5.0.

If I run this simple code:

from dolfin import*

mesh = UnitSquareMesh(10, 10)
V = FunctionSpace(mesh, 'CG', 1)
f = Function(V)

f.interpolate(Expression("1+x[0]"))

plot(f)

print 'a1 =', f.vector().array()

print 'a2 =', f.compute_vertex_values()

interactive()

What I get is:

a1 = [ 1.   1.   1.1  1.   1.1  1.2  1.   1.1  1.2  1.3  1.   1.1  1.2  1.3  1.4
  1.   1.1  1.2  1.3  1.4  1.5  1.   1.1  1.2  1.3  1.4  1.5  1.6  1.   1.1
  1.2  1.3  1.4  1.5  1.6  1.7  1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8
  1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  1.   1.1  1.2  1.3  1.4
  1.5  1.6  1.7  1.8  1.9  2.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9
  2.   1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.3  1.4  1.5  1.6  1.7
  1.8  1.9  2.   1.4  1.5  1.6  1.7  1.8  1.9  2.   1.5  1.6  1.7  1.8  1.9
  2.   1.6  1.7  1.8  1.9  2.   1.7  1.8  1.9  2.   1.8  1.9  2.   1.9  2.
  2. ]

a2 = [ 1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3
  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7
  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.
  1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4
  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8
  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1
  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5
  1.6  1.7  1.8  1.9  2.   1.   1.1  1.2  1.3  1.4  1.5  1.6  1.7  1.8  1.9
  2. ]

In the case of a2, obtained with the new method compute_vertex_values(), vertex values are ordered with the number of vertex in the mesh, while concerning a1 values are ordered in a different way. How can I get the same result with the vector() method and fix this? This never happened in older releases.

Thank you very much

Lisa

asked Feb 13, 2015 by lisa_grementieri FEniCS Novice (240 points)

1 Answer

0 votes
 
Best answer

Try setting parameters["reorder_dofs_serial"] = False at the top of your code.

answered Feb 13, 2015 by chris_richardson FEniCS Expert (31,740 points)
selected Feb 16, 2015 by lisa_grementieri

Thank you,
this solved the issue!

...