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