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

the typr is agin'list'. Just wite print type(F_vector). I want this result as <class 'dolfin.cpp.la.GeneraivVector>

–1 vote
asked Feb 15, 2016 by abdul FEniCS Novice (250 points)

1 Answer

0 votes
 
Best answer

Maybe try:

from dolfin import *
import numpy as np

yourlist = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
np_list = np.zeros(len(yourlist), dtype=np.float_)
np_list[:] = yourlist

mesh = UnitSquareMesh(2,2)
V = FunctionSpace(mesh, 'CG', 1)

F = Function(V)
F_vector = F.vector()
F_vector.set_local(np_list)
answered Feb 15, 2016 by hernan_mella FEniCS Expert (19,460 points)
selected Feb 15, 2016 by abdul
...