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