Hi Lawrence,

thanks, updating PETSc, petsc4py, ufl and firedrake fixes this, i.e. I can project the expression. However, I still have an issue when using PETSc vectors twice.

What I do in my code is this:

(in the constructor)
self._x = PETSc.Vec()
self._x.create()
self._x.setSizes((self._ndof, None))
self._x.setFromOptions()
self._y = self._x.duplicate()

(in the solve routine)
[line 208]: self._ksp.solve(self._y,self._x)

When I call the solve routine a second time (I do a warmup solve first) I still get the error that the vector is in the wrong state (see below). Do I have to unlock it?

Thanks,

Eike

  File "driver.py", line 478, in <module>
    main(parameter_filename)
  File "driver.py", line 388, in main
    u,p,b = gravitywave_solver_matrixfree.solve(r_u,r_p,r_b)
  File "/Users/eikemueller/PostDocBath/EllipticSolvers/Firedrake_workspace/firedrake-helmholtzsolver/source/gravitywaves.py", line 208, in solve
    self._ksp.solve(self._y,self._x)
  File "KSP.pyx", line 353, in petsc4py.PETSc.KSP.solve (src/petsc4py.PETSc.c:139671)
  File "libpetsc4py.pyx", line 1330, in libpetsc4py.PCApply_Python (src/libpetsc4py/libpetsc4py.c:13951)
  File "/Users/eikemueller/PostDocBath/EllipticSolvers/Firedrake_workspace/firedrake-helmholtzsolver/source/mixedpreconditioners.py", line 138, in apply
    self._mixedarray.split(x,u,p)
  File "/Users/eikemueller/PostDocBath/EllipticSolvers/Firedrake_workspace/firedrake-helmholtzsolver/source/mixedarray.py", line 65, in split
    x.array[:] = v.array[min_idx:max_idx]
  File "Vec.pyx", line 815, in petsc4py.PETSc.Vec.array.__get__ (src/petsc4py.PETSc.c:91905)
  File "arraynpy.pxi", line 67, in petsc4py.PETSc.asarray (src/petsc4py.PETSc.c:7333)
  File "petscvec.pxi", line 469, in petsc4py.PETSc._Vec_buffer.__getreadbuffer__ (src/petsc4py.PETSc.c:19630)
  File "petscvec.pxi", line 459, in petsc4py.PETSc._Vec_buffer.getbuffer (src/petsc4py.PETSc.c:19460)
petsc4py.PETSc.Error: error code 73
[0] KSPSolve() line 572 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/src/ksp/ksp/interface/itfunc.c
[0] KSPSolve_GMRES() line 234 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/src/ksp/ksp/impls/gmres/gmres.c
[0] KSPInitialResidual() line 63 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/src/ksp/ksp/interface/itres.c
[0] KSP_PCApply() line 235 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/include/petsc-private/kspimpl.h
[0] PCApply() line 449 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/src/ksp/pc/interface/precon.c
[0] VecGetArray() line 1646 in /Users/eikemueller/PostDocBath/EllipticSolvers/petsc/src/vec/vec/interface/rvector.c
[0] Object is in wrong state
[0]  Vec is locked read only, argument # 1
--

Dr Eike Hermann Mueller
Research Associate (PostDoc)

Department of Mathematical Sciences
University of Bath
Bath BA2 7AY, United Kingdom

+44 1225 38 5803
e.mueller@bath.ac.uk
http://people.bath.ac.uk/em459/

On 17 Feb 2015, at 11:30, Lawrence Mitchell <lawrence.mitchell@imperial.ac.uk> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 14/02/15 11:23, Eike Mueller wrote:
Dear firedrakers,

having just updated both petsc and petsc4py on my laptop (pulled
latest revision of mapdes/firedrake branch in both cases, and I use
the origin/multigrid-extrusion branch of firedrake), I get the
error message below when I try to project an expression onto a DG
function:

r_p = Function(W3) expression =
Expression('exp(-0.5*(x[0]*x[0]+x[1]*x[1])/(0.25*0.25))')
r_p.project(expression)

This issue only came up with the PETSc update I did, never seen it
before.

Yes, this is due to a petsc change.

This is fixed in firedrake master.

I have also merged the multigrid-extrusion branch to master so you
should be able to run with:

mapdes petsc/petsc4py (firedrake branches)
firedrake master


Cheers,

Lawrence
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQEcBAEBAgAGBQJU4yZfAAoJECOc1kQ8PEYvDZIH/1t7sgZEN9DZuuooKa8scDiA
KmXg5dkgmdW9kqGuMdua+Yyjgc9BF9wC3I0Wp+GqixTMJlZe0HqmU/cX28b6ONHr
qngtwf1mD2CK/v+KUlEdTbiafBSHPOHBMZxfnB2VoAMeuqZtwVhXeBFnb8u3hczn
B6/8Qlpg3+H4sTpSjMTawdntSi5vPomGCielP94ORHVj2aRYOC6IdhgZpKrQHcT1
F51Rnlq9Vxl6W2aqA86qrwvV6GdLHmBBBhskQ5Qui+vQRiTSdeEyzkyBvewqL9f3
898nRRA24fKWZN0x3+aQSUKbFWJTxnCN9RHuT5xK8B/4Au/HQ80I8AFur6uX5SY=
=TDtv
-----END PGP SIGNATURE-----

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake