1: #include <petsc/private/matimpl.h> 2: #include <../src/mat/impls/aij/seq/aij.h> 4: PetscErrorCode MatDestroySubMatrix_Dummy(Mat C) 5: { 7: Mat_SubSppt *submatj = (Mat_SubSppt*)C->data; 10: submatj->destroy(C); 11: MatDestroySubMatrix_Private(submatj); 12: return(0); 13: } 15: PetscErrorCode MatDestroySubMatrices_Dummy(PetscInt n, Mat *mat[]) 16: { 20: /* Destroy dummy submatrices (*mat)[n]...(*mat)[n+nstages-1] used for reuse struct Mat_SubSppt */ 21: if ((*mat)[n]) { 22: PetscBool isdummy; 23: PetscObjectTypeCompare((PetscObject)(*mat)[n],MATDUMMY,&isdummy); 24: if (isdummy) { 25: Mat_SubSppt* smat = (Mat_SubSppt*)((*mat)[n]->data); /* singleis and nstages are saved in (*mat)[n]->data */ 27: if (smat && !smat->singleis) { 28: PetscInt i,nstages=smat->nstages; 29: for (i=0; i<nstages; i++) { 30: MatDestroy(&(*mat)[n+i]); 31: } 32: } 33: } 34: } 36: /* memory is allocated even if n = 0 */ 37: PetscFree(*mat); 38: return(0); 39: } 41: PetscErrorCode MatDestroy_Dummy(Mat A) 42: { 46: PetscObjectChangeTypeName((PetscObject)A,0); 47: return(0); 48: } 50: /*MC 51: MATDUMMY - A matrix type to be used for reusing specific internal data structure. 53: Level: advanced 55: .seealso: Mat 57: M*/ 59: PETSC_EXTERN PetscErrorCode MatCreate_Dummy(Mat A) 60: { 61: PetscErrorCode ierr; 64: /* matrix ops */ 65: PetscMemzero(A->ops,sizeof(struct _MatOps)); 66: A->ops->destroy = MatDestroy_Dummy; 67: A->ops->destroysubmatrices = MatDestroySubMatrices_Dummy; 69: /* special MATPREALLOCATOR functions */ 70: PetscObjectChangeTypeName((PetscObject)A,MATDUMMY); 71: return(0); 72: }