12eac72dbSBarry Smith /* 22eac72dbSBarry Smith Include file for the matrix component of PETSc 32eac72dbSBarry Smith */ 40a835dfdSSatish Balay #ifndef __PETSCMAT_H 50a835dfdSSatish Balay #define __PETSCMAT_H 60a835dfdSSatish Balay #include "petscvec.h" 7e9fa29b7SSatish Balay PETSC_EXTERN_CXX_BEGIN 82eac72dbSBarry Smith 9d9274352SBarry Smith /*S 10d9274352SBarry Smith Mat - Abstract PETSc matrix object 112eac72dbSBarry Smith 12d91e6319SBarry Smith Level: beginner 13d91e6319SBarry Smith 14d9274352SBarry Smith Concepts: matrix; linear operator 15d9274352SBarry Smith 16d9274352SBarry Smith .seealso: MatCreate(), MatType, MatSetType() 17d9274352SBarry Smith S*/ 18d9274352SBarry Smith typedef struct _p_Mat* Mat; 19d9274352SBarry Smith 20d9274352SBarry Smith /*E 21d9274352SBarry Smith MatType - String with the name of a PETSc matrix or the creation function 22d9274352SBarry Smith with an optional dynamic library name, for example 23d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:mymatcreate() 24d9274352SBarry Smith 25d9274352SBarry Smith Level: beginner 26d9274352SBarry Smith 27d9274352SBarry Smith .seealso: MatSetType(), Mat 28d91e6319SBarry Smith E*/ 29273d9f13SBarry Smith #define MATSAME "same" 30273d9f13SBarry Smith #define MATSEQMAIJ "seqmaij" 31273d9f13SBarry Smith #define MATMPIMAIJ "mpimaij" 32209238afSKris Buschelman #define MATMAIJ "maij" 33273d9f13SBarry Smith #define MATIS "is" 34273d9f13SBarry Smith #define MATMPIROWBS "mpirowbs" 35273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 36273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 37209238afSKris Buschelman #define MATAIJ "aij" 38273d9f13SBarry Smith #define MATSHELL "shell" 39273d9f13SBarry Smith #define MATSEQBDIAG "seqbdiag" 40273d9f13SBarry Smith #define MATMPIBDIAG "mpibdiag" 41209238afSKris Buschelman #define MATBDIAG "bdiag" 42209238afSKris Buschelman #define MATSEQDENSE "seqdense" 43273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 44209238afSKris Buschelman #define MATDENSE "dense" 45273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 46273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 47209238afSKris Buschelman #define MATBAIJ "baij" 48273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 49273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 50273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 51209238afSKris Buschelman #define MATSBAIJ "sbaij" 52cebc7f6cSBarry Smith #define MATDAAD "daad" 53cebc7f6cSBarry Smith #define MATMFFD "mffd" 54c8a8475eSBarry Smith #define MATNORMAL "normal" 55b3a1e11cSKris Buschelman #define MATSEQAIJSPOOLES "seqaijspooles" 56d10c748bSKris Buschelman #define MATMPIAIJSPOOLES "mpiaijspooles" 579abb65ffSKris Buschelman #define MATSEQSBAIJSPOOLES "seqsbaijspooles" 5822191285SKris Buschelman #define MATMPISBAIJSPOOLES "mpisbaijspooles" 59bb4d4166SHong Zhang #define MATAIJSPOOLES "aijspooles" 60bb4d4166SHong Zhang #define MATSBAIJSPOOLES "sbaijspooles" 6114b396bbSKris Buschelman #define MATSUPERLU "superlu" 621d96aa28SKris Buschelman #define MATSUPERLU_DIST "superlu_dist" 631677d0b8SKris Buschelman #define MATUMFPACK "umfpack" 64e8aa55a4SKris Buschelman #define MATESSL "essl" 654eb8e494SKris Buschelman #define MATLUSOL "lusol" 66397b6df1SKris Buschelman #define MATAIJMUMPS "aijmumps" 67397b6df1SKris Buschelman #define MATSBAIJMUMPS "sbaijmumps" 688da957c5SKris Buschelman #define MATDSCPACK "dscpack" 697065e2aaSKris Buschelman #define MATMATLAB "matlab" 7049773a63SBarry Smith #define MatType char* 71d91e6319SBarry Smith 72c06d978dSMatthew Knepley /* Logging support */ 73552e946dSBarry Smith #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 746849ba73SBarry Smith extern PetscCookie MAT_COOKIE, MATSNESMFCTX_COOKIE, MAT_FDCOLORING_COOKIE, MAT_PARTITIONING_COOKIE, MAT_NULLSPACE_COOKIE; 756849ba73SBarry Smith extern PetscEvent MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose; 766849ba73SBarry Smith extern PetscEvent MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose; 776849ba73SBarry Smith extern PetscEvent MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic; 786849ba73SBarry Smith extern PetscEvent MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor; 796849ba73SBarry Smith extern PetscEvent MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin; 806849ba73SBarry Smith extern PetscEvent MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering; 816849ba73SBarry Smith extern PetscEvent MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate; 826849ba73SBarry Smith extern PetscEvent MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction; 83cb00f407SKris Buschelman extern PetscEvent MAT_MatMult, MAT_MatMultSymbolic, MAT_MatMultNumeric; 84534c1384SKris Buschelman extern PetscEvent MAT_PtAP, MAT_PtAPSymbolic, MAT_PtAPNumeric; 85bc011b1eSHong Zhang extern PetscEvent MAT_MatMultTranspose, MAT_MatMultTransposeSymbolic, MAT_MatMultTransposeNumeric; 86c06d978dSMatthew Knepley 87dfbe8321SBarry Smith EXTERN PetscErrorCode MatInitializePackage(char *); 88c06d978dSMatthew Knepley 89c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreate(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,Mat*); 90dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetType(Mat,const MatType); 91dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetFromOptions(Mat); 92dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUpPreallocation(Mat); 93dfbe8321SBarry Smith EXTERN PetscErrorCode MatRegisterAll(const char[]); 946849ba73SBarry Smith EXTERN PetscErrorCode MatRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat)); 9530de9b25SBarry Smith 9630de9b25SBarry Smith /*MC 9730de9b25SBarry Smith MatRegisterDynamic - Adds a new matrix type 9830de9b25SBarry Smith 9930de9b25SBarry Smith Synopsis: 100c1ac3661SBarry Smith PetscErrorCode MatRegisterDynamic(char *name,char *path,char *name_create,PetscErrorCode (*routine_create)(Mat)) 10130de9b25SBarry Smith 10230de9b25SBarry Smith Not Collective 10330de9b25SBarry Smith 10430de9b25SBarry Smith Input Parameters: 10530de9b25SBarry Smith + name - name of a new user-defined matrix type 10630de9b25SBarry Smith . path - path (either absolute or relative) the library containing this solver 10730de9b25SBarry Smith . name_create - name of routine to create method context 10830de9b25SBarry Smith - routine_create - routine to create method context 10930de9b25SBarry Smith 11030de9b25SBarry Smith Notes: 11130de9b25SBarry Smith MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 11230de9b25SBarry Smith 11330de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) 11430de9b25SBarry Smith is ignored. 11530de9b25SBarry Smith 11630de9b25SBarry Smith Sample usage: 11730de9b25SBarry Smith .vb 11830de9b25SBarry Smith MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 11930de9b25SBarry Smith "MyMatCreate",MyMatCreate); 12030de9b25SBarry Smith .ve 12130de9b25SBarry Smith 12230de9b25SBarry Smith Then, your solver can be chosen with the procedural interface via 12330de9b25SBarry Smith $ MatSetType(Mat,"my_mat") 12430de9b25SBarry Smith or at runtime via the option 12530de9b25SBarry Smith $ -mat_type my_mat 12630de9b25SBarry Smith 12730de9b25SBarry Smith Level: advanced 12830de9b25SBarry Smith 12930de9b25SBarry Smith Notes: ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 13030de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 13130de9b25SBarry Smith 13230de9b25SBarry Smith .keywords: Mat, register 13330de9b25SBarry Smith 13430de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy() 13530de9b25SBarry Smith 13630de9b25SBarry Smith M*/ 137273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 138273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 139273d9f13SBarry Smith #else 140273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 14130de9b25SBarry Smith #endif 14230de9b25SBarry Smith 143273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled; 144b0a32e0cSBarry Smith extern PetscFList MatList; 14528988994SBarry Smith 146c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqDense(MPI_Comm,PetscInt,PetscInt,PetscScalar[],Mat*); 147c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIDense(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscScalar[],Mat*); 148c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 149c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 150c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIRowbs(MPI_Comm,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 151c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 152c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBDiag(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscScalar*[],Mat*); 153c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 154c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 155c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPIAdj(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscInt[],Mat*); 156c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqSBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],Mat*); 157c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMPISBAIJ(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Mat*); 158c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateShell(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,void *,Mat*); 159c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateAdic(MPI_Comm,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,void (*)(void),Mat*); 160dfbe8321SBarry Smith EXTERN PetscErrorCode MatCreateNormal(Mat,Mat*); 161dfbe8321SBarry Smith EXTERN PetscErrorCode MatDestroy(Mat); 16221c89e3eSBarry Smith 163dfbe8321SBarry Smith EXTERN PetscErrorCode MatPrintHelp(Mat); 164dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetPetscMaps(Mat,PetscMap*,PetscMap*); 165ec0117caSBarry Smith 1668ed539a5SBarry Smith /* ------------------------------------------------------------*/ 167c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 168c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlocked(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 16984cb2905SBarry Smith 1702ef4de8bSBarry Smith /*S 1712ef4de8bSBarry Smith MatStencil - Data structure (C struct) for storing information about a single row or 1722ef4de8bSBarry Smith column of a matrix as index on an associated grid. 1732ef4de8bSBarry Smith 1742ef4de8bSBarry Smith Level: beginner 1752ef4de8bSBarry Smith 1762ef4de8bSBarry Smith Concepts: matrix; linear operator 1772ef4de8bSBarry Smith 178d7bd93baSBarry Smith .seealso: MatSetValuesStencil(), MatSetStencil(), MatSetValuesBlockStencil() 1792ef4de8bSBarry Smith S*/ 180435da068SBarry Smith typedef struct { 181c1ac3661SBarry Smith PetscInt k,j,i,c; 182435da068SBarry Smith } MatStencil; 1832ef4de8bSBarry Smith 184c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 185c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedStencil(Mat,PetscInt,const MatStencil[],PetscInt,const MatStencil[],const PetscScalar[],InsertMode); 186c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetStencil(Mat,PetscInt,const PetscInt[],const PetscInt[],PetscInt); 187435da068SBarry Smith 188dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetColoring(Mat,ISColoring); 189dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetValuesAdic(Mat,void*); 190c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesAdifor(Mat,PetscInt,void*); 1913a7fca6bSBarry Smith 192d91e6319SBarry Smith /*E 193d91e6319SBarry Smith MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 194d91e6319SBarry Smith to continue to add values to it 195d91e6319SBarry Smith 196d91e6319SBarry Smith Level: beginner 197d91e6319SBarry Smith 198d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd() 199d91e6319SBarry Smith E*/ 2006d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 201dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyBegin(Mat,MatAssemblyType); 202dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssemblyEnd(Mat,MatAssemblyType); 203dfbe8321SBarry Smith EXTERN PetscErrorCode MatAssembled(Mat,PetscTruth*); 2044f9c727eSBarry Smith 205c1ac3661SBarry Smith extern PetscInt MatSetValue_Row, MatSetValue_Column; 2061d73ed98SBarry Smith extern PetscScalar MatSetValue_Value; 2071d73ed98SBarry Smith 20830de9b25SBarry Smith /*MC 20930de9b25SBarry Smith MatSetValue - Set a single entry into a matrix. 21030de9b25SBarry Smith 21130de9b25SBarry Smith Synopsis: 212c1ac3661SBarry Smith PetscErrorCode MatSetValue(Mat m,PetscInt row,PetscInt col,PetscScalar value,InsertMode mode); 21330de9b25SBarry Smith 21430de9b25SBarry Smith Not collective 21530de9b25SBarry Smith 21630de9b25SBarry Smith Input Parameters: 21730de9b25SBarry Smith + m - the matrix 21830de9b25SBarry Smith . row - the row location of the entry 21930de9b25SBarry Smith . col - the column location of the entry 22030de9b25SBarry Smith . value - the value to insert 22130de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 22230de9b25SBarry Smith 22330de9b25SBarry Smith Notes: 22430de9b25SBarry Smith For efficiency one should use MatSetValues() and set several or many 22530de9b25SBarry Smith values simultaneously if possible. 22630de9b25SBarry Smith 22730de9b25SBarry Smith Level: beginner 22830de9b25SBarry Smith 22930de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal() 23030de9b25SBarry Smith M*/ 231b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \ 2321d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \ 2331d73ed98SBarry Smith MatSetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 23430de9b25SBarry Smith 235ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \ 2361d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,\ 2371d73ed98SBarry Smith MatGetValues(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&va)) 23830de9b25SBarry Smith 239d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \ 2401d73ed98SBarry Smith (MatSetValue_Row = i,MatSetValue_Column = j,MatSetValue_Value = va, \ 2411d73ed98SBarry Smith MatSetValuesLocal(v,1,&MatSetValue_Row,1,&MatSetValue_Column,&MatSetValue_Value,mode)) 24230de9b25SBarry Smith 243d91e6319SBarry Smith /*E 244d91e6319SBarry Smith MatOption - Options that may be set for a matrix and its behavior or storage 245d91e6319SBarry Smith 246d91e6319SBarry Smith Level: beginner 247d91e6319SBarry Smith 2480a835dfdSSatish Balay Any additions/changes here MUST also be made in include/finclude/petscmat.h 249d91e6319SBarry Smith 250d91e6319SBarry Smith .seealso: MatSetOption() 251d91e6319SBarry Smith E*/ 2526d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 2536d4a8577SBarry Smith MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 2546d4a8577SBarry Smith MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 2556ca9ecd3SBarry Smith MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 2566ca9ecd3SBarry Smith MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 2576ca9ecd3SBarry Smith MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 2586ca9ecd3SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 2594787f768SSatish Balay MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 2607c922b88SBarry Smith MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 2612bad1931SBarry Smith MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 262efcf0fc3SBarry Smith MAT_DO_NOT_USE_INODES=82,MAT_NOT_SYMMETRIC=83,MAT_HERMITIAN=84, 2639a4540c5SBarry Smith MAT_NOT_STRUCTURALLY_SYMMETRIC=85,MAT_NOT_HERMITIAN=86, 264d487561eSHong Zhang MAT_SYMMETRY_ETERNAL=87,MAT_NOT_SYMMETRY_ETERNAL=88, 265d487561eSHong Zhang MAT_USE_COMPRESSEDROW=89,MAT_DO_NOT_USE_COMPRESSEDROW=90} MatOption; 266dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetOption(Mat,MatOption); 267dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetType(Mat,MatType*); 26884cb2905SBarry Smith 269c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetValues(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscScalar[]); 270c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 271c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRow(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 272ba8c8a56SBarry Smith EXTERN PetscErrorCode MatGetColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 273ba8c8a56SBarry Smith EXTERN PetscErrorCode MatRestoreColumn(Mat,PetscInt,PetscInt *,const PetscInt *[],const PetscScalar*[]); 274c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnVector(Mat,Vec,PetscInt); 275dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetArray(Mat,PetscScalar *[]); 276dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestoreArray(Mat,PetscScalar *[]); 277c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetBlockSize(Mat,PetscInt *); 278521d7252SBarry Smith EXTERN PetscErrorCode MatSetBlockSize(Mat,PetscInt); 2797b80b807SBarry Smith 280dfbe8321SBarry Smith EXTERN PetscErrorCode MatMult(Mat,Vec,Vec); 281dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultAdd(Mat,Vec,Vec,Vec); 282dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTranspose(Mat,Vec,Vec); 283dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsTranspose(Mat,Mat,PetscReal,PetscTruth*); 284dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeAdd(Mat,Vec,Vec,Vec); 285dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultConstrained(Mat,Vec,Vec); 286dfbe8321SBarry Smith EXTERN PetscErrorCode MatMultTransposeConstrained(Mat,Vec,Vec); 2872eac72dbSBarry Smith 288d91e6319SBarry Smith /*E 289d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 290d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 291d91e6319SBarry Smith 292d91e6319SBarry Smith Level: beginner 293d91e6319SBarry Smith 294d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 295d91e6319SBarry Smith 296d91e6319SBarry Smith .seealso: MatDuplicate() 297d91e6319SBarry Smith E*/ 2982e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 2992e8a6d31SBarry Smith 3006849ba73SBarry Smith EXTERN PetscErrorCode MatConvertRegister(const char[],const char[],const char[],PetscErrorCode (*)(Mat,MatType,Mat*)); 301273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 302273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 303273d9f13SBarry Smith #else 304273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 305273d9f13SBarry Smith #endif 306dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvertRegisterAll(const char[]); 307dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvertRegisterDestroy(void); 308273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled; 309b0a32e0cSBarry Smith extern PetscFList MatConvertList; 310dfbe8321SBarry Smith EXTERN PetscErrorCode MatConvert(Mat,const MatType,Mat*); 311dfbe8321SBarry Smith EXTERN PetscErrorCode MatDuplicate(Mat,MatDuplicateOption,Mat*); 31294a9d846SBarry Smith 313d91e6319SBarry Smith /*E 314d91e6319SBarry Smith MatStructure - Indicates if the matrix has the same nonzero structure 315d91e6319SBarry Smith 316d91e6319SBarry Smith Level: beginner 317d91e6319SBarry Smith 318d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 319d91e6319SBarry Smith 32094b7f48cSBarry Smith .seealso: MatCopy(), KSPSetOperators(), PCSetOperators() 321d91e6319SBarry Smith E*/ 322c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 323cb5b572fSBarry Smith 324dfbe8321SBarry Smith EXTERN PetscErrorCode MatCopy(Mat,Mat,MatStructure); 325dfbe8321SBarry Smith EXTERN PetscErrorCode MatView(Mat,PetscViewer); 326dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetric(Mat,PetscReal,PetscTruth*); 327dfbe8321SBarry Smith EXTERN PetscErrorCode MatIsSymmetricKnown(Mat,PetscTruth*,PetscTruth*); 328e10ebe35SBarry Smith EXTERN PetscErrorCode MatIsHermitianKnown(Mat,PetscTruth*,PetscTruth*); 329dfbe8321SBarry Smith EXTERN PetscErrorCode MatLoad(PetscViewer,const MatType,Mat*); 3307b80b807SBarry Smith 331c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetRowIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 332c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreRowIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 333c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetColumnIJ(Mat,PetscInt,PetscTruth,PetscInt*,PetscInt *[],PetscInt *[],PetscTruth *); 334c1ac3661SBarry Smith EXTERN PetscErrorCode MatRestoreColumnIJ(Mat,PetscInt,PetscTruth,PetscInt *,PetscInt *[],PetscInt *[],PetscTruth *); 335d4fbbf0eSBarry Smith 336d91e6319SBarry Smith /*S 337d91e6319SBarry Smith MatInfo - Context of matrix information, used with MatGetInfo() 338d91e6319SBarry Smith 339d91e6319SBarry Smith In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 340d91e6319SBarry Smith 341d91e6319SBarry Smith Level: intermediate 342d91e6319SBarry Smith 343d91e6319SBarry Smith Concepts: matrix^nonzero information 344d91e6319SBarry Smith 345d9274352SBarry Smith .seealso: MatGetInfo(), MatInfoType 346d91e6319SBarry Smith S*/ 3474e220ebcSLois Curfman McInnes typedef struct { 348b0a32e0cSBarry Smith PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 349b0a32e0cSBarry Smith PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 350b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 351b0a32e0cSBarry Smith PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 352b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 353b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 354b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 355b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 356b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 3574e220ebcSLois Curfman McInnes } MatInfo; 3584e220ebcSLois Curfman McInnes 359d9274352SBarry Smith /*E 360d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 361d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 362d9274352SBarry Smith 363d9274352SBarry Smith Level: beginner 364d9274352SBarry Smith 365d9274352SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 366d9274352SBarry Smith 367d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo 368d9274352SBarry Smith E*/ 3697b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 370dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetInfo(Mat,MatInfoType,MatInfo*); 371dfbe8321SBarry Smith EXTERN PetscErrorCode MatValid(Mat,PetscTruth*); 372dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetDiagonal(Mat,Vec); 373dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetRowMax(Mat,Vec); 374dfbe8321SBarry Smith EXTERN PetscErrorCode MatTranspose(Mat,Mat*); 375dfbe8321SBarry Smith EXTERN PetscErrorCode MatPermute(Mat,IS,IS,Mat *); 376c1ac3661SBarry Smith EXTERN PetscErrorCode MatPermuteSparsify(Mat,PetscInt,PetscReal,PetscReal,IS,IS,Mat *); 377dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScale(Mat,Vec,Vec); 378dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalSet(Mat,Vec,InsertMode); 379dfbe8321SBarry Smith EXTERN PetscErrorCode MatEqual(Mat,Mat,PetscTruth*); 3807b80b807SBarry Smith 381dfbe8321SBarry Smith EXTERN PetscErrorCode MatNorm(Mat,NormType,PetscReal *); 382dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroEntries(Mat); 383dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRows(Mat,IS,const PetscScalar*); 384dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroColumns(Mat,IS,const PetscScalar*); 3857b80b807SBarry Smith 386dfbe8321SBarry Smith EXTERN PetscErrorCode MatUseScaledForm(Mat,PetscTruth); 387dfbe8321SBarry Smith EXTERN PetscErrorCode MatScaleSystem(Mat,Vec,Vec); 388dfbe8321SBarry Smith EXTERN PetscErrorCode MatUnScaleSystem(Mat,Vec,Vec); 3895ef9f2a5SBarry Smith 390c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSize(Mat,PetscInt*,PetscInt*); 391c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetLocalSize(Mat,PetscInt*,PetscInt*); 392c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetOwnershipRange(Mat,PetscInt*,PetscInt*); 3937b80b807SBarry Smith 394d91e6319SBarry Smith /*E 395d91e6319SBarry Smith MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 396d91e6319SBarry Smith or MatGetSubMatrix() are to be reused to store the new matrix values. 397d91e6319SBarry Smith 398d91e6319SBarry Smith Level: beginner 399d91e6319SBarry Smith 400d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 401d91e6319SBarry Smith 402d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 403d91e6319SBarry Smith E*/ 4047b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 405c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrices(Mat,PetscInt,const IS[],const IS[],MatReuse,Mat *[]); 406c1ac3661SBarry Smith EXTERN PetscErrorCode MatDestroyMatrices(PetscInt,Mat *[]); 407c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetSubMatrix(Mat,IS,IS,PetscInt,MatReuse,Mat *); 4080e36024fSHong Zhang EXTERN PetscErrorCode MatMerge(MPI_Comm,Mat,PetscInt,MatReuse,Mat*); 4090e36024fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPI(MPI_Comm,Mat,PetscInt,PetscInt,MatReuse,Mat*); 410a61c8c0fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPISymbolic(MPI_Comm,Mat,PetscInt,PetscInt,Mat*); 411a61c8c0fSHong Zhang EXTERN PetscErrorCode MatMerge_SeqsToMPINumeric(Mat,Mat); 4120febcb4bSHong Zhang EXTERN PetscErrorCode MatDestroy_MPIAIJ_SeqsToMPI(Mat); 41332fba14fSHong Zhang EXTERN PetscErrorCode MatGetLocalMat(Mat,MatReuse,Mat*); 41432fba14fSHong Zhang EXTERN PetscErrorCode MatGetLocalMatCondensed(Mat,MatReuse,IS*,IS*,Mat*); 41525616d81SHong Zhang EXTERN PetscErrorCode MatGetBrowsOfAcols(Mat,Mat,MatReuse,IS*,IS*,PetscInt*,Mat*); 416a6b2eed2SHong Zhang EXTERN PetscErrorCode MatGetBrowsOfAoCols(Mat,Mat,MatReuse,PetscInt**,PetscScalar**,Mat*); 4178efafbd8SBarry Smith 418c1ac3661SBarry Smith EXTERN PetscErrorCode MatIncreaseOverlap(Mat,PetscInt,IS[],PetscInt); 4197b80b807SBarry Smith 420dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMult(Mat,Mat,MatReuse,PetscReal,Mat*); 421dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultSymbolic(Mat,Mat,PetscReal,Mat*); 422dfbe8321SBarry Smith EXTERN PetscErrorCode MatMatMultNumeric(Mat,Mat,Mat); 42322440eb1SKris Buschelman 424dfbe8321SBarry Smith EXTERN PetscErrorCode MatPtAP(Mat,Mat,MatReuse,PetscReal,Mat*); 42522440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPSymbolic(Mat,Mat,PetscReal,Mat*); 42622440eb1SKris Buschelman EXTERN PetscErrorCode MatPtAPNumeric(Mat,Mat,Mat); 42722440eb1SKris Buschelman 428bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTranspose(Mat,Mat,MatReuse,PetscReal,Mat*); 429bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeSymbolic(Mat,Mat,PetscReal,Mat*); 430bc011b1eSHong Zhang EXTERN PetscErrorCode MatMatMultTransposeNumeric(Mat,Mat,Mat); 431bc011b1eSHong Zhang 432dfbe8321SBarry Smith EXTERN PetscErrorCode MatAXPY(const PetscScalar *,Mat,Mat,MatStructure); 433dfbe8321SBarry Smith EXTERN PetscErrorCode MatAYPX(const PetscScalar *,Mat,Mat); 434dfbe8321SBarry Smith EXTERN PetscErrorCode MatCompress(Mat); 4351c741599SHong Zhang 436dfbe8321SBarry Smith EXTERN PetscErrorCode MatScale(const PetscScalar *,Mat); 437dfbe8321SBarry Smith EXTERN PetscErrorCode MatShift(const PetscScalar *,Mat); 4387b80b807SBarry Smith 439dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 440dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 441dfbe8321SBarry Smith EXTERN PetscErrorCode MatZeroRowsLocal(Mat,IS,const PetscScalar*); 442c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 443c1ac3661SBarry Smith EXTERN PetscErrorCode MatSetValuesBlockedLocal(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[],const PetscScalar[],InsertMode); 444052efed2SBarry Smith 445c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashSetInitialSize(Mat,PetscInt,PetscInt); 446c1ac3661SBarry Smith EXTERN PetscErrorCode MatStashGetInfo(Mat,PetscInt*,PetscInt*,PetscInt*,PetscInt*); 44790f02eecSBarry Smith 448dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolateAdd(Mat,Vec,Vec,Vec); 449dfbe8321SBarry Smith EXTERN PetscErrorCode MatInterpolate(Mat,Vec,Vec); 450dfbe8321SBarry Smith EXTERN PetscErrorCode MatRestrict(Mat,Vec,Vec); 451dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetVecs(Mat,Vec*,Vec*); 452bd481603SBarry Smith 453bd481603SBarry Smith /*MC 454bd481603SBarry Smith MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per 455bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 456bd481603SBarry Smith 457bd481603SBarry Smith Synopsis: 458c1ac3661SBarry Smith PetscErrorCode MatPreallocateInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 459bd481603SBarry Smith 460bd481603SBarry Smith Collective on MPI_Comm 461bd481603SBarry Smith 462bd481603SBarry Smith Input Parameters: 463bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 464*859fcb39SBarry Smith . nrows - the number of LOCAL rows in the matrix 465*859fcb39SBarry Smith - ncols - the number of LOCAL columns in the matrix 466bd481603SBarry Smith 467bd481603SBarry Smith Output Parameters: 468bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 469bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 470bd481603SBarry Smith 471bd481603SBarry Smith 472bd481603SBarry Smith Level: intermediate 473bd481603SBarry Smith 474bd481603SBarry Smith Notes: 475bd481603SBarry Smith See the chapter in the users manual on performance for more details 476bd481603SBarry Smith 4771d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 478bd481603SBarry Smith 479bd481603SBarry Smith Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 480bd481603SBarry Smith 481bd481603SBarry Smith Concepts: preallocation^Matrix 482bd481603SBarry Smith 483bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 484bd481603SBarry Smith MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 485bd481603SBarry Smith M*/ 486c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 4877c922b88SBarry Smith { \ 488c1ac3661SBarry Smith PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 489c1ac3661SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 490c1ac3661SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 491c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 492c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 4937c922b88SBarry Smith 494bd481603SBarry Smith /*MC 495bd481603SBarry Smith MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 496bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 497bd481603SBarry Smith 498bd481603SBarry Smith Synopsis: 499c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricInitialize(MPI_Comm comm, PetscInt nrows, PetscInt ncols, PetscInt *dnz, PetscInt *onz) 500bd481603SBarry Smith 501bd481603SBarry Smith Collective on MPI_Comm 502bd481603SBarry Smith 503bd481603SBarry Smith Input Parameters: 504bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 505*859fcb39SBarry Smith . nrows - the number of LOCAL rows in the matrix 506*859fcb39SBarry Smith - ncols - the number of LOCAL columns in the matrix 507bd481603SBarry Smith 508bd481603SBarry Smith Output Parameters: 509bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 510bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 511bd481603SBarry Smith 512bd481603SBarry Smith 513bd481603SBarry Smith Level: intermediate 514bd481603SBarry Smith 515bd481603SBarry Smith Notes: 516bd481603SBarry Smith See the chapter in the users manual on performance for more details 517bd481603SBarry Smith 5181d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 519bd481603SBarry Smith 520bd481603SBarry Smith Concepts: preallocation^Matrix 521bd481603SBarry Smith 522bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 523bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 524bd481603SBarry Smith M*/ 525222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \ 526222b16d4SBarry Smith { \ 527c1ac3661SBarry Smith PetscErrorCode _4_ierr; PetscInt __tmp = (nrows),__ctmp = (ncols),__rstart,__end; \ 528c1ac3661SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(PetscInt),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 529c1ac3661SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(PetscInt));CHKERRQ(_4_ierr);\ 530c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 531c1ac3661SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPIU_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 532222b16d4SBarry Smith 533bd481603SBarry Smith /*MC 534bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 535bd481603SBarry Smith inserted using a local number of the rows and columns 536bd481603SBarry Smith 537bd481603SBarry Smith Synopsis: 538c1ac3661SBarry Smith PetscErrorCode MatPreallocateSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 539bd481603SBarry Smith 540bd481603SBarry Smith Not Collective 541bd481603SBarry Smith 542bd481603SBarry Smith Input Parameters: 543bd481603SBarry Smith + map - the mapping between local numbering and global numbering 544bd481603SBarry Smith . nrows - the number of rows indicated 5451d73ed98SBarry Smith . rows - the indices of the rows 546bd481603SBarry Smith . ncols - the number of columns in the matrix 547bd481603SBarry Smith . cols - the columns indicated 548bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 549bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 550bd481603SBarry Smith 551bd481603SBarry Smith 552bd481603SBarry Smith Level: intermediate 553bd481603SBarry Smith 554bd481603SBarry Smith Notes: 555bd481603SBarry Smith See the chapter in the users manual on performance for more details 556bd481603SBarry Smith 5571d73ed98SBarry Smith Do not malloc or free dnz and onz, that is handled internally by these routines 558bd481603SBarry Smith 559bd481603SBarry Smith Concepts: preallocation^Matrix 560bd481603SBarry Smith 561bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 562bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 563bd481603SBarry Smith M*/ 564c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 565c4f061fbSSatish Balay {\ 566c1ac3661SBarry Smith PetscInt __l;\ 567ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 568ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 569c4f061fbSSatish Balay for (__l=0;__l<nrows;__l++) {\ 570ef66eb69SBarry Smith _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 571c4f061fbSSatish Balay }\ 572c4f061fbSSatish Balay } 573c4f061fbSSatish Balay 574bd481603SBarry Smith /*MC 575bd481603SBarry Smith MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 576bd481603SBarry Smith inserted using a local number of the rows and columns 577bd481603SBarry Smith 578bd481603SBarry Smith Synopsis: 579c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 580bd481603SBarry Smith 581bd481603SBarry Smith Not Collective 582bd481603SBarry Smith 583bd481603SBarry Smith Input Parameters: 584bd481603SBarry Smith + map - the mapping between local numbering and global numbering 585bd481603SBarry Smith . nrows - the number of rows indicated 5861d73ed98SBarry Smith . rows - the indices of the rows 587bd481603SBarry Smith . ncols - the number of columns in the matrix 588bd481603SBarry Smith . cols - the columns indicated 589bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 590bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 591bd481603SBarry Smith 592bd481603SBarry Smith 593bd481603SBarry Smith Level: intermediate 594bd481603SBarry Smith 595bd481603SBarry Smith Notes: 596bd481603SBarry Smith See the chapter in the users manual on performance for more details 597bd481603SBarry Smith 598bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 599bd481603SBarry Smith 600bd481603SBarry Smith Concepts: preallocation^Matrix 601bd481603SBarry Smith 602bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 603bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 604bd481603SBarry Smith M*/ 605d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 606d3d32019SBarry Smith {\ 607c1ac3661SBarry Smith PetscInt __l;\ 608d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 609d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 610d3d32019SBarry Smith for (__l=0;__l<nrows;__l++) {\ 611d3d32019SBarry Smith _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 612d3d32019SBarry Smith }\ 613d3d32019SBarry Smith } 614d3d32019SBarry Smith 615bd481603SBarry Smith /*MC 616bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 617bd481603SBarry Smith inserted using a local number of the rows and columns 618bd481603SBarry Smith 619bd481603SBarry Smith Synopsis: 620c1ac3661SBarry Smith PetscErrorCode MatPreallocateSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 621bd481603SBarry Smith 622bd481603SBarry Smith Not Collective 623bd481603SBarry Smith 624bd481603SBarry Smith Input Parameters: 625bd481603SBarry Smith + nrows - the number of rows indicated 6261d73ed98SBarry Smith . rows - the indices of the rows 627bd481603SBarry Smith . ncols - the number of columns in the matrix 628a50f8bf6SHong Zhang - cols - the columns indicated 629a50f8bf6SHong Zhang 630a50f8bf6SHong Zhang Output Parameters: 631a50f8bf6SHong Zhang + dnz - the array that will be passed to the matrix preallocation routines 632bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 633bd481603SBarry Smith 634bd481603SBarry Smith 635bd481603SBarry Smith Level: intermediate 636bd481603SBarry Smith 637bd481603SBarry Smith Notes: 638bd481603SBarry Smith See the chapter in the users manual on performance for more details 639bd481603SBarry Smith 640bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 641bd481603SBarry Smith 642bd481603SBarry Smith Concepts: preallocation^Matrix 643bd481603SBarry Smith 644bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 645bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 646bd481603SBarry Smith M*/ 647c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 648c1ac3661SBarry Smith { PetscInt __i; \ 6497c922b88SBarry Smith for (__i=0; __i<nc; __i++) {\ 6507c922b88SBarry Smith if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 6517c922b88SBarry Smith }\ 6527c922b88SBarry Smith dnz[row - __rstart] = nc - onz[row - __rstart];\ 6537c922b88SBarry Smith } 6547c922b88SBarry Smith 655bd481603SBarry Smith /*MC 656bd481603SBarry Smith MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 657bd481603SBarry Smith inserted using a local number of the rows and columns 658bd481603SBarry Smith 659bd481603SBarry Smith Synopsis: 660c1ac3661SBarry Smith PetscErrorCode MatPreallocateSymmetricSet(PetscInt nrows, PetscInt *rows,PetscInt ncols, PetscInt *cols,PetscInt *dnz, PetscInt *onz) 661bd481603SBarry Smith 662bd481603SBarry Smith Not Collective 663bd481603SBarry Smith 664bd481603SBarry Smith Input Parameters: 665bd481603SBarry Smith + nrows - the number of rows indicated 6661d73ed98SBarry Smith . rows - the indices of the rows 667bd481603SBarry Smith . ncols - the number of columns in the matrix 668bd481603SBarry Smith . cols - the columns indicated 669bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 670bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 671bd481603SBarry Smith 672bd481603SBarry Smith 673bd481603SBarry Smith Level: intermediate 674bd481603SBarry Smith 675bd481603SBarry Smith Notes: 676bd481603SBarry Smith See the chapter in the users manual on performance for more details 677bd481603SBarry Smith 678bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 679bd481603SBarry Smith 680bd481603SBarry Smith Concepts: preallocation^Matrix 681bd481603SBarry Smith 682bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 683bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 684bd481603SBarry Smith M*/ 685d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 686c1ac3661SBarry Smith { PetscInt __i; \ 687d3d32019SBarry Smith for (__i=0; __i<nc; __i++) {\ 688d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 689d3d32019SBarry Smith else if (cols[__i] >= row) dnz[row - __rstart]++;\ 690d3d32019SBarry Smith }\ 691d3d32019SBarry Smith } 692d3d32019SBarry Smith 693bd481603SBarry Smith /*MC 694bd481603SBarry Smith MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per 695bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 696bd481603SBarry Smith 697bd481603SBarry Smith Synopsis: 698c1ac3661SBarry Smith PetscErrorCode MatPreallocateFinalize(PetscInt *dnz, PetscInt *onz) 699bd481603SBarry Smith 700bd481603SBarry Smith Collective on MPI_Comm 701bd481603SBarry Smith 702bd481603SBarry Smith Input Parameters: 703bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 704bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 705bd481603SBarry Smith 706bd481603SBarry Smith 707bd481603SBarry Smith Level: intermediate 708bd481603SBarry Smith 709bd481603SBarry Smith Notes: 710bd481603SBarry Smith See the chapter in the users manual on performance for more details 711bd481603SBarry Smith 712bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 713bd481603SBarry Smith 714bd481603SBarry Smith Concepts: preallocation^Matrix 715bd481603SBarry Smith 716bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 717bd481603SBarry Smith MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 718bd481603SBarry Smith M*/ 719ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 7207c922b88SBarry Smith 721bd481603SBarry Smith 722bd481603SBarry Smith 7237b80b807SBarry Smith /* Routines unique to particular data structures */ 724dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetContext(Mat,void **); 725435da068SBarry Smith 726c1ac3661SBarry Smith EXTERN PetscErrorCode MatBDiagGetData(Mat,PetscInt*,PetscInt*,PetscInt*[],PetscInt*[],PetscScalar***); 727c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetColumnIndices(Mat,PetscInt[]); 728c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetColumnIndices(Mat,PetscInt[]); 729c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateSeqAIJWithArrays(MPI_Comm,PetscInt,PetscInt,PetscInt[],PetscInt[],PetscScalar[],Mat*); 7307b80b807SBarry Smith 731c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 732c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[]); 733c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJSetPreallocation(Mat,PetscInt,const PetscInt[]); 734dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDensePreallocation(Mat,PetscScalar[]); 735c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 736dfbe8321SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 737273d9f13SBarry Smith 738c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 739c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 740c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJSetPreallocation(Mat,PetscInt,const PetscInt[],PetscInt,const PetscInt[]); 741ccd8e176SBarry Smith EXTERN PetscErrorCode MatMPIAIJSetPreallocationCSR(Mat,const PetscInt[],const PetscInt[],const PetscScalar[]); 742aac34f13SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetPreallocationCSR(Mat,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[]); 743dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDensePreallocation(Mat,PetscScalar[]); 744c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBDiagSetPreallocation(Mat,PetscInt,PetscInt,const PetscInt[],PetscScalar*[]); 745c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAdjSetPreallocation(Mat,PetscInt[],PetscInt[],PetscInt[]); 746dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 747c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIRowbsSetPreallocation(Mat,PetscInt,const PetscInt[]); 748c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,PetscInt*[]); 749c1ac3661SBarry Smith EXTERN PetscErrorCode MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,PetscInt*[]); 750dfbe8321SBarry Smith EXTERN PetscErrorCode MatAdicSetLocalFunction(Mat,void (*)(void)); 751273d9f13SBarry Smith 752c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqDenseSetLDA(Mat,PetscInt); 7531b807ce4Svictorle 754dfbe8321SBarry Smith EXTERN PetscErrorCode MatStoreValues(Mat); 755dfbe8321SBarry Smith EXTERN PetscErrorCode MatRetrieveValues(Mat); 7562e8a6d31SBarry Smith 757dfbe8321SBarry Smith EXTERN PetscErrorCode MatDAADSetCtx(Mat,void*); 7583a7fca6bSBarry Smith 7597b80b807SBarry Smith /* 7607b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 76194b7f48cSBarry Smith done through the KSP and PC interfaces. 7627b80b807SBarry Smith */ 7637b80b807SBarry Smith 764d9274352SBarry Smith /*E 765d9274352SBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 766d9274352SBarry Smith with an optional dynamic library name, for example 767d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 768d9274352SBarry Smith 769d9274352SBarry Smith Level: beginner 770d9274352SBarry Smith 771d9274352SBarry Smith .seealso: MatGetOrdering() 772d9274352SBarry Smith E*/ 77349773a63SBarry Smith #define MatOrderingType char* 774b12f92e5SBarry Smith #define MATORDERING_NATURAL "natural" 775b12f92e5SBarry Smith #define MATORDERING_ND "nd" 776b12f92e5SBarry Smith #define MATORDERING_1WD "1wd" 777b12f92e5SBarry Smith #define MATORDERING_RCM "rcm" 778b12f92e5SBarry Smith #define MATORDERING_QMD "qmd" 779b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength" 78062152c8bSBarry Smith #define MATORDERING_DSC_ND "dsc_nd" 78162152c8bSBarry Smith #define MATORDERING_DSC_MMD "dsc_mmd" 78262152c8bSBarry Smith #define MATORDERING_DSC_MDF "dsc_mdf" 783c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained" 784c06d978dSMatthew Knepley #define MATORDERING_IDENTITY "identity" 785c06d978dSMatthew Knepley #define MATORDERING_REVERSE "reverse" 786b12f92e5SBarry Smith 787dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetOrdering(Mat,const MatOrderingType,IS*,IS*); 7886849ba73SBarry Smith EXTERN PetscErrorCode MatOrderingRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatOrderingType,IS*,IS*)); 78930de9b25SBarry Smith 79030de9b25SBarry Smith /*MC 79130de9b25SBarry Smith MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 79230de9b25SBarry Smith matrix package. 79330de9b25SBarry Smith 79430de9b25SBarry Smith Synopsis: 795c1ac3661SBarry Smith PetscErrorCode MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,PetscErrorCode (*routine_create)(MatOrdering)) 79630de9b25SBarry Smith 79730de9b25SBarry Smith Not Collective 79830de9b25SBarry Smith 79930de9b25SBarry Smith Input Parameters: 80030de9b25SBarry Smith + sname - name of ordering (for example MATORDERING_ND) 80130de9b25SBarry Smith . path - location of library where creation routine is 80230de9b25SBarry Smith . name - name of function that creates the ordering type,a string 80330de9b25SBarry Smith - function - function pointer that creates the ordering 80430de9b25SBarry Smith 80530de9b25SBarry Smith Level: developer 80630de9b25SBarry Smith 80730de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 80830de9b25SBarry Smith is ignored. 80930de9b25SBarry Smith 81030de9b25SBarry Smith Sample usage: 81130de9b25SBarry Smith .vb 81230de9b25SBarry Smith MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 81330de9b25SBarry Smith "MyOrder",MyOrder); 81430de9b25SBarry Smith .ve 81530de9b25SBarry Smith 81630de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 81730de9b25SBarry Smith $ MatOrderingSetType(part,"my_order) 81830de9b25SBarry Smith or at runtime via the option 81930de9b25SBarry Smith $ -pc_ilu_mat_ordering_type my_order 82030de9b25SBarry Smith $ -pc_lu_mat_ordering_type my_order 82130de9b25SBarry Smith 82230de9b25SBarry Smith ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 82330de9b25SBarry Smith 82430de9b25SBarry Smith .keywords: matrix, ordering, register 82530de9b25SBarry Smith 82630de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 82730de9b25SBarry Smith M*/ 828aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 829f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 830b12f92e5SBarry Smith #else 831f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 832b12f92e5SBarry Smith #endif 83330de9b25SBarry Smith 834dfbe8321SBarry Smith EXTERN PetscErrorCode MatOrderingRegisterDestroy(void); 835dfbe8321SBarry Smith EXTERN PetscErrorCode MatOrderingRegisterAll(const char[]); 8362bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled; 837b0a32e0cSBarry Smith extern PetscFList MatOrderingList; 838d4fbbf0eSBarry Smith 839dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 840a2ce50c7SBarry Smith 841d91e6319SBarry Smith /*S 84215e8a5b3SHong Zhang MatFactorInfo - Data based into the matrix factorization routines 843b00f7748SHong Zhang 84415e8a5b3SHong Zhang In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE 845b00f7748SHong Zhang 84615e8a5b3SHong Zhang Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 847b00f7748SHong Zhang 848b00f7748SHong Zhang Level: developer 849b00f7748SHong Zhang 850d7d82daaSBarry Smith .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor(), 851d7d82daaSBarry Smith MatFactorInfoInitialize() 852b00f7748SHong Zhang 853b00f7748SHong Zhang S*/ 854b00f7748SHong Zhang typedef struct { 85515e8a5b3SHong Zhang PetscReal damping; /* scaling of identity added to matrix to prevent zero pivots */ 8562cea7109SBarry Smith PetscReal shift; /* if true, shift until positive pivots */ 8572cea7109SBarry Smith PetscReal shift_fraction; /* record shift fraction taken */ 85815e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 85915e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 860b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 86115e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 862f6275e2eSBarry Smith PetscReal fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 863348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 864bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 865bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 86615e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 86715e8a5b3SHong Zhang } MatFactorInfo; 868ffa6d0a5SLois Curfman McInnes 869d7d82daaSBarry Smith EXTERN PetscErrorCode MatFactorInfoInitialize(MatFactorInfo*); 870dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactor(Mat,IS,MatFactorInfo*); 871dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 872dfbe8321SBarry Smith EXTERN PetscErrorCode MatCholeskyFactorNumeric(Mat,Mat*); 873dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactor(Mat,IS,IS,MatFactorInfo*); 874dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactor(Mat,IS,IS,MatFactorInfo*); 875dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 876dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 877dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 878dfbe8321SBarry Smith EXTERN PetscErrorCode MatICCFactor(Mat,IS,MatFactorInfo*); 879dfbe8321SBarry Smith EXTERN PetscErrorCode MatLUFactorNumeric(Mat,Mat*); 880dfbe8321SBarry Smith EXTERN PetscErrorCode MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *); 881c1ac3661SBarry Smith EXTERN PetscErrorCode MatGetInertia(Mat,PetscInt*,PetscInt*,PetscInt*); 882dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolve(Mat,Vec,Vec); 883dfbe8321SBarry Smith EXTERN PetscErrorCode MatForwardSolve(Mat,Vec,Vec); 884dfbe8321SBarry Smith EXTERN PetscErrorCode MatBackwardSolve(Mat,Vec,Vec); 885dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveAdd(Mat,Vec,Vec,Vec); 886dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTranspose(Mat,Vec,Vec); 887dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 888dfbe8321SBarry Smith EXTERN PetscErrorCode MatSolves(Mat,Vecs,Vecs); 8898ed539a5SBarry Smith 890dfbe8321SBarry Smith EXTERN PetscErrorCode MatSetUnfactored(Mat); 891bb5a7306SBarry Smith 892d91e6319SBarry Smith /*E 893d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 894bb1eb677SSatish Balay 895d91e6319SBarry Smith Level: beginner 896d91e6319SBarry Smith 897d9274352SBarry Smith May be bitwise ORd together 898d9274352SBarry Smith 899d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 900d91e6319SBarry Smith 9014e7234bfSBarry Smith MatSORType may be bitwise ORd together, so do not change the numbers 9024e7234bfSBarry Smith 903a1d92eedSBarry Smith .seealso: MatRelax(), MatPBRelax() 904d91e6319SBarry Smith E*/ 905ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 906ee50ffe9SBarry Smith SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 907ee50ffe9SBarry Smith SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 90884cb2905SBarry Smith SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 909c1ac3661SBarry Smith EXTERN PetscErrorCode MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 910c1ac3661SBarry Smith EXTERN PetscErrorCode MatPBRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,PetscInt,PetscInt,Vec); 9118ed539a5SBarry Smith 912d4fbbf0eSBarry Smith /* 913639f9d9dSBarry Smith These routines are for efficiently computing Jacobians via finite differences. 914639f9d9dSBarry Smith */ 915b12f92e5SBarry Smith 916d9274352SBarry Smith /*E 917d9274352SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring or the creation function 918d9274352SBarry Smith with an optional dynamic library name, for example 919d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 920d9274352SBarry Smith 921d9274352SBarry Smith Level: beginner 922d9274352SBarry Smith 923d9274352SBarry Smith .seealso: MatGetColoring() 924d9274352SBarry Smith E*/ 92549773a63SBarry Smith #define MatColoringType char* 926b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural" 927b12f92e5SBarry Smith #define MATCOLORING_SL "sl" 928b12f92e5SBarry Smith #define MATCOLORING_LF "lf" 929b12f92e5SBarry Smith #define MATCOLORING_ID "id" 930b12f92e5SBarry Smith 931dfbe8321SBarry Smith EXTERN PetscErrorCode MatGetColoring(Mat,const MatColoringType,ISColoring*); 9326849ba73SBarry Smith EXTERN PetscErrorCode MatColoringRegister(const char[],const char[],const char[],PetscErrorCode(*)(Mat,const MatColoringType,ISColoring *)); 93330de9b25SBarry Smith 93430de9b25SBarry Smith /*MC 93530de9b25SBarry Smith MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 93630de9b25SBarry Smith matrix package. 93730de9b25SBarry Smith 93830de9b25SBarry Smith Synopsis: 939c1ac3661SBarry Smith PetscErrorCode MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,PetscErrorCode (*routine_create)(MatColoring)) 94030de9b25SBarry Smith 94130de9b25SBarry Smith Not Collective 94230de9b25SBarry Smith 94330de9b25SBarry Smith Input Parameters: 94430de9b25SBarry Smith + sname - name of Coloring (for example MATCOLORING_SL) 94530de9b25SBarry Smith . path - location of library where creation routine is 94630de9b25SBarry Smith . name - name of function that creates the Coloring type, a string 94730de9b25SBarry Smith - function - function pointer that creates the coloring 94830de9b25SBarry Smith 94930de9b25SBarry Smith Level: developer 95030de9b25SBarry Smith 95130de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 95230de9b25SBarry Smith is ignored. 95330de9b25SBarry Smith 95430de9b25SBarry Smith Sample usage: 95530de9b25SBarry Smith .vb 95630de9b25SBarry Smith MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 95730de9b25SBarry Smith "MyColor",MyColor); 95830de9b25SBarry Smith .ve 95930de9b25SBarry Smith 96030de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 96130de9b25SBarry Smith $ MatColoringSetType(part,"my_color") 96230de9b25SBarry Smith or at runtime via the option 96330de9b25SBarry Smith $ -mat_coloring_type my_color 96430de9b25SBarry Smith 96530de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 96630de9b25SBarry Smith 96730de9b25SBarry Smith .keywords: matrix, Coloring, register 96830de9b25SBarry Smith 96930de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 97030de9b25SBarry Smith M*/ 971aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 972f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 973b12f92e5SBarry Smith #else 974f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 975b12f92e5SBarry Smith #endif 97630de9b25SBarry Smith 977dfbe8321SBarry Smith EXTERN PetscErrorCode MatColoringRegisterAll(const char[]); 9782bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled; 979dfbe8321SBarry Smith EXTERN PetscErrorCode MatColoringRegisterDestroy(void); 980c1ac3661SBarry Smith EXTERN PetscErrorCode MatColoringPatch(Mat,PetscInt,PetscInt,ISColoringValue[],ISColoring*); 981639f9d9dSBarry Smith 982d9274352SBarry Smith /*S 983d9274352SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences 984d9274352SBarry Smith and coloring 985639f9d9dSBarry Smith 986d9274352SBarry Smith Level: beginner 987d9274352SBarry Smith 988d9274352SBarry Smith Concepts: coloring, sparse Jacobian, finite differences 989d9274352SBarry Smith 990d9274352SBarry Smith .seealso: MatFDColoringCreate() 991d9274352SBarry Smith S*/ 992e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 993639f9d9dSBarry Smith 994dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 995dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringDestroy(MatFDColoring); 996dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringView(MatFDColoring,PetscViewer); 9976849ba73SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFunction(MatFDColoring,PetscErrorCode (*)(void),void*); 998dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 999c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFrequency(MatFDColoring,PetscInt); 1000c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetFrequency(MatFDColoring,PetscInt*); 1001dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetFromOptions(MatFDColoring); 1002dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 1003dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 1004dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetRecompute(MatFDColoring); 1005dfbe8321SBarry Smith EXTERN PetscErrorCode MatFDColoringSetF(MatFDColoring,Vec); 1006c1ac3661SBarry Smith EXTERN PetscErrorCode MatFDColoringGetPerturbedColumns(MatFDColoring,PetscInt*,PetscInt*[]); 1007639f9d9dSBarry Smith /* 10080752156aSBarry Smith These routines are for partitioning matrices: currently used only 10093eda8832SBarry Smith for adjacency matrix, MatCreateMPIAdj(). 10100752156aSBarry Smith */ 1011ca161407SBarry Smith 1012d9274352SBarry Smith /*S 1013d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1014d9274352SBarry Smith 1015d9274352SBarry Smith Level: beginner 1016d9274352SBarry Smith 1017d9274352SBarry Smith Concepts: partitioning 1018d9274352SBarry Smith 1019743a1026Svictorle .seealso: MatPartitioningCreate(), MatPartitioningType 1020d9274352SBarry Smith S*/ 102191e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1022d9274352SBarry Smith 1023d9274352SBarry Smith /*E 10245bc6e7ccSvictorle MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1025d9274352SBarry Smith with an optional dynamic library name, for example 1026d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1027d9274352SBarry Smith 1028d9274352SBarry Smith Level: beginner 1029d9274352SBarry Smith 1030b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning 1031d9274352SBarry Smith E*/ 103249773a63SBarry Smith #define MatPartitioningType char* 10338ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT "current" 10348ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis" 103571306c60Sjroman #define MAT_PARTITIONING_CHACO "chaco" 103671306c60Sjroman #define MAT_PARTITIONING_JOSTLE "jostle" 103771306c60Sjroman #define MAT_PARTITIONING_PARTY "party" 103871306c60Sjroman #define MAT_PARTITIONING_SCOTCH "scotch" 103971306c60Sjroman 1040ca161407SBarry Smith 1041dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1042dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetType(MatPartitioning,const MatPartitioningType); 1043c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetNParts(MatPartitioning,PetscInt); 1044dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetAdjacency(MatPartitioning,Mat); 1045c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningSetVertexWeights(MatPartitioning,const PetscInt[]); 1046dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1047dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningApply(MatPartitioning,IS*); 1048dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningDestroy(MatPartitioning); 10492aabb6bbSBarry Smith 10506849ba73SBarry Smith EXTERN PetscErrorCode MatPartitioningRegister(const char[],const char[],const char[],PetscErrorCode (*)(MatPartitioning)); 105130de9b25SBarry Smith 105230de9b25SBarry Smith /*MC 105330de9b25SBarry Smith MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 105430de9b25SBarry Smith matrix package. 105530de9b25SBarry Smith 105630de9b25SBarry Smith Synopsis: 1057c1ac3661SBarry Smith PetscErrorCode MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,PetscErrorCode (*routine_create)(MatPartitioning)) 105830de9b25SBarry Smith 105930de9b25SBarry Smith Not Collective 106030de9b25SBarry Smith 106130de9b25SBarry Smith Input Parameters: 106230de9b25SBarry Smith + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 106330de9b25SBarry Smith . path - location of library where creation routine is 106430de9b25SBarry Smith . name - name of function that creates the partitioning type, a string 106530de9b25SBarry Smith - function - function pointer that creates the partitioning type 106630de9b25SBarry Smith 106730de9b25SBarry Smith Level: developer 106830de9b25SBarry Smith 106930de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 107030de9b25SBarry Smith is ignored. 107130de9b25SBarry Smith 107230de9b25SBarry Smith Sample usage: 107330de9b25SBarry Smith .vb 107430de9b25SBarry Smith MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 107530de9b25SBarry Smith "MyPartCreate",MyPartCreate); 107630de9b25SBarry Smith .ve 107730de9b25SBarry Smith 107830de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 107930de9b25SBarry Smith $ MatPartitioningSetType(part,"my_part") 108030de9b25SBarry Smith or at runtime via the option 108130de9b25SBarry Smith $ -mat_partitioning_type my_part 108230de9b25SBarry Smith 108330de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 108430de9b25SBarry Smith 108530de9b25SBarry Smith .keywords: matrix, partitioning, register 108630de9b25SBarry Smith 108730de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 108830de9b25SBarry Smith M*/ 1089aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1090f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 10912aabb6bbSBarry Smith #else 1092f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 10932aabb6bbSBarry Smith #endif 10942aabb6bbSBarry Smith 1095dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningRegisterAll(const char[]); 10962bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled; 1097dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningRegisterDestroy(void); 10982bad1931SBarry Smith 1099dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningView(MatPartitioning,PetscViewer); 1100dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningSetFromOptions(MatPartitioning); 1101dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1102ca161407SBarry Smith 1103dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 11040752156aSBarry Smith 1105dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseLevel(MatPartitioning,PetscReal); 1106dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningJostleSetCoarseSequential(MatPartitioning); 110771306c60Sjroman 110871306c60Sjroman typedef enum { MP_CHACO_MULTILEVEL_KL, MP_CHACO_SPECTRAL, MP_CHACO_LINEAR, 110971306c60Sjroman MP_CHACO_RANDOM, MP_CHACO_SCATTERED } MPChacoGlobalType; 1110dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetGlobal(MatPartitioning, MPChacoGlobalType); 111171306c60Sjroman typedef enum { MP_CHACO_KERNIGHAN_LIN, MP_CHACO_NONE } MPChacoLocalType; 1112dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetLocal(MatPartitioning, MPChacoLocalType); 1113dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetCoarseLevel(MatPartitioning,PetscReal); 111471306c60Sjroman typedef enum { MP_CHACO_LANCZOS, MP_CHACO_RQI_SYMMLQ } MPChacoEigenType; 1115dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenSolver(MatPartitioning,MPChacoEigenType); 1116dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenTol(MatPartitioning, PetscReal); 1117c1ac3661SBarry Smith EXTERN PetscErrorCode MatPartitioningChacoSetEigenNumber(MatPartitioning, PetscInt); 111871306c60Sjroman 111971306c60Sjroman #define MP_PARTY_OPT "opt" 112071306c60Sjroman #define MP_PARTY_LIN "lin" 112171306c60Sjroman #define MP_PARTY_SCA "sca" 112271306c60Sjroman #define MP_PARTY_RAN "ran" 112371306c60Sjroman #define MP_PARTY_GBF "gbf" 112471306c60Sjroman #define MP_PARTY_GCF "gcf" 112571306c60Sjroman #define MP_PARTY_BUB "bub" 112671306c60Sjroman #define MP_PARTY_DEF "def" 1127dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetGlobal(MatPartitioning, const char*); 112871306c60Sjroman #define MP_PARTY_HELPFUL_SETS "hs" 112971306c60Sjroman #define MP_PARTY_KERNIGHAN_LIN "kl" 113071306c60Sjroman #define MP_PARTY_NONE "no" 1131dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetLocal(MatPartitioning, const char*); 1132dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetCoarseLevel(MatPartitioning,PetscReal); 1133dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetBipart(MatPartitioning,PetscTruth); 1134dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningPartySetMatchOptimization(MatPartitioning,PetscTruth); 113571306c60Sjroman 113671306c60Sjroman typedef enum { MP_SCOTCH_GREEDY, MP_SCOTCH_GPS, MP_SCOTCH_GR_GPS } MPScotchGlobalType; 1137dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetArch(MatPartitioning,const char*); 1138dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMultilevel(MatPartitioning); 1139dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetGlobal(MatPartitioning,MPScotchGlobalType); 1140dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetCoarseLevel(MatPartitioning,PetscReal); 1141dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetHostList(MatPartitioning,const char*); 114271306c60Sjroman typedef enum { MP_SCOTCH_KERNIGHAN_LIN, MP_SCOTCH_NONE } MPScotchLocalType; 1143dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetLocal(MatPartitioning,MPScotchLocalType); 1144dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetMapping(MatPartitioning); 1145dfbe8321SBarry Smith EXTERN PetscErrorCode MatPartitioningScotchSetStrategy(MatPartitioning,char*); 114671306c60Sjroman 11470752156aSBarry Smith /* 11480a835dfdSSatish Balay If you add entries here you must also add them to finclude/petscmat.h 1149d4fbbf0eSBarry Smith */ 11501c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0, 11511c1c02c0SLois Curfman McInnes MATOP_GET_ROW=1, 11521c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW=2, 11531c1c02c0SLois Curfman McInnes MATOP_MULT=3, 11541c1c02c0SLois Curfman McInnes MATOP_MULT_ADD=4, 11557c922b88SBarry Smith MATOP_MULT_TRANSPOSE=5, 11567c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD=6, 11571c1c02c0SLois Curfman McInnes MATOP_SOLVE=7, 11581c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD=8, 11597c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE=9, 11607c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD=10, 11611c1c02c0SLois Curfman McInnes MATOP_LUFACTOR=11, 11621c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR=12, 11631c1c02c0SLois Curfman McInnes MATOP_RELAX=13, 11641c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE=14, 11651c1c02c0SLois Curfman McInnes MATOP_GETINFO=15, 11661c1c02c0SLois Curfman McInnes MATOP_EQUAL=16, 11671c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL=17, 11681c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE=18, 11691c1c02c0SLois Curfman McInnes MATOP_NORM=19, 11701c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN=20, 11711c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END=21, 11721c1c02c0SLois Curfman McInnes MATOP_COMPRESS=22, 11731c1c02c0SLois Curfman McInnes MATOP_SET_OPTION=23, 11741c1c02c0SLois Curfman McInnes MATOP_ZERO_ENTRIES=24, 11751c1c02c0SLois Curfman McInnes MATOP_ZERO_ROWS=25, 11761c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_SYMBOLIC=26, 11771c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_NUMERIC=27, 11781c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 11791c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1180d643ce63SMatthew Knepley MATOP_SETUP_PREALLOCATION=30, 1181d643ce63SMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC=31, 1182d643ce63SMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC=32, 1183d643ce63SMatthew Knepley MATOP_GET_ARRAY=33, 1184d643ce63SMatthew Knepley MATOP_RESTORE_ARRAY=34, 1185d643ce63SMatthew Knepley MATOP_DUPLCIATE=35, 1186d643ce63SMatthew Knepley MATOP_FORWARD_SOLVE=36, 1187d643ce63SMatthew Knepley MATOP_BACKWARD_SOLVE=37, 1188d643ce63SMatthew Knepley MATOP_ILUFACTOR=38, 1189d643ce63SMatthew Knepley MATOP_ICCFACTOR=39, 1190d643ce63SMatthew Knepley MATOP_AXPY=40, 1191d643ce63SMatthew Knepley MATOP_GET_SUBMATRICES=41, 1192d643ce63SMatthew Knepley MATOP_INCREASE_OVERLAP=42, 1193d643ce63SMatthew Knepley MATOP_GET_VALUES=43, 1194d643ce63SMatthew Knepley MATOP_COPY=44, 1195d643ce63SMatthew Knepley MATOP_PRINT_HELP=45, 1196d643ce63SMatthew Knepley MATOP_SCALE=46, 1197d643ce63SMatthew Knepley MATOP_SHIFT=47, 1198d643ce63SMatthew Knepley MATOP_DIAGONAL_SHIFT=48, 1199d643ce63SMatthew Knepley MATOP_ILUDT_FACTOR=49, 1200d643ce63SMatthew Knepley MATOP_GET_BLOCK_SIZE=50, 1201d643ce63SMatthew Knepley MATOP_GET_ROW_IJ=51, 1202d643ce63SMatthew Knepley MATOP_RESTORE_ROW_IJ=52, 1203d643ce63SMatthew Knepley MATOP_GET_COLUMN_IJ=53, 1204d643ce63SMatthew Knepley MATOP_RESTORE_COLUMN_IJ=54, 1205d643ce63SMatthew Knepley MATOP_FDCOLORING_CREATE=55, 1206d643ce63SMatthew Knepley MATOP_COLORING_PATCH=56, 1207d643ce63SMatthew Knepley MATOP_SET_UNFACTORED=57, 1208d643ce63SMatthew Knepley MATOP_PERMUTE=58, 1209d643ce63SMatthew Knepley MATOP_SET_VALUES_BLOCKED=59, 1210d643ce63SMatthew Knepley MATOP_GET_SUBMATRIX=60, 1211d643ce63SMatthew Knepley MATOP_DESTROY=61, 1212d643ce63SMatthew Knepley MATOP_VIEW=62, 1213d643ce63SMatthew Knepley MATOP_GET_MAPS=63, 1214d643ce63SMatthew Knepley MATOP_USE_SCALED_FORM=64, 1215d643ce63SMatthew Knepley MATOP_SCALE_SYSTEM=65, 1216d643ce63SMatthew Knepley MATOP_UNSCALE_SYSTEM=66, 1217ba16a8cbSKris Buschelman MATOP_SET_LOCAL_TO_GLOBAL_MAP=67, 1218d643ce63SMatthew Knepley MATOP_SET_VALUES_LOCAL=68, 1219d643ce63SMatthew Knepley MATOP_ZERO_ROWS_LOCAL=69, 1220d643ce63SMatthew Knepley MATOP_GET_ROW_MAX=70, 1221d643ce63SMatthew Knepley MATOP_CONVERT=71, 1222d643ce63SMatthew Knepley MATOP_SET_COLORING=72, 1223d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIC=73, 1224d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIFOR=74, 1225d643ce63SMatthew Knepley MATOP_FD_COLORING_APPLY=75, 1226d643ce63SMatthew Knepley MATOP_SET_FROM_OPTIONS=76, 1227ba16a8cbSKris Buschelman MATOP_MULT_CON=77, 1228ba16a8cbSKris Buschelman MATOP_MULT_TRANSPOSE_CON=78, 1229ba16a8cbSKris Buschelman MATOP_ILU_FACTOR_SYMBOLIC_CON=79, 1230d643ce63SMatthew Knepley MATOP_PERMUTE_SPARSIFY=80, 1231d643ce63SMatthew Knepley MATOP_MULT_MULTIPLE=81, 123241acf15aSKris Buschelman MATOP_SOLVE_MULTIPLE=82, 123341acf15aSKris Buschelman MATOP_GET_INERTIA=83, 123441acf15aSKris Buschelman MATOP_LOAD=84, 123541acf15aSKris Buschelman MATOP_IS_SYMMETRIC=85, 123641acf15aSKris Buschelman MATOP_IS_HERMITIAN=86, 123741acf15aSKris Buschelman MATOP_IS_STRUCTURALLY_SYMMETRIC=87, 123841acf15aSKris Buschelman MATOP_PB_RELAX=88, 123941acf15aSKris Buschelman MATOP_GET_VECS=89, 124041acf15aSKris Buschelman MATOP_MAT_MULT=90, 124141acf15aSKris Buschelman MATOP_MAT_MULT_SYMBOLIC=91, 124241acf15aSKris Buschelman MATOP_MAT_MULT_NUMERIC=92, 124341acf15aSKris Buschelman MATOP_PTAP=93, 124441acf15aSKris Buschelman MATOP_PTAP_SYMBOLIC=94, 1245bc011b1eSHong Zhang MATOP_PTAP_NUMERIC=95, 1246bc011b1eSHong Zhang MATOP_MAT_MULTTRANSPOSE=96, 1247bc011b1eSHong Zhang MATOP_MAT_MULTTRANSPOSE_SYMBOLIC=97, 12488aeee837SMatthew Knepley MATOP_MAT_MULTTRANSPOSE_NUMERIC=98 1249fae171e0SBarry Smith } MatOperation; 1250dfbe8321SBarry Smith EXTERN PetscErrorCode MatHasOperation(Mat,MatOperation,PetscTruth*); 1251dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1252dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1253dfbe8321SBarry Smith EXTERN PetscErrorCode MatShellSetContext(Mat,void*); 1254112a2221SBarry Smith 125590ace30eSBarry Smith /* 125690ace30eSBarry Smith Codes for matrices stored on disk. By default they are 125790ace30eSBarry Smith stored in a universal format. By changing the format with 1258fb9695e5SSatish Balay PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 125990ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 126090ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 126190ace30eSBarry Smith read into matrices of the same time. 126290ace30eSBarry Smith */ 126390ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 126490ace30eSBarry Smith 1265dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1266c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqAIJGetInodeSizes(Mat,PetscInt *,PetscInt *[],PetscInt *); 1267dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPIRowbsGetColor(Mat,ISColoring *); 1268860d1616SSatish Balay 1269dfbe8321SBarry Smith EXTERN PetscErrorCode MatISGetLocalMat(Mat,Mat*); 12701f4e1ec7SBarry Smith 1271d9274352SBarry Smith /*S 1272d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 1273d9274352SBarry Smith orthogonalizes the vector to a subsapce 1274d9274352SBarry Smith 1275f7a9e4ceSBarry Smith Level: advanced 1276d9274352SBarry Smith 1277d9274352SBarry Smith Concepts: matrix; linear operator, null space 1278d9274352SBarry Smith 12796e1639daSBarry Smith Users manual sections: 12806e1639daSBarry Smith . sec_singular 12816e1639daSBarry Smith 1282d9274352SBarry Smith .seealso: MatNullSpaceCreate() 1283d9274352SBarry Smith S*/ 128474637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace; 1285d9274352SBarry Smith 1286c1ac3661SBarry Smith EXTERN PetscErrorCode MatNullSpaceCreate(MPI_Comm,PetscTruth,PetscInt,const Vec[],MatNullSpace*); 1287dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceDestroy(MatNullSpace); 1288dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 1289dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceAttach(Mat,MatNullSpace); 1290dfbe8321SBarry Smith EXTERN PetscErrorCode MatNullSpaceTest(MatNullSpace,Mat); 129174637425SBarry Smith 1292dfbe8321SBarry Smith EXTERN PetscErrorCode MatReorderingSeqSBAIJ(Mat,IS); 1293dfbe8321SBarry Smith EXTERN PetscErrorCode MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1294c1ac3661SBarry Smith EXTERN PetscErrorCode MatSeqSBAIJSetColumnIndices(Mat,PetscInt *); 1295273d9f13SBarry Smith 12963f1d51d7SBarry Smith 1297c1ac3661SBarry Smith EXTERN PetscErrorCode MatCreateMAIJ(Mat,PetscInt,Mat*); 1298c1ac3661SBarry Smith EXTERN PetscErrorCode MatMAIJRedimension(Mat,PetscInt,Mat*); 1299dfbe8321SBarry Smith EXTERN PetscErrorCode MatMAIJGetAIJ(Mat,Mat*); 1300c4f061fbSSatish Balay 1301dfbe8321SBarry Smith EXTERN PetscErrorCode MatComputeExplicitOperator(Mat,Mat*); 1302b0a32e0cSBarry Smith 1303dfbe8321SBarry Smith EXTERN PetscErrorCode MatDiagonalScaleLocal(Mat,Vec); 130404f1ad80SBarry Smith 1305c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutMatrix(PetscViewer, PetscInt, PetscInt, PetscReal *); 1306c1ac3661SBarry Smith EXTERN PetscErrorCode PetscViewerMathematicaPutCSRMatrix(PetscViewer, PetscInt, PetscInt, PetscInt *, PetscInt *, PetscReal *); 13077dbadf16SMatthew Knepley 1308e9fa29b7SSatish Balay PETSC_EXTERN_CXX_END 13092eac72dbSBarry Smith #endif 1310