1 /* $Id: petscmat.h,v 1.228 2001/09/07 20:09:08 bsmith Exp $ */ 2 /* 3 Include file for the matrix component of PETSc 4 */ 5 #ifndef __PETSCMAT_H 6 #define __PETSCMAT_H 7 #include "petscvec.h" 8 9 /*S 10 Mat - Abstract PETSc matrix object 11 12 Level: beginner 13 14 Concepts: matrix; linear operator 15 16 .seealso: MatCreate(), MatType, MatSetType() 17 S*/ 18 typedef struct _p_Mat* Mat; 19 20 /*E 21 MatType - String with the name of a PETSc matrix or the creation function 22 with an optional dynamic library name, for example 23 http://www.mcs.anl.gov/petsc/lib.a:mymatcreate() 24 25 Level: beginner 26 27 .seealso: MatSetType(), Mat 28 E*/ 29 #define MATSAME "same" 30 #define MATSEQMAIJ "seqmaij" 31 #define MATMPIMAIJ "mpimaij" 32 #define MATIS "is" 33 #define MATMPIROWBS "mpirowbs" 34 #define MATSEQDENSE "seqdense" 35 #define MATSEQAIJ "seqaij" 36 #define MATMPIAIJ "mpiaij" 37 #define MATSHELL "shell" 38 #define MATSEQBDIAG "seqbdiag" 39 #define MATMPIBDIAG "mpibdiag" 40 #define MATMPIDENSE "mpidense" 41 #define MATSEQBAIJ "seqbaij" 42 #define MATMPIBAIJ "mpibaij" 43 #define MATMPIADJ "mpiadj" 44 #define MATSEQSBAIJ "seqsbaij" 45 #define MATMPISBAIJ "mpisbaij" 46 #define MATDAAD "daad" 47 #define MATMFFD "mffd" 48 #define MATESI "esi" 49 #define MATPETSCESI "petscesi" 50 #define MATNORMAL "normal" 51 #define MATSEQAIJSPOOLES "seqaijspooles" 52 typedef char* MatType; 53 54 #define MAT_SER_SEQAIJ_BINARY "seqaij_binary" 55 #define MAT_SER_MPIAIJ_BINARY "mpiaij_binary" 56 typedef char *MatSerializeType; 57 58 /* Logging support */ 59 #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 60 extern int MAT_COOKIE; 61 extern int MATSNESMFCTX_COOKIE; 62 extern int MAT_FDCOLORING_COOKIE; 63 extern int MAT_PARTITIONING_COOKIE; 64 extern int MAT_NULLSPACE_COOKIE; 65 extern int MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose; 66 extern int MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose; 67 extern int MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic; 68 extern int MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor; 69 extern int MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin; 70 extern int MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering; 71 extern int MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate; 72 extern int MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction; 73 74 EXTERN int MatInitializePackage(char *); 75 76 EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*); 77 EXTERN int MatSetType(Mat,MatType); 78 EXTERN int MatSetFromOptions(Mat); 79 EXTERN int MatSetUpPreallocation(Mat); 80 EXTERN int MatRegisterAll(char*); 81 EXTERN int MatRegister(char*,char*,char*,int(*)(Mat)); 82 EXTERN int MatSerializeRegister(const char [], const char [], const char [], int (*)(MPI_Comm, Mat *, PetscViewer, PetscTruth)); 83 84 /*MC 85 MatRegisterDynamic - Adds a new matrix type 86 87 Synopsis: 88 int MatRegisterDynamic(char *name,char *path,char *name_create,int (*routine_create)(Mat)) 89 90 Not Collective 91 92 Input Parameters: 93 + name - name of a new user-defined matrix type 94 . path - path (either absolute or relative) the library containing this solver 95 . name_create - name of routine to create method context 96 - routine_create - routine to create method context 97 98 Notes: 99 MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 100 101 If dynamic libraries are used, then the fourth input argument (routine_create) 102 is ignored. 103 104 Sample usage: 105 .vb 106 MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 107 "MyMatCreate",MyMatCreate); 108 .ve 109 110 Then, your solver can be chosen with the procedural interface via 111 $ MatSetType(Mat,"my_mat") 112 or at runtime via the option 113 $ -mat_type my_mat 114 115 Level: advanced 116 117 Notes: ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 118 If your function is not being put into a shared library then use VecRegister() instead 119 120 .keywords: Mat, register 121 122 .seealso: MatRegisterAll(), MatRegisterDestroy() 123 124 M*/ 125 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 126 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 127 #else 128 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 129 #endif 130 131 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 132 #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,0) 133 #else 134 #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,d) 135 #endif 136 137 extern PetscTruth MatRegisterAllCalled; 138 extern PetscFList MatList; 139 140 EXTERN PetscFList MatSerializeList; 141 EXTERN int MatSerializeRegisterAll(const char []); 142 EXTERN int MatSerializeRegisterDestroy(void); 143 EXTERN int MatSerializeRegisterAllCalled; 144 EXTERN int MatSerialize(MPI_Comm, Mat *, PetscViewer, PetscTruth); 145 EXTERN int MatSetSerializeType(Mat, MatSerializeType); 146 147 EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar[],Mat*); 148 EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar[],Mat*); 149 EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,const int[],Mat*); 150 EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,const int[],int,const int[],Mat*); 151 EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,const int[],Mat*); 152 EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,const int[],PetscScalar*[],Mat*); 153 EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,const int[],PetscScalar*[],Mat*); 154 EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*); 155 EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*); 156 EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int[],int[],int[],Mat*); 157 EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*); 158 EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*); 159 EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*); 160 EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*); 161 EXTERN int MatCreateNormal(Mat,Mat*); 162 EXTERN int MatDestroy(Mat); 163 164 EXTERN int MatPrintHelp(Mat); 165 EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*); 166 167 /* ------------------------------------------------------------*/ 168 EXTERN int MatSetValues(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 169 EXTERN int MatSetValuesBlocked(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 170 171 /*S 172 MatStencil - Data structure (C struct) for storing information about a single row or 173 column of a matrix as index on an associated grid. 174 175 Level: beginner 176 177 Concepts: matrix; linear operator 178 179 .seealso: MatSetValuesStencil(), MatSetStencil() 180 S*/ 181 typedef struct { 182 int k,j,i,c; 183 } MatStencil; 184 185 EXTERN int MatSetValuesStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode); 186 EXTERN int MatSetValuesBlockedStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode); 187 EXTERN int MatSetStencil(Mat,int,const int[],const int[],int); 188 189 EXTERN int MatSetColoring(Mat,ISColoring); 190 EXTERN int MatSetValuesAdic(Mat,void*); 191 EXTERN int MatSetValuesAdifor(Mat,int,void*); 192 193 /*E 194 MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 195 to continue to add values to it 196 197 Level: beginner 198 199 .seealso: MatAssemblyBegin(), MatAssemblyEnd() 200 E*/ 201 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 202 EXTERN int MatAssemblyBegin(Mat,MatAssemblyType); 203 EXTERN int MatAssemblyEnd(Mat,MatAssemblyType); 204 EXTERN int MatAssembled(Mat,PetscTruth*); 205 206 /*MC 207 MatSetValue - Set a single entry into a matrix. 208 209 Synopsis: 210 int MatSetValue(Mat m,int row,int col,PetscScalar value,InsertMode mode); 211 212 Not collective 213 214 Input Parameters: 215 + m - the matrix 216 . row - the row location of the entry 217 . col - the column location of the entry 218 . value - the value to insert 219 - mode - either INSERT_VALUES or ADD_VALUES 220 221 Notes: 222 For efficiency one should use MatSetValues() and set several or many 223 values simultaneously if possible. 224 225 Note that MatSetValue() does NOT return an error code (since this 226 is checked internally). 227 228 Level: beginner 229 230 .seealso: MatSetValues(), MatSetValueLocal() 231 M*/ 232 #define MatSetValue(v,i,j,va,mode) \ 233 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \ 234 _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 235 } 236 237 #define MatGetValue(v,i,j,va) \ 238 0; {int _ierr,_row = i,_col = j; \ 239 _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \ 240 } 241 242 #define MatSetValueLocal(v,i,j,va,mode) \ 243 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \ 244 _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 245 } 246 247 /*E 248 MatOption - Options that may be set for a matrix and its behavior or storage 249 250 Level: beginner 251 252 Any additions/changes here MUST also be made in include/finclude/petscmat.h 253 254 .seealso: MatSetOption() 255 E*/ 256 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 257 MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 258 MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 259 MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 260 MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 261 MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 262 MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 263 MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 264 MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 265 MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 266 MAT_DO_NOT_USE_INODES=82} MatOption; 267 EXTERN int MatSetOption(Mat,MatOption); 268 EXTERN int MatGetType(Mat,MatType*); 269 270 EXTERN int MatGetValues(Mat,int,const int[],int,const int[],PetscScalar[]); 271 EXTERN int MatGetRow(Mat,int,int *,int *[],PetscScalar*[]); 272 EXTERN int MatRestoreRow(Mat,int,int *,int *[],PetscScalar*[]); 273 EXTERN int MatGetColumn(Mat,int,int *,int **,PetscScalar**); 274 EXTERN int MatRestoreColumn(Mat,int,int *,int **,PetscScalar**); 275 EXTERN int MatGetColumnVector(Mat,Vec,int); 276 EXTERN int MatGetArray(Mat,PetscScalar **); 277 EXTERN int MatRestoreArray(Mat,PetscScalar **); 278 EXTERN int MatGetBlockSize(Mat,int *); 279 280 EXTERN int MatMult(Mat,Vec,Vec); 281 EXTERN int MatMultAdd(Mat,Vec,Vec,Vec); 282 EXTERN int MatMultTranspose(Mat,Vec,Vec); 283 EXTERN int MatIsSymmetric(Mat,Mat,PetscTruth*); 284 EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec); 285 EXTERN int MatMultConstrained(Mat,Vec,Vec); 286 EXTERN int MatMultTransposeConstrained(Mat,Vec,Vec); 287 288 /*E 289 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 290 its numerical values copied over or just its nonzero structure. 291 292 Level: beginner 293 294 Any additions/changes here MUST also be made in include/finclude/petscmat.h 295 296 .seealso: MatDuplicate() 297 E*/ 298 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 299 300 EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*)); 301 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 302 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 303 #else 304 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 305 #endif 306 EXTERN int MatConvertRegisterAll(char*); 307 EXTERN int MatConvertRegisterDestroy(void); 308 extern PetscTruth MatConvertRegisterAllCalled; 309 extern PetscFList MatConvertList; 310 EXTERN int MatConvert(Mat,MatType,Mat*); 311 EXTERN int MatDuplicate(Mat,MatDuplicateOption,Mat*); 312 313 /*E 314 MatStructure - Indicates if the matrix has the same nonzero structure 315 316 Level: beginner 317 318 Any additions/changes here MUST also be made in include/finclude/petscmat.h 319 320 .seealso: MatCopy(), SLESSetOperators(), PCSetOperators() 321 E*/ 322 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 323 324 EXTERN int MatCopy(Mat,Mat,MatStructure); 325 EXTERN int MatView(Mat,PetscViewer); 326 327 EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*)); 328 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 329 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0) 330 #else 331 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d) 332 #endif 333 EXTERN int MatLoadRegisterAll(char*); 334 EXTERN int MatLoadRegisterDestroy(void); 335 extern PetscTruth MatLoadRegisterAllCalled; 336 extern PetscFList MatLoadList; 337 EXTERN int MatLoad(PetscViewer,MatType,Mat*); 338 EXTERN int MatMerge(MPI_Comm,Mat,Mat*); 339 340 EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 341 EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 342 EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 343 EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 344 345 /*S 346 MatInfo - Context of matrix information, used with MatGetInfo() 347 348 In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 349 350 Level: intermediate 351 352 Concepts: matrix^nonzero information 353 354 .seealso: MatGetInfo(), MatInfoType 355 S*/ 356 typedef struct { 357 PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 358 PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 359 PetscLogDouble block_size; /* block size */ 360 PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 361 PetscLogDouble memory; /* memory allocated */ 362 PetscLogDouble assemblies; /* number of matrix assemblies called */ 363 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 364 PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 365 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 366 } MatInfo; 367 368 /*E 369 MatInfoType - Indicates if you want information about the local part of the matrix, 370 the entire parallel matrix or the maximum over all the local parts. 371 372 Level: beginner 373 374 Any additions/changes here MUST also be made in include/finclude/petscmat.h 375 376 .seealso: MatGetInfo(), MatInfo 377 E*/ 378 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 379 EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*); 380 EXTERN int MatValid(Mat,PetscTruth*); 381 EXTERN int MatGetDiagonal(Mat,Vec); 382 EXTERN int MatGetRowMax(Mat,Vec); 383 EXTERN int MatTranspose(Mat,Mat*); 384 EXTERN int MatPermute(Mat,IS,IS,Mat *); 385 EXTERN int MatPermuteSparsify(Mat,int,PetscReal,PetscReal,IS,IS,Mat *); 386 EXTERN int MatDiagonalScale(Mat,Vec,Vec); 387 EXTERN int MatDiagonalSet(Mat,Vec,InsertMode); 388 EXTERN int MatEqual(Mat,Mat,PetscTruth*); 389 390 EXTERN int MatNorm(Mat,NormType,PetscReal *); 391 EXTERN int MatZeroEntries(Mat); 392 EXTERN int MatZeroRows(Mat,IS,PetscScalar*); 393 EXTERN int MatZeroColumns(Mat,IS,PetscScalar*); 394 395 EXTERN int MatUseScaledForm(Mat,PetscTruth); 396 EXTERN int MatScaleSystem(Mat,Vec,Vec); 397 EXTERN int MatUnScaleSystem(Mat,Vec,Vec); 398 399 EXTERN int MatGetSize(Mat,int*,int*); 400 EXTERN int MatGetLocalSize(Mat,int*,int*); 401 EXTERN int MatGetOwnershipRange(Mat,int*,int*); 402 403 /*E 404 MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 405 or MatGetSubMatrix() are to be reused to store the new matrix values. 406 407 Level: beginner 408 409 Any additions/changes here MUST also be made in include/finclude/petscmat.h 410 411 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 412 E*/ 413 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 414 EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **); 415 EXTERN int MatDestroyMatrices(int,Mat **); 416 EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *); 417 418 EXTERN int MatIncreaseOverlap(Mat,int,IS *,int); 419 420 EXTERN int MatAXPY(PetscScalar *,Mat,Mat,MatStructure); 421 EXTERN int MatAYPX(PetscScalar *,Mat,Mat); 422 EXTERN int MatCompress(Mat); 423 424 EXTERN int MatScale(PetscScalar *,Mat); 425 EXTERN int MatShift(PetscScalar *,Mat); 426 427 EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 428 EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 429 EXTERN int MatZeroRowsLocal(Mat,IS,PetscScalar*); 430 EXTERN int MatSetValuesLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 431 EXTERN int MatSetValuesBlockedLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 432 433 EXTERN int MatSetStashInitialSize(Mat,int,int); 434 435 EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec); 436 EXTERN int MatInterpolate(Mat,Vec,Vec); 437 EXTERN int MatRestrict(Mat,Vec,Vec); 438 439 440 /*MC 441 MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per 442 row in a matrix providing the data that one can use to correctly preallocate the matrix. 443 444 Synopsis: 445 int MatPreallocateInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz) 446 447 Collective on MPI_Comm 448 449 Input Parameters: 450 + comm - the communicator that will share the eventually allocated matrix 451 . nrows - the number of rows in the matrix 452 - ncols - the number of columns in the matrix 453 454 Output Parameters: 455 + dnz - the array that will be passed to the matrix preallocation routines 456 - ozn - the other array passed to the matrix preallocation routines 457 458 459 Level: intermediate 460 461 Notes: 462 See the chapter in the users manual on performance for more details 463 464 Do not malloc or free dnz and onz that is handled internally by these routines 465 466 Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 467 468 Concepts: preallocation^Matrix 469 470 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 471 MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 472 M*/ 473 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 474 { \ 475 int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 476 _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 477 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\ 478 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 479 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 480 481 /*MC 482 MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 483 row in a matrix providing the data that one can use to correctly preallocate the matrix. 484 485 Synopsis: 486 int MatPreallocateSymmetricInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz) 487 488 Collective on MPI_Comm 489 490 Input Parameters: 491 + comm - the communicator that will share the eventually allocated matrix 492 . nrows - the number of rows in the matrix 493 - ncols - the number of columns in the matrix 494 495 Output Parameters: 496 + dnz - the array that will be passed to the matrix preallocation routines 497 - ozn - the other array passed to the matrix preallocation routines 498 499 500 Level: intermediate 501 502 Notes: 503 See the chapter in the users manual on performance for more details 504 505 Do not malloc or free dnz and onz that is handled internally by these routines 506 507 Concepts: preallocation^Matrix 508 509 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 510 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 511 M*/ 512 #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \ 513 { \ 514 int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__end; \ 515 _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 516 _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\ 517 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 518 _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 519 520 /*MC 521 MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 522 inserted using a local number of the rows and columns 523 524 Synopsis: 525 int MatPreallocateSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 526 527 Not Collective 528 529 Input Parameters: 530 + map - the mapping between local numbering and global numbering 531 . nrows - the number of rows indicated 532 . rows - the indices of the rows (these will be mapped in the 533 . ncols - the number of columns in the matrix 534 . cols - the columns indicated 535 . dnz - the array that will be passed to the matrix preallocation routines 536 - ozn - the other array passed to the matrix preallocation routines 537 538 539 Level: intermediate 540 541 Notes: 542 See the chapter in the users manual on performance for more details 543 544 Do not malloc or free dnz and onz that is handled internally by these routines 545 546 Concepts: preallocation^Matrix 547 548 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 549 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 550 M*/ 551 #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 552 {\ 553 int __l;\ 554 _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 555 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 556 for (__l=0;__l<nrows;__l++) {\ 557 _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 558 }\ 559 } 560 561 /*MC 562 MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 563 inserted using a local number of the rows and columns 564 565 Synopsis: 566 int MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 567 568 Not Collective 569 570 Input Parameters: 571 + map - the mapping between local numbering and global numbering 572 . nrows - the number of rows indicated 573 . rows - the indices of the rows (these will be mapped in the 574 . ncols - the number of columns in the matrix 575 . cols - the columns indicated 576 . dnz - the array that will be passed to the matrix preallocation routines 577 - ozn - the other array passed to the matrix preallocation routines 578 579 580 Level: intermediate 581 582 Notes: 583 See the chapter in the users manual on performance for more details 584 585 Do not malloc or free dnz and onz that is handled internally by these routines 586 587 Concepts: preallocation^Matrix 588 589 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 590 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 591 M*/ 592 #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 593 {\ 594 int __l;\ 595 _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 596 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 597 for (__l=0;__l<nrows;__l++) {\ 598 _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 599 }\ 600 } 601 602 /*MC 603 MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 604 inserted using a local number of the rows and columns 605 606 Synopsis: 607 int MatPreallocateSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 608 609 Not Collective 610 611 Input Parameters: 612 + nrows - the number of rows indicated 613 . rows - the indices of the rows (these will be mapped in the 614 . ncols - the number of columns in the matrix 615 . cols - the columns indicated 616 . dnz - the array that will be passed to the matrix preallocation routines 617 - ozn - the other array passed to the matrix preallocation routines 618 619 620 Level: intermediate 621 622 Notes: 623 See the chapter in the users manual on performance for more details 624 625 Do not malloc or free dnz and onz that is handled internally by these routines 626 627 Concepts: preallocation^Matrix 628 629 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 630 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 631 M*/ 632 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 633 { int __i; \ 634 for (__i=0; __i<nc; __i++) {\ 635 if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 636 }\ 637 dnz[row - __rstart] = nc - onz[row - __rstart];\ 638 } 639 640 /*MC 641 MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 642 inserted using a local number of the rows and columns 643 644 Synopsis: 645 int MatPreallocateSymmetricSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 646 647 Not Collective 648 649 Input Parameters: 650 + nrows - the number of rows indicated 651 . rows - the indices of the rows (these will be mapped in the 652 . ncols - the number of columns in the matrix 653 . cols - the columns indicated 654 . dnz - the array that will be passed to the matrix preallocation routines 655 - ozn - the other array passed to the matrix preallocation routines 656 657 658 Level: intermediate 659 660 Notes: 661 See the chapter in the users manual on performance for more details 662 663 Do not malloc or free dnz and onz that is handled internally by these routines 664 665 Concepts: preallocation^Matrix 666 667 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 668 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 669 M*/ 670 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 671 { int __i; \ 672 for (__i=0; __i<nc; __i++) {\ 673 if (cols[__i] >= __end) onz[row - __rstart]++; \ 674 else if (cols[__i] >= row) dnz[row - __rstart]++;\ 675 }\ 676 } 677 678 /*MC 679 MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per 680 row in a matrix providing the data that one can use to correctly preallocate the matrix. 681 682 Synopsis: 683 int MatPreallocateFinalize(int *dnz, int *onz) 684 685 Collective on MPI_Comm 686 687 Input Parameters: 688 + dnz - the array that will be passed to the matrix preallocation routines 689 - ozn - the other array passed to the matrix preallocation routines 690 691 692 Level: intermediate 693 694 Notes: 695 See the chapter in the users manual on performance for more details 696 697 Do not malloc or free dnz and onz that is handled internally by these routines 698 699 Concepts: preallocation^Matrix 700 701 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 702 MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 703 M*/ 704 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 705 706 707 708 /* Routines unique to particular data structures */ 709 EXTERN int MatShellGetContext(Mat,void **); 710 711 EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,PetscScalar***); 712 EXTERN int MatSeqAIJSetColumnIndices(Mat,int[]); 713 EXTERN int MatSeqBAIJSetColumnIndices(Mat,int[]); 714 EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int[],int[],PetscScalar[],Mat*); 715 716 EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,const int[]); 717 EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,const int[]); 718 EXTERN int MatSeqAIJSetPreallocation(Mat,int,const int[]); 719 EXTERN int MatSeqDensePreallocation(Mat,PetscScalar[]); 720 EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]); 721 EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 722 723 EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]); 724 EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]); 725 EXTERN int MatMPIAIJSetPreallocation(Mat,int,const int[],int,const int[]); 726 EXTERN int MatMPIDensePreallocation(Mat,PetscScalar[]); 727 EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]); 728 EXTERN int MatMPIAdjSetPreallocation(Mat,int[],int[],int[]); 729 EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 730 EXTERN int MatMPIRowbsSetPreallocation(Mat,int,const int[]); 731 EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**); 732 EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**); 733 EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void)); 734 735 EXTERN int MatSeqDenseSetLDA(Mat,int); 736 737 EXTERN int MatStoreValues(Mat); 738 EXTERN int MatRetrieveValues(Mat); 739 740 EXTERN int MatDAADSetCtx(Mat,void*); 741 742 /* 743 These routines are not usually accessed directly, rather solving is 744 done through the SLES, KSP and PC interfaces. 745 */ 746 747 /*E 748 MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 749 with an optional dynamic library name, for example 750 http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 751 752 Level: beginner 753 754 .seealso: MatGetOrdering() 755 E*/ 756 typedef char* MatOrderingType; 757 #define MATORDERING_NATURAL "natural" 758 #define MATORDERING_ND "nd" 759 #define MATORDERING_1WD "1wd" 760 #define MATORDERING_RCM "rcm" 761 #define MATORDERING_QMD "qmd" 762 #define MATORDERING_ROWLENGTH "rowlength" 763 #define MATORDERING_DSC_ND "dsc_nd" 764 #define MATORDERING_DSC_MMD "dsc_mmd" 765 #define MATORDERING_DSC_MDF "dsc_mdf" 766 #define MATORDERING_CONSTRAINED "constrained" 767 #define MATORDERING_IDENTITY "identity" 768 #define MATORDERING_REVERSE "reverse" 769 770 EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*); 771 EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*)); 772 773 /*MC 774 MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 775 matrix package. 776 777 Synopsis: 778 int MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,int (*routine_create)(MatOrdering)) 779 780 Not Collective 781 782 Input Parameters: 783 + sname - name of ordering (for example MATORDERING_ND) 784 . path - location of library where creation routine is 785 . name - name of function that creates the ordering type,a string 786 - function - function pointer that creates the ordering 787 788 Level: developer 789 790 If dynamic libraries are used, then the fourth input argument (function) 791 is ignored. 792 793 Sample usage: 794 .vb 795 MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 796 "MyOrder",MyOrder); 797 .ve 798 799 Then, your partitioner can be chosen with the procedural interface via 800 $ MatOrderingSetType(part,"my_order) 801 or at runtime via the option 802 $ -pc_ilu_mat_ordering_type my_order 803 $ -pc_lu_mat_ordering_type my_order 804 805 ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 806 807 .keywords: matrix, ordering, register 808 809 .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 810 M*/ 811 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 812 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 813 #else 814 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 815 #endif 816 817 EXTERN int MatOrderingRegisterDestroy(void); 818 EXTERN int MatOrderingRegisterAll(char*); 819 extern PetscTruth MatOrderingRegisterAllCalled; 820 extern PetscFList MatOrderingList; 821 822 EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 823 824 /*S 825 MatFactorInfo - Data based into the matrix factorization routines 826 827 In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE 828 829 Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 830 831 Level: developer 832 833 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor() 834 835 S*/ 836 typedef struct { 837 PetscReal damping; /* scaling of identity added to matrix to prevent zero pivots */ 838 PetscReal shift; /* if true, shift until positive pivots */ 839 PetscReal shift_fraction; /* record shift fraction taken */ 840 PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 841 PetscReal dt; /* drop tolerance */ 842 PetscReal dtcol; /* tolerance for pivoting */ 843 PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 844 PetscReal fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 845 PetscReal levels; /* ICC/ILU(levels) */ 846 PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 847 factorization may be faster if do not pivot */ 848 PetscReal zeropivot; /* pivot is called zero if less than this */ 849 } MatFactorInfo; 850 851 EXTERN int MatCholeskyFactor(Mat,IS,MatFactorInfo*); 852 EXTERN int MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 853 EXTERN int MatCholeskyFactorNumeric(Mat,Mat*); 854 EXTERN int MatLUFactor(Mat,IS,IS,MatFactorInfo*); 855 EXTERN int MatILUFactor(Mat,IS,IS,MatFactorInfo*); 856 EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 857 EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 858 EXTERN int MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 859 EXTERN int MatICCFactor(Mat,IS,MatFactorInfo*); 860 EXTERN int MatLUFactorNumeric(Mat,Mat*); 861 EXTERN int MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *); 862 EXTERN int MatGetInertia(Mat,int*,int*,int*); 863 EXTERN int MatSolve(Mat,Vec,Vec); 864 EXTERN int MatForwardSolve(Mat,Vec,Vec); 865 EXTERN int MatBackwardSolve(Mat,Vec,Vec); 866 EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec); 867 EXTERN int MatSolveTranspose(Mat,Vec,Vec); 868 EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 869 EXTERN int MatSolves(Mat,Vecs,Vecs); 870 871 EXTERN int MatSetUnfactored(Mat); 872 873 /* MatSORType may be bitwise ORd together, so do not change the numbers */ 874 /*E 875 MatSORType - What type of (S)SOR to perform 876 877 Level: beginner 878 879 May be bitwise ORd together 880 881 Any additions/changes here MUST also be made in include/finclude/petscmat.h 882 883 .seealso: MatRelax() 884 E*/ 885 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 886 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 887 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 888 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 889 EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec); 890 891 /* 892 These routines are for efficiently computing Jacobians via finite differences. 893 */ 894 895 /*E 896 MatColoringType - String with the name of a PETSc matrix coloring or the creation function 897 with an optional dynamic library name, for example 898 http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 899 900 Level: beginner 901 902 .seealso: MatGetColoring() 903 E*/ 904 typedef char* MatColoringType; 905 #define MATCOLORING_NATURAL "natural" 906 #define MATCOLORING_SL "sl" 907 #define MATCOLORING_LF "lf" 908 #define MATCOLORING_ID "id" 909 910 EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*); 911 EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *)); 912 913 /*MC 914 MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 915 matrix package. 916 917 Synopsis: 918 int MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,int (*routine_create)(MatColoring)) 919 920 Not Collective 921 922 Input Parameters: 923 + sname - name of Coloring (for example MATCOLORING_SL) 924 . path - location of library where creation routine is 925 . name - name of function that creates the Coloring type, a string 926 - function - function pointer that creates the coloring 927 928 Level: developer 929 930 If dynamic libraries are used, then the fourth input argument (function) 931 is ignored. 932 933 Sample usage: 934 .vb 935 MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 936 "MyColor",MyColor); 937 .ve 938 939 Then, your partitioner can be chosen with the procedural interface via 940 $ MatColoringSetType(part,"my_color") 941 or at runtime via the option 942 $ -mat_coloring_type my_color 943 944 $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 945 946 .keywords: matrix, Coloring, register 947 948 .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 949 M*/ 950 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 951 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 952 #else 953 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 954 #endif 955 956 EXTERN int MatColoringRegisterAll(char *); 957 extern PetscTruth MatColoringRegisterAllCalled; 958 EXTERN int MatColoringRegisterDestroy(void); 959 EXTERN int MatColoringPatch(Mat,int,int,ISColoringValue *,ISColoring*); 960 961 /*S 962 MatFDColoring - Object for computing a sparse Jacobian via finite differences 963 and coloring 964 965 Level: beginner 966 967 Concepts: coloring, sparse Jacobian, finite differences 968 969 .seealso: MatFDColoringCreate() 970 S*/ 971 typedef struct _p_MatFDColoring *MatFDColoring; 972 973 EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 974 EXTERN int MatFDColoringDestroy(MatFDColoring); 975 EXTERN int MatFDColoringView(MatFDColoring,PetscViewer); 976 EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*); 977 EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 978 EXTERN int MatFDColoringSetFrequency(MatFDColoring,int); 979 EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*); 980 EXTERN int MatFDColoringSetFromOptions(MatFDColoring); 981 EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 982 EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 983 EXTERN int MatFDColoringSetRecompute(MatFDColoring); 984 EXTERN int MatFDColoringSetF(MatFDColoring,Vec); 985 EXTERN int MatFDColoringGetPerturbedColumns(MatFDColoring,int*,int**); 986 /* 987 These routines are for partitioning matrices: currently used only 988 for adjacency matrix, MatCreateMPIAdj(). 989 */ 990 991 /*S 992 MatPartitioning - Object for managing the partitioning of a matrix or graph 993 994 Level: beginner 995 996 Concepts: partitioning 997 998 .seealso: MatPartitioningCreate(), MatPartitioningType 999 S*/ 1000 typedef struct _p_MatPartitioning *MatPartitioning; 1001 1002 /*E 1003 MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1004 with an optional dynamic library name, for example 1005 http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1006 1007 Level: beginner 1008 1009 .seealso: MatPartitioningCreate(), MatPartitioning 1010 E*/ 1011 typedef char* MatPartitioningType; 1012 #define MAT_PARTITIONING_CURRENT "current" 1013 #define MAT_PARTITIONING_PARMETIS "parmetis" 1014 1015 EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1016 EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType); 1017 EXTERN int MatPartitioningSetNParts(MatPartitioning,int); 1018 EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat); 1019 EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*); 1020 EXTERN int MatPartitioningApply(MatPartitioning,IS*); 1021 EXTERN int MatPartitioningDestroy(MatPartitioning); 1022 1023 EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning)); 1024 1025 /*MC 1026 MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 1027 matrix package. 1028 1029 Synopsis: 1030 int MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,int (*routine_create)(MatPartitioning)) 1031 1032 Not Collective 1033 1034 Input Parameters: 1035 + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 1036 . path - location of library where creation routine is 1037 . name - name of function that creates the partitioning type, a string 1038 - function - function pointer that creates the partitioning type 1039 1040 Level: developer 1041 1042 If dynamic libraries are used, then the fourth input argument (function) 1043 is ignored. 1044 1045 Sample usage: 1046 .vb 1047 MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 1048 "MyPartCreate",MyPartCreate); 1049 .ve 1050 1051 Then, your partitioner can be chosen with the procedural interface via 1052 $ MatPartitioningSetType(part,"my_part") 1053 or at runtime via the option 1054 $ -mat_partitioning_type my_part 1055 1056 $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 1057 1058 .keywords: matrix, partitioning, register 1059 1060 .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 1061 M*/ 1062 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1063 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 1064 #else 1065 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 1066 #endif 1067 1068 EXTERN int MatPartitioningRegisterAll(char *); 1069 extern PetscTruth MatPartitioningRegisterAllCalled; 1070 EXTERN int MatPartitioningRegisterDestroy(void); 1071 1072 EXTERN int MatPartitioningView(MatPartitioning,PetscViewer); 1073 EXTERN int MatPartitioningSetFromOptions(MatPartitioning); 1074 EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1075 1076 EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1077 1078 /* 1079 If you add entries here you must also add them to finclude/petscmat.h 1080 */ 1081 typedef enum { MATOP_SET_VALUES=0, 1082 MATOP_GET_ROW=1, 1083 MATOP_RESTORE_ROW=2, 1084 MATOP_MULT=3, 1085 MATOP_MULT_ADD=4, 1086 MATOP_MULT_TRANSPOSE=5, 1087 MATOP_MULT_TRANSPOSE_ADD=6, 1088 MATOP_SOLVE=7, 1089 MATOP_SOLVE_ADD=8, 1090 MATOP_SOLVE_TRANSPOSE=9, 1091 MATOP_SOLVE_TRANSPOSE_ADD=10, 1092 MATOP_LUFACTOR=11, 1093 MATOP_CHOLESKYFACTOR=12, 1094 MATOP_RELAX=13, 1095 MATOP_TRANSPOSE=14, 1096 MATOP_GETINFO=15, 1097 MATOP_EQUAL=16, 1098 MATOP_GET_DIAGONAL=17, 1099 MATOP_DIAGONAL_SCALE=18, 1100 MATOP_NORM=19, 1101 MATOP_ASSEMBLY_BEGIN=20, 1102 MATOP_ASSEMBLY_END=21, 1103 MATOP_COMPRESS=22, 1104 MATOP_SET_OPTION=23, 1105 MATOP_ZERO_ENTRIES=24, 1106 MATOP_ZERO_ROWS=25, 1107 MATOP_LUFACTOR_SYMBOLIC=26, 1108 MATOP_LUFACTOR_NUMERIC=27, 1109 MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 1110 MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1111 MATOP_SETUP_PREALLOCATION=30, 1112 MATOP_ILUFACTOR_SYMBOLIC=31, 1113 MATOP_ICCFACTOR_SYMBOLIC=32, 1114 MATOP_GET_ARRAY=33, 1115 MATOP_RESTORE_ARRAY=34, 1116 MATOP_DUPLCIATE=35, 1117 MATOP_FORWARD_SOLVE=36, 1118 MATOP_BACKWARD_SOLVE=37, 1119 MATOP_ILUFACTOR=38, 1120 MATOP_ICCFACTOR=39, 1121 MATOP_AXPY=40, 1122 MATOP_GET_SUBMATRICES=41, 1123 MATOP_INCREASE_OVERLAP=42, 1124 MATOP_GET_VALUES=43, 1125 MATOP_COPY=44, 1126 MATOP_PRINT_HELP=45, 1127 MATOP_SCALE=46, 1128 MATOP_SHIFT=47, 1129 MATOP_DIAGONAL_SHIFT=48, 1130 MATOP_ILUDT_FACTOR=49, 1131 MATOP_GET_BLOCK_SIZE=50, 1132 MATOP_GET_ROW_IJ=51, 1133 MATOP_RESTORE_ROW_IJ=52, 1134 MATOP_GET_COLUMN_IJ=53, 1135 MATOP_RESTORE_COLUMN_IJ=54, 1136 MATOP_FDCOLORING_CREATE=55, 1137 MATOP_COLORING_PATCH=56, 1138 MATOP_SET_UNFACTORED=57, 1139 MATOP_PERMUTE=58, 1140 MATOP_SET_VALUES_BLOCKED=59, 1141 MATOP_GET_SUBMATRIX=60, 1142 MATOP_DESTROY=61, 1143 MATOP_VIEW=62, 1144 MATOP_GET_MAPS=63, 1145 MATOP_USE_SCALED_FORM=64, 1146 MATOP_SCALE_SYSTEM=65, 1147 MATOP_UNSCALE_SYSTEM=66, 1148 MATOP_SET_LOCAL_TO_GLOBAL_MAPPING=67, 1149 MATOP_SET_VALUES_LOCAL=68, 1150 MATOP_ZERO_ROWS_LOCAL=69, 1151 MATOP_GET_ROW_MAX=70, 1152 MATOP_CONVERT=71, 1153 MATOP_SET_COLORING=72, 1154 MATOP_SET_VALUES_ADIC=73, 1155 MATOP_SET_VALUES_ADIFOR=74, 1156 MATOP_FD_COLORING_APPLY=75, 1157 MATOP_SET_FROM_OPTIONS=76, 1158 MATOP_MULT_CONSTRAINED=77, 1159 MATOP_MULT_TRANSPOSE_CONSTRAINED=78, 1160 MATOP_ILU_FACTOR_SYMBOLIC_CONSTRAINED=79, 1161 MATOP_PERMUTE_SPARSIFY=80, 1162 MATOP_MULT_MULTIPLE=81, 1163 MATOP_SOLVE_MULTIPLE=82 1164 } MatOperation; 1165 EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*); 1166 EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1167 EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1168 EXTERN int MatShellSetContext(Mat,void*); 1169 1170 /* 1171 Codes for matrices stored on disk. By default they are 1172 stored in a universal format. By changing the format with 1173 PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 1174 be stored in a way natural for the matrix, for example dense matrices 1175 would be stored as dense. Matrices stored this way may only be 1176 read into matrices of the same time. 1177 */ 1178 #define MATRIX_BINARY_FORMAT_DENSE -1 1179 1180 /* 1181 New matrix classes not yet distributed 1182 */ 1183 /* 1184 MatAIJIndices is a data structure for storing the nonzero location information 1185 for sparse matrices. Several matrices with identical nonzero structure can share 1186 the same MatAIJIndices. 1187 */ 1188 typedef struct _p_MatAIJIndices* MatAIJIndices; 1189 1190 EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*); 1191 EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*); 1192 EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*); 1193 EXTERN int MatDestroyAIJIndices(MatAIJIndices); 1194 EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*); 1195 EXTERN int MatValidateAIJIndices(int,MatAIJIndices); 1196 EXTERN int MatShiftAIJIndices(MatAIJIndices); 1197 EXTERN int MatShrinkAIJIndices(MatAIJIndices); 1198 EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*); 1199 1200 EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*); 1201 EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*); 1202 EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,PetscScalarPrecision,Mat*); 1203 1204 EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *); 1205 EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *); 1206 EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,PetscScalarPrecision,Mat *); 1207 1208 EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1209 EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *); 1210 EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *); 1211 1212 /*S 1213 MatNullSpace - Object that removes a null space from a vector, i.e. 1214 orthogonalizes the vector to a subsapce 1215 1216 Level: advanced 1217 1218 Concepts: matrix; linear operator, null space 1219 1220 Users manual sections: 1221 . sec_singular 1222 1223 .seealso: MatNullSpaceCreate() 1224 S*/ 1225 typedef struct _p_MatNullSpace* MatNullSpace; 1226 1227 EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*); 1228 EXTERN int MatNullSpaceDestroy(MatNullSpace); 1229 EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1230 EXTERN int MatNullSpaceAttach(Mat,MatNullSpace); 1231 EXTERN int MatNullSpaceTest(MatNullSpace,Mat); 1232 1233 EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp); 1234 EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1235 EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *); 1236 1237 EXTERN int MatMatMult(Mat A,Mat B, Mat *C); 1238 EXTERN int MatMatMultSymbolic(Mat A,Mat B,Mat *C); 1239 EXTERN int MatMatMultNumeric(Mat A,Mat B,Mat C); 1240 1241 EXTERN int MatCreateMAIJ(Mat,int,Mat*); 1242 EXTERN int MatMAIJRedimension(Mat,int,Mat*); 1243 EXTERN int MatMAIJGetAIJ(Mat,Mat*); 1244 1245 EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*); 1246 1247 EXTERN int MatComputeExplicitOperator(Mat,Mat*); 1248 1249 EXTERN int MatESISetType(Mat,char*); 1250 EXTERN int MatESISetFromOptions(Mat); 1251 1252 EXTERN int MatDiagonalScaleLocal(Mat,Vec); 1253 1254 EXTERN int PetscViewerMathematicaPutMatrix(PetscViewer, int, int, PetscReal *); 1255 EXTERN int PetscViewerMathematicaPutCSRMatrix(PetscViewer, int, int, int *, int *, PetscReal *); 1256 1257 EXTERN int MatUseSpooles_SeqAIJ(Mat); 1258 EXTERN int MatUseUMFPACK_SeqAIJ(Mat); 1259 EXTERN int MatUseSuperLU_SeqAIJ(Mat); 1260 EXTERN int MatUseEssl_SeqAIJ(Mat); 1261 EXTERN int MatUseLUSOL_SeqAIJ(Mat); 1262 EXTERN int MatUseMatlab_SeqAIJ(Mat); 1263 EXTERN int MatUseDXML_SeqAIJ(Mat); 1264 EXTERN int MatUsePETSc_SeqAIJ(Mat); 1265 EXTERN int MatUseSuperLU_DIST_MPIAIJ(Mat); 1266 EXTERN int MatUseSpooles_MPIAIJ(Mat); 1267 EXTERN int MatUseSpooles_SeqSBAIJ(Mat); 1268 EXTERN int MatUseSpooles_MPISBAIJ(Mat); 1269 EXTERN int MatUseMUMPS_MPIAIJ(Mat); 1270 1271 #endif 1272 1273 1274 1275