[petsc-users] Must I destroy the local matrix I have (created and) set with MatISSetLocalMat ?
Jed Brown
jed at jedbrown.org
Tue May 30 10:36:14 CDT 2017
Franck Houssen <franck.houssen at inria.fr> writes:
> Must I destroy the local matrix I have (created and) set with MatISSetLocalMat ?
The implementation references the local matrix so you need to destroy
your copy. This pattern is always used when setting sub-objects like
this.
static PetscErrorCode MatISSetLocalMat_IS(Mat mat,Mat local)
{
Mat_IS *is = (Mat_IS*)mat->data;
PetscInt nrows,ncols,orows,ocols;
PetscErrorCode ierr;
PetscFunctionBegin;
if (is->A) {
ierr = MatGetSize(is->A,&orows,&ocols);CHKERRQ(ierr);
ierr = MatGetSize(local,&nrows,&ncols);CHKERRQ(ierr);
if (orows != nrows || ocols != ncols) SETERRQ4(PETSC_COMM_SELF,PETSC_ERR_ARG_SIZ,"Local MATIS matrix should be of size %Dx%D (you passed a %Dx%D matrix)",orows,ocols,nrows,ncols);
}
ierr = PetscObjectReference((PetscObject)local);CHKERRQ(ierr);
ierr = MatDestroy(&is->A);CHKERRQ(ierr);
is->A = local;
PetscFunctionReturn(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170530/c9fc888c/attachment-0001.pgp>
More information about the petsc-users
mailing list