1 /* $Id: petscmat.h,v 1.221 2001/06/21 23:28:43 buschelm Exp bsmith $ */ 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 #define MAT_COOKIE PETSC_COOKIE+5 10 11 /*S 12 Mat - Abstract PETSc matrix object 13 14 Level: beginner 15 16 Concepts: matrix; linear operator 17 18 .seealso: MatCreate(), MatType, MatSetType() 19 S*/ 20 typedef struct _p_Mat* Mat; 21 22 /*E 23 MatType - String with the name of a PETSc matrix or the creation function 24 with an optional dynamic library name, for example 25 http://www.mcs.anl.gov/petsc/lib.a:mymatcreate() 26 27 Level: beginner 28 29 .seealso: MatSetType(), Mat 30 E*/ 31 #define MATSAME "same" 32 #define MATSEQMAIJ "seqmaij" 33 #define MATMPIMAIJ "mpimaij" 34 #define MATIS "is" 35 #define MATMPIROWBS "mpirowbs" 36 #define MATSEQDENSE "seqdense" 37 #define MATSEQAIJ "seqaij" 38 #define MATMPIAIJ "mpiaij" 39 #define MATSHELL "shell" 40 #define MATSEQBDIAG "seqbdiag" 41 #define MATMPIBDIAG "mpibdiag" 42 #define MATMPIDENSE "mpidense" 43 #define MATSEQBAIJ "seqbaij" 44 #define MATMPIBAIJ "mpibaij" 45 #define MATMPIADJ "mpiadj" 46 #define MATSEQSBAIJ "seqsbaij" 47 #define MATMPISBAIJ "mpisbaij" 48 #define MATDAAD "daad" 49 #define MATMFFD "mffd" 50 typedef char* MatType; 51 52 EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*); 53 EXTERN int MatSetType(Mat,MatType); 54 EXTERN int MatSetFromOptions(Mat); 55 EXTERN int MatSetUpPreallocation(Mat); 56 EXTERN int MatRegisterAll(char*); 57 EXTERN int MatRegister(char*,char*,char*,int(*)(Mat)); 58 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 59 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 60 #else 61 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 62 #endif 63 extern PetscTruth MatRegisterAllCalled; 64 extern PetscFList MatList; 65 66 EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*); 67 EXTERN int MatCreateSeqDense(MPI_Comm,int,int,Scalar*,Mat*); 68 EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,Scalar*,Mat*); 69 EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,int*,Mat*); 70 EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,int*,int,int*,Mat*); 71 EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,int*,Mat*); 72 EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,int*,Scalar**,Mat*); 73 EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,int*,Scalar**,Mat*); 74 EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,int*,Mat*); 75 EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*); 76 EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int*,int*,int *,Mat*); 77 EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,int*,Mat*); 78 EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,int*,int,int*,Mat*); 79 EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*); 80 EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*); 81 EXTERN int MatDestroy(Mat); 82 83 EXTERN int MatPrintHelp(Mat); 84 EXTERN int MatGetMaps(Mat,Map*,Map*); 85 86 /* ------------------------------------------------------------*/ 87 EXTERN int MatSetValues(Mat,int,int*,int,int*,Scalar*,InsertMode); 88 EXTERN int MatSetValuesBlocked(Mat,int,int*,int,int*,Scalar*,InsertMode); 89 90 /*S 91 MatStencil - Data structure (C struct) for storing information about a single row or 92 column of a matrix as index on an associated grid. 93 94 Level: beginner 95 96 Concepts: matrix; linear operator 97 98 .seealso: MatSetValuesStencil(), MatSetStencil() 99 S*/ 100 typedef struct { 101 int k,j,i,c; 102 } MatStencil; 103 104 EXTERN int MatSetValuesStencil(Mat,int,MatStencil*,int,MatStencil*,Scalar*,InsertMode); 105 EXTERN int MatSetValuesBlockedStencil(Mat,int,MatStencil*,int,MatStencil*,Scalar*,InsertMode); 106 EXTERN int MatSetStencil(Mat,int,int*,int*,int); 107 108 EXTERN int MatSetColoring(Mat,ISColoring); 109 EXTERN int MatSetValuesAdic(Mat,void*); 110 EXTERN int MatSetValuesAdifor(Mat,int,void*); 111 112 /*E 113 MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 114 to continue to add values to it 115 116 Level: beginner 117 118 .seealso: MatAssemblyBegin(), MatAssemblyEnd() 119 E*/ 120 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 121 EXTERN int MatAssemblyBegin(Mat,MatAssemblyType); 122 EXTERN int MatAssemblyEnd(Mat,MatAssemblyType); 123 EXTERN int MatAssembled(Mat,PetscTruth*); 124 125 #define MatSetValue(v,i,j,va,mode) \ 126 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \ 127 _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 128 } 129 #define MatGetValue(v,i,j,va) \ 130 0; {int _ierr,_row = i,_col = j; \ 131 _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \ 132 } 133 #define MatSetValueLocal(v,i,j,va,mode) \ 134 0; {int _ierr,_row = i,_col = j; Scalar _va = va; \ 135 _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 136 } 137 /*E 138 MatOption - Options that may be set for a matrix and its behavior or storage 139 140 Level: beginner 141 142 Any additions/changes here MUST also be made in include/finclude/petscmat.h 143 144 .seealso: MatSetOption() 145 E*/ 146 typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 147 MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 148 MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 149 MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 150 MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 151 MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 152 MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 153 MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 154 MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 155 MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 156 MAT_DO_NOT_USE_INODES=82,MAT_USE_SINGLE_PRECISION_SOLVES=83} MatOption; 157 EXTERN int MatSetOption(Mat,MatOption); 158 EXTERN int MatGetType(Mat,MatType*); 159 160 EXTERN int MatGetValues(Mat,int,int*,int,int*,Scalar*); 161 EXTERN int MatGetRow(Mat,int,int *,int **,Scalar**); 162 EXTERN int MatRestoreRow(Mat,int,int *,int **,Scalar**); 163 EXTERN int MatGetColumn(Mat,int,int *,int **,Scalar**); 164 EXTERN int MatRestoreColumn(Mat,int,int *,int **,Scalar**); 165 EXTERN int MatGetColumnVector(Mat,Vec,int); 166 EXTERN int MatGetArray(Mat,Scalar **); 167 EXTERN int MatRestoreArray(Mat,Scalar **); 168 EXTERN int MatGetBlockSize(Mat,int *); 169 170 EXTERN int MatMult(Mat,Vec,Vec); 171 EXTERN int MatMultAdd(Mat,Vec,Vec,Vec); 172 EXTERN int MatMultTranspose(Mat,Vec,Vec); 173 EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec); 174 175 /*E 176 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 177 its numerical values copied over or just its nonzero structure. 178 179 Level: beginner 180 181 Any additions/changes here MUST also be made in include/finclude/petscmat.h 182 183 .seealso: MatDuplicate() 184 E*/ 185 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 186 187 EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*)); 188 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 189 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 190 #else 191 #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 192 #endif 193 EXTERN int MatConvertRegisterAll(char*); 194 EXTERN int MatConvertRegisterDestroy(void); 195 extern PetscTruth MatConvertRegisterAllCalled; 196 extern PetscFList MatConvertList; 197 EXTERN int MatConvert(Mat,MatType,Mat*); 198 EXTERN int MatDuplicate(Mat,MatDuplicateOption,Mat*); 199 200 /*E 201 MatStructure - Indicates if the matrix has the same nonzero structure 202 203 Level: beginner 204 205 Any additions/changes here MUST also be made in include/finclude/petscmat.h 206 207 .seealso: MatCopy(), SLESSetOperators(), PCSetOperators() 208 E*/ 209 typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure; 210 211 EXTERN int MatCopy(Mat,Mat,MatStructure); 212 EXTERN int MatView(Mat,PetscViewer); 213 214 EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*)); 215 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 216 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0) 217 #else 218 #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d) 219 #endif 220 EXTERN int MatLoadRegisterAll(char*); 221 EXTERN int MatLoadRegisterDestroy(void); 222 extern PetscTruth MatLoadRegisterAllCalled; 223 extern PetscFList MatLoadList; 224 EXTERN int MatLoad(PetscViewer,MatType,Mat*); 225 226 EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 227 EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 228 EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int **,int **,PetscTruth *); 229 EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int **,int **,PetscTruth *); 230 231 /*S 232 MatInfo - Context of matrix information, used with MatGetInfo() 233 234 In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 235 236 Level: intermediate 237 238 Concepts: matrix^nonzero information 239 240 .seealso: MatGetInfo(), MatInfoType 241 S*/ 242 typedef struct { 243 PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 244 PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 245 PetscLogDouble block_size; /* block size */ 246 PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 247 PetscLogDouble memory; /* memory allocated */ 248 PetscLogDouble assemblies; /* number of matrix assemblies called */ 249 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 250 PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 251 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 252 } MatInfo; 253 254 /*E 255 MatInfoType - Indicates if you want information about the local part of the matrix, 256 the entire parallel matrix or the maximum over all the local parts. 257 258 Level: beginner 259 260 Any additions/changes here MUST also be made in include/finclude/petscmat.h 261 262 .seealso: MatGetInfo(), MatInfo 263 E*/ 264 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 265 EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*); 266 EXTERN int MatValid(Mat,PetscTruth*); 267 EXTERN int MatGetDiagonal(Mat,Vec); 268 EXTERN int MatGetRowMax(Mat,Vec); 269 EXTERN int MatTranspose(Mat,Mat*); 270 EXTERN int MatPermute(Mat,IS,IS,Mat *); 271 EXTERN int MatDiagonalScale(Mat,Vec,Vec); 272 EXTERN int MatDiagonalSet(Mat,Vec,InsertMode); 273 EXTERN int MatEqual(Mat,Mat,PetscTruth*); 274 275 EXTERN int MatNorm(Mat,NormType,double *); 276 EXTERN int MatZeroEntries(Mat); 277 EXTERN int MatZeroRows(Mat,IS,Scalar*); 278 EXTERN int MatZeroColumns(Mat,IS,Scalar*); 279 280 EXTERN int MatUseScaledForm(Mat,PetscTruth); 281 EXTERN int MatScaleSystem(Mat,Vec,Vec); 282 EXTERN int MatUnScaleSystem(Mat,Vec,Vec); 283 284 EXTERN int MatGetSize(Mat,int*,int*); 285 EXTERN int MatGetLocalSize(Mat,int*,int*); 286 EXTERN int MatGetOwnershipRange(Mat,int*,int*); 287 288 /*E 289 MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 290 or MatGetSubMatrix() are to be reused to store the new matrix values. 291 292 Level: beginner 293 294 Any additions/changes here MUST also be made in include/finclude/petscmat.h 295 296 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 297 E*/ 298 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 299 EXTERN int MatGetSubMatrices(Mat,int,IS *,IS *,MatReuse,Mat **); 300 EXTERN int MatDestroyMatrices(int,Mat **); 301 EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *); 302 303 EXTERN int MatIncreaseOverlap(Mat,int,IS *,int); 304 305 EXTERN int MatAXPY(Scalar *,Mat,Mat); 306 EXTERN int MatAYPX(Scalar *,Mat,Mat); 307 EXTERN int MatCompress(Mat); 308 309 EXTERN int MatScale(Scalar *,Mat); 310 EXTERN int MatShift(Scalar *,Mat); 311 312 EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 313 EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 314 EXTERN int MatZeroRowsLocal(Mat,IS,Scalar*); 315 EXTERN int MatSetValuesLocal(Mat,int,int*,int,int*,Scalar*,InsertMode); 316 EXTERN int MatSetValuesBlockedLocal(Mat,int,int*,int,int*,Scalar*,InsertMode); 317 318 EXTERN int MatSetStashInitialSize(Mat,int,int); 319 320 EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec); 321 EXTERN int MatInterpolate(Mat,Vec,Vec); 322 EXTERN int MatRestrict(Mat,Vec,Vec); 323 324 /* 325 These three (or four) macros MUST be used together. The third one closes the open { of the first one 326 */ 327 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 328 { \ 329 int __ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 330 __ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(__ierr);onz = dnz + __tmp;\ 331 __ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(__ierr);\ 332 __ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __start = __end - __ctmp;\ 333 __ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(__ierr); __rstart = __rstart - __tmp; 334 335 #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 336 {\ 337 int __l;\ 338 __ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(__ierr);\ 339 __ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(__ierr);\ 340 for (__l=0;__l<nrows;__l++) {\ 341 __ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(__ierr);\ 342 }\ 343 } 344 345 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 346 { int __i; \ 347 for (__i=0; __i<nc; __i++) {\ 348 if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 349 }\ 350 dnz[row - __rstart] = nc - onz[row - __rstart];\ 351 } 352 353 #define MatPreallocateFinalize(dnz,onz) 0;__ierr = PetscFree(dnz);CHKERRQ(__ierr);} 354 355 /* Routines unique to particular data structures */ 356 EXTERN int MatShellGetContext(Mat,void **); 357 358 EXTERN int MatBDiagGetData(Mat,int*,int*,int**,int**,Scalar***); 359 EXTERN int MatSeqAIJSetColumnIndices(Mat,int *); 360 EXTERN int MatSeqBAIJSetColumnIndices(Mat,int *); 361 EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int*,int*,Scalar *,Mat*); 362 363 EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,int*); 364 EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,int*); 365 EXTERN int MatSeqAIJSetPreallocation(Mat,int,int*); 366 EXTERN int MatSeqDensePreallocation(Mat,Scalar*); 367 EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,int*,Scalar**); 368 EXTERN int MatSeqDenseSetPreallocation(Mat,Scalar*); 369 370 EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,int*,int,int*); 371 EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,int*,int,int*); 372 EXTERN int MatMPIAIJSetPreallocation(Mat,int,int*,int,int*); 373 EXTERN int MatMPIDensePreallocation(Mat,Scalar*); 374 EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,int*,Scalar**); 375 EXTERN int MatMPIAdjSetPreallocation(Mat,int*,int*,int*); 376 EXTERN int MatMPIDenseSetPreallocation(Mat,Scalar*); 377 EXTERN int MatMPIRowbsSetPreallocation(Mat,int,int*); 378 EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int**); 379 EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int**); 380 EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void)); 381 382 EXTERN int MatStoreValues(Mat); 383 EXTERN int MatRetrieveValues(Mat); 384 385 EXTERN int MatDAADSetCtx(Mat,void*); 386 387 /* 388 These routines are not usually accessed directly, rather solving is 389 done through the SLES, KSP and PC interfaces. 390 */ 391 392 /*E 393 MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 394 with an optional dynamic library name, for example 395 http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 396 397 Level: beginner 398 399 .seealso: MatGetOrdering() 400 E*/ 401 typedef char* MatOrderingType; 402 #define MATORDERING_NATURAL "natural" 403 #define MATORDERING_ND "nd" 404 #define MATORDERING_1WD "1wd" 405 #define MATORDERING_RCM "rcm" 406 #define MATORDERING_QMD "qmd" 407 #define MATORDERING_ROWLENGTH "rowlength" 408 #define MATORDERING_DSC_ND "dsc_nd" 409 #define MATORDERING_DSC_MMD "dsc_mmd" 410 #define MATORDERING_DSC_MDF "dsc_mdf" 411 412 EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*); 413 EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*)); 414 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 415 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 416 #else 417 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 418 #endif 419 EXTERN int MatOrderingRegisterDestroy(void); 420 EXTERN int MatOrderingRegisterAll(char*); 421 extern PetscTruth MatOrderingRegisterAllCalled; 422 extern PetscFList MatOrderingList; 423 424 EXTERN int MatReorderForNonzeroDiagonal(Mat,double,IS,IS); 425 426 EXTERN int MatCholeskyFactor(Mat,IS,double); 427 EXTERN int MatCholeskyFactorSymbolic(Mat,IS,double,Mat*); 428 EXTERN int MatCholeskyFactorNumeric(Mat,Mat*); 429 430 /*S 431 MatILUInfo - Data based into the matrix ILU factorization routines 432 433 In Fortran these are simply double precision arrays of size MAT_ILUINFO_SIZE 434 435 Notes: These are not usually directly used by users, instead use the PC type of ILU 436 All entries are double precision. 437 438 Level: developer 439 440 .seealso: MatILUFactorSymbolic(), MatILUFactor(), MatLUInfo, MatCholeskyInfo 441 442 S*/ 443 typedef struct { 444 double levels; /* ILU(levels) */ 445 double fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 446 double diagonal_fill; /* force diagonal to fill in if initially not filled */ 447 double dt; /* drop tolerance */ 448 double dtcol; /* tolerance for pivoting */ 449 double dtcount; /* maximum nonzeros to be allowed per row */ 450 double damping; /* scaling of identity added to matrix to prevent zero pivots */ 451 double damp; /* if is 1.0 and factorization fails, damp until successful */ 452 } MatILUInfo; 453 454 /*S 455 MatLUInfo - Data based into the matrix LU factorization routines 456 457 In Fortran these are simply double precision arrays of size MAT_LUINFO_SIZE 458 459 Notes: These are not usually directly used by users, instead use the PC type of LU 460 All entries are double precision. 461 462 Level: developer 463 464 .seealso: MatLUFactorSymbolic(), MatILUInfo, MatCholeskyInfo 465 466 S*/ 467 typedef struct { 468 double fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */ 469 double dtcol; /* tolerance for pivoting; pivot if off_diagonal*dtcol > diagonal */ 470 double damping; /* scaling of identity added to matrix to prevent zero pivots */ 471 double damp; /* if this is 1.0 and factorization fails, damp until successful */ 472 } MatLUInfo; 473 474 /*S 475 MatCholeskyInfo - Data based into the matrix Cholesky factorization routines 476 477 In Fortran these are simply double precision arrays of size MAT_CHOLESKYINFO_SIZE 478 479 Notes: These are not usually directly used by users, instead use the PC type of Cholesky 480 All entries are double precision. 481 482 Level: developer 483 484 .seealso: MatCholeskyFactorSymbolic(), MatLUInfo, MatILUInfo 485 486 S*/ 487 typedef struct { 488 double fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix */ 489 double damping; /* scaling of identity added to matrix to prevent zero pivots */ 490 double damp; /* if this is 1.0 and factorization fails, damp until successful */ 491 } MatCholeskyInfo; 492 493 EXTERN int MatLUFactor(Mat,IS,IS,MatLUInfo*); 494 EXTERN int MatILUFactor(Mat,IS,IS,MatILUInfo*); 495 EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatLUInfo*,Mat*); 496 EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatILUInfo*,Mat*); 497 EXTERN int MatICCFactorSymbolic(Mat,IS,double,int,Mat*); 498 EXTERN int MatICCFactor(Mat,IS,double,int); 499 EXTERN int MatLUFactorNumeric(Mat,Mat*); 500 EXTERN int MatILUDTFactor(Mat,MatILUInfo*,IS,IS,Mat *); 501 502 EXTERN int MatSolve(Mat,Vec,Vec); 503 EXTERN int MatForwardSolve(Mat,Vec,Vec); 504 EXTERN int MatBackwardSolve(Mat,Vec,Vec); 505 EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec); 506 EXTERN int MatSolveTranspose(Mat,Vec,Vec); 507 EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 508 509 EXTERN int MatSetUnfactored(Mat); 510 511 /* MatSORType may be bitwise ORd together, so do not change the numbers */ 512 /*E 513 MatSORType - What type of (S)SOR to perform 514 515 Level: beginner 516 517 May be bitwise ORd together 518 519 Any additions/changes here MUST also be made in include/finclude/petscmat.h 520 521 .seealso: MatRelax() 522 E*/ 523 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 524 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 525 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 526 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 527 EXTERN int MatRelax(Mat,Vec,double,MatSORType,double,int,Vec); 528 529 /* 530 These routines are for efficiently computing Jacobians via finite differences. 531 */ 532 533 /*E 534 MatColoringType - String with the name of a PETSc matrix coloring or the creation function 535 with an optional dynamic library name, for example 536 http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 537 538 Level: beginner 539 540 .seealso: MatGetColoring() 541 E*/ 542 typedef char* MatColoringType; 543 #define MATCOLORING_NATURAL "natural" 544 #define MATCOLORING_SL "sl" 545 #define MATCOLORING_LF "lf" 546 #define MATCOLORING_ID "id" 547 548 EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*); 549 EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *)); 550 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 551 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 552 #else 553 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 554 #endif 555 EXTERN int MatColoringRegisterAll(char *); 556 extern PetscTruth MatColoringRegisterAllCalled; 557 EXTERN int MatColoringRegisterDestroy(void); 558 EXTERN int MatColoringPatch(Mat,int,int,int *,ISColoring*); 559 560 #define MAT_FDCOLORING_COOKIE PETSC_COOKIE + 23 561 /*S 562 MatFDColoring - Object for computing a sparse Jacobian via finite differences 563 and coloring 564 565 Level: beginner 566 567 Concepts: coloring, sparse Jacobian, finite differences 568 569 .seealso: MatFDColoringCreate() 570 S*/ 571 typedef struct _p_MatFDColoring *MatFDColoring; 572 573 EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 574 EXTERN int MatFDColoringDestroy(MatFDColoring); 575 EXTERN int MatFDColoringView(MatFDColoring,PetscViewer); 576 EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*); 577 EXTERN int MatFDColoringSetParameters(MatFDColoring,double,double); 578 EXTERN int MatFDColoringSetFrequency(MatFDColoring,int); 579 EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*); 580 EXTERN int MatFDColoringSetFromOptions(MatFDColoring); 581 EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 582 EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,double,Vec,MatStructure*,void *); 583 EXTERN int MatFDColoringSetRecompute(MatFDColoring); 584 EXTERN int MatFDColoringSetF(MatFDColoring,Vec); 585 586 /* 587 These routines are for partitioning matrices: currently used only 588 for adjacency matrix, MatCreateMPIAdj(). 589 */ 590 #define MATPARTITIONING_COOKIE PETSC_COOKIE + 25 591 592 /*S 593 MatPartitioning - Object for managing the partitioning of a matrix or graph 594 595 Level: beginner 596 597 Concepts: partitioning 598 599 .seealso: MatParitioningCreate(), MatPartitioningType 600 S*/ 601 typedef struct _p_MatPartitioning *MatPartitioning; 602 603 /*E 604 MatPartitioningType - String with the name of a PETSc matrix partitioing or the creation function 605 with an optional dynamic library name, for example 606 http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 607 608 Level: beginner 609 610 .seealso: MatPartitioingCreate(), MatPartitioning 611 E*/ 612 typedef char* MatPartitioningType; 613 #define MATPARTITIONING_CURRENT "current" 614 #define MATPARTITIONING_PARMETIS "parmetis" 615 616 EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*); 617 EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType); 618 EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat); 619 EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,int*); 620 EXTERN int MatPartitioningApply(MatPartitioning,IS*); 621 EXTERN int MatPartitioningDestroy(MatPartitioning); 622 623 EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning)); 624 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 625 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 626 #else 627 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 628 #endif 629 630 EXTERN int MatPartitioningRegisterAll(char *); 631 extern PetscTruth MatPartitioningRegisterAllCalled; 632 EXTERN int MatPartitioningRegisterDestroy(void); 633 634 EXTERN int MatPartitioningView(MatPartitioning,PetscViewer); 635 EXTERN int MatPartitioningSetFromOptions(MatPartitioning); 636 EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 637 638 EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 639 640 /* 641 If you add entries here you must also add them to finclude/petscmat.h 642 */ 643 typedef enum { MATOP_SET_VALUES=0, 644 MATOP_GET_ROW=1, 645 MATOP_RESTORE_ROW=2, 646 MATOP_MULT=3, 647 MATOP_MULT_ADD=4, 648 MATOP_MULT_TRANSPOSE=5, 649 MATOP_MULT_TRANSPOSE_ADD=6, 650 MATOP_SOLVE=7, 651 MATOP_SOLVE_ADD=8, 652 MATOP_SOLVE_TRANSPOSE=9, 653 MATOP_SOLVE_TRANSPOSE_ADD=10, 654 MATOP_LUFACTOR=11, 655 MATOP_CHOLESKYFACTOR=12, 656 MATOP_RELAX=13, 657 MATOP_TRANSPOSE=14, 658 MATOP_GETINFO=15, 659 MATOP_EQUAL=16, 660 MATOP_GET_DIAGONAL=17, 661 MATOP_DIAGONAL_SCALE=18, 662 MATOP_NORM=19, 663 MATOP_ASSEMBLY_BEGIN=20, 664 MATOP_ASSEMBLY_END=21, 665 MATOP_COMPRESS=22, 666 MATOP_SET_OPTION=23, 667 MATOP_ZERO_ENTRIES=24, 668 MATOP_ZERO_ROWS=25, 669 MATOP_LUFACTOR_SYMBOLIC=26, 670 MATOP_LUFACTOR_NUMERIC=27, 671 MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 672 MATOP_CHOLESKY_FACTOR_NUMERIC=29, 673 MATOP_GET_SIZE=30, 674 MATOP_GET_LOCAL_SIZE=31, 675 MATOP_GET_OWNERSHIP_RANGE=32, 676 MATOP_ILUFACTOR_SYMBOLIC=33, 677 MATOP_ICCFACTOR_SYMBOLIC=34, 678 MATOP_GET_ARRAY=35, 679 MATOP_RESTORE_ARRAY=36, 680 681 MATOP_CONVERT_SAME_TYPE=37, 682 MATOP_FORWARD_SOLVE=38, 683 MATOP_BACKWARD_SOLVE=39, 684 MATOP_ILUFACTOR=40, 685 MATOP_ICCFACTOR=41, 686 MATOP_AXPY=42, 687 MATOP_GET_SUBMATRICES=43, 688 MATOP_INCREASE_OVERLAP=44, 689 MATOP_GET_VALUES=45, 690 MATOP_COPY=46, 691 MATOP_PRINT_HELP=47, 692 MATOP_SCALE=48, 693 MATOP_SHIFT=49, 694 MATOP_DIAGONAL_SHIFT=50, 695 MATOP_ILUDT_FACTOR=51, 696 MATOP_GET_BLOCK_SIZE=52, 697 MATOP_GET_ROW_IJ=53, 698 MATOP_RESTORE_ROW_IJ=54, 699 MATOP_GET_COLUMN_IJ=55, 700 MATOP_RESTORE_COLUMN_IJ=56, 701 MATOP_FDCOLORING_CREATE=57, 702 MATOP_COLORING_PATCH=58, 703 MATOP_SET_UNFACTORED=59, 704 MATOP_PERMUTE=60, 705 MATOP_SET_VALUES_BLOCKED=61, 706 MATOP_DESTROY=250, 707 MATOP_VIEW=251 708 } MatOperation; 709 EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*); 710 EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)()); 711 EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)()); 712 EXTERN int MatShellSetContext(Mat,void*); 713 714 /* 715 Codes for matrices stored on disk. By default they are 716 stored in a universal format. By changing the format with 717 PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 718 be stored in a way natural for the matrix, for example dense matrices 719 would be stored as dense. Matrices stored this way may only be 720 read into matrices of the same time. 721 */ 722 #define MATRIX_BINARY_FORMAT_DENSE -1 723 724 /* 725 New matrix classes not yet distributed 726 */ 727 /* 728 MatAIJIndices is a data structure for storing the nonzero location information 729 for sparse matrices. Several matrices with identical nonzero structure can share 730 the same MatAIJIndices. 731 */ 732 typedef struct _p_MatAIJIndices* MatAIJIndices; 733 734 EXTERN int MatCreateAIJIndices(int,int,int*,int*,PetscTruth,MatAIJIndices*); 735 EXTERN int MatCreateAIJIndicesEmpty(int,int,int*,PetscTruth,MatAIJIndices*); 736 EXTERN int MatAttachAIJIndices(MatAIJIndices,MatAIJIndices*); 737 EXTERN int MatDestroyAIJIndices(MatAIJIndices); 738 EXTERN int MatCopyAIJIndices(MatAIJIndices,MatAIJIndices*); 739 EXTERN int MatValidateAIJIndices(int,MatAIJIndices); 740 EXTERN int MatShiftAIJIndices(MatAIJIndices); 741 EXTERN int MatShrinkAIJIndices(MatAIJIndices); 742 EXTERN int MatTransposeAIJIndices(MatAIJIndices,MatAIJIndices*); 743 744 EXTERN int MatCreateSeqCSN(MPI_Comm,int,int,int*,int,Mat*); 745 EXTERN int MatCreateSeqCSN_Single(MPI_Comm,int,int,int*,int,Mat*); 746 EXTERN int MatCreateSeqCSNWithPrecision(MPI_Comm,int,int,int*,int,ScalarPrecision,Mat*); 747 748 EXTERN int MatCreateSeqCSNIndices(MPI_Comm,MatAIJIndices,int,Mat *); 749 EXTERN int MatCreateSeqCSNIndices_Single(MPI_Comm,MatAIJIndices,int,Mat *); 750 EXTERN int MatCreateSeqCSNIndicesWithPrecision(MPI_Comm,MatAIJIndices,int,ScalarPrecision,Mat *); 751 752 EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 753 EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *); 754 EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *); 755 756 /*S 757 MatNullSpace - Object that removes a null space from a vector, i.e. 758 orthogonalizes the vector to a subsapce 759 760 Level: beginner 761 762 Concepts: matrix; linear operator, null space 763 764 .seealso: MatNullSpaceCreate() 765 S*/ 766 typedef struct _p_MatNullSpace* MatNullSpace; 767 768 #define MATNULLSPACE_COOKIE PETSC_COOKIE+17 769 770 EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,Vec *,MatNullSpace*); 771 EXTERN int MatNullSpaceDestroy(MatNullSpace); 772 EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 773 EXTERN int MatNullSpaceAttach(Mat,MatNullSpace); 774 EXTERN int MatNullSpaceTest(MatNullSpace,Mat); 775 776 EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp); 777 EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 778 EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *); 779 780 781 EXTERN int MatCreateMAIJ(Mat,int,Mat*); 782 EXTERN int MatMAIJRedimension(Mat,int,Mat*); 783 EXTERN int MatMAIJGetAIJ(Mat,Mat*); 784 785 EXTERN int MatMPIAdjSetValues(Mat,int*,int*,int*); 786 787 EXTERN int MatComputeExplicitOperator(Mat,Mat*); 788 789 #endif 790 791 792 793