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