[petsc-users] Question about DMDAGetElements
Smith, Barry F.
bsmith at mcs.anl.gov
Tue Nov 13 18:02:47 CST 2018
> On Nov 13, 2018, at 3:03 PM, Jed Brown via petsc-users <petsc-users at mcs.anl.gov> wrote:
>
> Sajid Ali <sajidsyed2021 at u.northwestern.edu> writes:
>
>> I'm still confused and have the following questions :
>>
>> 1) Suppose as in the case above a DM object (created using DMCreate1D) is
>> used to created a matrix A using DMCreateMatrix, how does one convert the
>> indices obtained from DMDAGetElements to the row and column indices for the
>> matrix A ? Is there a function telling me exactly which sub-matrix each
>> rank is storing ?
>
> Submatrix?
>
>> 2) From the ex6.c example above, it looks like e corresponds to row index
>> and nen is the number of columns and i is the column index (which runs from
>> 0 to nel) when addressing the matrix elements via MatSetValuesLocal. Is
>> this correct?
>
> Yes, that's how local indices are used. It's also referenced in the man
> page.
>
>> 3) How would the indices obtained from DMDAGetElements correspond to the
>> indices for a vector created using DMCreateGlobalVector ?
>
> They don't; you want a local vector.
Similar to the MatSetValuesLocal() there is a VecSetValuesLocal() that can be used with a vector obtained with DMCreateGlobalVector() to assemble the load.
Barry
More information about the petsc-users
mailing list