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