<div class="gmail_quote">On Tue, Nov 8, 2011 at 14:05, Matthew Knepley <span dir="ltr"><<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just want to check that the following is a kosher use of the return error handler<br>
<br>
bool _is_ghosted = true;<br>
PetscErrorCode ierr;<br>
PetscPushErrorHandler(PetscReturnErrorHandler,PETSC_NULL);<br>
ierr= VecGhostGetLocalForm(*x, x_ghosted.get());<br>
if (ierr != 0 )<br>
_is_ghosted = false;<br>
PetscPopErrorHandler();<br></blockquote><div><br></div></div><div>Do you need to mess with the error handler?</div></blockquote></div><br><div>Yes, otherwise an error message would be printed.</div><div><br></div><div>
Mark, what you describe is okay. We, or you, could make a VecIsGhosted(). The code shows how it determines whether a Vec is ghosted.</div><div><br></div><div><div>PetscErrorCode VecGhostGetLocalForm(Vec g,Vec *l)</div><div>
{</div><div> PetscErrorCode ierr;</div><div> PetscBool isseq,ismpi;</div><div><br></div><div> PetscFunctionBegin;</div><div> PetscValidHeaderSpecific(g,VEC_CLASSID,1);</div><div> PetscValidPointer(l,2);</div><div>
<br></div><div> ierr = PetscTypeCompare((PetscObject)g,VECSEQ,&isseq);CHKERRQ(ierr);</div><div> ierr = PetscTypeCompare((PetscObject)g,VECMPI,&ismpi);CHKERRQ(ierr);</div><div> if (ismpi) {</div><div> Vec_MPI *v = (Vec_MPI*)g->data;</div>
<div> if (!v->localrep) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Vector is not ghosted");</div><div> *l = v->localrep;</div><div> } else if (isseq) {</div><div> *l = g;</div><div> } else {</div>
<div> SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Vector type %s does not have local representation",((PetscObject)g)->type_name);</div><div> }</div><div> ierr = VecGhostStateSync_Private(g,*l);CHKERRQ(ierr);</div>
<div> ierr = PetscObjectReference((PetscObject)*l);CHKERRQ(ierr);</div><div> PetscFunctionReturn(0);</div><div>}</div></div>