<div dir="ltr"><div>So, DMDA is used for sparse matrices arising from FD/FE and MatCreateMPIAIJ can be used for dense matrices (though it is strongly discouraged). <br><br></div>My confusion stemmed from DMDAGetElements giving the element indices for the 1D mesh/vector of size N(when the DMDACreate1d is used). But these indices were then used as local indices to set the values for a 2D matrix (via
<span class="gmail-pl-c1">MatSetValuesLocal</span>
) created using the same DM (now we have NxN elements). <br><br></div>