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