 |
Ice Sheet System Model
4.18
Code documentation
|
Go to the documentation of this file.
10 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
15 #include "../petscincludes.h"
16 #include "../../../shared/shared.h"
42 MatSetSizes(this->
matrix,m,n,M,N);
43 MatSetFromOptions(this->
matrix);
56 #ifdef _HAVE_PETSC_MPI_
57 int* nnz =
new int[M];
58 for(
int i = 0; i < M; i++)
59 nnz[i] = o_nnz[i] + d_nnz[i];
61 PetscErrorCode ierr = MatSeqAIJSetPreallocation(this->
matrix,0,nnz);
64 PetscErrorCode ierr = MatMPIAIJSetPreallocation(this->
matrix,0,d_nnz,0,o_nnz);
66 if(ierr)
_error_(
"PETSc could not allocate matrix (probably not enough memory)");
77 if(M)idxm=xNew<int>(M);
78 if(N)idxn=xNew<int>(N);
80 for(i=0;i<M;i++)idxm[i]=i;
81 for(i=0;i<N;i++)idxn[i]=i;
84 MatSetValues(this->
matrix,M,idxm,N,idxn,serial_mat,INSERT_VALUES);
85 MatAssemblyBegin(this->
matrix,MAT_FINAL_ASSEMBLY);
86 MatAssemblyEnd(this->
matrix,MAT_FINAL_ASSEMBLY);
108 MatGetInfo(this->
matrix,MAT_GLOBAL_SUM,&info);
109 _printf0_(
"=========================== Stiffness matrix allocation info ===========================\n");
111 _printf0_(
" Block size : "<<info.block_size <<
"\n");
112 _printf0_(
" nz_allocated: "<<info.nz_allocated <<
"\n");
113 _printf0_(
" nz_used : "<<info.nz_used <<
"\n");
114 _printf0_(
" nz_unneeded : "<<info.nz_unneeded<<
" ("<<
double(info.nz_unneeded)/
double(info.nz_allocated)*100.<<
"%)\n");
116 _printf0_(
"========================================================================================\n");
121 MatView(this->
matrix,PETSC_VIEWER_STDOUT_WORLD);
127 MatAssemblyBegin(this->
matrix,MAT_FINAL_ASSEMBLY);
128 MatAssemblyEnd(this->
matrix,MAT_FINAL_ASSEMBLY);
145 MatGetSize(this->
matrix,pM,pN);
151 MatGetLocalSize(this->
matrix,pM,pN);
167 MatDuplicate(this->
matrix,MAT_COPY_VALUES,&output->
matrix);
185 if(ierr)
_error_(
"PETSc's MatSetValues reported an error");
196 MatZeroEntries(this->
matrix);
Mat NewMat(int M, int N, ISSM_MPI_Comm comm)
void AllocationInfo(void)
#define _printf0_(StreamArgs)
static ISSM_MPI_Comm GetComm(void)
MatType ISSMToPetscMatrixType(MatrixType type)
void GetLocalSize(int *pM, int *pN)
void MatMult(PetscVec *X, PetscVec *AX)
NormType ISSMToPetscNormMode(NormMode mode)
IssmDouble * ToSerial(void)
IssmDouble Norm(NormMode norm_type)
void MatMultPatch(Mat A, Vec X, Vec AX, ISSM_MPI_Comm comm)
void MatToSerial(double **poutmatrix, Mat matrix, ISSM_MPI_Comm comm)
void SetValues(int m, int *idxm, int n, int *idxn, IssmDouble *values, InsMode mode)
#define _error_(StreamArgs)
InsertMode ISSMToPetscInsertMode(InsMode mode)
void GetSize(int *pM, int *pN)
void Convert(MatrixType type)
PetscMat * Duplicate(void)