/* This is used in VecGhostGetLocalForm and VecGhostRestoreLocalForm to ensure that the state is updated if either vector has changed since the last time one of these functions was called. It could apply to any PetscObject, but VecGhost is quite different from other objects in that two separate vectors look at the same memory. In principle, we could only propagate state to the local vector on GetLocalForm and to the global vector on RestoreLocalForm, but this version is more conservative (i.e. robust against misuse) and simpler. Note that this function is correct and changes nothing if both arguments are the same, which is the case in serial. */ static PetscErrorCode VecGhostStateSync_Private(Vec g,Vec l) { PetscErrorCode ierr; PetscInt gstate,lstate; PetscFunctionBegin; ierr = PetscObjectStateQuery((PetscObject)g,&gstate);CHKERRQ(ierr); ierr = PetscObjectStateQuery((PetscObject)l,&lstate);CHKERRQ(ierr); ierr = PetscObjectSetState((PetscObject)g,PetscMax(gstate,lstate));CHKERRQ(ierr); ierr = PetscObjectSetState((PetscObject)l,PetscMax(gstate,lstate));CHKERRQ(ierr); PetscFunctionReturn(0); }
static dErr VecStateSync_Private(Vec x,Vec y) { dInt xstate,ystate; dErr err; dFunctionBegin; dValidHeader(x,VEC_CLASSID,1); dValidHeader(y,VEC_CLASSID,2); err = PetscObjectStateQuery((dObject)x,&xstate);dCHK(err); err = PetscObjectStateQuery((dObject)y,&ystate);dCHK(err); err = PetscObjectSetState((dObject)x,dMaxInt(xstate,ystate));dCHK(err); err = PetscObjectSetState((dObject)y,dMaxInt(xstate,ystate));dCHK(err); dFunctionReturn(0); }