1be1d678aSKris Buschelman #define PETSCMAT_DLL 2be1d678aSKris Buschelman 3b4319ba4SBarry Smith /* 4b4319ba4SBarry Smith Creates a matrix class for using the Neumann-Neumann type preconditioners. 5b4319ba4SBarry Smith This stores the matrices in globally unassembled form. Each processor 6b4319ba4SBarry Smith assembles only its local Neumann problem and the parallel matrix vector 7b4319ba4SBarry Smith product is handled "implicitly". 8b4319ba4SBarry Smith 9b4319ba4SBarry Smith We provide: 10b4319ba4SBarry Smith MatMult() 11b4319ba4SBarry Smith 12b4319ba4SBarry Smith Currently this allows for only one subdomain per processor. 13b4319ba4SBarry Smith 14b4319ba4SBarry Smith */ 15b4319ba4SBarry Smith 16b4319ba4SBarry Smith #include "src/mat/impls/is/matis.h" /*I "petscmat.h" I*/ 17b4319ba4SBarry Smith 18b4319ba4SBarry Smith #undef __FUNCT__ 19b4319ba4SBarry Smith #define __FUNCT__ "MatDestroy_IS" 20dfbe8321SBarry Smith PetscErrorCode MatDestroy_IS(Mat A) 21b4319ba4SBarry Smith { 22dfbe8321SBarry Smith PetscErrorCode ierr; 23b4319ba4SBarry Smith Mat_IS *b = (Mat_IS*)A->data; 24b4319ba4SBarry Smith 25b4319ba4SBarry Smith PetscFunctionBegin; 26b4319ba4SBarry Smith if (b->A) { 27b4319ba4SBarry Smith ierr = MatDestroy(b->A);CHKERRQ(ierr); 28b4319ba4SBarry Smith } 29b4319ba4SBarry Smith if (b->ctx) { 30b4319ba4SBarry Smith ierr = VecScatterDestroy(b->ctx);CHKERRQ(ierr); 31b4319ba4SBarry Smith } 32b4319ba4SBarry Smith if (b->x) { 33b4319ba4SBarry Smith ierr = VecDestroy(b->x);CHKERRQ(ierr); 34b4319ba4SBarry Smith } 35b4319ba4SBarry Smith if (b->y) { 36b4319ba4SBarry Smith ierr = VecDestroy(b->y);CHKERRQ(ierr); 37b4319ba4SBarry Smith } 38b4319ba4SBarry Smith if (b->mapping) { 39b4319ba4SBarry Smith ierr = ISLocalToGlobalMappingDestroy(b->mapping);CHKERRQ(ierr); 40b4319ba4SBarry Smith } 41b4319ba4SBarry Smith ierr = PetscFree(b);CHKERRQ(ierr); 42*dbd8c25aSHong Zhang ierr = PetscObjectChangeTypeName((PetscObject)A,0);CHKERRQ(ierr); 43901853e0SKris Buschelman ierr = PetscObjectComposeFunction((PetscObject)A,"MatISGetLocalMat_C","",PETSC_NULL);CHKERRQ(ierr); 44b4319ba4SBarry Smith PetscFunctionReturn(0); 45b4319ba4SBarry Smith } 46b4319ba4SBarry Smith 47b4319ba4SBarry Smith #undef __FUNCT__ 48b4319ba4SBarry Smith #define __FUNCT__ "MatMult_IS" 49dfbe8321SBarry Smith PetscErrorCode MatMult_IS(Mat A,Vec x,Vec y) 50b4319ba4SBarry Smith { 51dfbe8321SBarry Smith PetscErrorCode ierr; 52b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 53b4319ba4SBarry Smith PetscScalar zero = 0.0; 54b4319ba4SBarry Smith 55b4319ba4SBarry Smith PetscFunctionBegin; 56b4319ba4SBarry Smith /* scatter the global vector x into the local work vector */ 57b4319ba4SBarry Smith ierr = VecScatterBegin(x,is->x,INSERT_VALUES,SCATTER_FORWARD,is->ctx);CHKERRQ(ierr); 58b4319ba4SBarry Smith ierr = VecScatterEnd(x,is->x,INSERT_VALUES,SCATTER_FORWARD,is->ctx);CHKERRQ(ierr); 59b4319ba4SBarry Smith 60b4319ba4SBarry Smith /* multiply the local matrix */ 61b4319ba4SBarry Smith ierr = MatMult(is->A,is->x,is->y);CHKERRQ(ierr); 62b4319ba4SBarry Smith 63b4319ba4SBarry Smith /* scatter product back into global memory */ 642dcb1b2aSMatthew Knepley ierr = VecSet(y,zero);CHKERRQ(ierr); 65b4319ba4SBarry Smith ierr = VecScatterBegin(is->y,y,ADD_VALUES,SCATTER_REVERSE,is->ctx);CHKERRQ(ierr); 66b4319ba4SBarry Smith ierr = VecScatterEnd(is->y,y,ADD_VALUES,SCATTER_REVERSE,is->ctx);CHKERRQ(ierr); 67b4319ba4SBarry Smith 68b4319ba4SBarry Smith PetscFunctionReturn(0); 69b4319ba4SBarry Smith } 70b4319ba4SBarry Smith 71b4319ba4SBarry Smith #undef __FUNCT__ 72b4319ba4SBarry Smith #define __FUNCT__ "MatView_IS" 73dfbe8321SBarry Smith PetscErrorCode MatView_IS(Mat A,PetscViewer viewer) 74b4319ba4SBarry Smith { 75b4319ba4SBarry Smith Mat_IS *a = (Mat_IS*)A->data; 76dfbe8321SBarry Smith PetscErrorCode ierr; 77b4319ba4SBarry Smith PetscViewer sviewer; 78b4319ba4SBarry Smith 79b4319ba4SBarry Smith PetscFunctionBegin; 80b4319ba4SBarry Smith ierr = PetscViewerGetSingleton(viewer,&sviewer);CHKERRQ(ierr); 81b4319ba4SBarry Smith ierr = MatView(a->A,sviewer);CHKERRQ(ierr); 82b4319ba4SBarry Smith ierr = PetscViewerRestoreSingleton(viewer,&sviewer);CHKERRQ(ierr); 83b4319ba4SBarry Smith PetscFunctionReturn(0); 84b4319ba4SBarry Smith } 85b4319ba4SBarry Smith 86b4319ba4SBarry Smith #undef __FUNCT__ 87b4319ba4SBarry Smith #define __FUNCT__ "MatSetLocalToGlobalMapping_IS" 88dfbe8321SBarry Smith PetscErrorCode MatSetLocalToGlobalMapping_IS(Mat A,ISLocalToGlobalMapping mapping) 89b4319ba4SBarry Smith { 90dfbe8321SBarry Smith PetscErrorCode ierr; 9113f74950SBarry Smith PetscInt n; 92b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 93b4319ba4SBarry Smith IS from,to; 94b4319ba4SBarry Smith Vec global; 95b4319ba4SBarry Smith 96b4319ba4SBarry Smith PetscFunctionBegin; 97b4319ba4SBarry Smith is->mapping = mapping; 98b4319ba4SBarry Smith ierr = PetscObjectReference((PetscObject)mapping);CHKERRQ(ierr); 99b4319ba4SBarry Smith 100b4319ba4SBarry Smith /* Create the local matrix A */ 101b4319ba4SBarry Smith ierr = ISLocalToGlobalMappingGetSize(mapping,&n);CHKERRQ(ierr); 102f69a0ea3SMatthew Knepley ierr = MatCreate(PETSC_COMM_SELF,&is->A);CHKERRQ(ierr); 103f69a0ea3SMatthew Knepley ierr = MatSetSizes(is->A,n,n,n,n);CHKERRQ(ierr); 104b4319ba4SBarry Smith ierr = PetscObjectSetOptionsPrefix((PetscObject)is->A,"is");CHKERRQ(ierr); 105b4319ba4SBarry Smith ierr = MatSetFromOptions(is->A);CHKERRQ(ierr); 106b4319ba4SBarry Smith 107b4319ba4SBarry Smith /* Create the local work vectors */ 108b4319ba4SBarry Smith ierr = VecCreateSeq(PETSC_COMM_SELF,n,&is->x);CHKERRQ(ierr); 109b4319ba4SBarry Smith ierr = VecDuplicate(is->x,&is->y);CHKERRQ(ierr); 110b4319ba4SBarry Smith 111b4319ba4SBarry Smith /* setup the global to local scatter */ 112b4319ba4SBarry Smith ierr = ISCreateStride(PETSC_COMM_SELF,n,0,1,&to);CHKERRQ(ierr); 113b4319ba4SBarry Smith ierr = ISLocalToGlobalMappingApplyIS(mapping,to,&from);CHKERRQ(ierr); 114899cda47SBarry Smith ierr = VecCreateMPI(A->comm,A->cmap.n,A->cmap.N,&global);CHKERRQ(ierr); 115b4319ba4SBarry Smith ierr = VecScatterCreate(global,from,is->x,to,&is->ctx);CHKERRQ(ierr); 116b4319ba4SBarry Smith ierr = VecDestroy(global);CHKERRQ(ierr); 117b4319ba4SBarry Smith ierr = ISDestroy(to);CHKERRQ(ierr); 118b4319ba4SBarry Smith ierr = ISDestroy(from);CHKERRQ(ierr); 119b4319ba4SBarry Smith PetscFunctionReturn(0); 120b4319ba4SBarry Smith } 121b4319ba4SBarry Smith 122b4319ba4SBarry Smith 123b4319ba4SBarry Smith #undef __FUNCT__ 124b4319ba4SBarry Smith #define __FUNCT__ "MatSetValuesLocal_IS" 12513f74950SBarry Smith PetscErrorCode MatSetValuesLocal_IS(Mat A,PetscInt m,const PetscInt *rows, PetscInt n,const PetscInt *cols,const PetscScalar *values,InsertMode addv) 126b4319ba4SBarry Smith { 127dfbe8321SBarry Smith PetscErrorCode ierr; 128b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 129b4319ba4SBarry Smith 130b4319ba4SBarry Smith PetscFunctionBegin; 131b4319ba4SBarry Smith ierr = MatSetValues(is->A,m,rows,n,cols,values,addv);CHKERRQ(ierr); 132b4319ba4SBarry Smith PetscFunctionReturn(0); 133b4319ba4SBarry Smith } 134b4319ba4SBarry Smith 135b4319ba4SBarry Smith #undef __FUNCT__ 136b4319ba4SBarry Smith #define __FUNCT__ "MatZeroRowsLocal_IS" 137f4df32b1SMatthew Knepley PetscErrorCode MatZeroRowsLocal_IS(Mat A,PetscInt n,const PetscInt rows[],PetscScalar diag) 138b4319ba4SBarry Smith { 139b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 140dfbe8321SBarry Smith PetscErrorCode ierr; 141f4df32b1SMatthew Knepley PetscInt i; 142b4319ba4SBarry Smith PetscScalar *array; 143b4319ba4SBarry Smith 144b4319ba4SBarry Smith PetscFunctionBegin; 145b4319ba4SBarry Smith { 146b4319ba4SBarry Smith /* 147b4319ba4SBarry Smith Set up is->x as a "counting vector". This is in order to MatMult_IS 148b4319ba4SBarry Smith work properly in the interface nodes. 149b4319ba4SBarry Smith */ 150b4319ba4SBarry Smith Vec counter; 151b4319ba4SBarry Smith PetscScalar one=1.0, zero=0.0; 152899cda47SBarry Smith ierr = VecCreateMPI(A->comm,A->cmap.n,A->cmap.N,&counter);CHKERRQ(ierr); 1532dcb1b2aSMatthew Knepley ierr = VecSet(counter,zero);CHKERRQ(ierr); 1542dcb1b2aSMatthew Knepley ierr = VecSet(is->x,one);CHKERRQ(ierr); 155b4319ba4SBarry Smith ierr = VecScatterBegin(is->x,counter,ADD_VALUES,SCATTER_REVERSE,is->ctx);CHKERRQ(ierr); 156b4319ba4SBarry Smith ierr = VecScatterEnd (is->x,counter,ADD_VALUES,SCATTER_REVERSE,is->ctx);CHKERRQ(ierr); 157b4319ba4SBarry Smith ierr = VecScatterBegin(counter,is->x,INSERT_VALUES,SCATTER_FORWARD,is->ctx);CHKERRQ(ierr); 158b4319ba4SBarry Smith ierr = VecScatterEnd (counter,is->x,INSERT_VALUES,SCATTER_FORWARD,is->ctx);CHKERRQ(ierr); 159b4319ba4SBarry Smith ierr = VecDestroy(counter);CHKERRQ(ierr); 160b4319ba4SBarry Smith } 161958c9bccSBarry Smith if (!n) { 162b4319ba4SBarry Smith is->pure_neumann = PETSC_TRUE; 163b4319ba4SBarry Smith } else { 164b4319ba4SBarry Smith is->pure_neumann = PETSC_FALSE; 165b4319ba4SBarry Smith ierr = VecGetArray(is->x,&array);CHKERRQ(ierr); 166f4df32b1SMatthew Knepley ierr = MatZeroRows(is->A,n,rows,diag);CHKERRQ(ierr); 167b4319ba4SBarry Smith for (i=0; i<n; i++) { 168f4df32b1SMatthew Knepley ierr = MatSetValue(is->A,rows[i],rows[i],diag/(array[rows[i]]),INSERT_VALUES);CHKERRQ(ierr); 169b4319ba4SBarry Smith } 170b4319ba4SBarry Smith ierr = MatAssemblyBegin(is->A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); 171b4319ba4SBarry Smith ierr = MatAssemblyEnd (is->A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr); 172b4319ba4SBarry Smith ierr = VecRestoreArray(is->x,&array);CHKERRQ(ierr); 173b4319ba4SBarry Smith } 174b4319ba4SBarry Smith 175b4319ba4SBarry Smith PetscFunctionReturn(0); 176b4319ba4SBarry Smith } 177b4319ba4SBarry Smith 178b4319ba4SBarry Smith #undef __FUNCT__ 179b4319ba4SBarry Smith #define __FUNCT__ "MatAssemblyBegin_IS" 180dfbe8321SBarry Smith PetscErrorCode MatAssemblyBegin_IS(Mat A,MatAssemblyType type) 181b4319ba4SBarry Smith { 182b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 183dfbe8321SBarry Smith PetscErrorCode ierr; 184b4319ba4SBarry Smith 185b4319ba4SBarry Smith PetscFunctionBegin; 186b4319ba4SBarry Smith ierr = MatAssemblyBegin(is->A,type);CHKERRQ(ierr); 187b4319ba4SBarry Smith PetscFunctionReturn(0); 188b4319ba4SBarry Smith } 189b4319ba4SBarry Smith 190b4319ba4SBarry Smith #undef __FUNCT__ 191b4319ba4SBarry Smith #define __FUNCT__ "MatAssemblyEnd_IS" 192dfbe8321SBarry Smith PetscErrorCode MatAssemblyEnd_IS(Mat A,MatAssemblyType type) 193b4319ba4SBarry Smith { 194b4319ba4SBarry Smith Mat_IS *is = (Mat_IS*)A->data; 195dfbe8321SBarry Smith PetscErrorCode ierr; 196b4319ba4SBarry Smith 197b4319ba4SBarry Smith PetscFunctionBegin; 198b4319ba4SBarry Smith ierr = MatAssemblyEnd(is->A,type);CHKERRQ(ierr); 199b4319ba4SBarry Smith PetscFunctionReturn(0); 200b4319ba4SBarry Smith } 201b4319ba4SBarry Smith 202b4319ba4SBarry Smith EXTERN_C_BEGIN 203b4319ba4SBarry Smith #undef __FUNCT__ 204b4319ba4SBarry Smith #define __FUNCT__ "MatISGetLocalMat_IS" 205be1d678aSKris Buschelman PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat_IS(Mat mat,Mat *local) 206b4319ba4SBarry Smith { 207b4319ba4SBarry Smith Mat_IS *is = (Mat_IS *)mat->data; 208b4319ba4SBarry Smith 209b4319ba4SBarry Smith PetscFunctionBegin; 210b4319ba4SBarry Smith *local = is->A; 211b4319ba4SBarry Smith PetscFunctionReturn(0); 212b4319ba4SBarry Smith } 213b4319ba4SBarry Smith EXTERN_C_END 214b4319ba4SBarry Smith 215b4319ba4SBarry Smith #undef __FUNCT__ 216b4319ba4SBarry Smith #define __FUNCT__ "MatISGetLocalMat" 217b4319ba4SBarry Smith /*@ 218b4319ba4SBarry Smith MatISGetLocalMat - Gets the local matrix stored inside a MATIS matrix. 219b4319ba4SBarry Smith 220b4319ba4SBarry Smith Input Parameter: 221b4319ba4SBarry Smith . mat - the matrix 222b4319ba4SBarry Smith 223b4319ba4SBarry Smith Output Parameter: 224b4319ba4SBarry Smith . local - the local matrix usually MATSEQAIJ 225b4319ba4SBarry Smith 226b4319ba4SBarry Smith Level: advanced 227b4319ba4SBarry Smith 228b4319ba4SBarry Smith Notes: 229b4319ba4SBarry Smith This can be called if you have precomputed the nonzero structure of the 230b4319ba4SBarry Smith matrix and want to provide it to the inner matrix object to improve the performance 231b4319ba4SBarry Smith of the MatSetValues() operation. 232b4319ba4SBarry Smith 233b4319ba4SBarry Smith .seealso: MATIS 234b4319ba4SBarry Smith @*/ 235be1d678aSKris Buschelman PetscErrorCode PETSCMAT_DLLEXPORT MatISGetLocalMat(Mat mat,Mat *local) 236b4319ba4SBarry Smith { 237dfbe8321SBarry Smith PetscErrorCode ierr,(*f)(Mat,Mat *); 238b4319ba4SBarry Smith 239b4319ba4SBarry Smith PetscFunctionBegin; 240b4319ba4SBarry Smith PetscValidHeaderSpecific(mat,MAT_COOKIE,1); 241b4319ba4SBarry Smith PetscValidPointer(local,2); 242b4319ba4SBarry Smith ierr = PetscObjectQueryFunction((PetscObject)mat,"MatISGetLocalMat_C",(void (**)(void))&f);CHKERRQ(ierr); 243b4319ba4SBarry Smith if (f) { 244b4319ba4SBarry Smith ierr = (*f)(mat,local);CHKERRQ(ierr); 245b4319ba4SBarry Smith } else { 246b4319ba4SBarry Smith local = 0; 247b4319ba4SBarry Smith } 248b4319ba4SBarry Smith PetscFunctionReturn(0); 249b4319ba4SBarry Smith } 250b4319ba4SBarry Smith 2516726f965SBarry Smith #undef __FUNCT__ 2526726f965SBarry Smith #define __FUNCT__ "MatZeroEntries_IS" 2536726f965SBarry Smith PetscErrorCode MatZeroEntries_IS(Mat A) 2546726f965SBarry Smith { 2556726f965SBarry Smith Mat_IS *a = (Mat_IS*)A->data; 2566726f965SBarry Smith PetscErrorCode ierr; 2576726f965SBarry Smith 2586726f965SBarry Smith PetscFunctionBegin; 2596726f965SBarry Smith ierr = MatZeroEntries(a->A);CHKERRQ(ierr); 2606726f965SBarry Smith PetscFunctionReturn(0); 2616726f965SBarry Smith } 2626726f965SBarry Smith 2636726f965SBarry Smith #undef __FUNCT__ 2646726f965SBarry Smith #define __FUNCT__ "MatSetOption_IS" 2656726f965SBarry Smith PetscErrorCode MatSetOption_IS(Mat A,MatOption op) 2666726f965SBarry Smith { 2676726f965SBarry Smith Mat_IS *a = (Mat_IS*)A->data; 2686726f965SBarry Smith PetscErrorCode ierr; 2696726f965SBarry Smith 2706726f965SBarry Smith PetscFunctionBegin; 2716726f965SBarry Smith ierr = MatSetOption(a->A,op);CHKERRQ(ierr); 2726726f965SBarry Smith PetscFunctionReturn(0); 2736726f965SBarry Smith } 2746726f965SBarry Smith 275284134d9SBarry Smith #undef __FUNCT__ 276284134d9SBarry Smith #define __FUNCT__ "MatCreateIS" 277284134d9SBarry Smith /*@ 278284134d9SBarry Smith MatCreateIS - Creates a "process" unassmembled matrix, it is assembled on each 279284134d9SBarry Smith process but not across processes. 280284134d9SBarry Smith 281284134d9SBarry Smith Input Parameters: 282284134d9SBarry Smith + comm - MPI communicator that will share the matrix 283284134d9SBarry Smith . m,n,M,N - local and/or global sizes of the the left and right vector used in matrix vector products 284284134d9SBarry Smith - map - mapping that defines the global number for each local number 285284134d9SBarry Smith 286284134d9SBarry Smith Output Parameter: 287284134d9SBarry Smith . A - the resulting matrix 288284134d9SBarry Smith 2898e6c10adSSatish Balay Level: advanced 2908e6c10adSSatish Balay 291284134d9SBarry Smith Notes: See MATIS for more details 292284134d9SBarry Smith m and n are NOT related to the size of the map 293284134d9SBarry Smith 294284134d9SBarry Smith .seealso: MATIS, MatSetLocalToGlobalMapping() 295284134d9SBarry Smith @*/ 296284134d9SBarry Smith PetscErrorCode PETSCMAT_DLLEXPORT MatCreateIS(MPI_Comm comm,PetscInt m,PetscInt n,PetscInt M,PetscInt N,ISLocalToGlobalMapping map,Mat *A) 297284134d9SBarry Smith { 298284134d9SBarry Smith PetscErrorCode ierr; 299284134d9SBarry Smith 300284134d9SBarry Smith PetscFunctionBegin; 301284134d9SBarry Smith ierr = MatCreate(comm,A);CHKERRQ(ierr); 302284134d9SBarry Smith ierr = MatSetSizes(*A,m,n,M,N);CHKERRQ(ierr); 303284134d9SBarry Smith ierr = MatSetType(*A,MATIS);CHKERRQ(ierr); 304284134d9SBarry Smith ierr = MatSetLocalToGlobalMapping(*A,map);CHKERRQ(ierr); 305284134d9SBarry Smith PetscFunctionReturn(0); 306284134d9SBarry Smith } 307284134d9SBarry Smith 308b4319ba4SBarry Smith /*MC 309b4319ba4SBarry Smith MATIS - MATIS = "is" - A matrix type to be used for using the Neumann-Neumann type preconditioners. 310b4319ba4SBarry Smith This stores the matrices in globally unassembled form. Each processor 311b4319ba4SBarry Smith assembles only its local Neumann problem and the parallel matrix vector 312b4319ba4SBarry Smith product is handled "implicitly". 313b4319ba4SBarry Smith 314b4319ba4SBarry Smith Operations Provided: 3156726f965SBarry Smith + MatMult() 3166726f965SBarry Smith . MatZeroEntries() 3176726f965SBarry Smith . MatSetOption() 3186726f965SBarry Smith . MatZeroRowsLocal() 3196726f965SBarry Smith . MatSetValuesLocal() 3206726f965SBarry Smith - MatSetLocalToGlobalMapping() 321b4319ba4SBarry Smith 322b4319ba4SBarry Smith Options Database Keys: 323b4319ba4SBarry Smith . -mat_type is - sets the matrix type to "is" during a call to MatSetFromOptions() 324b4319ba4SBarry Smith 325b4319ba4SBarry Smith Notes: Options prefix for the inner matrix are given by -is_mat_xxx 326b4319ba4SBarry Smith 327b4319ba4SBarry Smith You must call MatSetLocalToGlobalMapping() before using this matrix type. 328b4319ba4SBarry Smith 329b4319ba4SBarry Smith You can do matrix preallocation on the local matrix after you obtain it with 330b4319ba4SBarry Smith MatISGetLocalMat() 331b4319ba4SBarry Smith 332b4319ba4SBarry Smith Level: advanced 333b4319ba4SBarry Smith 334b4319ba4SBarry Smith .seealso: PC, MatISGetLocalMat(), MatSetLocalToGlobalMapping() 335b4319ba4SBarry Smith 336b4319ba4SBarry Smith M*/ 337b4319ba4SBarry Smith 338b4319ba4SBarry Smith EXTERN_C_BEGIN 339b4319ba4SBarry Smith #undef __FUNCT__ 340b4319ba4SBarry Smith #define __FUNCT__ "MatCreate_IS" 341be1d678aSKris Buschelman PetscErrorCode PETSCMAT_DLLEXPORT MatCreate_IS(Mat A) 342b4319ba4SBarry Smith { 343dfbe8321SBarry Smith PetscErrorCode ierr; 344b4319ba4SBarry Smith Mat_IS *b; 345b4319ba4SBarry Smith 346b4319ba4SBarry Smith PetscFunctionBegin; 347b4319ba4SBarry Smith ierr = PetscNew(Mat_IS,&b);CHKERRQ(ierr); 348b4319ba4SBarry Smith A->data = (void*)b; 349b4319ba4SBarry Smith ierr = PetscMemzero(A->ops,sizeof(struct _MatOps));CHKERRQ(ierr); 350b4319ba4SBarry Smith A->factor = 0; 351b4319ba4SBarry Smith A->mapping = 0; 352b4319ba4SBarry Smith 353b4319ba4SBarry Smith A->ops->mult = MatMult_IS; 354b4319ba4SBarry Smith A->ops->destroy = MatDestroy_IS; 355b4319ba4SBarry Smith A->ops->setlocaltoglobalmapping = MatSetLocalToGlobalMapping_IS; 356b4319ba4SBarry Smith A->ops->setvalueslocal = MatSetValuesLocal_IS; 357b4319ba4SBarry Smith A->ops->zerorowslocal = MatZeroRowsLocal_IS; 358b4319ba4SBarry Smith A->ops->assemblybegin = MatAssemblyBegin_IS; 359b4319ba4SBarry Smith A->ops->assemblyend = MatAssemblyEnd_IS; 360b4319ba4SBarry Smith A->ops->view = MatView_IS; 3616726f965SBarry Smith A->ops->zeroentries = MatZeroEntries_IS; 3626726f965SBarry Smith A->ops->setoption = MatSetOption_IS; 363b4319ba4SBarry Smith 364899cda47SBarry Smith ierr = PetscMapInitialize(A->comm,&A->rmap);CHKERRQ(ierr); 365899cda47SBarry Smith ierr = PetscMapInitialize(A->comm,&A->cmap);CHKERRQ(ierr); 366b4319ba4SBarry Smith 367b4319ba4SBarry Smith b->A = 0; 368b4319ba4SBarry Smith b->ctx = 0; 369b4319ba4SBarry Smith b->x = 0; 370b4319ba4SBarry Smith b->y = 0; 371b4319ba4SBarry Smith ierr = PetscObjectComposeFunctionDynamic((PetscObject)A,"MatISGetLocalMat_C","MatISGetLocalMat_IS",MatISGetLocalMat_IS);CHKERRQ(ierr); 37217667f90SBarry Smith ierr = PetscObjectChangeTypeName((PetscObject)A,MATIS);CHKERRQ(ierr); 373b4319ba4SBarry Smith 374b4319ba4SBarry Smith PetscFunctionReturn(0); 375b4319ba4SBarry Smith } 376b4319ba4SBarry Smith EXTERN_C_END 377b4319ba4SBarry Smith 378b4319ba4SBarry Smith 379b4319ba4SBarry Smith 380b4319ba4SBarry Smith 381b4319ba4SBarry Smith 382b4319ba4SBarry Smith 383b4319ba4SBarry Smith 384b4319ba4SBarry Smith 385b4319ba4SBarry Smith 386b4319ba4SBarry Smith 387b4319ba4SBarry Smith 388b4319ba4SBarry Smith 389b4319ba4SBarry Smith 390