173f4d377SMatthew Knepley /* $Id: petscmat.h,v 1.228 2001/09/07 20:09:08 bsmith Exp $ */ 22eac72dbSBarry Smith /* 32eac72dbSBarry Smith Include file for the matrix component of PETSc 42eac72dbSBarry Smith */ 50a835dfdSSatish Balay #ifndef __PETSCMAT_H 60a835dfdSSatish Balay #define __PETSCMAT_H 70a835dfdSSatish Balay #include "petscvec.h" 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" 32273d9f13SBarry Smith #define MATIS "is" 33273d9f13SBarry Smith #define MATMPIROWBS "mpirowbs" 34273d9f13SBarry Smith #define MATSEQDENSE "seqdense" 35273d9f13SBarry Smith #define MATSEQAIJ "seqaij" 36273d9f13SBarry Smith #define MATMPIAIJ "mpiaij" 37273d9f13SBarry Smith #define MATSHELL "shell" 38273d9f13SBarry Smith #define MATSEQBDIAG "seqbdiag" 39273d9f13SBarry Smith #define MATMPIBDIAG "mpibdiag" 40273d9f13SBarry Smith #define MATMPIDENSE "mpidense" 41273d9f13SBarry Smith #define MATSEQBAIJ "seqbaij" 42273d9f13SBarry Smith #define MATMPIBAIJ "mpibaij" 43273d9f13SBarry Smith #define MATMPIADJ "mpiadj" 44273d9f13SBarry Smith #define MATSEQSBAIJ "seqsbaij" 45273d9f13SBarry Smith #define MATMPISBAIJ "mpisbaij" 46cebc7f6cSBarry Smith #define MATDAAD "daad" 47cebc7f6cSBarry Smith #define MATMFFD "mffd" 486d88219bSBarry Smith #define MATESI "esi" 496d88219bSBarry Smith #define MATPETSCESI "petscesi" 50c8a8475eSBarry Smith #define MATNORMAL "normal" 51b3a1e11cSKris Buschelman #define MATSEQAIJSPOOLES "seqaijspooles" 52d10c748bSKris Buschelman #define MATMPIAIJSPOOLES "mpiaijspooles" 539abb65ffSKris Buschelman #define MATSEQSBAIJSPOOLES "seqsbaijspooles" 5422191285SKris Buschelman #define MATMPISBAIJSPOOLES "mpisbaijspooles" 5514b396bbSKris Buschelman #define MATSUPERLU "superlu" 56*1d96aa28SKris Buschelman #define MATSUPERLU_DIST "superlu_dist" 571677d0b8SKris Buschelman #define MATUMFPACK "umfpack" 58e8aa55a4SKris Buschelman #define MATESSL "essl" 594eb8e494SKris Buschelman #define MATLUSOL "lusol" 60397b6df1SKris Buschelman #define MATAIJMUMPS "aijmumps" 61397b6df1SKris Buschelman #define MATSBAIJMUMPS "sbaijmumps" 62273d9f13SBarry Smith typedef char* MatType; 63d91e6319SBarry Smith 64c06d978dSMatthew Knepley #define MAT_SER_SEQAIJ_BINARY "seqaij_binary" 65c06d978dSMatthew Knepley #define MAT_SER_MPIAIJ_BINARY "mpiaij_binary" 66c06d978dSMatthew Knepley typedef char *MatSerializeType; 67c06d978dSMatthew Knepley 68c06d978dSMatthew Knepley /* Logging support */ 69552e946dSBarry Smith #define MAT_FILE_COOKIE 1211216 /* used to indicate matrices in binary files */ 70c06d978dSMatthew Knepley extern int MAT_COOKIE; 7171d41ebeSBarry Smith extern int MATSNESMFCTX_COOKIE; 72c06d978dSMatthew Knepley extern int MAT_FDCOLORING_COOKIE; 738ba1e511SMatthew Knepley extern int MAT_PARTITIONING_COOKIE; 748ba1e511SMatthew Knepley extern int MAT_NULLSPACE_COOKIE; 75d59c15a7SBarry Smith extern int MAT_Mult, MAT_MultMatrixFree, MAT_Mults, MAT_MultConstrained, MAT_MultAdd, MAT_MultTranspose; 76d59c15a7SBarry Smith extern int MAT_MultTransposeConstrained, MAT_MultTransposeAdd, MAT_Solve, MAT_Solves, MAT_SolveAdd, MAT_SolveTranspose; 77d5ba7fb7SMatthew Knepley extern int MAT_SolveTransposeAdd, MAT_Relax, MAT_ForwardSolve, MAT_BackwardSolve, MAT_LUFactor, MAT_LUFactorSymbolic; 78d5ba7fb7SMatthew Knepley extern int MAT_LUFactorNumeric, MAT_CholeskyFactor, MAT_CholeskyFactorSymbolic, MAT_CholeskyFactorNumeric, MAT_ILUFactor; 79d5ba7fb7SMatthew Knepley extern int MAT_ILUFactorSymbolic, MAT_ICCFactorSymbolic, MAT_Copy, MAT_Convert, MAT_Scale, MAT_AssemblyBegin; 80d5ba7fb7SMatthew Knepley extern int MAT_AssemblyEnd, MAT_SetValues, MAT_GetValues, MAT_GetRow, MAT_GetSubMatrices, MAT_GetColoring, MAT_GetOrdering; 81d5ba7fb7SMatthew Knepley extern int MAT_IncreaseOverlap, MAT_Partitioning, MAT_ZeroEntries, MAT_Load, MAT_View, MAT_AXPY, MAT_FDColoringCreate; 8266f9b7ceSBarry Smith extern int MAT_FDColoringApply, MAT_Transpose, MAT_FDColoringFunction; 83c06d978dSMatthew Knepley 848ba1e511SMatthew Knepley EXTERN int MatInitializePackage(char *); 85c06d978dSMatthew Knepley 86273d9f13SBarry Smith EXTERN int MatCreate(MPI_Comm,int,int,int,int,Mat*); 87273d9f13SBarry Smith EXTERN int MatSetType(Mat,MatType); 88273d9f13SBarry Smith EXTERN int MatSetFromOptions(Mat); 89273d9f13SBarry Smith EXTERN int MatSetUpPreallocation(Mat); 90273d9f13SBarry Smith EXTERN int MatRegisterAll(char*); 91273d9f13SBarry Smith EXTERN int MatRegister(char*,char*,char*,int(*)(Mat)); 92c06d978dSMatthew Knepley EXTERN int MatSerializeRegister(const char [], const char [], const char [], int (*)(MPI_Comm, Mat *, PetscViewer, PetscTruth)); 9330de9b25SBarry Smith 9430de9b25SBarry Smith /*MC 9530de9b25SBarry Smith MatRegisterDynamic - Adds a new matrix type 9630de9b25SBarry Smith 9730de9b25SBarry Smith Synopsis: 9830de9b25SBarry Smith int MatRegisterDynamic(char *name,char *path,char *name_create,int (*routine_create)(Mat)) 9930de9b25SBarry Smith 10030de9b25SBarry Smith Not Collective 10130de9b25SBarry Smith 10230de9b25SBarry Smith Input Parameters: 10330de9b25SBarry Smith + name - name of a new user-defined matrix type 10430de9b25SBarry Smith . path - path (either absolute or relative) the library containing this solver 10530de9b25SBarry Smith . name_create - name of routine to create method context 10630de9b25SBarry Smith - routine_create - routine to create method context 10730de9b25SBarry Smith 10830de9b25SBarry Smith Notes: 10930de9b25SBarry Smith MatRegisterDynamic() may be called multiple times to add several user-defined solvers. 11030de9b25SBarry Smith 11130de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (routine_create) 11230de9b25SBarry Smith is ignored. 11330de9b25SBarry Smith 11430de9b25SBarry Smith Sample usage: 11530de9b25SBarry Smith .vb 11630de9b25SBarry Smith MatRegisterDynamic("my_mat",/home/username/my_lib/lib/libO/solaris/mylib.a, 11730de9b25SBarry Smith "MyMatCreate",MyMatCreate); 11830de9b25SBarry Smith .ve 11930de9b25SBarry Smith 12030de9b25SBarry Smith Then, your solver can be chosen with the procedural interface via 12130de9b25SBarry Smith $ MatSetType(Mat,"my_mat") 12230de9b25SBarry Smith or at runtime via the option 12330de9b25SBarry Smith $ -mat_type my_mat 12430de9b25SBarry Smith 12530de9b25SBarry Smith Level: advanced 12630de9b25SBarry Smith 12730de9b25SBarry Smith Notes: ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 12830de9b25SBarry Smith If your function is not being put into a shared library then use VecRegister() instead 12930de9b25SBarry Smith 13030de9b25SBarry Smith .keywords: Mat, register 13130de9b25SBarry Smith 13230de9b25SBarry Smith .seealso: MatRegisterAll(), MatRegisterDestroy() 13330de9b25SBarry Smith 13430de9b25SBarry Smith M*/ 135273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 136273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,0) 137273d9f13SBarry Smith #else 138273d9f13SBarry Smith #define MatRegisterDynamic(a,b,c,d) MatRegister(a,b,c,d) 13930de9b25SBarry Smith #endif 14030de9b25SBarry Smith 14130de9b25SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 14230de9b25SBarry Smith #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,0) 14330de9b25SBarry Smith #else 144c06d978dSMatthew Knepley #define MatSerializeRegisterDynamic(a,b,c,d) MatSerializeRegister(a,b,c,d) 145273d9f13SBarry Smith #endif 14630de9b25SBarry Smith 147273d9f13SBarry Smith extern PetscTruth MatRegisterAllCalled; 148b0a32e0cSBarry Smith extern PetscFList MatList; 14928988994SBarry Smith 150c06d978dSMatthew Knepley EXTERN PetscFList MatSerializeList; 151c06d978dSMatthew Knepley EXTERN int MatSerializeRegisterAll(const char []); 15265804fbbSSatish Balay EXTERN int MatSerializeRegisterDestroy(void); 153c06d978dSMatthew Knepley EXTERN int MatSerializeRegisterAllCalled; 154c06d978dSMatthew Knepley EXTERN int MatSerialize(MPI_Comm, Mat *, PetscViewer, PetscTruth); 155c06d978dSMatthew Knepley EXTERN int MatSetSerializeType(Mat, MatSerializeType); 156c06d978dSMatthew Knepley 157ca01db9bSBarry Smith EXTERN int MatCreateSeqDense(MPI_Comm,int,int,PetscScalar[],Mat*); 158ca01db9bSBarry Smith EXTERN int MatCreateMPIDense(MPI_Comm,int,int,int,int,PetscScalar[],Mat*); 159ca01db9bSBarry Smith EXTERN int MatCreateSeqAIJ(MPI_Comm,int,int,int,const int[],Mat*); 160ca01db9bSBarry Smith EXTERN int MatCreateMPIAIJ(MPI_Comm,int,int,int,int,int,const int[],int,const int[],Mat*); 161ca01db9bSBarry Smith EXTERN int MatCreateMPIRowbs(MPI_Comm,int,int,int,const int[],Mat*); 162ca01db9bSBarry Smith EXTERN int MatCreateSeqBDiag(MPI_Comm,int,int,int,int,const int[],PetscScalar*[],Mat*); 163ca01db9bSBarry Smith EXTERN int MatCreateMPIBDiag(MPI_Comm,int,int,int,int,int,const int[],PetscScalar*[],Mat*); 164ca01db9bSBarry Smith EXTERN int MatCreateSeqBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*); 165ca01db9bSBarry Smith EXTERN int MatCreateMPIBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*); 166ca01db9bSBarry Smith EXTERN int MatCreateMPIAdj(MPI_Comm,int,int,int[],int[],int[],Mat*); 167ca01db9bSBarry Smith EXTERN int MatCreateSeqSBAIJ(MPI_Comm,int,int,int,int,const int[],Mat*); 168ca01db9bSBarry Smith EXTERN int MatCreateMPISBAIJ(MPI_Comm,int,int,int,int,int,int,const int[],int,const int[],Mat*); 169ca44d042SBarry Smith EXTERN int MatCreateShell(MPI_Comm,int,int,int,int,void *,Mat*); 1703a7fca6bSBarry Smith EXTERN int MatCreateAdic(MPI_Comm,int,int,int,int,int,void (*)(void),Mat*); 171c8a8475eSBarry Smith EXTERN int MatCreateNormal(Mat,Mat*); 172435da068SBarry Smith EXTERN int MatDestroy(Mat); 17321c89e3eSBarry Smith 174ca44d042SBarry Smith EXTERN int MatPrintHelp(Mat); 1758a124369SBarry Smith EXTERN int MatGetPetscMaps(Mat,PetscMap*,PetscMap*); 176ec0117caSBarry Smith 1778ed539a5SBarry Smith /* ------------------------------------------------------------*/ 178f15d580aSBarry Smith EXTERN int MatSetValues(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 179f15d580aSBarry Smith EXTERN int MatSetValuesBlocked(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 18084cb2905SBarry Smith 1812ef4de8bSBarry Smith /*S 1822ef4de8bSBarry Smith MatStencil - Data structure (C struct) for storing information about a single row or 1832ef4de8bSBarry Smith column of a matrix as index on an associated grid. 1842ef4de8bSBarry Smith 1852ef4de8bSBarry Smith Level: beginner 1862ef4de8bSBarry Smith 1872ef4de8bSBarry Smith Concepts: matrix; linear operator 1882ef4de8bSBarry Smith 1892ef4de8bSBarry Smith .seealso: MatSetValuesStencil(), MatSetStencil() 1902ef4de8bSBarry Smith S*/ 191435da068SBarry Smith typedef struct { 192435da068SBarry Smith int k,j,i,c; 193435da068SBarry Smith } MatStencil; 1942ef4de8bSBarry Smith 195f15d580aSBarry Smith EXTERN int MatSetValuesStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode); 196f15d580aSBarry Smith EXTERN int MatSetValuesBlockedStencil(Mat,int,const MatStencil[],int,const MatStencil[],const PetscScalar[],InsertMode); 197f15d580aSBarry Smith EXTERN int MatSetStencil(Mat,int,const int[],const int[],int); 198435da068SBarry Smith 1993a7fca6bSBarry Smith EXTERN int MatSetColoring(Mat,ISColoring); 2003a7fca6bSBarry Smith EXTERN int MatSetValuesAdic(Mat,void*); 2013a7fca6bSBarry Smith EXTERN int MatSetValuesAdifor(Mat,int,void*); 2023a7fca6bSBarry Smith 203d91e6319SBarry Smith /*E 204d91e6319SBarry Smith MatAssemblyType - Indicates if the matrix is now to be used, or if you plan 205d91e6319SBarry Smith to continue to add values to it 206d91e6319SBarry Smith 207d91e6319SBarry Smith Level: beginner 208d91e6319SBarry Smith 209d91e6319SBarry Smith .seealso: MatAssemblyBegin(), MatAssemblyEnd() 210d91e6319SBarry Smith E*/ 2116d4a8577SBarry Smith typedef enum {MAT_FLUSH_ASSEMBLY=1,MAT_FINAL_ASSEMBLY=0} MatAssemblyType; 212ca44d042SBarry Smith EXTERN int MatAssemblyBegin(Mat,MatAssemblyType); 213ca44d042SBarry Smith EXTERN int MatAssemblyEnd(Mat,MatAssemblyType); 214ca44d042SBarry Smith EXTERN int MatAssembled(Mat,PetscTruth*); 2154f9c727eSBarry Smith 21630de9b25SBarry Smith /*MC 21730de9b25SBarry Smith MatSetValue - Set a single entry into a matrix. 21830de9b25SBarry Smith 21930de9b25SBarry Smith Synopsis: 22030de9b25SBarry Smith int MatSetValue(Mat m,int row,int col,PetscScalar value,InsertMode mode); 22130de9b25SBarry Smith 22230de9b25SBarry Smith Not collective 22330de9b25SBarry Smith 22430de9b25SBarry Smith Input Parameters: 22530de9b25SBarry Smith + m - the matrix 22630de9b25SBarry Smith . row - the row location of the entry 22730de9b25SBarry Smith . col - the column location of the entry 22830de9b25SBarry Smith . value - the value to insert 22930de9b25SBarry Smith - mode - either INSERT_VALUES or ADD_VALUES 23030de9b25SBarry Smith 23130de9b25SBarry Smith Notes: 23230de9b25SBarry Smith For efficiency one should use MatSetValues() and set several or many 23330de9b25SBarry Smith values simultaneously if possible. 23430de9b25SBarry Smith 23530de9b25SBarry Smith Note that MatSetValue() does NOT return an error code (since this 23630de9b25SBarry Smith is checked internally). 23730de9b25SBarry Smith 23830de9b25SBarry Smith Level: beginner 23930de9b25SBarry Smith 24030de9b25SBarry Smith .seealso: MatSetValues(), MatSetValueLocal() 24130de9b25SBarry Smith M*/ 242b951964fSBarry Smith #define MatSetValue(v,i,j,va,mode) \ 243ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \ 244b951964fSBarry Smith _ierr = MatSetValues(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 245b951964fSBarry Smith } 24630de9b25SBarry Smith 247ea06a074SBarry Smith #define MatGetValue(v,i,j,va) \ 248d91e6319SBarry Smith 0; {int _ierr,_row = i,_col = j; \ 249ea06a074SBarry Smith _ierr = MatGetValues(v,1,&_row,1,&_col,&va);CHKERRQ(_ierr); \ 250ea06a074SBarry Smith } 25130de9b25SBarry Smith 252d91e6319SBarry Smith #define MatSetValueLocal(v,i,j,va,mode) \ 253ea709b57SSatish Balay 0; {int _ierr,_row = i,_col = j; PetscScalar _va = va; \ 254d91e6319SBarry Smith _ierr = MatSetValuesLocal(v,1,&_row,1,&_col,&_va,mode);CHKERRQ(_ierr); \ 255d91e6319SBarry Smith } 25630de9b25SBarry Smith 257d91e6319SBarry Smith /*E 258d91e6319SBarry Smith MatOption - Options that may be set for a matrix and its behavior or storage 259d91e6319SBarry Smith 260d91e6319SBarry Smith Level: beginner 261d91e6319SBarry Smith 2620a835dfdSSatish Balay Any additions/changes here MUST also be made in include/finclude/petscmat.h 263d91e6319SBarry Smith 264d91e6319SBarry Smith .seealso: MatSetOption() 265d91e6319SBarry Smith E*/ 2666d4a8577SBarry Smith typedef enum {MAT_ROW_ORIENTED=1,MAT_COLUMN_ORIENTED=2,MAT_ROWS_SORTED=4, 2676d4a8577SBarry Smith MAT_COLUMNS_SORTED=8,MAT_NO_NEW_NONZERO_LOCATIONS=16, 2686d4a8577SBarry Smith MAT_YES_NEW_NONZERO_LOCATIONS=32,MAT_SYMMETRIC=64, 2696ca9ecd3SBarry Smith MAT_STRUCTURALLY_SYMMETRIC=65,MAT_NO_NEW_DIAGONALS=66, 2706ca9ecd3SBarry Smith MAT_YES_NEW_DIAGONALS=67,MAT_INODE_LIMIT_1=68,MAT_INODE_LIMIT_2=69, 2716ca9ecd3SBarry Smith MAT_INODE_LIMIT_3=70,MAT_INODE_LIMIT_4=71,MAT_INODE_LIMIT_5=72, 2726ca9ecd3SBarry Smith MAT_IGNORE_OFF_PROC_ENTRIES=73,MAT_ROWS_UNSORTED=74, 2734787f768SSatish Balay MAT_COLUMNS_UNSORTED=75,MAT_NEW_NONZERO_LOCATION_ERR=76, 2747c922b88SBarry Smith MAT_NEW_NONZERO_ALLOCATION_ERR=77,MAT_USE_HASH_TABLE=78, 2752bad1931SBarry Smith MAT_KEEP_ZEROED_ROWS=79,MAT_IGNORE_ZERO_ENTRIES=80,MAT_USE_INODES=81, 276123145dfSKris Buschelman MAT_DO_NOT_USE_INODES=82} MatOption; 277ca44d042SBarry Smith EXTERN int MatSetOption(Mat,MatOption); 278273d9f13SBarry Smith EXTERN int MatGetType(Mat,MatType*); 27984cb2905SBarry Smith 280f15d580aSBarry Smith EXTERN int MatGetValues(Mat,int,const int[],int,const int[],PetscScalar[]); 281f15d580aSBarry Smith EXTERN int MatGetRow(Mat,int,int *,int *[],PetscScalar*[]); 282f15d580aSBarry Smith EXTERN int MatRestoreRow(Mat,int,int *,int *[],PetscScalar*[]); 2834e7234bfSBarry Smith EXTERN int MatGetColumn(Mat,int,int *,int *[],PetscScalar*[]); 2844e7234bfSBarry Smith EXTERN int MatRestoreColumn(Mat,int,int *,int *[],PetscScalar*[]); 285ca44d042SBarry Smith EXTERN int MatGetColumnVector(Mat,Vec,int); 2864e7234bfSBarry Smith EXTERN int MatGetArray(Mat,PetscScalar *[]); 2874e7234bfSBarry Smith EXTERN int MatRestoreArray(Mat,PetscScalar *[]); 288ca44d042SBarry Smith EXTERN int MatGetBlockSize(Mat,int *); 2897b80b807SBarry Smith 290ca44d042SBarry Smith EXTERN int MatMult(Mat,Vec,Vec); 291ca44d042SBarry Smith EXTERN int MatMultAdd(Mat,Vec,Vec,Vec); 292ca44d042SBarry Smith EXTERN int MatMultTranspose(Mat,Vec,Vec); 293cd0d46ebSvictorle EXTERN int MatIsSymmetric(Mat,Mat,PetscTruth*); 294ca44d042SBarry Smith EXTERN int MatMultTransposeAdd(Mat,Vec,Vec,Vec); 295c06d978dSMatthew Knepley EXTERN int MatMultConstrained(Mat,Vec,Vec); 2966d0dc95fSMatthew Knepley EXTERN int MatMultTransposeConstrained(Mat,Vec,Vec); 2972eac72dbSBarry Smith 298d91e6319SBarry Smith /*E 299d91e6319SBarry Smith MatDuplicateOption - Indicates if a duplicated sparse matrix should have 300d91e6319SBarry Smith its numerical values copied over or just its nonzero structure. 301d91e6319SBarry Smith 302d91e6319SBarry Smith Level: beginner 303d91e6319SBarry Smith 304d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 305d91e6319SBarry Smith 306d91e6319SBarry Smith .seealso: MatDuplicate() 307d91e6319SBarry Smith E*/ 3082e8a6d31SBarry Smith typedef enum {MAT_DO_NOT_COPY_VALUES,MAT_COPY_VALUES} MatDuplicateOption; 3092e8a6d31SBarry Smith 310273d9f13SBarry Smith EXTERN int MatConvertRegister(char*,char*,char*,int (*)(Mat,MatType,Mat*)); 311273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 312273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,0) 313273d9f13SBarry Smith #else 314273d9f13SBarry Smith #define MatConvertRegisterDynamic(a,b,c,d) MatConvertRegister(a,b,c,d) 315273d9f13SBarry Smith #endif 316273d9f13SBarry Smith EXTERN int MatConvertRegisterAll(char*); 317273d9f13SBarry Smith EXTERN int MatConvertRegisterDestroy(void); 318273d9f13SBarry Smith extern PetscTruth MatConvertRegisterAllCalled; 319b0a32e0cSBarry Smith extern PetscFList MatConvertList; 320ca44d042SBarry Smith EXTERN int MatConvert(Mat,MatType,Mat*); 321ca44d042SBarry Smith EXTERN int MatDuplicate(Mat,MatDuplicateOption,Mat*); 32294a9d846SBarry Smith 323d91e6319SBarry Smith /*E 324d91e6319SBarry Smith MatStructure - Indicates if the matrix has the same nonzero structure 325d91e6319SBarry Smith 326d91e6319SBarry Smith Level: beginner 327d91e6319SBarry Smith 328d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 329d91e6319SBarry Smith 330d91e6319SBarry Smith .seealso: MatCopy(), SLESSetOperators(), PCSetOperators() 331d91e6319SBarry Smith E*/ 332c537a176SHong Zhang typedef enum {SAME_NONZERO_PATTERN,DIFFERENT_NONZERO_PATTERN,SAME_PRECONDITIONER,SUBSET_NONZERO_PATTERN} MatStructure; 333cb5b572fSBarry Smith 334ca44d042SBarry Smith EXTERN int MatCopy(Mat,Mat,MatStructure); 335b0a32e0cSBarry Smith EXTERN int MatView(Mat,PetscViewer); 336273d9f13SBarry Smith 337b0a32e0cSBarry Smith EXTERN int MatLoadRegister(char*,char*,char*,int (*)(PetscViewer,MatType,Mat*)); 338273d9f13SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 339273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,0) 340273d9f13SBarry Smith #else 341273d9f13SBarry Smith #define MatLoadRegisterDynamic(a,b,c,d) MatLoadRegister(a,b,c,d) 342273d9f13SBarry Smith #endif 343273d9f13SBarry Smith EXTERN int MatLoadRegisterAll(char*); 344273d9f13SBarry Smith EXTERN int MatLoadRegisterDestroy(void); 345273d9f13SBarry Smith extern PetscTruth MatLoadRegisterAllCalled; 346b0a32e0cSBarry Smith extern PetscFList MatLoadList; 347b0a32e0cSBarry Smith EXTERN int MatLoad(PetscViewer,MatType,Mat*); 34851dd7536SBarry Smith EXTERN int MatMerge(MPI_Comm,Mat,Mat*); 3497b80b807SBarry Smith 3504e7234bfSBarry Smith EXTERN int MatGetRowIJ(Mat,int,PetscTruth,int*,int *[],int *[],PetscTruth *); 3514e7234bfSBarry Smith EXTERN int MatRestoreRowIJ(Mat,int,PetscTruth,int *,int *[],int *[],PetscTruth *); 3524e7234bfSBarry Smith EXTERN int MatGetColumnIJ(Mat,int,PetscTruth,int*,int *[],int *[],PetscTruth *); 3534e7234bfSBarry Smith EXTERN int MatRestoreColumnIJ(Mat,int,PetscTruth,int *,int *[],int *[],PetscTruth *); 354d4fbbf0eSBarry Smith 355d91e6319SBarry Smith /*S 356d91e6319SBarry Smith MatInfo - Context of matrix information, used with MatGetInfo() 357d91e6319SBarry Smith 358d91e6319SBarry Smith In Fortran this is simply a double precision array of dimension MAT_INFO_SIZE 359d91e6319SBarry Smith 360d91e6319SBarry Smith Level: intermediate 361d91e6319SBarry Smith 362d91e6319SBarry Smith Concepts: matrix^nonzero information 363d91e6319SBarry Smith 364d9274352SBarry Smith .seealso: MatGetInfo(), MatInfoType 365d91e6319SBarry Smith S*/ 3664e220ebcSLois Curfman McInnes typedef struct { 367b0a32e0cSBarry Smith PetscLogDouble rows_global,columns_global; /* number of global rows and columns */ 368b0a32e0cSBarry Smith PetscLogDouble rows_local,columns_local; /* number of local rows and columns */ 369b0a32e0cSBarry Smith PetscLogDouble block_size; /* block size */ 370b0a32e0cSBarry Smith PetscLogDouble nz_allocated,nz_used,nz_unneeded; /* number of nonzeros */ 371b0a32e0cSBarry Smith PetscLogDouble memory; /* memory allocated */ 372b0a32e0cSBarry Smith PetscLogDouble assemblies; /* number of matrix assemblies called */ 373b0a32e0cSBarry Smith PetscLogDouble mallocs; /* number of mallocs during MatSetValues() */ 374b0a32e0cSBarry Smith PetscLogDouble fill_ratio_given,fill_ratio_needed; /* fill ratio for LU/ILU */ 375b0a32e0cSBarry Smith PetscLogDouble factor_mallocs; /* number of mallocs during factorization */ 3764e220ebcSLois Curfman McInnes } MatInfo; 3774e220ebcSLois Curfman McInnes 378d9274352SBarry Smith /*E 379d9274352SBarry Smith MatInfoType - Indicates if you want information about the local part of the matrix, 380d9274352SBarry Smith the entire parallel matrix or the maximum over all the local parts. 381d9274352SBarry Smith 382d9274352SBarry Smith Level: beginner 383d9274352SBarry Smith 384d9274352SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 385d9274352SBarry Smith 386d9274352SBarry Smith .seealso: MatGetInfo(), MatInfo 387d9274352SBarry Smith E*/ 3887b80b807SBarry Smith typedef enum {MAT_LOCAL=1,MAT_GLOBAL_MAX=2,MAT_GLOBAL_SUM=3} MatInfoType; 389ca44d042SBarry Smith EXTERN int MatGetInfo(Mat,MatInfoType,MatInfo*); 390ca44d042SBarry Smith EXTERN int MatValid(Mat,PetscTruth*); 391ca44d042SBarry Smith EXTERN int MatGetDiagonal(Mat,Vec); 392273d9f13SBarry Smith EXTERN int MatGetRowMax(Mat,Vec); 393ca44d042SBarry Smith EXTERN int MatTranspose(Mat,Mat*); 394ca44d042SBarry Smith EXTERN int MatPermute(Mat,IS,IS,Mat *); 395bf1d55d4SSatish Balay EXTERN int MatPermuteSparsify(Mat,int,PetscReal,PetscReal,IS,IS,Mat *); 396ca44d042SBarry Smith EXTERN int MatDiagonalScale(Mat,Vec,Vec); 39706ef90c2SBarry Smith EXTERN int MatDiagonalSet(Mat,Vec,InsertMode); 398ca44d042SBarry Smith EXTERN int MatEqual(Mat,Mat,PetscTruth*); 3997b80b807SBarry Smith 40087828ca2SBarry Smith EXTERN int MatNorm(Mat,NormType,PetscReal *); 401ca44d042SBarry Smith EXTERN int MatZeroEntries(Mat); 402268466fbSBarry Smith EXTERN int MatZeroRows(Mat,IS,const PetscScalar*); 403268466fbSBarry Smith EXTERN int MatZeroColumns(Mat,IS,const PetscScalar*); 4047b80b807SBarry Smith 405ca44d042SBarry Smith EXTERN int MatUseScaledForm(Mat,PetscTruth); 406ca44d042SBarry Smith EXTERN int MatScaleSystem(Mat,Vec,Vec); 407ca44d042SBarry Smith EXTERN int MatUnScaleSystem(Mat,Vec,Vec); 4085ef9f2a5SBarry Smith 409ca44d042SBarry Smith EXTERN int MatGetSize(Mat,int*,int*); 410ca44d042SBarry Smith EXTERN int MatGetLocalSize(Mat,int*,int*); 411ca44d042SBarry Smith EXTERN int MatGetOwnershipRange(Mat,int*,int*); 4127b80b807SBarry Smith 413d91e6319SBarry Smith /*E 414d91e6319SBarry Smith MatReuse - Indicates if matrices obtained from a previous call to MatGetSubMatrices() 415d91e6319SBarry Smith or MatGetSubMatrix() are to be reused to store the new matrix values. 416d91e6319SBarry Smith 417d91e6319SBarry Smith Level: beginner 418d91e6319SBarry Smith 419d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 420d91e6319SBarry Smith 421d91e6319SBarry Smith .seealso: MatGetSubMatrices(), MatGetSubMatrix(), MatDestroyMatrices() 422d91e6319SBarry Smith E*/ 4237b2a1423SBarry Smith typedef enum {MAT_INITIAL_MATRIX,MAT_REUSE_MATRIX} MatReuse; 424268466fbSBarry Smith EXTERN int MatGetSubMatrices(Mat,int,const IS[],const IS[],MatReuse,Mat *[]); 425268466fbSBarry Smith EXTERN int MatDestroyMatrices(int,Mat *[]); 426ca44d042SBarry Smith EXTERN int MatGetSubMatrix(Mat,IS,IS,int,MatReuse,Mat *); 4278efafbd8SBarry Smith 428268466fbSBarry Smith EXTERN int MatIncreaseOverlap(Mat,int,IS[],int); 4297b80b807SBarry Smith 430268466fbSBarry Smith EXTERN int MatAXPY(const PetscScalar *,Mat,Mat,MatStructure); 431268466fbSBarry Smith EXTERN int MatAYPX(const PetscScalar *,Mat,Mat); 432ca44d042SBarry Smith EXTERN int MatCompress(Mat); 4337b80b807SBarry Smith 434268466fbSBarry Smith EXTERN int MatScale(const PetscScalar *,Mat); 435268466fbSBarry Smith EXTERN int MatShift(const PetscScalar *,Mat); 436052efed2SBarry Smith 437ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMapping(Mat,ISLocalToGlobalMapping); 438ca44d042SBarry Smith EXTERN int MatSetLocalToGlobalMappingBlock(Mat,ISLocalToGlobalMapping); 439268466fbSBarry Smith EXTERN int MatZeroRowsLocal(Mat,IS,const PetscScalar*); 440f15d580aSBarry Smith EXTERN int MatSetValuesLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 441f15d580aSBarry Smith EXTERN int MatSetValuesBlockedLocal(Mat,int,const int[],int,const int[],const PetscScalar[],InsertMode); 44290f02eecSBarry Smith 443ca44d042SBarry Smith EXTERN int MatSetStashInitialSize(Mat,int,int); 444649db694SBarry Smith 445ca44d042SBarry Smith EXTERN int MatInterpolateAdd(Mat,Vec,Vec,Vec); 446ca44d042SBarry Smith EXTERN int MatInterpolate(Mat,Vec,Vec); 447ca44d042SBarry Smith EXTERN int MatRestrict(Mat,Vec,Vec); 4487c922b88SBarry Smith 449bd481603SBarry Smith 450bd481603SBarry Smith /*MC 451bd481603SBarry Smith MatPreallocInitialize - Begins the block of code that will count the number of nonzeros per 452bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 453bd481603SBarry Smith 454bd481603SBarry Smith Synopsis: 455bd481603SBarry Smith int MatPreallocateInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz) 456bd481603SBarry Smith 457bd481603SBarry Smith Collective on MPI_Comm 458bd481603SBarry Smith 459bd481603SBarry Smith Input Parameters: 460bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 461bd481603SBarry Smith . nrows - the number of rows in the matrix 462bd481603SBarry Smith - ncols - the number of columns in the matrix 463bd481603SBarry Smith 464bd481603SBarry Smith Output Parameters: 465bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 466bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 467bd481603SBarry Smith 468bd481603SBarry Smith 469bd481603SBarry Smith Level: intermediate 470bd481603SBarry Smith 471bd481603SBarry Smith Notes: 472bd481603SBarry Smith See the chapter in the users manual on performance for more details 473bd481603SBarry Smith 474bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 475bd481603SBarry Smith 476bd481603SBarry Smith Use MatPreallocateInitializeSymmetric() for symmetric matrices (MPISBAIJ matrices) 477bd481603SBarry Smith 478bd481603SBarry Smith Concepts: preallocation^Matrix 479bd481603SBarry Smith 480bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 481bd481603SBarry Smith MatPreallocateInitializeSymmetric(), MatPreallocateSymmetricSetLocal() 482bd481603SBarry Smith M*/ 483c4f061fbSSatish Balay #define MatPreallocateInitialize(comm,nrows,ncols,dnz,onz) 0; \ 4847c922b88SBarry Smith { \ 485ef66eb69SBarry Smith int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__start,__end; \ 486ef66eb69SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 487ef66eb69SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\ 488ef66eb69SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __start = __end - __ctmp;\ 489ef66eb69SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 4907c922b88SBarry Smith 491bd481603SBarry Smith /*MC 492bd481603SBarry Smith MatPreallocSymmetricInitialize - Begins the block of code that will count the number of nonzeros per 493bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 494bd481603SBarry Smith 495bd481603SBarry Smith Synopsis: 496bd481603SBarry Smith int MatPreallocateSymmetricInitialize(MPI_Comm comm, int nrows, int ncols, int *dnz, int *onz) 497bd481603SBarry Smith 498bd481603SBarry Smith Collective on MPI_Comm 499bd481603SBarry Smith 500bd481603SBarry Smith Input Parameters: 501bd481603SBarry Smith + comm - the communicator that will share the eventually allocated matrix 502bd481603SBarry Smith . nrows - the number of rows in the matrix 503bd481603SBarry Smith - ncols - the number of columns in the matrix 504bd481603SBarry Smith 505bd481603SBarry Smith Output Parameters: 506bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 507bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 508bd481603SBarry Smith 509bd481603SBarry Smith 510bd481603SBarry Smith Level: intermediate 511bd481603SBarry Smith 512bd481603SBarry Smith Notes: 513bd481603SBarry Smith See the chapter in the users manual on performance for more details 514bd481603SBarry Smith 515bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 516bd481603SBarry Smith 517bd481603SBarry Smith Concepts: preallocation^Matrix 518bd481603SBarry Smith 519bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 520bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 521bd481603SBarry Smith M*/ 522222b16d4SBarry Smith #define MatPreallocateSymmetricInitialize(comm,nrows,ncols,dnz,onz) 0; \ 523222b16d4SBarry Smith { \ 524222b16d4SBarry Smith int _4_ierr,__tmp = (nrows),__ctmp = (ncols),__rstart,__end; \ 525222b16d4SBarry Smith _4_ierr = PetscMalloc(2*__tmp*sizeof(int),&dnz);CHKERRQ(_4_ierr);onz = dnz + __tmp;\ 526222b16d4SBarry Smith _4_ierr = PetscMemzero(dnz,2*__tmp*sizeof(int));CHKERRQ(_4_ierr);\ 527222b16d4SBarry Smith _4_ierr = MPI_Scan(&__ctmp,&__end,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr);\ 528222b16d4SBarry Smith _4_ierr = MPI_Scan(&__tmp,&__rstart,1,MPI_INT,MPI_SUM,comm);CHKERRQ(_4_ierr); __rstart = __rstart - __tmp; 529222b16d4SBarry Smith 530bd481603SBarry Smith /*MC 531bd481603SBarry Smith MatPreallocateSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 532bd481603SBarry Smith inserted using a local number of the rows and columns 533bd481603SBarry Smith 534bd481603SBarry Smith Synopsis: 535bd481603SBarry Smith int MatPreallocateSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 536bd481603SBarry Smith 537bd481603SBarry Smith Not Collective 538bd481603SBarry Smith 539bd481603SBarry Smith Input Parameters: 540bd481603SBarry Smith + map - the mapping between local numbering and global numbering 541bd481603SBarry Smith . nrows - the number of rows indicated 542bd481603SBarry Smith . rows - the indices of the rows (these will be mapped in the 543bd481603SBarry Smith . ncols - the number of columns in the matrix 544bd481603SBarry Smith . cols - the columns indicated 545bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 546bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 547bd481603SBarry Smith 548bd481603SBarry Smith 549bd481603SBarry Smith Level: intermediate 550bd481603SBarry Smith 551bd481603SBarry Smith Notes: 552bd481603SBarry Smith See the chapter in the users manual on performance for more details 553bd481603SBarry Smith 554bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 555bd481603SBarry Smith 556bd481603SBarry Smith Concepts: preallocation^Matrix 557bd481603SBarry Smith 558bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 559bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal() 560bd481603SBarry Smith M*/ 561c4f061fbSSatish Balay #define MatPreallocateSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 562c4f061fbSSatish Balay {\ 563c4f061fbSSatish Balay int __l;\ 564ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 565ef66eb69SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 566c4f061fbSSatish Balay for (__l=0;__l<nrows;__l++) {\ 567ef66eb69SBarry Smith _4_ierr = MatPreallocateSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 568c4f061fbSSatish Balay }\ 569c4f061fbSSatish Balay } 570c4f061fbSSatish Balay 571bd481603SBarry Smith /*MC 572bd481603SBarry Smith MatPreallocateSymmetricSetLocal - Indicates the locations (rows and columns) in the matrix where nonzeros will be 573bd481603SBarry Smith inserted using a local number of the rows and columns 574bd481603SBarry Smith 575bd481603SBarry Smith Synopsis: 576bd481603SBarry Smith int MatPreallocateSymmetricSetLocal(ISLocalToGlobalMappping map,int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 577bd481603SBarry Smith 578bd481603SBarry Smith Not Collective 579bd481603SBarry Smith 580bd481603SBarry Smith Input Parameters: 581bd481603SBarry Smith + map - the mapping between local numbering and global numbering 582bd481603SBarry Smith . nrows - the number of rows indicated 583bd481603SBarry Smith . rows - the indices of the rows (these will be mapped in the 584bd481603SBarry Smith . ncols - the number of columns in the matrix 585bd481603SBarry Smith . cols - the columns indicated 586bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 587bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 588bd481603SBarry Smith 589bd481603SBarry Smith 590bd481603SBarry Smith Level: intermediate 591bd481603SBarry Smith 592bd481603SBarry Smith Notes: 593bd481603SBarry Smith See the chapter in the users manual on performance for more details 594bd481603SBarry Smith 595bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 596bd481603SBarry Smith 597bd481603SBarry Smith Concepts: preallocation^Matrix 598bd481603SBarry Smith 599bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 600bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 601bd481603SBarry Smith M*/ 602d3d32019SBarry Smith #define MatPreallocateSymmetricSetLocal(map,nrows,rows,ncols,cols,dnz,onz) 0;\ 603d3d32019SBarry Smith {\ 604d3d32019SBarry Smith int __l;\ 605d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,nrows,rows,rows);CHKERRQ(_4_ierr);\ 606d3d32019SBarry Smith _4_ierr = ISLocalToGlobalMappingApply(map,ncols,cols,cols);CHKERRQ(_4_ierr);\ 607d3d32019SBarry Smith for (__l=0;__l<nrows;__l++) {\ 608d3d32019SBarry Smith _4_ierr = MatPreallocateSymmetricSet((rows)[__l],ncols,cols,dnz,onz);CHKERRQ(_4_ierr);\ 609d3d32019SBarry Smith }\ 610d3d32019SBarry Smith } 611d3d32019SBarry Smith 612bd481603SBarry Smith /*MC 613bd481603SBarry Smith MatPreallocateSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 614bd481603SBarry Smith inserted using a local number of the rows and columns 615bd481603SBarry Smith 616bd481603SBarry Smith Synopsis: 617bd481603SBarry Smith int MatPreallocateSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 618bd481603SBarry Smith 619bd481603SBarry Smith Not Collective 620bd481603SBarry Smith 621bd481603SBarry Smith Input Parameters: 622bd481603SBarry Smith + nrows - the number of rows indicated 623bd481603SBarry Smith . rows - the indices of the rows (these will be mapped in the 624bd481603SBarry Smith . ncols - the number of columns in the matrix 625bd481603SBarry Smith . cols - the columns indicated 626bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 627bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 628bd481603SBarry Smith 629bd481603SBarry Smith 630bd481603SBarry Smith Level: intermediate 631bd481603SBarry Smith 632bd481603SBarry Smith Notes: 633bd481603SBarry Smith See the chapter in the users manual on performance for more details 634bd481603SBarry Smith 635bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 636bd481603SBarry Smith 637bd481603SBarry Smith Concepts: preallocation^Matrix 638bd481603SBarry Smith 639bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 640bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 641bd481603SBarry Smith M*/ 642c4f061fbSSatish Balay #define MatPreallocateSet(row,nc,cols,dnz,onz) 0;\ 6437c922b88SBarry Smith { int __i; \ 6447c922b88SBarry Smith for (__i=0; __i<nc; __i++) {\ 6457c922b88SBarry Smith if (cols[__i] < __start || cols[__i] >= __end) onz[row - __rstart]++; \ 6467c922b88SBarry Smith }\ 6477c922b88SBarry Smith dnz[row - __rstart] = nc - onz[row - __rstart];\ 6487c922b88SBarry Smith } 6497c922b88SBarry Smith 650bd481603SBarry Smith /*MC 651bd481603SBarry Smith MatPreallocateSymmetricSet - Indicates the locations (rows and columns) in the matrix where nonzeros will be 652bd481603SBarry Smith inserted using a local number of the rows and columns 653bd481603SBarry Smith 654bd481603SBarry Smith Synopsis: 655bd481603SBarry Smith int MatPreallocateSymmetricSet(int nrows, int *rows,int ncols, int *cols,int *dnz, int *onz) 656bd481603SBarry Smith 657bd481603SBarry Smith Not Collective 658bd481603SBarry Smith 659bd481603SBarry Smith Input Parameters: 660bd481603SBarry Smith + nrows - the number of rows indicated 661bd481603SBarry Smith . rows - the indices of the rows (these will be mapped in the 662bd481603SBarry Smith . ncols - the number of columns in the matrix 663bd481603SBarry Smith . cols - the columns indicated 664bd481603SBarry Smith . dnz - the array that will be passed to the matrix preallocation routines 665bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 666bd481603SBarry Smith 667bd481603SBarry Smith 668bd481603SBarry Smith Level: intermediate 669bd481603SBarry Smith 670bd481603SBarry Smith Notes: 671bd481603SBarry Smith See the chapter in the users manual on performance for more details 672bd481603SBarry Smith 673bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 674bd481603SBarry Smith 675bd481603SBarry Smith Concepts: preallocation^Matrix 676bd481603SBarry Smith 677bd481603SBarry Smith .seealso: MatPreallocateFinalize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateInitialize(), 678bd481603SBarry Smith MatPreallocateInitialize(), MatPreallocateSymmetricSetLocal(), MatPreallocateSetLocal() 679bd481603SBarry Smith M*/ 680d3d32019SBarry Smith #define MatPreallocateSymmetricSet(row,nc,cols,dnz,onz) 0;\ 681d3d32019SBarry Smith { int __i; \ 682d3d32019SBarry Smith for (__i=0; __i<nc; __i++) {\ 683d3d32019SBarry Smith if (cols[__i] >= __end) onz[row - __rstart]++; \ 684d3d32019SBarry Smith else if (cols[__i] >= row) dnz[row - __rstart]++;\ 685d3d32019SBarry Smith }\ 686d3d32019SBarry Smith } 687d3d32019SBarry Smith 688bd481603SBarry Smith /*MC 689bd481603SBarry Smith MatPreallocFinalize - Ends the block of code that will count the number of nonzeros per 690bd481603SBarry Smith row in a matrix providing the data that one can use to correctly preallocate the matrix. 691bd481603SBarry Smith 692bd481603SBarry Smith Synopsis: 693bd481603SBarry Smith int MatPreallocateFinalize(int *dnz, int *onz) 694bd481603SBarry Smith 695bd481603SBarry Smith Collective on MPI_Comm 696bd481603SBarry Smith 697bd481603SBarry Smith Input Parameters: 698bd481603SBarry Smith + dnz - the array that will be passed to the matrix preallocation routines 699bd481603SBarry Smith - ozn - the other array passed to the matrix preallocation routines 700bd481603SBarry Smith 701bd481603SBarry Smith 702bd481603SBarry Smith Level: intermediate 703bd481603SBarry Smith 704bd481603SBarry Smith Notes: 705bd481603SBarry Smith See the chapter in the users manual on performance for more details 706bd481603SBarry Smith 707bd481603SBarry Smith Do not malloc or free dnz and onz that is handled internally by these routines 708bd481603SBarry Smith 709bd481603SBarry Smith Concepts: preallocation^Matrix 710bd481603SBarry Smith 711bd481603SBarry Smith .seealso: MatPreallocateInitialize(), MatPreallocateSet(), MatPreallocateSymmetricSet(), MatPreallocateSetLocal(), 712bd481603SBarry Smith MatPreallocateSymmetricInitialize(), MatPreallocateSymmetricSetLocal() 713bd481603SBarry Smith M*/ 714ef66eb69SBarry Smith #define MatPreallocateFinalize(dnz,onz) 0;_4_ierr = PetscFree(dnz);CHKERRQ(_4_ierr);} 7157c922b88SBarry Smith 716bd481603SBarry Smith 717bd481603SBarry Smith 7187b80b807SBarry Smith /* Routines unique to particular data structures */ 719435da068SBarry Smith EXTERN int MatShellGetContext(Mat,void **); 720435da068SBarry Smith 721268466fbSBarry Smith EXTERN int MatBDiagGetData(Mat,int*,int*,int*[],int*[],PetscScalar***); 722ca01db9bSBarry Smith EXTERN int MatSeqAIJSetColumnIndices(Mat,int[]); 723ca01db9bSBarry Smith EXTERN int MatSeqBAIJSetColumnIndices(Mat,int[]); 724ca01db9bSBarry Smith EXTERN int MatCreateSeqAIJWithArrays(MPI_Comm,int,int,int[],int[],PetscScalar[],Mat*); 7257b80b807SBarry Smith 726ca01db9bSBarry Smith EXTERN int MatSeqBAIJSetPreallocation(Mat,int,int,const int[]); 727ca01db9bSBarry Smith EXTERN int MatSeqSBAIJSetPreallocation(Mat,int,int,const int[]); 728ca01db9bSBarry Smith EXTERN int MatSeqAIJSetPreallocation(Mat,int,const int[]); 729ca01db9bSBarry Smith EXTERN int MatSeqDensePreallocation(Mat,PetscScalar[]); 730ca01db9bSBarry Smith EXTERN int MatSeqBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]); 731ca01db9bSBarry Smith EXTERN int MatSeqDenseSetPreallocation(Mat,PetscScalar[]); 732273d9f13SBarry Smith 733ca01db9bSBarry Smith EXTERN int MatMPIBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]); 734ca01db9bSBarry Smith EXTERN int MatMPISBAIJSetPreallocation(Mat,int,int,const int[],int,const int[]); 735ca01db9bSBarry Smith EXTERN int MatMPIAIJSetPreallocation(Mat,int,const int[],int,const int[]); 736ca01db9bSBarry Smith EXTERN int MatMPIDensePreallocation(Mat,PetscScalar[]); 737ca01db9bSBarry Smith EXTERN int MatMPIBDiagSetPreallocation(Mat,int,int,const int[],PetscScalar*[]); 738ca01db9bSBarry Smith EXTERN int MatMPIAdjSetPreallocation(Mat,int[],int[],int[]); 739ca01db9bSBarry Smith EXTERN int MatMPIDenseSetPreallocation(Mat,PetscScalar[]); 740ca01db9bSBarry Smith EXTERN int MatMPIRowbsSetPreallocation(Mat,int,const int[]); 741268466fbSBarry Smith EXTERN int MatMPIAIJGetSeqAIJ(Mat,Mat*,Mat*,int*[]); 742268466fbSBarry Smith EXTERN int MatMPIBAIJGetSeqBAIJ(Mat,Mat*,Mat*,int*[]); 7433a7fca6bSBarry Smith EXTERN int MatAdicSetLocalFunction(Mat,void (*)(void)); 744273d9f13SBarry Smith 7451b807ce4Svictorle EXTERN int MatSeqDenseSetLDA(Mat,int); 7461b807ce4Svictorle 747ca44d042SBarry Smith EXTERN int MatStoreValues(Mat); 748ca44d042SBarry Smith EXTERN int MatRetrieveValues(Mat); 7492e8a6d31SBarry Smith 7503a7fca6bSBarry Smith EXTERN int MatDAADSetCtx(Mat,void*); 7513a7fca6bSBarry Smith 7527b80b807SBarry Smith /* 7537b80b807SBarry Smith These routines are not usually accessed directly, rather solving is 7547b80b807SBarry Smith done through the SLES, KSP and PC interfaces. 7557b80b807SBarry Smith */ 7567b80b807SBarry Smith 757d9274352SBarry Smith /*E 758d9274352SBarry Smith MatOrderingType - String with the name of a PETSc matrix ordering or the creation function 759d9274352SBarry Smith with an optional dynamic library name, for example 760d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:orderingcreate() 761d9274352SBarry Smith 762d9274352SBarry Smith Level: beginner 763d9274352SBarry Smith 764d9274352SBarry Smith .seealso: MatGetOrdering() 765d9274352SBarry Smith E*/ 766b12f92e5SBarry Smith typedef char* MatOrderingType; 767b12f92e5SBarry Smith #define MATORDERING_NATURAL "natural" 768b12f92e5SBarry Smith #define MATORDERING_ND "nd" 769b12f92e5SBarry Smith #define MATORDERING_1WD "1wd" 770b12f92e5SBarry Smith #define MATORDERING_RCM "rcm" 771b12f92e5SBarry Smith #define MATORDERING_QMD "qmd" 772b12f92e5SBarry Smith #define MATORDERING_ROWLENGTH "rowlength" 77362152c8bSBarry Smith #define MATORDERING_DSC_ND "dsc_nd" 77462152c8bSBarry Smith #define MATORDERING_DSC_MMD "dsc_mmd" 77562152c8bSBarry Smith #define MATORDERING_DSC_MDF "dsc_mdf" 776c06d978dSMatthew Knepley #define MATORDERING_CONSTRAINED "constrained" 777c06d978dSMatthew Knepley #define MATORDERING_IDENTITY "identity" 778c06d978dSMatthew Knepley #define MATORDERING_REVERSE "reverse" 779b12f92e5SBarry Smith 780ca44d042SBarry Smith EXTERN int MatGetOrdering(Mat,MatOrderingType,IS*,IS*); 781ca44d042SBarry Smith EXTERN int MatOrderingRegister(char*,char*,char*,int(*)(Mat,MatOrderingType,IS*,IS*)); 78230de9b25SBarry Smith 78330de9b25SBarry Smith /*MC 78430de9b25SBarry Smith MatOrderingRegisterDynamic - Adds a new sparse matrix ordering to the 78530de9b25SBarry Smith matrix package. 78630de9b25SBarry Smith 78730de9b25SBarry Smith Synopsis: 78830de9b25SBarry Smith int MatOrderingRegisterDynamic(char *name_ordering,char *path,char *name_create,int (*routine_create)(MatOrdering)) 78930de9b25SBarry Smith 79030de9b25SBarry Smith Not Collective 79130de9b25SBarry Smith 79230de9b25SBarry Smith Input Parameters: 79330de9b25SBarry Smith + sname - name of ordering (for example MATORDERING_ND) 79430de9b25SBarry Smith . path - location of library where creation routine is 79530de9b25SBarry Smith . name - name of function that creates the ordering type,a string 79630de9b25SBarry Smith - function - function pointer that creates the ordering 79730de9b25SBarry Smith 79830de9b25SBarry Smith Level: developer 79930de9b25SBarry Smith 80030de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 80130de9b25SBarry Smith is ignored. 80230de9b25SBarry Smith 80330de9b25SBarry Smith Sample usage: 80430de9b25SBarry Smith .vb 80530de9b25SBarry Smith MatOrderingRegisterDynamic("my_order",/home/username/my_lib/lib/libO/solaris/mylib.a, 80630de9b25SBarry Smith "MyOrder",MyOrder); 80730de9b25SBarry Smith .ve 80830de9b25SBarry Smith 80930de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 81030de9b25SBarry Smith $ MatOrderingSetType(part,"my_order) 81130de9b25SBarry Smith or at runtime via the option 81230de9b25SBarry Smith $ -pc_ilu_mat_ordering_type my_order 81330de9b25SBarry Smith $ -pc_lu_mat_ordering_type my_order 81430de9b25SBarry Smith 81530de9b25SBarry Smith ${PETSC_ARCH} and ${BOPT} occuring in pathname will be replaced with appropriate values. 81630de9b25SBarry Smith 81730de9b25SBarry Smith .keywords: matrix, ordering, register 81830de9b25SBarry Smith 81930de9b25SBarry Smith .seealso: MatOrderingRegisterDestroy(), MatOrderingRegisterAll() 82030de9b25SBarry Smith M*/ 821aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 822f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,0) 823b12f92e5SBarry Smith #else 824f1af5d2fSBarry Smith #define MatOrderingRegisterDynamic(a,b,c,d) MatOrderingRegister(a,b,c,d) 825b12f92e5SBarry Smith #endif 82630de9b25SBarry Smith 827ca44d042SBarry Smith EXTERN int MatOrderingRegisterDestroy(void); 828ca44d042SBarry Smith EXTERN int MatOrderingRegisterAll(char*); 8292bad1931SBarry Smith extern PetscTruth MatOrderingRegisterAllCalled; 830b0a32e0cSBarry Smith extern PetscFList MatOrderingList; 831d4fbbf0eSBarry Smith 83287828ca2SBarry Smith EXTERN int MatReorderForNonzeroDiagonal(Mat,PetscReal,IS,IS); 833a2ce50c7SBarry Smith 834d91e6319SBarry Smith /*S 83515e8a5b3SHong Zhang MatFactorInfo - Data based into the matrix factorization routines 836b00f7748SHong Zhang 83715e8a5b3SHong Zhang In Fortran these are simply double precision arrays of size MAT_FACTORINFO_SIZE 838b00f7748SHong Zhang 83915e8a5b3SHong Zhang Notes: These are not usually directly used by users, instead use PC type of LU, ILU, CHOLESKY or ICC. 840b00f7748SHong Zhang 841b00f7748SHong Zhang Level: developer 842b00f7748SHong Zhang 843b380c88cSHong Zhang .seealso: MatLUFactorSymbolic(), MatILUFactorSymbolic(), MatCholeskyFactorSymbolic(), MatICCFactorSymbolic(), MatICCFactor() 844b00f7748SHong Zhang 845b00f7748SHong Zhang S*/ 846b00f7748SHong Zhang typedef struct { 84715e8a5b3SHong Zhang PetscReal damping; /* scaling of identity added to matrix to prevent zero pivots */ 8482cea7109SBarry Smith PetscReal shift; /* if true, shift until positive pivots */ 8492cea7109SBarry Smith PetscReal shift_fraction; /* record shift fraction taken */ 85015e8a5b3SHong Zhang PetscReal diagonal_fill; /* force diagonal to fill in if initially not filled */ 85115e8a5b3SHong Zhang PetscReal dt; /* drop tolerance */ 852b00f7748SHong Zhang PetscReal dtcol; /* tolerance for pivoting */ 85315e8a5b3SHong Zhang PetscReal dtcount; /* maximum nonzeros to be allowed per row */ 854f6275e2eSBarry Smith PetscReal fill; /* expected fill; nonzeros in factored matrix/nonzeros in original matrix*/ 855348344bbSBarry Smith PetscReal levels; /* ICC/ILU(levels) */ 856bcd9e38bSBarry Smith PetscReal pivotinblocks; /* for BAIJ and SBAIJ matrices pivot in factorization on blocks, default 1.0 857bcd9e38bSBarry Smith factorization may be faster if do not pivot */ 85815e8a5b3SHong Zhang PetscReal zeropivot; /* pivot is called zero if less than this */ 85915e8a5b3SHong Zhang } MatFactorInfo; 860ffa6d0a5SLois Curfman McInnes 86115e8a5b3SHong Zhang EXTERN int MatCholeskyFactor(Mat,IS,MatFactorInfo*); 86215e8a5b3SHong Zhang EXTERN int MatCholeskyFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 86315e8a5b3SHong Zhang EXTERN int MatCholeskyFactorNumeric(Mat,Mat*); 864b380c88cSHong Zhang EXTERN int MatLUFactor(Mat,IS,IS,MatFactorInfo*); 865b380c88cSHong Zhang EXTERN int MatILUFactor(Mat,IS,IS,MatFactorInfo*); 866b380c88cSHong Zhang EXTERN int MatLUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 867b380c88cSHong Zhang EXTERN int MatILUFactorSymbolic(Mat,IS,IS,MatFactorInfo*,Mat*); 86815e8a5b3SHong Zhang EXTERN int MatICCFactorSymbolic(Mat,IS,MatFactorInfo*,Mat*); 86915e8a5b3SHong Zhang EXTERN int MatICCFactor(Mat,IS,MatFactorInfo*); 870ca44d042SBarry Smith EXTERN int MatLUFactorNumeric(Mat,Mat*); 871b380c88cSHong Zhang EXTERN int MatILUDTFactor(Mat,MatFactorInfo*,IS,IS,Mat *); 8723e0d88b5SBarry Smith EXTERN int MatGetInertia(Mat,int*,int*,int*); 873ca44d042SBarry Smith EXTERN int MatSolve(Mat,Vec,Vec); 874ca44d042SBarry Smith EXTERN int MatForwardSolve(Mat,Vec,Vec); 875ca44d042SBarry Smith EXTERN int MatBackwardSolve(Mat,Vec,Vec); 876ca44d042SBarry Smith EXTERN int MatSolveAdd(Mat,Vec,Vec,Vec); 877ca44d042SBarry Smith EXTERN int MatSolveTranspose(Mat,Vec,Vec); 878ca44d042SBarry Smith EXTERN int MatSolveTransposeAdd(Mat,Vec,Vec,Vec); 879d59c15a7SBarry Smith EXTERN int MatSolves(Mat,Vecs,Vecs); 8808ed539a5SBarry Smith 881ca44d042SBarry Smith EXTERN int MatSetUnfactored(Mat); 882bb5a7306SBarry Smith 883d91e6319SBarry Smith /*E 884d91e6319SBarry Smith MatSORType - What type of (S)SOR to perform 885bb1eb677SSatish Balay 886d91e6319SBarry Smith Level: beginner 887d91e6319SBarry Smith 888d9274352SBarry Smith May be bitwise ORd together 889d9274352SBarry Smith 890d91e6319SBarry Smith Any additions/changes here MUST also be made in include/finclude/petscmat.h 891d91e6319SBarry Smith 8924e7234bfSBarry Smith MatSORType may be bitwise ORd together, so do not change the numbers 8934e7234bfSBarry Smith 894d91e6319SBarry Smith .seealso: MatRelax() 895d91e6319SBarry Smith E*/ 896ee50ffe9SBarry Smith typedef enum {SOR_FORWARD_SWEEP=1,SOR_BACKWARD_SWEEP=2,SOR_SYMMETRIC_SWEEP=3, 897ee50ffe9SBarry Smith SOR_LOCAL_FORWARD_SWEEP=4,SOR_LOCAL_BACKWARD_SWEEP=8, 898ee50ffe9SBarry Smith SOR_LOCAL_SYMMETRIC_SWEEP=12,SOR_ZERO_INITIAL_GUESS=16, 89984cb2905SBarry Smith SOR_EISENSTAT=32,SOR_APPLY_UPPER=64,SOR_APPLY_LOWER=128} MatSORType; 900c14dc6b6SHong Zhang EXTERN int MatRelax(Mat,Vec,PetscReal,MatSORType,PetscReal,int,int,Vec); 9018ed539a5SBarry Smith 902d4fbbf0eSBarry Smith /* 903639f9d9dSBarry Smith These routines are for efficiently computing Jacobians via finite differences. 904639f9d9dSBarry Smith */ 905b12f92e5SBarry Smith 906d9274352SBarry Smith /*E 907d9274352SBarry Smith MatColoringType - String with the name of a PETSc matrix coloring or the creation function 908d9274352SBarry Smith with an optional dynamic library name, for example 909d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:coloringcreate() 910d9274352SBarry Smith 911d9274352SBarry Smith Level: beginner 912d9274352SBarry Smith 913d9274352SBarry Smith .seealso: MatGetColoring() 914d9274352SBarry Smith E*/ 915b12f92e5SBarry Smith typedef char* MatColoringType; 916b12f92e5SBarry Smith #define MATCOLORING_NATURAL "natural" 917b12f92e5SBarry Smith #define MATCOLORING_SL "sl" 918b12f92e5SBarry Smith #define MATCOLORING_LF "lf" 919b12f92e5SBarry Smith #define MATCOLORING_ID "id" 920b12f92e5SBarry Smith 921ca44d042SBarry Smith EXTERN int MatGetColoring(Mat,MatColoringType,ISColoring*); 922ca44d042SBarry Smith EXTERN int MatColoringRegister(char*,char*,char*,int(*)(Mat,MatColoringType,ISColoring *)); 92330de9b25SBarry Smith 92430de9b25SBarry Smith /*MC 92530de9b25SBarry Smith MatColoringRegisterDynamic - Adds a new sparse matrix coloring to the 92630de9b25SBarry Smith matrix package. 92730de9b25SBarry Smith 92830de9b25SBarry Smith Synopsis: 92930de9b25SBarry Smith int MatColoringRegisterDynamic(char *name_coloring,char *path,char *name_create,int (*routine_create)(MatColoring)) 93030de9b25SBarry Smith 93130de9b25SBarry Smith Not Collective 93230de9b25SBarry Smith 93330de9b25SBarry Smith Input Parameters: 93430de9b25SBarry Smith + sname - name of Coloring (for example MATCOLORING_SL) 93530de9b25SBarry Smith . path - location of library where creation routine is 93630de9b25SBarry Smith . name - name of function that creates the Coloring type, a string 93730de9b25SBarry Smith - function - function pointer that creates the coloring 93830de9b25SBarry Smith 93930de9b25SBarry Smith Level: developer 94030de9b25SBarry Smith 94130de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 94230de9b25SBarry Smith is ignored. 94330de9b25SBarry Smith 94430de9b25SBarry Smith Sample usage: 94530de9b25SBarry Smith .vb 94630de9b25SBarry Smith MatColoringRegisterDynamic("my_color",/home/username/my_lib/lib/libO/solaris/mylib.a, 94730de9b25SBarry Smith "MyColor",MyColor); 94830de9b25SBarry Smith .ve 94930de9b25SBarry Smith 95030de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 95130de9b25SBarry Smith $ MatColoringSetType(part,"my_color") 95230de9b25SBarry Smith or at runtime via the option 95330de9b25SBarry Smith $ -mat_coloring_type my_color 95430de9b25SBarry Smith 95530de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 95630de9b25SBarry Smith 95730de9b25SBarry Smith .keywords: matrix, Coloring, register 95830de9b25SBarry Smith 95930de9b25SBarry Smith .seealso: MatColoringRegisterDestroy(), MatColoringRegisterAll() 96030de9b25SBarry Smith M*/ 961aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 962f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,0) 963b12f92e5SBarry Smith #else 964f1af5d2fSBarry Smith #define MatColoringRegisterDynamic(a,b,c,d) MatColoringRegister(a,b,c,d) 965b12f92e5SBarry Smith #endif 96630de9b25SBarry Smith 967ca44d042SBarry Smith EXTERN int MatColoringRegisterAll(char *); 9682bad1931SBarry Smith extern PetscTruth MatColoringRegisterAllCalled; 969ca44d042SBarry Smith EXTERN int MatColoringRegisterDestroy(void); 9704e7234bfSBarry Smith EXTERN int MatColoringPatch(Mat,int,int,const ISColoringValue[],ISColoring*); 971639f9d9dSBarry Smith 972d9274352SBarry Smith /*S 973d9274352SBarry Smith MatFDColoring - Object for computing a sparse Jacobian via finite differences 974d9274352SBarry Smith and coloring 975639f9d9dSBarry Smith 976d9274352SBarry Smith Level: beginner 977d9274352SBarry Smith 978d9274352SBarry Smith Concepts: coloring, sparse Jacobian, finite differences 979d9274352SBarry Smith 980d9274352SBarry Smith .seealso: MatFDColoringCreate() 981d9274352SBarry Smith S*/ 982e2a1c21fSSatish Balay typedef struct _p_MatFDColoring *MatFDColoring; 983639f9d9dSBarry Smith 984ca44d042SBarry Smith EXTERN int MatFDColoringCreate(Mat,ISColoring,MatFDColoring *); 985ca44d042SBarry Smith EXTERN int MatFDColoringDestroy(MatFDColoring); 986b0a32e0cSBarry Smith EXTERN int MatFDColoringView(MatFDColoring,PetscViewer); 987ca44d042SBarry Smith EXTERN int MatFDColoringSetFunction(MatFDColoring,int (*)(void),void*); 98887828ca2SBarry Smith EXTERN int MatFDColoringSetParameters(MatFDColoring,PetscReal,PetscReal); 989ca44d042SBarry Smith EXTERN int MatFDColoringSetFrequency(MatFDColoring,int); 990ca44d042SBarry Smith EXTERN int MatFDColoringGetFrequency(MatFDColoring,int*); 991ca44d042SBarry Smith EXTERN int MatFDColoringSetFromOptions(MatFDColoring); 992ca44d042SBarry Smith EXTERN int MatFDColoringApply(Mat,MatFDColoring,Vec,MatStructure*,void *); 99387828ca2SBarry Smith EXTERN int MatFDColoringApplyTS(Mat,MatFDColoring,PetscReal,Vec,MatStructure*,void *); 99462152c8bSBarry Smith EXTERN int MatFDColoringSetRecompute(MatFDColoring); 9953a7fca6bSBarry Smith EXTERN int MatFDColoringSetF(MatFDColoring,Vec); 9964e7234bfSBarry Smith EXTERN int MatFDColoringGetPerturbedColumns(MatFDColoring,int*,int*[]); 997639f9d9dSBarry Smith /* 9980752156aSBarry Smith These routines are for partitioning matrices: currently used only 9993eda8832SBarry Smith for adjacency matrix, MatCreateMPIAdj(). 10000752156aSBarry Smith */ 1001ca161407SBarry Smith 1002d9274352SBarry Smith /*S 1003d9274352SBarry Smith MatPartitioning - Object for managing the partitioning of a matrix or graph 1004d9274352SBarry Smith 1005d9274352SBarry Smith Level: beginner 1006d9274352SBarry Smith 1007d9274352SBarry Smith Concepts: partitioning 1008d9274352SBarry Smith 1009743a1026Svictorle .seealso: MatPartitioningCreate(), MatPartitioningType 1010d9274352SBarry Smith S*/ 101191e9ee9fSBarry Smith typedef struct _p_MatPartitioning *MatPartitioning; 1012d9274352SBarry Smith 1013d9274352SBarry Smith /*E 10145bc6e7ccSvictorle MatPartitioningType - String with the name of a PETSc matrix partitioning or the creation function 1015d9274352SBarry Smith with an optional dynamic library name, for example 1016d9274352SBarry Smith http://www.mcs.anl.gov/petsc/lib.a:partitioningcreate() 1017d9274352SBarry Smith 1018d9274352SBarry Smith Level: beginner 1019d9274352SBarry Smith 1020b547a13bSvictorle .seealso: MatPartitioningCreate(), MatPartitioning 1021d9274352SBarry Smith E*/ 10222aabb6bbSBarry Smith typedef char* MatPartitioningType; 10238ba1e511SMatthew Knepley #define MAT_PARTITIONING_CURRENT "current" 10248ba1e511SMatthew Knepley #define MAT_PARTITIONING_PARMETIS "parmetis" 1025ca161407SBarry Smith 1026ca44d042SBarry Smith EXTERN int MatPartitioningCreate(MPI_Comm,MatPartitioning*); 1027ca44d042SBarry Smith EXTERN int MatPartitioningSetType(MatPartitioning,MatPartitioningType); 10285bc6e7ccSvictorle EXTERN int MatPartitioningSetNParts(MatPartitioning,int); 1029ca44d042SBarry Smith EXTERN int MatPartitioningSetAdjacency(MatPartitioning,Mat); 10304e7234bfSBarry Smith EXTERN int MatPartitioningSetVertexWeights(MatPartitioning,const int[]); 10314e7234bfSBarry Smith EXTERN int MatPartitioningSetPartitionWeights(MatPartitioning,const PetscReal []); 1032ca44d042SBarry Smith EXTERN int MatPartitioningApply(MatPartitioning,IS*); 1033ca44d042SBarry Smith EXTERN int MatPartitioningDestroy(MatPartitioning); 10342aabb6bbSBarry Smith 1035ca44d042SBarry Smith EXTERN int MatPartitioningRegister(char*,char*,char*,int(*)(MatPartitioning)); 103630de9b25SBarry Smith 103730de9b25SBarry Smith /*MC 103830de9b25SBarry Smith MatPartitioningRegisterDynamic - Adds a new sparse matrix partitioning to the 103930de9b25SBarry Smith matrix package. 104030de9b25SBarry Smith 104130de9b25SBarry Smith Synopsis: 104230de9b25SBarry Smith int MatPartitioningRegisterDynamic(char *name_partitioning,char *path,char *name_create,int (*routine_create)(MatPartitioning)) 104330de9b25SBarry Smith 104430de9b25SBarry Smith Not Collective 104530de9b25SBarry Smith 104630de9b25SBarry Smith Input Parameters: 104730de9b25SBarry Smith + sname - name of partitioning (for example MAT_PARTITIONING_CURRENT) or parmetis 104830de9b25SBarry Smith . path - location of library where creation routine is 104930de9b25SBarry Smith . name - name of function that creates the partitioning type, a string 105030de9b25SBarry Smith - function - function pointer that creates the partitioning type 105130de9b25SBarry Smith 105230de9b25SBarry Smith Level: developer 105330de9b25SBarry Smith 105430de9b25SBarry Smith If dynamic libraries are used, then the fourth input argument (function) 105530de9b25SBarry Smith is ignored. 105630de9b25SBarry Smith 105730de9b25SBarry Smith Sample usage: 105830de9b25SBarry Smith .vb 105930de9b25SBarry Smith MatPartitioningRegisterDynamic("my_part",/home/username/my_lib/lib/libO/solaris/mylib.a, 106030de9b25SBarry Smith "MyPartCreate",MyPartCreate); 106130de9b25SBarry Smith .ve 106230de9b25SBarry Smith 106330de9b25SBarry Smith Then, your partitioner can be chosen with the procedural interface via 106430de9b25SBarry Smith $ MatPartitioningSetType(part,"my_part") 106530de9b25SBarry Smith or at runtime via the option 106630de9b25SBarry Smith $ -mat_partitioning_type my_part 106730de9b25SBarry Smith 106830de9b25SBarry Smith $PETSC_ARCH and $BOPT occuring in pathname will be replaced with appropriate values. 106930de9b25SBarry Smith 107030de9b25SBarry Smith .keywords: matrix, partitioning, register 107130de9b25SBarry Smith 107230de9b25SBarry Smith .seealso: MatPartitioningRegisterDestroy(), MatPartitioningRegisterAll() 107330de9b25SBarry Smith M*/ 1074aa482453SBarry Smith #if defined(PETSC_USE_DYNAMIC_LIBRARIES) 1075f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,0) 10762aabb6bbSBarry Smith #else 1077f1af5d2fSBarry Smith #define MatPartitioningRegisterDynamic(a,b,c,d) MatPartitioningRegister(a,b,c,d) 10782aabb6bbSBarry Smith #endif 10792aabb6bbSBarry Smith 1080ca44d042SBarry Smith EXTERN int MatPartitioningRegisterAll(char *); 10812bad1931SBarry Smith extern PetscTruth MatPartitioningRegisterAllCalled; 1082ca44d042SBarry Smith EXTERN int MatPartitioningRegisterDestroy(void); 10832bad1931SBarry Smith 1084b0a32e0cSBarry Smith EXTERN int MatPartitioningView(MatPartitioning,PetscViewer); 1085ca44d042SBarry Smith EXTERN int MatPartitioningSetFromOptions(MatPartitioning); 1086ca44d042SBarry Smith EXTERN int MatPartitioningGetType(MatPartitioning,MatPartitioningType*); 1087ca161407SBarry Smith 1088ca44d042SBarry Smith EXTERN int MatPartitioningParmetisSetCoarseSequential(MatPartitioning); 10890752156aSBarry Smith 10900752156aSBarry Smith /* 10910a835dfdSSatish Balay If you add entries here you must also add them to finclude/petscmat.h 1092d4fbbf0eSBarry Smith */ 10931c1c02c0SLois Curfman McInnes typedef enum { MATOP_SET_VALUES=0, 10941c1c02c0SLois Curfman McInnes MATOP_GET_ROW=1, 10951c1c02c0SLois Curfman McInnes MATOP_RESTORE_ROW=2, 10961c1c02c0SLois Curfman McInnes MATOP_MULT=3, 10971c1c02c0SLois Curfman McInnes MATOP_MULT_ADD=4, 10987c922b88SBarry Smith MATOP_MULT_TRANSPOSE=5, 10997c922b88SBarry Smith MATOP_MULT_TRANSPOSE_ADD=6, 11001c1c02c0SLois Curfman McInnes MATOP_SOLVE=7, 11011c1c02c0SLois Curfman McInnes MATOP_SOLVE_ADD=8, 11027c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE=9, 11037c922b88SBarry Smith MATOP_SOLVE_TRANSPOSE_ADD=10, 11041c1c02c0SLois Curfman McInnes MATOP_LUFACTOR=11, 11051c1c02c0SLois Curfman McInnes MATOP_CHOLESKYFACTOR=12, 11061c1c02c0SLois Curfman McInnes MATOP_RELAX=13, 11071c1c02c0SLois Curfman McInnes MATOP_TRANSPOSE=14, 11081c1c02c0SLois Curfman McInnes MATOP_GETINFO=15, 11091c1c02c0SLois Curfman McInnes MATOP_EQUAL=16, 11101c1c02c0SLois Curfman McInnes MATOP_GET_DIAGONAL=17, 11111c1c02c0SLois Curfman McInnes MATOP_DIAGONAL_SCALE=18, 11121c1c02c0SLois Curfman McInnes MATOP_NORM=19, 11131c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_BEGIN=20, 11141c1c02c0SLois Curfman McInnes MATOP_ASSEMBLY_END=21, 11151c1c02c0SLois Curfman McInnes MATOP_COMPRESS=22, 11161c1c02c0SLois Curfman McInnes MATOP_SET_OPTION=23, 11171c1c02c0SLois Curfman McInnes MATOP_ZERO_ENTRIES=24, 11181c1c02c0SLois Curfman McInnes MATOP_ZERO_ROWS=25, 11191c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_SYMBOLIC=26, 11201c1c02c0SLois Curfman McInnes MATOP_LUFACTOR_NUMERIC=27, 11211c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_SYMBOLIC=28, 11221c1c02c0SLois Curfman McInnes MATOP_CHOLESKY_FACTOR_NUMERIC=29, 1123d643ce63SMatthew Knepley MATOP_SETUP_PREALLOCATION=30, 1124d643ce63SMatthew Knepley MATOP_ILUFACTOR_SYMBOLIC=31, 1125d643ce63SMatthew Knepley MATOP_ICCFACTOR_SYMBOLIC=32, 1126d643ce63SMatthew Knepley MATOP_GET_ARRAY=33, 1127d643ce63SMatthew Knepley MATOP_RESTORE_ARRAY=34, 1128d643ce63SMatthew Knepley MATOP_DUPLCIATE=35, 1129d643ce63SMatthew Knepley MATOP_FORWARD_SOLVE=36, 1130d643ce63SMatthew Knepley MATOP_BACKWARD_SOLVE=37, 1131d643ce63SMatthew Knepley MATOP_ILUFACTOR=38, 1132d643ce63SMatthew Knepley MATOP_ICCFACTOR=39, 1133d643ce63SMatthew Knepley MATOP_AXPY=40, 1134d643ce63SMatthew Knepley MATOP_GET_SUBMATRICES=41, 1135d643ce63SMatthew Knepley MATOP_INCREASE_OVERLAP=42, 1136d643ce63SMatthew Knepley MATOP_GET_VALUES=43, 1137d643ce63SMatthew Knepley MATOP_COPY=44, 1138d643ce63SMatthew Knepley MATOP_PRINT_HELP=45, 1139d643ce63SMatthew Knepley MATOP_SCALE=46, 1140d643ce63SMatthew Knepley MATOP_SHIFT=47, 1141d643ce63SMatthew Knepley MATOP_DIAGONAL_SHIFT=48, 1142d643ce63SMatthew Knepley MATOP_ILUDT_FACTOR=49, 1143d643ce63SMatthew Knepley MATOP_GET_BLOCK_SIZE=50, 1144d643ce63SMatthew Knepley MATOP_GET_ROW_IJ=51, 1145d643ce63SMatthew Knepley MATOP_RESTORE_ROW_IJ=52, 1146d643ce63SMatthew Knepley MATOP_GET_COLUMN_IJ=53, 1147d643ce63SMatthew Knepley MATOP_RESTORE_COLUMN_IJ=54, 1148d643ce63SMatthew Knepley MATOP_FDCOLORING_CREATE=55, 1149d643ce63SMatthew Knepley MATOP_COLORING_PATCH=56, 1150d643ce63SMatthew Knepley MATOP_SET_UNFACTORED=57, 1151d643ce63SMatthew Knepley MATOP_PERMUTE=58, 1152d643ce63SMatthew Knepley MATOP_SET_VALUES_BLOCKED=59, 1153d643ce63SMatthew Knepley MATOP_GET_SUBMATRIX=60, 1154d643ce63SMatthew Knepley MATOP_DESTROY=61, 1155d643ce63SMatthew Knepley MATOP_VIEW=62, 1156d643ce63SMatthew Knepley MATOP_GET_MAPS=63, 1157d643ce63SMatthew Knepley MATOP_USE_SCALED_FORM=64, 1158d643ce63SMatthew Knepley MATOP_SCALE_SYSTEM=65, 1159d643ce63SMatthew Knepley MATOP_UNSCALE_SYSTEM=66, 1160d643ce63SMatthew Knepley MATOP_SET_LOCAL_TO_GLOBAL_MAPPING=67, 1161d643ce63SMatthew Knepley MATOP_SET_VALUES_LOCAL=68, 1162d643ce63SMatthew Knepley MATOP_ZERO_ROWS_LOCAL=69, 1163d643ce63SMatthew Knepley MATOP_GET_ROW_MAX=70, 1164d643ce63SMatthew Knepley MATOP_CONVERT=71, 1165d643ce63SMatthew Knepley MATOP_SET_COLORING=72, 1166d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIC=73, 1167d643ce63SMatthew Knepley MATOP_SET_VALUES_ADIFOR=74, 1168d643ce63SMatthew Knepley MATOP_FD_COLORING_APPLY=75, 1169d643ce63SMatthew Knepley MATOP_SET_FROM_OPTIONS=76, 1170d643ce63SMatthew Knepley MATOP_MULT_CONSTRAINED=77, 1171d643ce63SMatthew Knepley MATOP_MULT_TRANSPOSE_CONSTRAINED=78, 1172d643ce63SMatthew Knepley MATOP_ILU_FACTOR_SYMBOLIC_CONSTRAINED=79, 1173d643ce63SMatthew Knepley MATOP_PERMUTE_SPARSIFY=80, 1174d643ce63SMatthew Knepley MATOP_MULT_MULTIPLE=81, 1175d643ce63SMatthew Knepley MATOP_SOLVE_MULTIPLE=82 1176fae171e0SBarry Smith } MatOperation; 1177ca44d042SBarry Smith EXTERN int MatHasOperation(Mat,MatOperation,PetscTruth*); 1178ff8b7a98SSatish Balay EXTERN int MatShellSetOperation(Mat,MatOperation,void(*)(void)); 1179ff8b7a98SSatish Balay EXTERN int MatShellGetOperation(Mat,MatOperation,void(**)(void)); 1180273d9f13SBarry Smith EXTERN int MatShellSetContext(Mat,void*); 1181112a2221SBarry Smith 118290ace30eSBarry Smith /* 118390ace30eSBarry Smith Codes for matrices stored on disk. By default they are 118490ace30eSBarry Smith stored in a universal format. By changing the format with 1185fb9695e5SSatish Balay PetscViewerSetFormat(viewer,PETSC_VIEWER_BINARY_NATIVE); the matrices will 118690ace30eSBarry Smith be stored in a way natural for the matrix, for example dense matrices 118790ace30eSBarry Smith would be stored as dense. Matrices stored this way may only be 118890ace30eSBarry Smith read into matrices of the same time. 118990ace30eSBarry Smith */ 119090ace30eSBarry Smith #define MATRIX_BINARY_FORMAT_DENSE -1 119190ace30eSBarry Smith 11926d053be9SSatish Balay EXTERN int MatMPIBAIJSetHashTableFactor(Mat,PetscReal); 1193ca44d042SBarry Smith EXTERN int MatSeqAIJGetInodeSizes(Mat,int *,int *[],int *); 119408918a0eSSatish Balay EXTERN int MatMPIRowbsGetColor(Mat,ISColoring *); 1195860d1616SSatish Balay 1196d9274352SBarry Smith /*S 1197d9274352SBarry Smith MatNullSpace - Object that removes a null space from a vector, i.e. 1198d9274352SBarry Smith orthogonalizes the vector to a subsapce 1199d9274352SBarry Smith 1200f7a9e4ceSBarry Smith Level: advanced 1201d9274352SBarry Smith 1202d9274352SBarry Smith Concepts: matrix; linear operator, null space 1203d9274352SBarry Smith 12046e1639daSBarry Smith Users manual sections: 12056e1639daSBarry Smith . sec_singular 12066e1639daSBarry Smith 1207d9274352SBarry Smith .seealso: MatNullSpaceCreate() 1208d9274352SBarry Smith S*/ 120974637425SBarry Smith typedef struct _p_MatNullSpace* MatNullSpace; 1210d9274352SBarry Smith 12114e7234bfSBarry Smith EXTERN int MatNullSpaceCreate(MPI_Comm,int,int,const Vec[],MatNullSpace*); 121274637425SBarry Smith EXTERN int MatNullSpaceDestroy(MatNullSpace); 121374637425SBarry Smith EXTERN int MatNullSpaceRemove(MatNullSpace,Vec,Vec*); 121474637425SBarry Smith EXTERN int MatNullSpaceAttach(Mat,MatNullSpace); 121574637425SBarry Smith EXTERN int MatNullSpaceTest(MatNullSpace,Mat); 121674637425SBarry Smith 1217273d9f13SBarry Smith EXTERN int MatReorderingSeqSBAIJ(Mat A,IS isp); 1218273d9f13SBarry Smith EXTERN int MatMPISBAIJSetHashTableFactor(Mat,PetscReal); 1219273d9f13SBarry Smith EXTERN int MatSeqSBAIJSetColumnIndices(Mat,int *); 1220273d9f13SBarry Smith 12215c66b693SKris Buschelman EXTERN int MatMatMult(Mat A,Mat B, Mat *C); 12225c66b693SKris Buschelman EXTERN int MatMatMultSymbolic(Mat A,Mat B,Mat *C); 12235c66b693SKris Buschelman EXTERN int MatMatMultNumeric(Mat A,Mat B,Mat C); 12243f1d51d7SBarry Smith 1225f069c275SSatish Balay EXTERN int MatCreateMAIJ(Mat,int,Mat*); 1226c4f061fbSSatish Balay EXTERN int MatMAIJRedimension(Mat,int,Mat*); 1227c4f061fbSSatish Balay EXTERN int MatMAIJGetAIJ(Mat,Mat*); 1228c4f061fbSSatish Balay 1229b0a32e0cSBarry Smith EXTERN int MatComputeExplicitOperator(Mat,Mat*); 1230b0a32e0cSBarry Smith 123124a595ddSBarry Smith EXTERN int MatESISetType(Mat,char*); 123224a595ddSBarry Smith EXTERN int MatESISetFromOptions(Mat); 123324a595ddSBarry Smith 12342cd6534aSBarry Smith EXTERN int MatDiagonalScaleLocal(Mat,Vec); 123504f1ad80SBarry Smith 12367dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutMatrix(PetscViewer, int, int, PetscReal *); 12377dbadf16SMatthew Knepley EXTERN int PetscViewerMathematicaPutCSRMatrix(PetscViewer, int, int, int *, int *, PetscReal *); 12387dbadf16SMatthew Knepley 1239e82a3eeeSBarry Smith EXTERN int MatUseSpooles_SeqAIJ(Mat); 1240e82a3eeeSBarry Smith EXTERN int MatUseUMFPACK_SeqAIJ(Mat); 1241e82a3eeeSBarry Smith EXTERN int MatUseSuperLU_SeqAIJ(Mat); 1242e82a3eeeSBarry Smith EXTERN int MatUseEssl_SeqAIJ(Mat); 1243e82a3eeeSBarry Smith EXTERN int MatUseLUSOL_SeqAIJ(Mat); 1244e82a3eeeSBarry Smith EXTERN int MatUseMatlab_SeqAIJ(Mat); 1245e82a3eeeSBarry Smith EXTERN int MatUseDXML_SeqAIJ(Mat); 12460889b5dcSvictorle EXTERN int MatUsePETSc_SeqAIJ(Mat); 1247e82a3eeeSBarry Smith EXTERN int MatUseSuperLU_DIST_MPIAIJ(Mat); 1248e82a3eeeSBarry Smith EXTERN int MatUseSpooles_MPIAIJ(Mat); 1249e82a3eeeSBarry Smith EXTERN int MatUseSpooles_SeqSBAIJ(Mat); 1250eee76cafSHong Zhang EXTERN int MatUseSpooles_MPISBAIJ(Mat); 1251eee76cafSHong Zhang EXTERN int MatUseMUMPS_MPIAIJ(Mat); 1252e82a3eeeSBarry Smith 12532eac72dbSBarry Smith #endif 12542eac72dbSBarry Smith 12552eac72dbSBarry Smith 12569d00d63dSBarry Smith 1257