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