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