#ifdef PETSC_RCS_HEADER static char vcid[] = "$Id: shellcnv.c,v 1.4 1997/07/09 20:54:17 balay Exp bsmith $"; #endif #include "petsc.h" #include "src/mat/matimpl.h" /*I "mat.h" I*/ #include "src/vec/vecimpl.h" #undef __FUNC__ #define __FUNC__ "MatConvert_Shell" int MatConvert_Shell(Mat oldmat,MatType newtype, Mat *mat) { Vec in,out; int ierr,i,M,m,size,*rows,start,end; MPI_Comm comm; Scalar *array,zero = 0.0,one = 1.0; PetscFunctionBegin; PetscValidHeaderSpecific(oldmat,MAT_COOKIE); PetscValidPointer(mat); if (newtype != MATSEQDENSE || newtype != MATMPIDENSE) { SETERRQ(PETSC_ERR_SUP,1,"Can only convert shell matrices to dense currently"); } comm = oldmat->comm; MPI_Comm_size(comm,&size); ierr = MatGetOwnershipRange(oldmat,&start,&end); CHKERRQ(ierr); ierr = VecCreateMPI(comm,end-start,PETSC_DECIDE,&in); CHKERRQ(ierr); ierr = VecDuplicate(in,&out); CHKERRQ(ierr); ierr = VecGetSize(in,&M); CHKERRQ(ierr); ierr = VecGetLocalSize(in,&m); CHKERRQ(ierr); rows = (int *) PetscMalloc( (m+1)*sizeof(int) ); CHKPTRQ(rows); for ( i=0; i