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