[petsc-users] Question about DMDAGetElements

Smith, Barry F. bsmith at mcs.anl.gov
Mon Nov 19 15:38:12 CST 2018



> On Nov 19, 2018, at 3:30 PM, Sajid Ali <sajidsyed2021 at u.northwestern.edu> wrote:
> 
> I think what confused me was the fact that using DMCreateMatrix(da,&A) created a 12x12 matrix with 144 elements but summing up nel*nen from each rank gives only 2*2+3*2+3*2+3*2=20 elements. So this means that DMDAGetElements returns the elements for the vector created on the mesh and this happens to be used for indexing the matrix (created using the same DM object) via the local indices. Luckily since this code just creates a tridiagonal matrix, this works here (since if I wanted to create a dense matrix I'd want to have access to all the indices which would happen if the addressable indices at each rank (for the submatrix stored locally) add up to the size of the total matrix).

   I don't understand. This code would not work for a dense matrix where each process can set all the values via a local index. It only works when each process sets values for its local and ghost points (where the ghost points are defined by the stencil).   DMDA is not intended for problems with completely coupling of unknowns (that is dense matrices). It is meant for matrices arising from finite differences or finite elements.

  Barry


> Is my understanding correct? 
> 
> Thanks for the help! 
> 
> -- 
> Sajid Ali
> Applied Physics
> Northwestern University



More information about the petsc-users mailing list