[petsc-users] Set nnz for Mat & MatSetValues

Shiyuan gshy2014 at gmail.com
Tue Sep 27 21:44:54 CDT 2011


Hi,
1.
 I want to allow setting the MatType by option -mat_type. It seems that I
can rewrite
  ierr=MatCreateSeqAIJ(comm,m,n,nz,nnz,A); CHKERRQ(ierr);
  to
  ierr=MatCreate(comm,A);CHKERRQ(ierr);
  ierr=MatSetSizes(*A,PETSC_DECIDE,PETSC_DECIDE,m,n);CHKERRQ(ierr);
  ierr=MatSetFromOptions(*A);CHKERRQ(ierr);
  So that the MatType can be set using -mat_type options.
  But then how can the nz or nnz be specified?

2. If we set mat_type to cusp and use MatSetValues, when do the values goto
device memory? Is it assembly first on host memory and then copy it once to
device memory together after MatAssemblyEnd() or is it done in a different
way? Does it also contain a flag to indicate whether the data value is
current?

Thanks.

 Shiyuan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110927/235a52ac/attachment.htm>


More information about the petsc-users mailing list