Hello,

We are working with an application using SNES and having a problem with the 
SNESFunction f called by SNESSetFunction(SNES snes,Vec r,PetscErrorCode 
(*f)(SNES,Vec,Vec,void*),void *ctx).

We would like our SNESFunction(SNES snes,Vec x,Vec f,void *ctx) to be able to 
modify Vec x each time the function is called, how ever the vector is locked 
read only. We are running PETSc 3.9.3 with debugging turned on which tells us 
that Vec x is locked read only.

To get around this, we have tried to make a local copy of the Vec x using 
VecCopy (x, xCopy). This gave us the error:
[0]PETSC ERROR: Null argument, when expecting valid pointer
[0]PETSC ERROR: Null Object: Parameter # 2


We have also tried using VecDuplicate(vecWithDesiredLayout, &xLocalCopy) and 
then VecSetValues to fill the xLocalCopy with the values of Vec x. This gave 
the error:
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR:  Vec is locked read only, argument # 2


Also, we have tried using VecLockPop in PETSc 3.9.3 to overide the the lock 
however this seems gives a "Vector has been unlocked too many times" error at 
runtime:
[0]PETSC ERROR: Object is in wrong state
[0]PETSC ERROR: Vector has been unlocked too many times


Any advice on how to make a local, modifiable copy of the locked read only 
vector? Any and All help is appreciated!

Andy Holm
Aeroscience Engineer
Kratos Defense and Security Solutions
4904 Research Drive
Huntsville, AL 35805

Reply via email to