[petsc-users] Creating Local Copy of locked read only Vec

Smith, Barry F. bsmith at mcs.anl.gov
Wed Aug 28 11:13:59 CDT 2019


  You should be able to do VecDuplicate() and then VecCopy() into the duplicate but there may be a bug with the lock being passed through the VecDuplicate() we'll check this and get back to your soon.

    Barry


> On Aug 28, 2019, at 10:38 AM, Andrew Holm via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> 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



More information about the petsc-users mailing list