[petsc-users] Error message of nnz cannot be greater than block row length from MatSetValues()

Evan Um evanum at gmail.com
Thu Nov 6 19:04:04 CST 2014


Dear Jed,

In my problem, each process has a part of contiguous rows of matrix B. In
this partitioned matrix, locations of non-zero elements are irregular
because it is a part of unstructured matrix. It is hard to define the
distribution of a vector that the partitioned matrix B is multiplied with.
Both  MatSetSizes(B, partitioned_row_size, partitioned_row_size,
ngedges_internal, ngedges_internal) and MatSetSizes(B,
partitioned_row_size, PETSC_DECIDE, ngedges_internal, ngedges_internal)
produced segmentation fault errors. How should MatSetSizes() be used for
row-based-partitioned unstructured matrices?

Evan

On Thu, Nov 6, 2014 at 4:48 PM, Jed Brown <jed at jedbrown.org> wrote:

> Evan Um <evanum at gmail.com> writes:
>
> > Dear Jed,
> >
> > Thanks for your help many times. These numbers mean the total number of
> > elements to be added using MatSetValues(). For example, at process 0,
> > 148767+5821 elements are added to matrix B. In other words, the length of
> > arrays (i.e. mat_b_i_partitioned, mat_b_j_partitioned and
> > mat_b_val_partitioned)
> > is 148767+5821. I used "ADD_VALUES" but "INSERT_VALUES" should be the
> same
> > for my work.
> >
> > As you suggested, I explicitly passed the number of local rows to
> > MatSetSizes as shown below. The number of local rows agrees with a range
> of
> > continuous row indices stored at array mat_b_i_partitioned. I also
> > explicitly set up the number of local column=the matrix size. In this
> case,
> > I get error message: "Sum of local lengths 156315 does not equal global
> > length 52105, my local length 52105". I used 3 processes. I guess
> > that number 156315 seems to be related with 3*size of my global column
> > size. In my problem, the matrix is partitioned by rows but not by
> columns.
>
> Column ownership there refers to the distributiov of a vector that your
> matrix can be multiplied with, not with the ownership of entries (that
> is row-based for all of these formats, though others like MATELEMENTAL
> use totally different distributions for the entries).  Since you have a
> square matrix, you probably want
>
> MatSetSizes(B, partitioned_row_size, partitioned_row_size,
> ngedges_internal, ngedges_internal);
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20141106/0fd4b873/attachment.html>


More information about the petsc-users mailing list