[petsc-users] Preserving nonzero structure during MatMatMult

Ghosh, Swarnava sghosh2012 at gatech.edu
Thu Sep 3 17:55:34 CDT 2015


Hi,
 
  I want to do the following:
Matrices DM1, DM2 and DM3 (MPIAIJ type) have the same non zero structure. I want to multiply DM1*DM2=DM3. BUT the resulting matrix should preserve the initial non-zero pattern that was set to it. Basically multiplication should not create new non-zero locations.

For this I do:

/* after setting the nonzero locations/*

    ierr =  MatAssemblyBegin(DM1,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
    ierr =  MatAssemblyEnd(DM1,MAT_FINAL_ASSEMBLY); CHKERRQ(ierr);
   
   MatSetOption(DM1,MAT_NEW_NONZERO_LOCATIONS,PETSC_FALSE);
   MatSetOption(DM1,MAT_KEEP_NONZERO_PATTERN,PETSC_TRUE);
   
   
 Similarly for the matrices DM2 and DM3, the above is done.

However When I do MatMatMultSymbolic, the number of non-zeros change,

BEFORE MULT: NNZ allocated : 531441.000000 NNZ used: 518155.000000 
AFTER MULT: NNZ allocated : 2350209.000000 NNZ used: 2350209.000000 


Could you let me know how do I preserve the nonzero locations after MatMatMult?

Regards,
Swarnava
-- 
Swarnava Ghosh
PhD Candidate,
Structural Engineering, Mechanics and Materials
School of Civil and Environmental Engineering
Georgia Institute of Technology
Atlanta, GA 30332


More information about the petsc-users mailing list