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