[petsc-users] Error message after call VecSet(R_, zero)

Barry Smith bsmith at mcs.anl.gov
Tue Sep 7 18:29:47 CDT 2010


   The error messages says it all. You must have calls to VecSetValues() before the VecSet() but not have a VecAssemblyBegin/End(). After your VecSetValues() you always need to have VecAssemblyBegin/End()

    Barry

On Sep 7, 2010, at 5:56 PM, NAN ZHAO wrote:

> Dear all,
> 
> I got a strange petsc error when I am running my code with petsc as a linear sover:
> [0]PETSC ERROR: --------------------- Error Message ------------------------------------
> [0]PETSC ERROR: Object is in wrong state!
> [0]PETSC ERROR: You cannot call this after you have called VecSetValues() but
>  before you have called VecAssemblyBegin/End()!
> [0]PETSC ERROR: ------------------------------------------------------------------------
> [0]PETSC ERROR: Petsc Release Version 2.3.3, Patch 15, Tue Sep 23 10:02:49 CDT 2008 HG revision: 31306062cd1a6f6a2496fccb4878f485c9b91760
> [0]PETSC ERROR: See docs/changes/index.html for recent updates.
> [0]PETSC ERROR: See docs/faq.html for hints about trouble shooting.
> [0]PETSC ERROR: See docs/index.html for manual pages.
> I think this error is happening when I want to reset the vector and matrix to zero before solving the Ax=b,
> this is my code:
> PetscScalar zero = 0.;
> 
>   // Reset J, R and Y
>   cout<<"reset jacobian to zero"<<endl;
>   MatZeroEntries(J_);
>   cout<<"reset R to zero"<<endl;
>   VecSet(R_, zero);
>   cout<<"reset Y to zero"<<endl;
>   VecSet(Y_, zero);
> 
> Is anyone have some clue to solve this problem.
> 
> Thanks,
> 
> Nan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100907/e899c48c/attachment.htm>


More information about the petsc-users mailing list