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