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