I’m trying to generate a generic vector (not related to a particular function space), but I receive an error when I try to perform an update of the vector. Example code snippet below.
from dolfin import Vector, PETScVector
from petsc4py import PETSc
import numpy as np
x = PETSc.Vec().createSeq(3)
X = Vector(PETScVector(x))
X.get_local()
#array([ 0., 0., 0.])
X.set_local(np.array([1,2,3],dtype=np.float64))
The last command produces the following error
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to successfully call PETSc function 'VecSetValuesLocal'.
*** Reason: PETSc error code is: 73 (Object is in wrong state).
*** Where: This error was encountered inside /tmp/sebo/fenics/dolfin-2017.2.0/dolfin/la/PETScVector.cpp.
*** Process: 0
***
*** DOLFIN version: 2017.2.0
*** Git changeset:
*** -------------------------------------------------------------------------