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