1 /* 2 Include file for the matrix component of PETSc 3 */ 4 #ifndef __PETSCMAT_H 5 #define __PETSCMAT_H 6 #include "petscvec.h" 7 8 /*S 9 Mat - Abstract PETSc matrix object 10 11 Level: beginner 12 13 Concepts: matrix; linear operator 14 15 .seealso: MatCreate(), MatType, MatSetType() 16 S*/ 17 typedef struct _p_Mat* Mat; 18 19 /*J 20 MatType - String with the name of a PETSc matrix or the creation function 21 with an optional dynamic library name, for example 22 http://www.mcs.anl.gov/petsc/lib.a:mymatcreate() 23 24 Level: beginner 25 26 .seealso: MatSetType(), Mat, MatSolverPackage 27 J*/ 28 #define MatType char* 29 #define MATSAME "same" 30 #define MATMAIJ "maij" 31 #define MATSEQMAIJ "seqmaij" 32 #define MATMPIMAIJ "mpimaij" 33 #define MATIS "is" 34 #define MATAIJ "aij" 35 #define MATSEQAIJ "seqaij" 36 #define MATSEQAIJPTHREAD "seqaijpthread" 37 #define MATAIJPTHREAD "aijpthread" 38 #define MATMPIAIJ "mpiaij" 39 #define MATAIJCRL "aijcrl" 40 #define MATSEQAIJCRL "seqaijcrl" 41 #define MATMPIAIJCRL "mpiaijcrl" 42 #define MATAIJCUSP "aijcusp" 43 #define MATSEQAIJCUSP "seqaijcusp" 44 #define MATMPIAIJCUSP "mpiaijcusp" 45 #define MATAIJPERM "aijperm" 46 #define MATSEQAIJPERM "seqaijperm" 47 #define MATMPIAIJPERM "mpiaijperm" 48 #define MATSHELL "shell" 49 #define MATDENSE "dense" 50 #define MATSEQDENSE "seqdense" 51 #define MATMPIDENSE "mpidense" 52 #define MATELEMENTAL "elemental" 53 #define MATBAIJ "baij" 54 #define MATSEQBAIJ "seqbaij" 55 #define MATMPIBAIJ "mpibaij" 56 #define MATMPIADJ "mpiadj" 57 #define MATSBAIJ "sbaij" 58 #define MATSEQSBAIJ "seqsbaij" 59 #define MATMPISBAIJ "mpisbaij" 60 #define MATSEQBSTRM "seqbstrm" 61 #define MATMPIBSTRM "mpibstrm" 62 #define MATBSTRM "bstrm" 63 #define MATSEQSBSTRM "seqsbstrm" 64 #define MATMPISBSTRM "mpisbstrm" 65 #define MATSBSTRM "sbstrm" 66 #define MATDAAD "daad" 67 #define MATMFFD "mffd" 68 #define MATNORMAL "normal" 69 #define MATLRC "lrc" 70 #define MATSCATTER "scatter" 71 #define MATBLOCKMAT "blockmat" 72 #define MATCOMPOSITE "composite" 73 #define MATFFT "fft" 74 #define MATFFTW "fftw" 75 #define MATSEQCUFFT "seqcufft" 76 #define MATTRANSPOSEMAT "transpose" 77 #define MATSCHURCOMPLEMENT "schurcomplement" 78 #define MATPYTHON "python" 79 #define MATHYPRESTRUCT "hyprestruct" 80 #define MATHYPRESSTRUCT "hypresstruct" 81 #define MATSUBMATRIX "submatrix" 82 #define MATLOCALREF "localref" 83 #define MATNEST "nest" 84 #define MATIJ "ij" 85 86 /*J 87 MatSolverPackage - String with the name of a PETSc matrix solver type. 88 89 For example: "petsc" indicates what PETSc provides, "superlu" indicates either 90 SuperLU or SuperLU_Dist etc. 91 92 93 Level: beginner 94 95 .seealso: MatGetFactor(), Mat, MatSetType(), MatType 96 J*/ 97 #define MatSolverPackage char* 98 #define MATSOLVERSPOOLES "spooles" 99 #define MATSOLVERSUPERLU "superlu" 100 #define MATSOLVERSUPERLU_DIST "superlu_dist" 101 #define MATSOLVERUMFPACK "umfpack" 102 #define MATSOLVERCHOLMOD "cholmod" 103 #define MATSOLVERESSL "essl" 104 #define MATSOLVERLUSOL "lusol" 105 #define MATSOLVERMUMPS "mumps" 106 #define MATSOLVERPASTIX "pastix" 107 #define MATSOLVERMATLAB "matlab" 108 #define MATSOLVERPETSC "petsc" 109 #define MATSOLVERPLAPACK "plapack" 110 #define MATSOLVERBAS "bas" 111 112 #define MATSOLVERBSTRM "bstrm" 113 #define MATSOLVERSBSTRM "sbstrm" 114 115 /*E 116 MatFactorType - indicates what type of factorization is requested 117 118 Level: beginner 119 120 Any additions/changes here MUST also be made in include/finclude/petscmat.h 121 122 .seealso: MatSolverPackage, MatGetFactor() 123 E*/ 124 typedef enum {MAT_FACTOR_NONE, MAT_FACTOR_LU, MAT_FACTOR_CHOLESKY, MAT_FACTOR_ILU, MAT_FACTOR_ICC,MAT_FACTOR_ILUDT} MatFactorType; 125 PETSC_EXTERN const char *const MatFactorTypes[]; 126 127 PETSC_EXTERN PetscErrorCode MatGetFactor(Mat,const MatSolverPackage,MatFactorType,Mat*); 128 PETSC_EXTERN PetscErrorCode MatGetFactorAvailable(Mat,const MatSolverPackage,MatFactorType,PetscBool *); 129 PETSC_EXTERN PetscErrorCode MatFactorGetSolverPackage(Mat,const MatSolverPackage*); 130 PETSC_EXTERN PetscErrorCode MatGetFactorType(Mat,MatFactorType*); 131 132 /* Logging support */ 133 #define MAT_FILE_CLASSID 1211216 /* used to indicate matrices in binary files */ 134 PETSC_EXTERN PetscClassId MAT_CLASSID; 135 PETSC_EXTERN PetscClassId MAT_FDCOLORING_CLASSID; 136 PETSC_EXTERN PetscClassId MAT_TRANSPOSECOLORING_CLASSID; 137 PETSC_EXTERN PetscClassId MAT_PARTITIONING_CLASSID; 138 PETSC_EXTERN PetscClassId MAT_COARSEN_CLASSID; 139 PETSC_EXTERN PetscClassId MAT_NULLSPACE_CLASSID; 140 PETSC_EXTERN PetscClassId MATMFFD_CLASSID; 141 142 /*E 143 MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 144 or MatGetSubMatrix() are to be reused to store the new matrix values. For MatConvert() is used to indicate 145 that the input matrix is to be replaced with the converted matrix. 146 147 Level: beginner 148 149 Any additions/changes here MUST also be made in include/finclude/petscmat.h 150 151 .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices(), MatConvert() 152 E*/ 153 typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX,MAT_IGNORE_MATRIX} MatReuse; 154 155 /*E 156 MatGetSubMatrixOption - Indicates if matrices obtained from a call to MatGetSubMatrices() 157 include the matrix values. Currently it is only used by MatGetSeqNonzerostructure(). 158 159 Level: beginner 160 161 .seealso: MatGetSeqNonzerostructure() 162 E*/ 163 typedef enum {MAT_DO_NOT_GET_VALUES,MAT_GET_VALUES} MatGetSubMatrixOption; 164 165 PETSC_EXTERN PetscErrorCode MatInitializePackage(const char[]); 166 167 PETSC_EXTERN PetscErrorCode MatCreate(MPI_Comm,Mat*); 168 PETSC_EXTERN PetscErrorCode MatSetSizes(Mat,PetscInt,PetscInt,PetscInt,PetscInt); 169 PETSC_EXTERN PetscErrorCode MatSetType(Mat,const MatType); 170 PETSC_EXTERN PetscErrorCode MatSetFromOptions(Mat); 171 PETSC_EXTERN PetscErrorCode MatRegisterAll(const char[]); 172 PETSC_EXTERN PetscErrorCode MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat)); 173 PETSC_EXTERN PetscErrorCode MatRegisterBaseName(const char[],const char[],const char[]); 174 PETSC_EXTERN PetscErrorCode MatSetOptionsPrefix(Mat,const char[]); 175 PETSC_EXTERN PetscErrorCode MatAppendOptionsPrefix(Mat,const char[]); 176 PETSC_EXTERN PetscErrorCode MatGetOptionsPrefix(Mat,const char*[]); 177 178 /*MC 179 MatRegisterDynamic - Adds a new matrix type 180 181 Synopsis: 182 PetscErrorCode MatRegisterDynamic(const char *name,const char *path,const char *name_create,PetscErrorCode (*routine_create)(Mat)) 183 184 Not Collective 185 186 Input Parameters: 187 + name - name of a new user-defined matrix type 188 . path - path (either absolute or relative) the library containing this solver 189 . name_create - name of routine to create method context 190 - routine_create - routine to create method context 191 192 Notes: 193 MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 194 195 If dynamic libraries are used, then the fourth input argument (routine_create) 196 is ignored. 197 198 Sample usage: 199 .vb 200 MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 201 "MyMatCreate",MyMatCreate); 202 .ve 203 204 Then, your solver can be chosen with the procedural interface via 205 $ MatSetType(Mat,"my_mat") 206 or at runtime via the option 207 $ -mat_type my_mat 208 209 Level: advanced 210 211 Notes: ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 212 If your function is not being put into a shared library then use VecRegister() instead 213 214 .keywords: Mat, register 215 216 .seealso: MatRegisterAll(), MatRegisterDestroy() 217 218 M*/ 219 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 220 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 221 #else 222 #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 223 #endif 224 225 PETSC_EXTERN PetscBool MatRegisterAllCalled; 226 PETSC_EXTERN PetscFList MatList; 227 PETSC_EXTERN PetscFList MatColoringList; 228 PETSC_EXTERN PetscFList MatPartitioningList; 229 PETSC_EXTERN PetscFList MatCoarsenList; 230 231 /*E 232 MatStructure - Indicates if the matrix has the same nonzero structure 233 234 Level: beginner 235 236 Any additions/changes here MUST also be made in include/finclude/petscmat.h 237 238 .seealso: MatCopy(), KSPSetOperators(), PCSetOperators() 239 E*/ 240 typedef enum {DIFFERENT_NONZERO_PATTERN,SUBSET_NONZERO_PATTERN,SAME_NONZERO_PATTERN,SAME_PRECONDITIONER} MatStructure; 241 242 PETSC_EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*); 243 PETSC_EXTERN PetscErrorCode MatCreateDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*); 244 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 245 PETSC_EXTERN PetscErrorCode MatCreateAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 246 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *); 247 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJWithSplitArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],PetscInt[],PetscInt[],PetscScalar[],Mat*); 248 249 PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 250 PETSC_EXTERN PetscErrorCode MatCreateBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 251 PETSC_EXTERN PetscErrorCode MatCreateMPIBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat*); 252 253 PETSC_EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*); 254 PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 255 256 PETSC_EXTERN PetscErrorCode MatCreateSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 257 PETSC_EXTERN PetscErrorCode MatCreateMPISBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],Mat *); 258 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 259 PETSC_EXTERN PetscErrorCode MatXAIJSetPreallocation(Mat,PetscInt,const PetscInt*,const PetscInt*,const PetscInt*,const PetscInt*); 260 261 PETSC_EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*); 262 PETSC_EXTERN PetscErrorCode MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*); 263 PETSC_EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*); 264 PETSC_EXTERN PetscErrorCode MatCreateLRC(Mat,Mat,Mat,Mat*); 265 PETSC_EXTERN PetscErrorCode MatCreateIS(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,ISLocalToGlobalMapping,Mat*); 266 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 267 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJCRL(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 268 269 PETSC_EXTERN PetscErrorCode MatCreateSeqBSTRM(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 270 PETSC_EXTERN PetscErrorCode MatCreateMPIBSTRM(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 271 PETSC_EXTERN PetscErrorCode MatCreateSeqSBSTRM(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 272 PETSC_EXTERN PetscErrorCode MatCreateMPISBSTRM(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 273 274 PETSC_EXTERN PetscErrorCode MatCreateScatter(MPI_Comm,VecScatter,Mat*); 275 PETSC_EXTERN PetscErrorCode MatScatterSetVecScatter(Mat,VecScatter); 276 PETSC_EXTERN PetscErrorCode MatScatterGetVecScatter(Mat,VecScatter*); 277 PETSC_EXTERN PetscErrorCode MatCreateBlockMat(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,Mat*); 278 PETSC_EXTERN PetscErrorCode MatCompositeAddMat(Mat,Mat); 279 PETSC_EXTERN PetscErrorCode MatCompositeMerge(Mat); 280 PETSC_EXTERN PetscErrorCode MatCreateComposite(MPI_Comm,PetscInt,const Mat*,Mat*); 281 typedef enum {MAT_COMPOSITE_ADDITIVE,MAT_COMPOSITE_MULTIPLICATIVE} MatCompositeType; 282 PETSC_EXTERN PetscErrorCode MatCompositeSetType(Mat,MatCompositeType); 283 284 PETSC_EXTERN PetscErrorCode MatCreateFFT(MPI_Comm,PetscInt,const PetscInt[],const MatType,Mat*); 285 PETSC_EXTERN PetscErrorCode MatCreateSeqCUFFT(MPI_Comm,PetscInt,const PetscInt[],Mat*); 286 287 PETSC_EXTERN PetscErrorCode MatCreateTranspose(Mat,Mat*); 288 PETSC_EXTERN PetscErrorCode MatCreateSubMatrix(Mat,IS,IS,Mat*); 289 PETSC_EXTERN PetscErrorCode MatSubMatrixUpdate(Mat,Mat,IS,IS); 290 PETSC_EXTERN PetscErrorCode MatCreateLocalRef(Mat,IS,IS,Mat*); 291 292 PETSC_EXTERN PetscErrorCode MatPythonSetType(Mat,const char[]); 293 294 PETSC_EXTERN PetscErrorCode MatSetUp(Mat); 295 PETSC_EXTERN PetscErrorCode MatDestroy(Mat*); 296 297 PETSC_EXTERN PetscErrorCode MatConjugate(Mat); 298 PETSC_EXTERN PetscErrorCode MatRealPart(Mat); 299 PETSC_EXTERN PetscErrorCode MatImaginaryPart(Mat); 300 PETSC_EXTERN PetscErrorCode MatGetDiagonalBlock(Mat,Mat*); 301 PETSC_EXTERN PetscErrorCode MatGetTrace(Mat,PetscScalar*); 302 PETSC_EXTERN PetscErrorCode MatInvertBlockDiagonal(Mat,const PetscScalar **); 303 304 /* ------------------------------------------------------------*/ 305 PETSC_EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 306 PETSC_EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 307 PETSC_EXTERN PetscErrorCode MatSetValuesRow(Mat,PetscInt,const PetscScalar[]); 308 PETSC_EXTERN PetscErrorCode MatSetValuesRowLocal(Mat,PetscInt,const PetscScalar[]); 309 PETSC_EXTERN PetscErrorCode MatSetValuesBatch(Mat,PetscInt,PetscInt,PetscInt[],const PetscScalar[]); 310 311 /*S 312 MatStencil - Data structure (C struct) for storing information about a single row or 313 column of a matrix as indexed on an associated grid. 314 315 Fortran usage is different, see MatSetValuesStencil() for details. 316 317 Level: beginner 318 319 Concepts: matrix; linear operator 320 321 .seealso: MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockedStencil() 322 S*/ 323 typedef struct { 324 PetscInt k,j,i,c; 325 } MatStencil; 326 327 PETSC_EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 328 PETSC_EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 329 PETSC_EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt); 330 331 PETSC_EXTERN PetscErrorCode MatSetColoring(Mat,ISColoring); 332 PETSC_EXTERN PetscErrorCode MatSetValuesAdic(Mat,void*); 333 PETSC_EXTERN PetscErrorCode MatSetValuesAdifor(Mat,PetscInt,void*); 334 335 /*E 336 MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 337 to continue to add values to it 338 339 Level: beginner 340 341 .seealso: MatAssemblyBegin(), MatAssemblyEnd() 342 E*/ 343 typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 344 PETSC_EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType); 345 PETSC_EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType); 346 PETSC_EXTERN PetscErrorCode MatAssembled(Mat,PetscBool *); 347 348 349 350 /*E 351 MatOption - Options that may be set for a matrix and its behavior or storage 352 353 Level: beginner 354 355 Any additions/changes here MUST also be made in include/finclude/petscmat.h 356 357 .seealso: MatSetOption() 358 E*/ 359 typedef enum {MAT_ROW_ORIENTED,MAT_NEW_NONZERO_LOCATIONS, 360 MAT_SYMMETRIC, 361 MAT_STRUCTURALLY_SYMMETRIC, 362 MAT_NEW_DIAGONALS,MAT_IGNORE_OFF_PROC_ENTRIES, 363 MAT_NEW_NONZERO_LOCATION_ERR, 364 MAT_NEW_NONZERO_ALLOCATION_ERR,MAT_USE_HASH_TABLE, 365 MAT_KEEP_NONZERO_PATTERN,MAT_IGNORE_ZERO_ENTRIES, 366 MAT_USE_INODES, 367 MAT_HERMITIAN, 368 MAT_SYMMETRY_ETERNAL, 369 MAT_CHECK_COMPRESSED_ROW, 370 MAT_IGNORE_LOWER_TRIANGULAR,MAT_ERROR_LOWER_TRIANGULAR, 371 MAT_GETROW_UPPERTRIANGULAR,MAT_UNUSED_NONZERO_LOCATION_ERR, 372 MAT_SPD,MAT_NO_OFF_PROC_ENTRIES,MAT_NO_OFF_PROC_ZERO_ROWS, 373 NUM_MAT_OPTIONS} MatOption; 374 PETSC_EXTERN const char *MatOptions[]; 375 PETSC_EXTERN PetscErrorCode MatSetOption(Mat,MatOption,PetscBool ); 376 PETSC_EXTERN PetscErrorCode MatGetType(Mat,const MatType*); 377 378 PETSC_EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]); 379 PETSC_EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 380 PETSC_EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 381 PETSC_EXTERN PetscErrorCode MatGetRowUpperTriangular(Mat); 382 PETSC_EXTERN PetscErrorCode MatRestoreRowUpperTriangular(Mat); 383 PETSC_EXTERN PetscErrorCode MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 384 PETSC_EXTERN PetscErrorCode MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 385 PETSC_EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt); 386 PETSC_EXTERN PetscErrorCode MatGetArray(Mat,PetscScalar *[]); 387 PETSC_EXTERN PetscErrorCode MatRestoreArray(Mat,PetscScalar *[]); 388 PETSC_EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *); 389 PETSC_EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt); 390 PETSC_EXTERN PetscErrorCode MatGetBlockSizes(Mat,PetscInt *,PetscInt *); 391 PETSC_EXTERN PetscErrorCode MatSetBlockSizes(Mat,PetscInt,PetscInt); 392 PETSC_EXTERN PetscErrorCode MatSetNThreads(Mat,PetscInt); 393 PETSC_EXTERN PetscErrorCode MatGetNThreads(Mat,PetscInt*); 394 395 PETSC_EXTERN PetscErrorCode MatMult(Mat,Vec,Vec); 396 PETSC_EXTERN PetscErrorCode MatMultDiagonalBlock(Mat,Vec,Vec); 397 PETSC_EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec); 398 PETSC_EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec); 399 PETSC_EXTERN PetscErrorCode MatMultHermitianTranspose(Mat,Vec,Vec); 400 PETSC_EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscBool *); 401 PETSC_EXTERN PetscErrorCode MatIsHermitianTranspose(Mat,Mat,PetscReal,PetscBool *); 402 PETSC_EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec); 403 PETSC_EXTERN PetscErrorCode MatMultHermitianTransposeAdd(Mat,Vec,Vec,Vec); 404 PETSC_EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec); 405 PETSC_EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec); 406 PETSC_EXTERN PetscErrorCode MatMatSolve(Mat,Mat,Mat); 407 408 /*E 409 MatDuplicateOption - Indicates if a duplicated sparse matrix should have 410 its numerical values copied over or just its nonzero structure. 411 412 Level: beginner 413 414 Any additions/changes here MUST also be made in include/finclude/petscmat.h 415 416 $ MAT_SHARE_NONZERO_PATTERN - the i and j arrays in the new matrix will be shared with the original matrix 417 $ this also triggers the MAT_DO_NOT_COPY_VALUES option. This is used when you 418 $ have several matrices with the same nonzero pattern. 419 420 .seealso: MatDuplicate() 421 E*/ 422 typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES,MAT_SHARE_NONZERO_PATTERN} MatDuplicateOption; 423 424 PETSC_EXTERN PetscErrorCode MatConvert(Mat,const MatType,MatReuse,Mat*); 425 PETSC_EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*); 426 427 428 PETSC_EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure); 429 PETSC_EXTERN PetscErrorCode MatView(Mat,PetscViewer); 430 PETSC_EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscBool *); 431 PETSC_EXTERN PetscErrorCode MatIsStructurallySymmetric(Mat,PetscBool *); 432 PETSC_EXTERN PetscErrorCode MatIsHermitian(Mat,PetscReal,PetscBool *); 433 PETSC_EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscBool *,PetscBool *); 434 PETSC_EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscBool *,PetscBool *); 435 PETSC_EXTERN PetscErrorCode MatMissingDiagonal(Mat,PetscBool *,PetscInt *); 436 PETSC_EXTERN PetscErrorCode MatLoad(Mat, PetscViewer); 437 438 PETSC_EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,PetscInt *[],PetscInt *[],PetscBool *); 439 PETSC_EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,PetscInt *[],PetscInt *[],PetscBool *); 440 PETSC_EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt*,PetscInt *[],PetscInt *[],PetscBool *); 441 PETSC_EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscBool ,PetscBool ,PetscInt *,PetscInt *[],PetscInt *[],PetscBool *); 442 443 /*S 444 MatInfo - Context of matrix information, used with MatGetInfo() 445 446 In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 447 448 Level: intermediate 449 450 Concepts: matrix^nonzero information 451 452 .seealso: MatGetInfo(), MatInfoType 453 S*/ 454 typedef struct { 455 PetscLogDouble block_size; /* block size */ 456 PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 457 PetscLogDouble memory; /* memory allocated */ 458 PetscLogDouble assemblies; /* number of matrix assemblies called */ 459 PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 460 PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 461 PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 462 } MatInfo; 463 464 /*E 465 MatInfoType - Indicates if you want information about the local part of the matrix, 466 the entire parallel matrix or the maximum over all the local parts. 467 468 Level: beginner 469 470 Any additions/changes here MUST also be made in include/finclude/petscmat.h 471 472 .seealso: MatGetInfo(), MatInfo 473 E*/ 474 typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 475 PETSC_EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*); 476 PETSC_EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec); 477 PETSC_EXTERN PetscErrorCode MatGetRowMax(Mat,Vec,PetscInt[]); 478 PETSC_EXTERN PetscErrorCode MatGetRowMin(Mat,Vec,PetscInt[]); 479 PETSC_EXTERN PetscErrorCode MatGetRowMaxAbs(Mat,Vec,PetscInt[]); 480 PETSC_EXTERN PetscErrorCode MatGetRowMinAbs(Mat,Vec,PetscInt[]); 481 PETSC_EXTERN PetscErrorCode MatGetRowSum(Mat,Vec); 482 PETSC_EXTERN PetscErrorCode MatTranspose(Mat,MatReuse,Mat*); 483 PETSC_EXTERN PetscErrorCode MatHermitianTranspose(Mat,MatReuse,Mat*); 484 PETSC_EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat *); 485 PETSC_EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec); 486 PETSC_EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode); 487 PETSC_EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscBool *); 488 PETSC_EXTERN PetscErrorCode MatMultEqual(Mat,Mat,PetscInt,PetscBool *); 489 PETSC_EXTERN PetscErrorCode MatMultAddEqual(Mat,Mat,PetscInt,PetscBool *); 490 PETSC_EXTERN PetscErrorCode MatMultTransposeEqual(Mat,Mat,PetscInt,PetscBool *); 491 PETSC_EXTERN PetscErrorCode MatMultTransposeAddEqual(Mat,Mat,PetscInt,PetscBool *); 492 493 PETSC_EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal *); 494 PETSC_EXTERN PetscErrorCode MatGetColumnNorms(Mat,NormType,PetscReal *); 495 PETSC_EXTERN PetscErrorCode MatZeroEntries(Mat); 496 PETSC_EXTERN PetscErrorCode MatZeroRows(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec); 497 PETSC_EXTERN PetscErrorCode MatZeroRowsIS(Mat,IS,PetscScalar,Vec,Vec); 498 PETSC_EXTERN PetscErrorCode MatZeroRowsStencil(Mat,PetscInt,const MatStencil [],PetscScalar,Vec,Vec); 499 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsStencil(Mat,PetscInt,const MatStencil[],PetscScalar,Vec,Vec); 500 PETSC_EXTERN PetscErrorCode MatZeroRowsColumns(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec); 501 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsIS(Mat,IS,PetscScalar,Vec,Vec); 502 503 PETSC_EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*); 504 PETSC_EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*); 505 PETSC_EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*); 506 PETSC_EXTERN PetscErrorCode MatGetOwnershipRanges(Mat,const PetscInt**); 507 PETSC_EXTERN PetscErrorCode MatGetOwnershipRangeColumn(Mat,PetscInt*,PetscInt*); 508 PETSC_EXTERN PetscErrorCode MatGetOwnershipRangesColumn(Mat,const PetscInt**); 509 PETSC_EXTERN PetscErrorCode MatGetOwnershipIS(Mat,IS*,IS*); 510 511 PETSC_EXTERN PetscErrorCode MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 512 PETSC_EXTERN PetscErrorCode MatGetSubMatricesParallel(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 513 PETSC_EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]); 514 PETSC_EXTERN PetscErrorCode MatGetSubMatrix(Mat,IS,IS,MatReuse,Mat *); 515 PETSC_EXTERN PetscErrorCode MatGetLocalSubMatrix(Mat,IS,IS,Mat*); 516 PETSC_EXTERN PetscErrorCode MatRestoreLocalSubMatrix(Mat,IS,IS,Mat*); 517 PETSC_EXTERN PetscErrorCode MatGetSeqNonzeroStructure(Mat,Mat*); 518 PETSC_EXTERN PetscErrorCode MatDestroySeqNonzeroStructure(Mat*); 519 520 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJConcatenateSeqAIJ(MPI_Comm,Mat,PetscInt,MatReuse,Mat*); 521 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJConcatenateSeqAIJSymbolic(MPI_Comm,Mat,PetscInt,Mat*); 522 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJConcatenateSeqAIJNumeric(MPI_Comm,Mat,PetscInt,Mat); 523 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJ(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*); 524 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJSymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*); 525 PETSC_EXTERN PetscErrorCode MatCreateMPIAIJSumSeqAIJNumeric(Mat,Mat); 526 PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMat(Mat,MatReuse,Mat*); 527 PETSC_EXTERN PetscErrorCode MatMPIAIJGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*); 528 PETSC_EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,Mat*); 529 #if defined (PETSC_USE_CTABLE) 530 PETSC_EXTERN PetscErrorCode MatGetCommunicationStructs(Mat, Vec *, PetscTable *, VecScatter *); 531 #else 532 PETSC_EXTERN PetscErrorCode MatGetCommunicationStructs(Mat, Vec *, PetscInt *[], VecScatter *); 533 #endif 534 PETSC_EXTERN PetscErrorCode MatGetGhosts(Mat, PetscInt *,const PetscInt *[]); 535 536 PETSC_EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt); 537 538 PETSC_EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 539 PETSC_EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 540 PETSC_EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat); 541 542 PETSC_EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*); 543 PETSC_EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*); 544 PETSC_EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat); 545 PETSC_EXTERN PetscErrorCode MatRARt(Mat,Mat,MatReuse,PetscReal,Mat*); 546 PETSC_EXTERN PetscErrorCode MatRARtSymbolic(Mat,Mat,PetscReal,Mat*); 547 PETSC_EXTERN PetscErrorCode MatRARtNumeric(Mat,Mat,Mat); 548 549 PETSC_EXTERN PetscErrorCode MatTransposeMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 550 PETSC_EXTERN PetscErrorCode MatTransposetMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 551 PETSC_EXTERN PetscErrorCode MatTransposetMatMultNumeric(Mat,Mat,Mat); 552 PETSC_EXTERN PetscErrorCode MatMatTransposeMult(Mat,Mat,MatReuse,PetscReal,Mat*); 553 PETSC_EXTERN PetscErrorCode MatMatTransposeMultSymbolic(Mat,Mat,PetscReal,Mat*); 554 PETSC_EXTERN PetscErrorCode MatMatTransposeMultNumeric(Mat,Mat,Mat); 555 556 PETSC_EXTERN PetscErrorCode MatAXPY(Mat,PetscScalar,Mat,MatStructure); 557 PETSC_EXTERN PetscErrorCode MatAYPX(Mat,PetscScalar,Mat,MatStructure); 558 559 PETSC_EXTERN PetscErrorCode MatScale(Mat,PetscScalar); 560 PETSC_EXTERN PetscErrorCode MatShift(Mat,PetscScalar); 561 562 PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping,ISLocalToGlobalMapping); 563 PETSC_EXTERN PetscErrorCode MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping,ISLocalToGlobalMapping); 564 PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping*,ISLocalToGlobalMapping*); 565 PETSC_EXTERN PetscErrorCode MatGetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping*,ISLocalToGlobalMapping*); 566 PETSC_EXTERN PetscErrorCode MatZeroRowsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec); 567 PETSC_EXTERN PetscErrorCode MatZeroRowsLocalIS(Mat,IS,PetscScalar,Vec,Vec); 568 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocal(Mat,PetscInt,const PetscInt [],PetscScalar,Vec,Vec); 569 PETSC_EXTERN PetscErrorCode MatZeroRowsColumnsLocalIS(Mat,IS,PetscScalar,Vec,Vec); 570 PETSC_EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 571 PETSC_EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 572 573 PETSC_EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt); 574 PETSC_EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 575 576 PETSC_EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec); 577 PETSC_EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec); 578 PETSC_EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec); 579 PETSC_EXTERN PetscErrorCode MatGetVecs(Mat,Vec*,Vec*); 580 PETSC_EXTERN PetscErrorCode MatGetRedundantMatrix(Mat,PetscInt,MPI_Comm,PetscInt,MatReuse,Mat*); 581 PETSC_EXTERN PetscErrorCode MatGetMultiProcBlock(Mat,MPI_Comm,MatReuse,Mat*); 582 PETSC_EXTERN PetscErrorCode MatFindZeroDiagonals(Mat,IS*); 583 584 /*MC 585 MatSetValue - Set a single entry into a matrix. 586 587 Not collective 588 589 Input Parameters: 590 + m - the matrix 591 . row - the row location of the entry 592 . col - the column location of the entry 593 . value - the value to insert 594 - mode - either INSERT_VALUES or ADD_VALUES 595 596 Notes: 597 For efficiency one should use MatSetValues() and set several or many 598 values simultaneously if possible. 599 600 Level: beginner 601 602 .seealso: MatSetValues(), MatSetValueLocal() 603 M*/ 604 PETSC_STATIC_INLINE PetscErrorCode MatSetValue(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValues(v,1,&i,1,&j,&va,mode);} 605 606 PETSC_STATIC_INLINE PetscErrorCode MatGetValue(Mat v,PetscInt i,PetscInt j,PetscScalar *va) {return MatGetValues(v,1,&i,1,&j,va);} 607 608 PETSC_STATIC_INLINE PetscErrorCode MatSetValueLocal(Mat v,PetscInt i,PetscInt j,PetscScalar va,InsertMode mode) {return MatSetValuesLocal(v,1,&i,1,&j,&va,mode);} 609 610 /*MC 611 MatPreallocateInitialize - Begins the block of code that will count the number of nonzeros per 612 row in a matrix providing the data that one can use to correctly preallocate the matrix. 613 614 Synopsis: 615 PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 616 617 Collective on MPI_Comm 618 619 Input Parameters: 620 + comm - the communicator that will share the eventually allocated matrix 621 . nrows - the number of LOCAL rows in the matrix 622 - ncols - the number of LOCAL columns in the matrix 623 624 Output Parameters: 625 + dnz - the array that will be passed to the matrix preallocation routines 626 - ozn - the other array passed to the matrix preallocation routines 627 628 629 Level: intermediate 630 631 Notes: 632 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 633 634 Do not malloc or free dnz and onz, that is handled internally by these routines 635 636 Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 637 638 This is a MACRO not a function because it has a leading { that is closed by PetscPreallocateFinalize(). 639 640 Concepts: preallocation^Matrix 641 642 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 643 MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 644 M*/ 645 #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 646 { \ 647 PetscErrorCode _4_ierr; PetscInt __nrows = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 648 _4_ierr = PetscMalloc2(__nrows,PetscInt,&dnz,__nrows,PetscInt,&onz);CHKERRQ(_4_ierr); \ 649 _4_ierr = PetscMemzero(dnz,__nrows*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 650 _4_ierr = PetscMemzero(onz,__nrows*sizeof(PetscInt));CHKERRQ(_4_ierr); __start = 0; __end = __start; \ 651 _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 652 _4_ierr = MPI_Scan(&__nrows,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __nrows; 653 654 /*MC 655 MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 656 inserted using a local number of the rows and columns 657 658 Synopsis: 659 PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 660 661 Not Collective 662 663 Input Parameters: 664 + map - the row mapping from local numbering to global numbering 665 . nrows - the number of rows indicated 666 . rows - the indices of the rows 667 . cmap - the column mapping from local to global numbering 668 . ncols - the number of columns in the matrix 669 . cols - the columns indicated 670 . dnz - the array that will be passed to the matrix preallocation routines 671 - ozn - the other array passed to the matrix preallocation routines 672 673 674 Level: intermediate 675 676 Notes: 677 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 678 679 Do not malloc or free dnz and onz, that is handled internally by these routines 680 681 Concepts: preallocation^Matrix 682 683 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 684 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 685 M*/ 686 #define MatPreallocateSetLocal(rmap,nrows,rows,cmap,ncols,cols,dnz,onz) 0; \ 687 {\ 688 PetscInt __l;\ 689 _4_ierr = ISLocalToGlobalMappingApply(rmap,nrows,rows,rows);CHKERRQ(_4_ierr);\ 690 _4_ierr = ISLocalToGlobalMappingApply(cmap,ncols,cols,cols);CHKERRQ(_4_ierr);\ 691 for (__l=0;__l<nrows;__l++) {\ 692 _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 693 }\ 694 } 695 696 /*MC 697 MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 698 inserted using a local number of the rows and columns 699 700 Synopsis: 701 PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 702 703 Not Collective 704 705 Input Parameters: 706 + map - the mapping between local numbering and global numbering 707 . nrows - the number of rows indicated 708 . rows - the indices of the rows 709 . ncols - the number of columns in the matrix 710 . cols - the columns indicated 711 . dnz - the array that will be passed to the matrix preallocation routines 712 - ozn - the other array passed to the matrix preallocation routines 713 714 715 Level: intermediate 716 717 Notes: 718 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 719 720 Do not malloc or free dnz and onz that is handled internally by these routines 721 722 Concepts: preallocation^Matrix 723 724 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 725 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 726 M*/ 727 #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 728 {\ 729 PetscInt __l;\ 730 _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 731 _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 732 for (__l=0;__l<nrows;__l++) {\ 733 _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 734 }\ 735 } 736 737 /*MC 738 MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 739 inserted using a local number of the rows and columns 740 741 Synopsis: 742 PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 743 744 Not Collective 745 746 Input Parameters: 747 + row - the row 748 . ncols - the number of columns in the matrix 749 - cols - the columns indicated 750 751 Output Parameters: 752 + dnz - the array that will be passed to the matrix preallocation routines 753 - ozn - the other array passed to the matrix preallocation routines 754 755 756 Level: intermediate 757 758 Notes: 759 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 760 761 Do not malloc or free dnz and onz that is handled internally by these routines 762 763 This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize(). 764 765 Concepts: preallocation^Matrix 766 767 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 768 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 769 M*/ 770 #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 771 { PetscInt __i; \ 772 if (row < __rstart) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D less than first local row %D",row,__rstart);\ 773 if (row >= __rstart+__nrows) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"Trying to set preallocation for row %D greater than last local row %D",row,__rstart+__nrows-1);\ 774 for (__i=0; __i<nc; __i++) {\ 775 if ((cols)[__i] < __start || (cols)[__i] >= __end) onz[row - __rstart]++; \ 776 else dnz[row - __rstart]++;\ 777 }\ 778 } 779 780 /*MC 781 MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 782 inserted using a local number of the rows and columns 783 784 Synopsis: 785 PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 786 787 Not Collective 788 789 Input Parameters: 790 + nrows - the number of rows indicated 791 . rows - the indices of the rows 792 . ncols - the number of columns in the matrix 793 . cols - the columns indicated 794 . dnz - the array that will be passed to the matrix preallocation routines 795 - ozn - the other array passed to the matrix preallocation routines 796 797 798 Level: intermediate 799 800 Notes: 801 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 802 803 Do not malloc or free dnz and onz that is handled internally by these routines 804 805 This is a MACRO not a function because it uses variables declared in MatPreallocateInitialize(). 806 807 Concepts: preallocation^Matrix 808 809 .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 810 MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 811 M*/ 812 #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 813 { PetscInt __i; \ 814 for (__i=0; __i<nc; __i++) {\ 815 if (cols[__i] >= __end) onz[row - __rstart]++; \ 816 else if (cols[__i] >= row) dnz[row - __rstart]++;\ 817 }\ 818 } 819 820 /*MC 821 MatPreallocateLocation - An alternative to MatPreallocationSet() that puts the nonzero locations into the matrix if it exists 822 823 Synopsis: 824 PetscErrorCode MatPreallocateLocations(Mat A,PetscInt row,PetscInt ncols,PetscInt *cols,PetscInt *dnz,PetscInt *onz) 825 826 Not Collective 827 828 Input Parameters: 829 . A - matrix 830 . row - row where values exist (must be local to this process) 831 . ncols - number of columns 832 . cols - columns with nonzeros 833 . dnz - the array that will be passed to the matrix preallocation routines 834 - ozn - the other array passed to the matrix preallocation routines 835 836 837 Level: intermediate 838 839 Notes: 840 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 841 842 Do not malloc or free dnz and onz that is handled internally by these routines 843 844 This is a MACRO not a function because it uses a bunch of variables private to the MatPreallocation.... routines. 845 846 Concepts: preallocation^Matrix 847 848 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 849 MatPreallocateSymmetricSetLocal() 850 M*/ 851 #define MatPreallocateLocation(A,row,ncols,cols,dnz,onz) 0;if (A) {ierr = MatSetValues(A,1,&row,ncols,cols,PETSC_NULL,INSERT_VALUES);CHKERRQ(ierr);} else {ierr = MatPreallocateSet(row,ncols,cols,dnz,onz);CHKERRQ(ierr);} 852 853 854 /*MC 855 MatPreallocateFinalize - Ends the block of code that will count the number of nonzeros per 856 row in a matrix providing the data that one can use to correctly preallocate the matrix. 857 858 Synopsis: 859 PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz) 860 861 Collective on MPI_Comm 862 863 Input Parameters: 864 + dnz - the array that was be passed to the matrix preallocation routines 865 - ozn - the other array passed to the matrix preallocation routines 866 867 868 Level: intermediate 869 870 Notes: 871 See the <A href="../../docs/manual.pdf#nameddest=ch_performance">Hints for Performance Improvment</A> chapter in the users manual for more details. 872 873 Do not malloc or free dnz and onz that is handled internally by these routines 874 875 This is a MACRO not a function because it closes the { started in MatPreallocateInitialize(). 876 877 Concepts: preallocation^Matrix 878 879 .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 880 MatPreallocateSymmetricSetLocal() 881 M*/ 882 #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree2(dnz,onz);CHKERRQ(_4_ierr);} 883 884 885 886 /* Routines unique to particular data structures */ 887 PETSC_EXTERN PetscErrorCode MatShellGetContext(Mat,void *); 888 889 PETSC_EXTERN PetscErrorCode MatInodeAdjustForInodes(Mat,IS*,IS*); 890 PETSC_EXTERN PetscErrorCode MatInodeGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *); 891 892 PETSC_EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]); 893 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]); 894 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 895 PETSC_EXTERN PetscErrorCode MatCreateSeqBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 896 PETSC_EXTERN PetscErrorCode MatCreateSeqSBAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 897 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJFromTriple(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*,PetscInt,PetscBool); 898 899 #define MAT_SKIP_ALLOCATION -4 900 901 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 902 PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 903 PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]); 904 905 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 906 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 907 PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 908 PETSC_EXTERN PetscErrorCode MatSeqAIJSetPreallocationCSR(Mat,const PetscInt [],const PetscInt [],const PetscScalar []); 909 PETSC_EXTERN PetscErrorCode MatSeqBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 910 PETSC_EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]); 911 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 912 PETSC_EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]); 913 PETSC_EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 914 PETSC_EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 915 PETSC_EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]); 916 PETSC_EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]); 917 PETSC_EXTERN PetscErrorCode MatAdicSetLocalFunction(Mat,void (*)(void)); 918 PETSC_EXTERN PetscErrorCode MatMPIAdjCreateNonemptySubcommMat(Mat,Mat*); 919 920 PETSC_EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt); 921 PETSC_EXTERN PetscErrorCode MatDenseGetLocalMatrix(Mat,Mat*); 922 923 PETSC_EXTERN PetscErrorCode MatStoreValues(Mat); 924 PETSC_EXTERN PetscErrorCode MatRetrieveValues(Mat); 925 926 PETSC_EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*); 927 928 PETSC_EXTERN PetscErrorCode MatFindNonzeroRows(Mat,IS*); 929 /* 930 These routines are not usually accessed directly, rather solving is 931 done through the KSP and PC interfaces. 932 */ 933 934 /*J 935 MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 936 with an optional dynamic library name, for example 937 http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 938 939 Level: beginner 940 941 Cannot use const because the PC objects manipulate the string 942 943 .seealso: MatGetOrdering() 944 J*/ 945 #define MatOrderingType char* 946 #define MATORDERINGNATURAL "natural" 947 #define MATORDERINGND "nd" 948 #define MATORDERING1WD "1wd" 949 #define MATORDERINGRCM "rcm" 950 #define MATORDERINGQMD "qmd" 951 #define MATORDERINGROWLENGTH "rowlength" 952 #define MATORDERINGAMD "amd" /* only works if UMFPACK is installed with PETSc */ 953 954 PETSC_EXTERN PetscErrorCode MatGetOrdering(Mat,const MatOrderingType,IS*,IS*); 955 PETSC_EXTERN PetscErrorCode MatGetOrderingList(PetscFList *list); 956 PETSC_EXTERN PetscErrorCode MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*)); 957 958 /*MC 959 MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the matrix package. 960 961 Synopsis: 962 PetscErrorCode MatOrderingRegisterDynamic(const char *name_ordering,const char *path,const char *name_create,PetscErrorCode (*routine_create)(MatOrdering)) 963 964 Not Collective 965 966 Input Parameters: 967 + sname - name of ordering (for example MATORDERINGND) 968 . path - location of library where creation routine is 969 . name - name of function that creates the ordering type,a string 970 - function - function pointer that creates the ordering 971 972 Level: developer 973 974 If dynamic libraries are used, then the fourth input argument (function) 975 is ignored. 976 977 Sample usage: 978 .vb 979 MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 980 "MyOrder",MyOrder); 981 .ve 982 983 Then, your partitioner can be chosen with the procedural interface via 984 $ MatOrderingSetType(part,"my_order) 985 or at runtime via the option 986 $ -pc_factor_mat_ordering_type my_order 987 988 ${PETSC_ARCH} occuring in pathname will be replaced with appropriate values. 989 990 .keywords: matrix, ordering, register 991 992 .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 993 M*/ 994 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 995 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 996 #else 997 #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 998 #endif 999 1000 PETSC_EXTERN PetscErrorCode MatOrderingRegisterDestroy(void); 1001 PETSC_EXTERN PetscErrorCode MatOrderingRegisterAll(const char[]); 1002 PETSC_EXTERN PetscBool MatOrderingRegisterAllCalled; 1003 PETSC_EXTERN PetscFList MatOrderingList; 1004 1005 PETSC_EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 1006 1007 /*S 1008 MatFactorShiftType - Numeric Shift. 1009 1010 Level: beginner 1011 1012 S*/ 1013 typedef enum {MAT_SHIFT_NONE,MAT_SHIFT_NONZERO,MAT_SHIFT_POSITIVE_DEFINITE,MAT_SHIFT_INBLOCKS} MatFactorShiftType; 1014 PETSC_EXTERN const char *MatFactorShiftTypes[]; 1015 1016 /*S 1017 MatFactorInfo - Data passed into the matrix factorization routines 1018 1019 In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE, that is use 1020 $ MatFactorInfo info(MAT_FACTORINFO_SIZE) 1021 1022 Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 1023 1024 You can use MatFactorInfoInitialize() to set default values. 1025 1026 Level: developer 1027 1028 .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(), 1029 MatFactorInfoInitialize() 1030 1031 S*/ 1032 typedef struct { 1033 PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 1034 PetscReal usedt; 1035 PetscReal dt; /* drop tolerance */ 1036 PetscReal dtcol; /* tolerance for pivoting */ 1037 PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 1038 PetscReal fill; /* expected fill, nonzeros in factored matrix/nonzeros in original matrix */ 1039 PetscReal levels; /* ICC/ILU(levels) */ 1040 PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 1041 factorization may be faster if do not pivot */ 1042 PetscReal zeropivot; /* pivot is called zero if less than this */ 1043 PetscReal shifttype; /* type of shift added to matrix factor to prevent zero pivots */ 1044 PetscReal shiftamount; /* how large the shift is */ 1045 } MatFactorInfo; 1046 1047 PETSC_EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*); 1048 PETSC_EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,const MatFactorInfo*); 1049 PETSC_EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*); 1050 PETSC_EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,Mat,const MatFactorInfo*); 1051 PETSC_EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,const MatFactorInfo*); 1052 PETSC_EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,const MatFactorInfo*); 1053 PETSC_EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*); 1054 PETSC_EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,Mat,IS,IS,const MatFactorInfo*); 1055 PETSC_EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,Mat,IS,const MatFactorInfo*); 1056 PETSC_EXTERN PetscErrorCode MatICCFactor(Mat,IS,const MatFactorInfo*); 1057 PETSC_EXTERN PetscErrorCode MatLUFactorNumeric(Mat,Mat,const MatFactorInfo*); 1058 PETSC_EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*); 1059 PETSC_EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec); 1060 PETSC_EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec); 1061 PETSC_EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec); 1062 PETSC_EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec); 1063 PETSC_EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec); 1064 PETSC_EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 1065 PETSC_EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs); 1066 1067 PETSC_EXTERN PetscErrorCode MatSetUnfactored(Mat); 1068 1069 /*E 1070 MatSORType - What type of (S)SOR to perform 1071 1072 Level: beginner 1073 1074 May be bitwise ORd together 1075 1076 Any additions/changes here MUST also be made in include/finclude/petscmat.h 1077 1078 MatSORType may be bitwise ORd together, so do not change the numbers 1079 1080 .seealso: MatSOR() 1081 E*/ 1082 typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 1083 SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 1084 SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 1085 SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 1086 PETSC_EXTERN PetscErrorCode MatSOR(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 1087 1088 /* 1089 These routines are for efficiently computing Jacobians via finite differences. 1090 */ 1091 1092 /*J 1093 MatColoringType - String with the name of a PETSc matrix coloring or the creation function 1094 with an optional dynamic library name, for example 1095 http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 1096 1097 Level: beginner 1098 1099 .seealso: MatGetColoring() 1100 J*/ 1101 #define MatColoringType char* 1102 #define MATCOLORINGNATURAL "natural" 1103 #define MATCOLORINGSL "sl" 1104 #define MATCOLORINGLF "lf" 1105 #define MATCOLORINGID "id" 1106 1107 PETSC_EXTERN PetscErrorCode MatGetColoring(Mat,const MatColoringType,ISColoring*); 1108 PETSC_EXTERN PetscErrorCode MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,MatColoringType,ISColoring *)); 1109 1110 /*MC 1111 MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 1112 matrix package. 1113 1114 Synopsis: 1115 PetscErrorCode MatColoringRegisterDynamic(const char *name_coloring,const char *path,const char *name_create,PetscErrorCode (*routine_create)(MatColoring)) 1116 1117 Not Collective 1118 1119 Input Parameters: 1120 + sname - name of Coloring (for example MATCOLORINGSL) 1121 . path - location of library where creation routine is 1122 . name - name of function that creates the Coloring type, a string 1123 - function - function pointer that creates the coloring 1124 1125 Level: developer 1126 1127 If dynamic libraries are used, then the fourth input argument (function) 1128 is ignored. 1129 1130 Sample usage: 1131 .vb 1132 MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 1133 "MyColor",MyColor); 1134 .ve 1135 1136 Then, your partitioner can be chosen with the procedural interface via 1137 $ MatColoringSetType(part,"my_color") 1138 or at runtime via the option 1139 $ -mat_coloring_type my_color 1140 1141 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1142 1143 .keywords: matrix, Coloring, register 1144 1145 .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 1146 M*/ 1147 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1148 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 1149 #else 1150 #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 1151 #endif 1152 1153 PETSC_EXTERN PetscBool MatColoringRegisterAllCalled; 1154 1155 PETSC_EXTERN PetscErrorCode MatColoringRegisterAll(const char[]); 1156 PETSC_EXTERN PetscErrorCode MatColoringRegisterDestroy(void); 1157 PETSC_EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*); 1158 1159 /*S 1160 MatFDColoring - Object for computing a sparse Jacobian via finite differences 1161 and coloring 1162 1163 Level: beginner 1164 1165 Concepts: coloring, sparse Jacobian, finite differences 1166 1167 .seealso: MatFDColoringCreate() 1168 S*/ 1169 typedef struct _p_MatFDColoring* MatFDColoring; 1170 1171 PETSC_EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 1172 PETSC_EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring*); 1173 PETSC_EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer); 1174 PETSC_EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*); 1175 PETSC_EXTERN PetscErrorCode MatFDColoringGetFunction(MatFDColoring,PetscErrorCode (**)(void),void**); 1176 PETSC_EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 1177 PETSC_EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1178 PETSC_EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 1179 PETSC_EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec); 1180 PETSC_EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]); 1181 1182 /*S 1183 MatTransposeColoring - Object for computing a sparse matrix product C=A*B^T via coloring 1184 1185 Level: beginner 1186 1187 Concepts: coloring, sparse matrix product 1188 1189 .seealso: MatTransposeColoringCreate() 1190 S*/ 1191 typedef struct _p_MatTransposeColoring* MatTransposeColoring; 1192 1193 PETSC_EXTERN PetscErrorCode MatTransposeColoringCreate(Mat,ISColoring,MatTransposeColoring *); 1194 PETSC_EXTERN PetscErrorCode MatTransColoringApplySpToDen(MatTransposeColoring,Mat,Mat); 1195 PETSC_EXTERN PetscErrorCode MatTransColoringApplyDenToSp(MatTransposeColoring,Mat,Mat); 1196 PETSC_EXTERN PetscErrorCode MatTransposeColoringDestroy(MatTransposeColoring*); 1197 1198 /* 1199 These routines are for partitioning matrices: currently used only 1200 for adjacency matrix, MatCreateMPIAdj(). 1201 */ 1202 1203 /*S 1204 MatPartitioning - Object for managing the partitioning of a matrix or graph 1205 1206 Level: beginner 1207 1208 Concepts: partitioning 1209 1210 .seealso: MatPartitioningCreate(), MatPartitioningType 1211 S*/ 1212 typedef struct _p_MatPartitioning* MatPartitioning; 1213 1214 /*J 1215 MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1216 with an optional dynamic library name, for example 1217 http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1218 1219 Level: beginner 1220 dm 1221 .seealso: MatPartitioningCreate(), MatPartitioning 1222 J*/ 1223 #define MatPartitioningType char* 1224 #define MATPARTITIONINGCURRENT "current" 1225 #define MATPARTITIONINGSQUARE "square" 1226 #define MATPARTITIONINGPARMETIS "parmetis" 1227 #define MATPARTITIONINGCHACO "chaco" 1228 #define MATPARTITIONINGPARTY "party" 1229 #define MATPARTITIONINGPTSCOTCH "ptscotch" 1230 1231 1232 PETSC_EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1233 PETSC_EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,const MatPartitioningType); 1234 PETSC_EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt); 1235 PETSC_EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat); 1236 PETSC_EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]); 1237 PETSC_EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1238 PETSC_EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*); 1239 PETSC_EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning*); 1240 1241 PETSC_EXTERN PetscErrorCode MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning)); 1242 1243 /*MC 1244 MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 1245 matrix package. 1246 1247 Synopsis: 1248 PetscErrorCode MatPartitioningRegisterDynamic(const char *name_partitioning,const char *path,const char *name_create,PetscErrorCode (*routine_create)(MatPartitioning)) 1249 1250 Not Collective 1251 1252 Input Parameters: 1253 + sname - name of partitioning (for example MATPARTITIONINGCURRENT) or parmetis 1254 . path - location of library where creation routine is 1255 . name - name of function that creates the partitioning type, a string 1256 - function - function pointer that creates the partitioning type 1257 1258 Level: developer 1259 1260 If dynamic libraries are used, then the fourth input argument (function) 1261 is ignored. 1262 1263 Sample usage: 1264 .vb 1265 MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 1266 "MyPartCreate",MyPartCreate); 1267 .ve 1268 1269 Then, your partitioner can be chosen with the procedural interface via 1270 $ MatPartitioningSetType(part,"my_part") 1271 or at runtime via the option 1272 $ -mat_partitioning_type my_part 1273 1274 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1275 1276 .keywords: matrix, partitioning, register 1277 1278 .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 1279 M*/ 1280 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1281 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 1282 #else 1283 #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 1284 #endif 1285 1286 PETSC_EXTERN PetscBool MatPartitioningRegisterAllCalled; 1287 1288 PETSC_EXTERN PetscErrorCode MatPartitioningRegisterAll(const char[]); 1289 PETSC_EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void); 1290 1291 PETSC_EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer); 1292 PETSC_EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 1293 PETSC_EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,const MatPartitioningType*); 1294 1295 PETSC_EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 1296 PETSC_EXTERN PetscErrorCode MatPartitioningParmetisGetEdgeCut(MatPartitioning, PetscInt *); 1297 1298 typedef enum { MP_CHACO_MULTILEVEL=1,MP_CHACO_SPECTRAL=2,MP_CHACO_LINEAR=4,MP_CHACO_RANDOM=5,MP_CHACO_SCATTERED=6 } MPChacoGlobalType; 1299 PETSC_EXTERN const char *MPChacoGlobalTypes[]; 1300 typedef enum { MP_CHACO_KERNIGHAN=1,MP_CHACO_NONE=2 } MPChacoLocalType; 1301 PETSC_EXTERN const char *MPChacoLocalTypes[]; 1302 typedef enum { MP_CHACO_LANCZOS=0,MP_CHACO_RQI=1 } MPChacoEigenType; 1303 PETSC_EXTERN const char *MPChacoEigenTypes[]; 1304 1305 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning,MPChacoGlobalType); 1306 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetGlobal(MatPartitioning,MPChacoGlobalType*); 1307 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning,MPChacoLocalType); 1308 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetLocal(MatPartitioning,MPChacoLocalType*); 1309 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal); 1310 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType); 1311 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenSolver(MatPartitioning,MPChacoEigenType*); 1312 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning,PetscReal); 1313 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenTol(MatPartitioning,PetscReal*); 1314 PETSC_EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning,PetscInt); 1315 PETSC_EXTERN PetscErrorCode MatPartitioningChacoGetEigenNumber(MatPartitioning,PetscInt*); 1316 1317 #define MP_PARTY_OPT "opt" 1318 #define MP_PARTY_LIN "lin" 1319 #define MP_PARTY_SCA "sca" 1320 #define MP_PARTY_RAN "ran" 1321 #define MP_PARTY_GBF "gbf" 1322 #define MP_PARTY_GCF "gcf" 1323 #define MP_PARTY_BUB "bub" 1324 #define MP_PARTY_DEF "def" 1325 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning,const char*); 1326 #define MP_PARTY_HELPFUL_SETS "hs" 1327 #define MP_PARTY_KERNIGHAN_LIN "kl" 1328 #define MP_PARTY_NONE "no" 1329 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning,const char*); 1330 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal); 1331 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscBool); 1332 PETSC_EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscBool); 1333 1334 typedef enum { MP_PTSCOTCH_QUALITY,MP_PTSCOTCH_SPEED,MP_PTSCOTCH_BALANCE,MP_PTSCOTCH_SAFETY,MP_PTSCOTCH_SCALABILITY } MPPTScotchStrategyType; 1335 PETSC_EXTERN const char *MPPTScotchStrategyTypes[]; 1336 1337 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetImbalance(MatPartitioning,PetscReal); 1338 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetImbalance(MatPartitioning,PetscReal*); 1339 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchSetStrategy(MatPartitioning,MPPTScotchStrategyType); 1340 PETSC_EXTERN PetscErrorCode MatPartitioningPTScotchGetStrategy(MatPartitioning,MPPTScotchStrategyType*); 1341 1342 /* 1343 These routines are for coarsening matrices: 1344 */ 1345 1346 /*S 1347 MatCoarsen - Object for managing the coarsening of a graph (symmetric matrix) 1348 1349 Level: beginner 1350 1351 Concepts: coarsen 1352 1353 .seealso: MatCoarsenCreate), MatCoarsenType 1354 S*/ 1355 typedef struct _p_MatCoarsen* MatCoarsen; 1356 1357 /*J 1358 MatCoarsenType - String with the name of a PETSc matrix coarsen or the creation function 1359 with an optional dynamic library name, for example 1360 http://www.mcs.anl.gov/petsc/lib.a:coarsencreate() 1361 1362 Level: beginner 1363 dm 1364 .seealso: MatCoarsenCreate(), MatCoarsen 1365 J*/ 1366 #define MatCoarsenType char* 1367 #define MATCOARSENMIS "mis" 1368 #define MATCOARSENHEM "hem" 1369 1370 /* linked list for aggregates */ 1371 typedef struct _PetscCDIntNd{ 1372 struct _PetscCDIntNd *next; 1373 PetscInt gid; 1374 }PetscCDIntNd; 1375 1376 /* only used by node pool */ 1377 typedef struct _PetscCDArrNd{ 1378 struct _PetscCDArrNd *next; 1379 struct _PetscCDIntNd *array; 1380 }PetscCDArrNd; 1381 1382 typedef struct _PetscCoarsenData{ 1383 /* node pool */ 1384 PetscCDArrNd pool_list; 1385 PetscCDIntNd *new_node; 1386 PetscInt new_left; 1387 PetscInt chk_sz; 1388 PetscCDIntNd *extra_nodes; 1389 /* Array of lists */ 1390 PetscCDIntNd **array; 1391 PetscInt size; 1392 /* cache a Mat for communication data */ 1393 Mat mat; 1394 /* cache IS of removed equations */ 1395 IS removedIS; 1396 }PetscCoarsenData; 1397 1398 PETSC_EXTERN PetscErrorCode MatCoarsenCreate(MPI_Comm,MatCoarsen*); 1399 PETSC_EXTERN PetscErrorCode MatCoarsenSetType(MatCoarsen,const MatCoarsenType); 1400 PETSC_EXTERN PetscErrorCode MatCoarsenSetAdjacency(MatCoarsen,Mat); 1401 PETSC_EXTERN PetscErrorCode MatCoarsenSetGreedyOrdering(MatCoarsen,const IS); 1402 PETSC_EXTERN PetscErrorCode MatCoarsenSetStrictAggs(MatCoarsen,PetscBool); 1403 PETSC_EXTERN PetscErrorCode MatCoarsenSetVerbose(MatCoarsen,PetscInt); 1404 PETSC_EXTERN PetscErrorCode MatCoarsenGetData( MatCoarsen, PetscCoarsenData ** ); 1405 PETSC_EXTERN PetscErrorCode MatCoarsenApply(MatCoarsen); 1406 PETSC_EXTERN PetscErrorCode MatCoarsenDestroy(MatCoarsen*); 1407 1408 PETSC_EXTERN PetscErrorCode MatCoarsenRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatCoarsen)); 1409 1410 /*MC 1411 MatCoarsenRegisterDynamic - Adds a new sparse matrix coarsen to the 1412 matrix package. 1413 1414 Synopsis: 1415 PetscErrorCode MatCoarsenRegisterDynamic(const char *name_coarsen,const char *path,const char *name_create,PetscErrorCode (*routine_create)(MatCoarsen)) 1416 1417 Not Collective 1418 1419 Input Parameters: 1420 + sname - name of coarsen (for example MATCOARSENMIS) 1421 . path - location of library where creation routine is 1422 . name - name of function that creates the coarsen type, a string 1423 - function - function pointer that creates the coarsen type 1424 1425 Level: developer 1426 1427 If dynamic libraries are used, then the fourth input argument (function) 1428 is ignored. 1429 1430 Sample usage: 1431 .vb 1432 MatCoarsenRegisterDynamic("my_agg",/home/username/my_lib/lib/libO/solaris/mylib.a, 1433 "MyAggCreate",MyAggCreate); 1434 .ve 1435 1436 Then, your aggregator can be chosen with the procedural interface via 1437 $ MatCoarsenSetType(agg,"my_agg") 1438 or at runtime via the option 1439 $ -mat_coarsen_type my_agg 1440 1441 $PETSC_ARCH occuring in pathname will be replaced with appropriate values. 1442 1443 .keywords: matrix, coarsen, register 1444 1445 .seealso: MatCoarsenRegisterDestroy(), MatCoarsenRegisterAll() 1446 M*/ 1447 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1448 #define MatCoarsenRegisterDynamic(a,b,c,d) MatCoarsenRegister(a,b,c,0) 1449 #else 1450 #define MatCoarsenRegisterDynamic(a,b,c,d) MatCoarsenRegister(a,b,c,d) 1451 #endif 1452 1453 PETSC_EXTERN PetscBool MatCoarsenRegisterAllCalled; 1454 1455 PETSC_EXTERN PetscErrorCode MatCoarsenRegisterAll(const char[]); 1456 PETSC_EXTERN PetscErrorCode MatCoarsenRegisterDestroy(void); 1457 1458 PETSC_EXTERN PetscErrorCode MatCoarsenView(MatCoarsen,PetscViewer); 1459 PETSC_EXTERN PetscErrorCode MatCoarsenSetFromOptions(MatCoarsen); 1460 PETSC_EXTERN PetscErrorCode MatCoarsenGetType(MatCoarsen,const MatCoarsenType*); 1461 1462 1463 PETSC_EXTERN PetscErrorCode MatMeshToVertexGraph(Mat,PetscInt,Mat*); 1464 PETSC_EXTERN PetscErrorCode MatMeshToCellGraph(Mat,PetscInt,Mat*); 1465 1466 /* 1467 If you add entries here you must also add them to finclude/petscmat.h 1468 */ 1469 typedef enum { MATOP_SET_VALUES=0, 1470 MATOP_GET_ROW=1, 1471 MATOP_RESTORE_ROW=2, 1472 MATOP_MULT=3, 1473 MATOP_MULT_ADD=4, 1474 MATOP_MULT_TRANSPOSE=5, 1475 MATOP_MULT_TRANSPOSE_ADD=6, 1476 MATOP_SOLVE=7, 1477 MATOP_SOLVE_ADD=8, 1478 MATOP_SOLVE_TRANSPOSE=9, 1479 MATOP_SOLVE_TRANSPOSE_ADD=10, 1480 MATOP_LUFACTOR=11, 1481 MATOP_CHOLESKYFACTOR=12, 1482 MATOP_SOR=13, 1483 MATOP_TRANSPOSE=14, 1484 MATOP_GETINFO=15, 1485 MATOP_EQUAL=16, 1486 MATOP_GET_DIAGONAL=17, 1487 MATOP_DIAGONAL_SCALE=18, 1488 MATOP_NORM=19, 1489 MATOP_ASSEMBLY_BEGIN=20, 1490 MATOP_ASSEMBLY_END=21, 1491 MATOP_SET_OPTION=22, 1492 MATOP_ZERO_ENTRIES=23, 1493 MATOP_ZERO_ROWS=24, 1494 MATOP_LUFACTOR_SYMBOLIC=25, 1495 MATOP_LUFACTOR_NUMERIC=26, 1496 MATOP_CHOLESKY_FACTOR_SYMBOLIC=27, 1497 MATOP_CHOLESKY_FACTOR_NUMERIC=28, 1498 MATOP_SETUP_PREALLOCATION=29, 1499 MATOP_ILUFACTOR_SYMBOLIC=30, 1500 MATOP_ICCFACTOR_SYMBOLIC=31, 1501 MATOP_GET_ARRAY=32, 1502 MATOP_RESTORE_ARRAY=33, 1503 MATOP_DUPLICATE=34, 1504 MATOP_FORWARD_SOLVE=35, 1505 MATOP_BACKWARD_SOLVE=36, 1506 MATOP_ILUFACTOR=37, 1507 MATOP_ICCFACTOR=38, 1508 MATOP_AXPY=39, 1509 MATOP_GET_SUBMATRICES=40, 1510 MATOP_INCREASE_OVERLAP=41, 1511 MATOP_GET_VALUES=42, 1512 MATOP_COPY=43, 1513 MATOP_GET_ROW_MAX=44, 1514 MATOP_SCALE=45, 1515 MATOP_SHIFT=46, 1516 MATOP_DIAGONAL_SET=47, 1517 MATOP_ILUDT_FACTOR=48, 1518 MATOP_SET_BLOCK_SIZE=49, 1519 MATOP_GET_ROW_IJ=50, 1520 MATOP_RESTORE_ROW_IJ=51, 1521 MATOP_GET_COLUMN_IJ=52, 1522 MATOP_RESTORE_COLUMN_IJ=53, 1523 MATOP_FDCOLORING_CREATE=54, 1524 MATOP_COLORING_PATCH=55, 1525 MATOP_SET_UNFACTORED=56, 1526 MATOP_PERMUTE=57, 1527 MATOP_SET_VALUES_BLOCKED=58, 1528 MATOP_GET_SUBMATRIX=59, 1529 MATOP_DESTROY=60, 1530 MATOP_VIEW=61, 1531 MATOP_CONVERT_FROM=62, 1532 MATOP_USE_SCALED_FORM=63, 1533 MATOP_SCALE_SYSTEM=64, 1534 MATOP_UNSCALE_SYSTEM=65, 1535 MATOP_SET_LOCAL_TO_GLOBAL_MAP=66, 1536 MATOP_SET_VALUES_LOCAL=67, 1537 MATOP_ZERO_ROWS_LOCAL=68, 1538 MATOP_GET_ROW_MAX_ABS=69, 1539 MATOP_GET_ROW_MIN_ABS=70, 1540 MATOP_CONVERT=71, 1541 MATOP_SET_COLORING=72, 1542 MATOP_SET_VALUES_ADIC=73, 1543 MATOP_SET_VALUES_ADIFOR=74, 1544 MATOP_FD_COLORING_APPLY=75, 1545 MATOP_SET_FROM_OPTIONS=76, 1546 MATOP_MULT_CON=77, 1547 MATOP_MULT_TRANSPOSE_CON=78, 1548 MATOP_PERMUTE_SPARSIFY=79, 1549 MATOP_MULT_MULTIPLE=80, 1550 MATOP_SOLVE_MULTIPLE=81, 1551 MATOP_GET_INERTIA=82, 1552 MATOP_LOAD=83, 1553 MATOP_IS_SYMMETRIC=84, 1554 MATOP_IS_HERMITIAN=85, 1555 MATOP_IS_STRUCTURALLY_SYMMETRIC=86, 1556 MATOP_DUMMY=87, 1557 MATOP_GET_VECS=88, 1558 MATOP_MAT_MULT=89, 1559 MATOP_MAT_MULT_SYMBOLIC=90, 1560 MATOP_MAT_MULT_NUMERIC=91, 1561 MATOP_PTAP=92, 1562 MATOP_PTAP_SYMBOLIC=93, 1563 MATOP_PTAP_NUMERIC=94, 1564 MATOP_MAT_MULTTRANSPOSE=95, 1565 MATOP_MAT_MULTTRANSPOSE_SYM=96, 1566 MATOP_MAT_MULTTRANSPOSE_NUM=97, 1567 MATOP_PTAP_SYMBOLIC_SEQAIJ=98, 1568 MATOP_PTAP_NUMERIC_SEQAIJ=99, 1569 MATOP_PTAP_SYMBOLIC_MPIAIJ=100, 1570 MATOP_PTAP_NUMERIC_MPIAIJ=101, 1571 MATOP_CONJUGATE=102, 1572 MATOP_SET_SIZES=103, 1573 MATOP_SET_VALUES_ROW=104, 1574 MATOP_REAL_PART=105, 1575 MATOP_IMAG_PART=106, 1576 MATOP_GET_ROW_UTRIANGULAR=107, 1577 MATOP_RESTORE_ROW_UTRIANGULAR=108, 1578 MATOP_MATSOLVE=109, 1579 MATOP_GET_REDUNDANTMATRIX=110, 1580 MATOP_GET_ROW_MIN=111, 1581 MATOP_GET_COLUMN_VEC=112, 1582 MATOP_MISSING_DIAGONAL=113, 1583 MATOP_MATGETSEQNONZEROSTRUCTURE=114, 1584 MATOP_CREATE=115, 1585 MATOP_GET_GHOSTS=116, 1586 MATOP_GET_LOCALSUBMATRIX=117, 1587 MATOP_RESTORE_LOCALSUBMATRIX=118, 1588 MATOP_MULT_DIAGONAL_BLOCK=119, 1589 MATOP_HERMITIANTRANSPOSE=120, 1590 MATOP_MULTHERMITIANTRANSPOSE=121, 1591 MATOP_MULTHERMITIANTRANSPOSEADD=122, 1592 MATOP_GETMULTIPROCBLOCK=123, 1593 MATOP_GETCOLUMNNORMS=125, 1594 MATOP_GET_SUBMATRICES_PARALLEL=128, 1595 MATOP_SET_VALUES_BATCH=129, 1596 MATOP_TRANSPOSEMATMULT=130, 1597 MATOP_TRANSPOSEMATMULT_SYMBOLIC=131, 1598 MATOP_TRANSPOSEMATMULT_NUMERIC=132, 1599 MATOP_TRANSPOSECOLORING_CREATE=133, 1600 MATOP_TRANSCOLORING_APPLY_SPTODEN=134, 1601 MATOP_TRANSCOLORING_APPLY_DENTOSP=135, 1602 MATOP_RARt=136, 1603 MATOP_RARt_SYMBOLIC=137, 1604 MATOP_RARt_NUMERIC=138, 1605 MATOP_SET_BLOCK_SIZES=139 1606 } MatOperation; 1607 PETSC_EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscBool *); 1608 PETSC_EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1609 PETSC_EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1610 PETSC_EXTERN PetscErrorCode MatShellSetContext(Mat,void*); 1611 1612 /* 1613 Codes for matrices stored on disk. By default they are 1614 stored in a universal format. By changing the format with 1615 PetscViewerSetFormat(viewer,PETSC_VIEWER_NATIVE); the matrices will 1616 be stored in a way natural for the matrix, for example dense matrices 1617 would be stored as dense. Matrices stored this way may only be 1618 read into matrices of the same type. 1619 */ 1620 #define MATRIX_BINARY_FORMAT_DENSE -1 1621 1622 PETSC_EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1623 PETSC_EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*); 1624 PETSC_EXTERN PetscErrorCode MatISSetLocalMat(Mat,Mat); 1625 1626 /*S 1627 MatNullSpace - Object that removes a null space from a vector, i.e. 1628 orthogonalizes the vector to a subsapce 1629 1630 Level: advanced 1631 1632 Concepts: matrix; linear operator, null space 1633 1634 Users manual sections: 1635 . sec_singular 1636 1637 .seealso: MatNullSpaceCreate() 1638 S*/ 1639 typedef struct _p_MatNullSpace* MatNullSpace; 1640 1641 PETSC_EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscBool ,PetscInt,const Vec[],MatNullSpace*); 1642 PETSC_EXTERN PetscErrorCode MatNullSpaceSetFunction(MatNullSpace,PetscErrorCode (*)(MatNullSpace,Vec,void*),void*); 1643 PETSC_EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace*); 1644 PETSC_EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1645 PETSC_EXTERN PetscErrorCode MatGetNullSpace(Mat, MatNullSpace *); 1646 PETSC_EXTERN PetscErrorCode MatSetNullSpace(Mat,MatNullSpace); 1647 PETSC_EXTERN PetscErrorCode MatSetNearNullSpace(Mat,MatNullSpace); 1648 PETSC_EXTERN PetscErrorCode MatGetNearNullSpace(Mat,MatNullSpace*); 1649 PETSC_EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat,PetscBool *); 1650 PETSC_EXTERN PetscErrorCode MatNullSpaceView(MatNullSpace,PetscViewer); 1651 PETSC_EXTERN PetscErrorCode MatNullSpaceGetVecs(MatNullSpace,PetscBool*,PetscInt*,const Vec**); 1652 PETSC_EXTERN PetscErrorCode MatNullSpaceCreateRigidBody(Vec,MatNullSpace*); 1653 1654 PETSC_EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS); 1655 PETSC_EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1656 PETSC_EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *); 1657 PETSC_EXTERN PetscErrorCode MatSeqBAIJInvertBlockDiagonal(Mat); 1658 1659 PETSC_EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*); 1660 PETSC_EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*); 1661 PETSC_EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*); 1662 1663 PETSC_EXTERN PetscErrorCode MatComputeExplicitOperator(Mat,Mat*); 1664 1665 PETSC_EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec); 1666 1667 PETSC_EXTERN PetscErrorCode MatCreateMFFD(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*); 1668 PETSC_EXTERN PetscErrorCode MatMFFDSetBase(Mat,Vec,Vec); 1669 PETSC_EXTERN PetscErrorCode MatMFFDSetFunction(Mat,PetscErrorCode(*)(void*,Vec,Vec),void*); 1670 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioni(Mat,PetscErrorCode (*)(void*,PetscInt,Vec,PetscScalar*)); 1671 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctioniBase(Mat,PetscErrorCode (*)(void*,Vec)); 1672 PETSC_EXTERN PetscErrorCode MatMFFDAddNullSpace(Mat,MatNullSpace); 1673 PETSC_EXTERN PetscErrorCode MatMFFDSetHHistory(Mat,PetscScalar[],PetscInt); 1674 PETSC_EXTERN PetscErrorCode MatMFFDResetHHistory(Mat); 1675 PETSC_EXTERN PetscErrorCode MatMFFDSetFunctionError(Mat,PetscReal); 1676 PETSC_EXTERN PetscErrorCode MatMFFDSetPeriod(Mat,PetscInt); 1677 PETSC_EXTERN PetscErrorCode MatMFFDGetH(Mat,PetscScalar *); 1678 PETSC_EXTERN PetscErrorCode MatMFFDSetOptionsPrefix(Mat,const char[]); 1679 PETSC_EXTERN PetscErrorCode MatMFFDCheckPositivity(void*,Vec,Vec,PetscScalar*); 1680 PETSC_EXTERN PetscErrorCode MatMFFDSetCheckh(Mat,PetscErrorCode (*)(void*,Vec,Vec,PetscScalar*),void*); 1681 1682 /*S 1683 MatMFFD - A data structured used to manage the computation of the h differencing parameter for matrix-free 1684 Jacobian vector products 1685 1686 Notes: MATMFFD is a specific MatType which uses the MatMFFD data structure 1687 1688 MatMFFD*() methods actually take the Mat as their first argument. Not a MatMFFD data structure 1689 1690 Level: developer 1691 1692 .seealso: MATMFFD, MatCreateMFFD(), MatMFFDSetFuction(), MatMFFDSetType(), MatMFFDRegister() 1693 S*/ 1694 typedef struct _p_MatMFFD* MatMFFD; 1695 1696 /*J 1697 MatMFFDType - algorithm used to compute the h used in computing matrix-vector products via differencing of the function 1698 1699 Level: beginner 1700 1701 .seealso: MatMFFDSetType(), MatMFFDRegister() 1702 J*/ 1703 #define MatMFFDType char* 1704 #define MATMFFD_DS "ds" 1705 #define MATMFFD_WP "wp" 1706 1707 PETSC_EXTERN PetscErrorCode MatMFFDSetType(Mat,const MatMFFDType); 1708 PETSC_EXTERN PetscErrorCode MatMFFDRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatMFFD)); 1709 1710 /*MC 1711 MatMFFDRegisterDynamic - Adds a method to the MatMFFD registry. 1712 1713 Synopsis: 1714 PetscErrorCode MatMFFDRegisterDynamic(const char *name_solver,const char *path,const char *name_create,PetscErrorCode (*routine_create)(MatMFFD)) 1715 1716 Not Collective 1717 1718 Input Parameters: 1719 + name_solver - name of a new user-defined compute-h module 1720 . path - path (either absolute or relative) the library containing this solver 1721 . name_create - name of routine to create method context 1722 - routine_create - routine to create method context 1723 1724 Level: developer 1725 1726 Notes: 1727 MatMFFDRegisterDynamic() may be called multiple times to add several user-defined solvers. 1728 1729 If dynamic libraries are used, then the fourth input argument (routine_create) 1730 is ignored. 1731 1732 Sample usage: 1733 .vb 1734 MatMFFDRegisterDynamic("my_h",/home/username/my_lib/lib/libO/solaris/mylib.a, 1735 "MyHCreate",MyHCreate); 1736 .ve 1737 1738 Then, your solver can be chosen with the procedural interface via 1739 $ MatMFFDSetType(mfctx,"my_h") 1740 or at runtime via the option 1741 $ -snes_mf_type my_h 1742 1743 .keywords: MatMFFD, register 1744 1745 .seealso: MatMFFDRegisterAll(), MatMFFDRegisterDestroy() 1746 M*/ 1747 #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1748 #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,0) 1749 #else 1750 #define MatMFFDRegisterDynamic(a,b,c,d) MatMFFDRegister(a,b,c,d) 1751 #endif 1752 1753 PETSC_EXTERN PetscErrorCode MatMFFDRegisterAll(const char[]); 1754 PETSC_EXTERN PetscErrorCode MatMFFDRegisterDestroy(void); 1755 PETSC_EXTERN PetscErrorCode MatMFFDDSSetUmin(Mat,PetscReal); 1756 PETSC_EXTERN PetscErrorCode MatMFFDWPSetComputeNormU(Mat,PetscBool ); 1757 1758 1759 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 1760 PETSC_EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 1761 1762 /* 1763 PETSc interface to MUMPS 1764 */ 1765 #ifdef PETSC_HAVE_MUMPS 1766 PETSC_EXTERN PetscErrorCode MatMumpsSetIcntl(Mat,PetscInt,PetscInt); 1767 #endif 1768 1769 /* 1770 PETSc interface to SUPERLU 1771 */ 1772 #ifdef PETSC_HAVE_SUPERLU 1773 PETSC_EXTERN PetscErrorCode MatSuperluSetILUDropTol(Mat,PetscReal); 1774 #endif 1775 1776 #if defined(PETSC_HAVE_CUSP) 1777 PETSC_EXTERN PetscErrorCode MatCreateSeqAIJCUSP(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 1778 PETSC_EXTERN PetscErrorCode MatCreateAIJCUSP(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 1779 #endif 1780 1781 /* 1782 PETSc interface to FFTW 1783 */ 1784 #if defined(PETSC_HAVE_FFTW) 1785 PETSC_EXTERN PetscErrorCode VecScatterPetscToFFTW(Mat,Vec,Vec); 1786 PETSC_EXTERN PetscErrorCode VecScatterFFTWToPetsc(Mat,Vec,Vec); 1787 PETSC_EXTERN PetscErrorCode MatGetVecsFFTW(Mat,Vec*,Vec*,Vec*); 1788 #endif 1789 1790 #if defined(PETSC_HAVE_ELEMENTAL) 1791 PETSC_EXTERN PetscErrorCode PetscElementalInitializePackage(const char*); 1792 PETSC_EXTERN PetscErrorCode PetscElementalFinalizePackage(void); 1793 #endif 1794 1795 PETSC_EXTERN PetscErrorCode MatCreateNest(MPI_Comm,PetscInt,const IS[],PetscInt,const IS[],const Mat[],Mat*); 1796 PETSC_EXTERN PetscErrorCode MatNestGetSize(Mat,PetscInt*,PetscInt*); 1797 PETSC_EXTERN PetscErrorCode MatNestGetISs(Mat,IS[],IS[]); 1798 PETSC_EXTERN PetscErrorCode MatNestGetLocalISs(Mat,IS[],IS[]); 1799 PETSC_EXTERN PetscErrorCode MatNestGetSubMats(Mat,PetscInt*,PetscInt*,Mat***); 1800 PETSC_EXTERN PetscErrorCode MatNestGetSubMat(Mat,PetscInt,PetscInt,Mat*); 1801 PETSC_EXTERN PetscErrorCode MatNestSetVecType(Mat,const VecType); 1802 PETSC_EXTERN PetscErrorCode MatNestSetSubMats(Mat,PetscInt,const IS[],PetscInt,const IS[],const Mat[]); 1803 PETSC_EXTERN PetscErrorCode MatNestSetSubMat(Mat,PetscInt,PetscInt,Mat); 1804 1805 /* 1806 MatIJ: 1807 An unweighted directed pseudograph 1808 An interpretation of this matrix as a (pseudo)graph allows us to define additional operations on it: 1809 A MatIJ can act on sparse arrays: arrays of indices, or index arrays of integers, scalars, or integer-scalar pairs 1810 by mapping the indices to the indices connected to them by the (pseudo)graph ed 1811 */ 1812 typedef enum {MATIJ_LOCAL, MATIJ_GLOBAL} MatIJIndexType; 1813 PETSC_EXTERN PetscErrorCode MatIJSetMultivalued(Mat, PetscBool); 1814 PETSC_EXTERN PetscErrorCode MatIJGetMultivalued(Mat, PetscBool*); 1815 PETSC_EXTERN PetscErrorCode MatIJSetEdges(Mat, PetscInt, const PetscInt*, const PetscInt*); 1816 PETSC_EXTERN PetscErrorCode MatIJGetEdges(Mat, PetscInt *, PetscInt **, PetscInt **); 1817 PETSC_EXTERN PetscErrorCode MatIJSetEdgesIS(Mat, IS, IS); 1818 PETSC_EXTERN PetscErrorCode MatIJGetEdgesIS(Mat, IS*, IS*); 1819 PETSC_EXTERN PetscErrorCode MatIJGetRowSizes(Mat, MatIJIndexType, PetscInt, const PetscInt *, PetscInt **); 1820 PETSC_EXTERN PetscErrorCode MatIJGetMinRowSize(Mat, PetscInt *); 1821 PETSC_EXTERN PetscErrorCode MatIJGetMaxRowSize(Mat, PetscInt *); 1822 PETSC_EXTERN PetscErrorCode MatIJGetSupport(Mat, PetscInt *, PetscInt **); 1823 PETSC_EXTERN PetscErrorCode MatIJGetSupportIS(Mat, IS *); 1824 PETSC_EXTERN PetscErrorCode MatIJGetImage(Mat, PetscInt*, PetscInt**); 1825 PETSC_EXTERN PetscErrorCode MatIJGetImageIS(Mat, IS *); 1826 PETSC_EXTERN PetscErrorCode MatIJGetSupportSize(Mat, PetscInt *); 1827 PETSC_EXTERN PetscErrorCode MatIJGetImageSize(Mat, PetscInt *); 1828 1829 PETSC_EXTERN PetscErrorCode MatIJBinRenumber(Mat, Mat*); 1830 1831 PETSC_EXTERN PetscErrorCode MatIJMap(Mat, MatIJIndexType, PetscInt,const PetscInt*,const PetscInt*,const PetscScalar*, MatIJIndexType,PetscInt*,PetscInt**,PetscInt**,PetscScalar**,PetscInt**); 1832 PETSC_EXTERN PetscErrorCode MatIJBin(Mat, MatIJIndexType, PetscInt,const PetscInt*,const PetscInt*,const PetscScalar*,PetscInt*,PetscInt**,PetscInt**,PetscScalar**,PetscInt**); 1833 PETSC_EXTERN PetscErrorCode MatIJBinMap(Mat,Mat, MatIJIndexType,PetscInt,const PetscInt*,const PetscInt*,const PetscScalar*,MatIJIndexType,PetscInt*,PetscInt**,PetscInt**,PetscScalar**,PetscInt**); 1834 1835 #endif 1836