On Mon, Aug 4, 2008 at 10:53 PM, Ahmed El Zein <ahmed at azein.com> wrote: > my code looks like: > ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr); > ierr = MatSetSizes(A,M,N,M,N); CHKERRQ(ierr); > ierr = MatSetType(A, MATSEQAIJ); CHKERRQ(ierr); > ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); > [...lots of MatSetValue() calls...] > ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
I think that the code should be ierr = MatCreate(PETSC_COMM_WORLD,&A); CHKERRQ(ierr); ierr = MatSetSizes(A,M,N,M,N); CHKERRQ(ierr); ierr = MatSetType(A, MATSEQAIJ); CHKERRQ(ierr); [...lots of MatSetValue() calls...] ierr = MatAssemblyBegin(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); ierr = MatAssemblyEnd(A, MAT_FINAL_ASSEMBLY); CHKERRQ(ierr); The routines MatAssemblyBegin and MatAssemblyEnd should be called after completing all calls to MatSetValues().