[petsc-users] Question about MatGetRow

김성익 ksi2443 at gmail.com
Fri Feb 3 07:52:25 CST 2023


I want to extract same row values of global matrix in all processes.
Then how can I do this??

The case of same problem of vector, I just use vecscattertoall.
However, I can't find same function for matrix.

Hyung Kim

2023년 2월 3일 (금) 오후 10:47, Matthew Knepley <knepley at gmail.com>님이 작성:

> On Fri, Feb 3, 2023 at 8:45 AM 김성익 <ksi2443 at gmail.com> wrote:
>
>> Following your comments,
>> If I extract first row of below matrix.
>> [image: image.png]
>> IS isrow;
>> PetscInt *indices;
>> PetscMalloc1(1, *indices);
>>
>
> That should be &indices.
>
>
>> Indices[0] = 0;
>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES, &isrow);
>>
>
> You should use PETSC_OWN_POINTER.
>
>
>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,&newmat);
>>
>> Then can I get the array about first row of global matrix in all
>> processes?
>>
>
> No, just on the process which gives 0. If you do that on every process,
> every rank with get row 0.
>
>   Thanks,
>
>      Matt
>
>
>> Hyung Kim
>>
>> 2023년 2월 3일 (금) 오후 10:26, Matthew Knepley <knepley at gmail.com>님이 작성:
>>
>>> On Fri, Feb 3, 2023 at 8:06 AM 김성익 <ksi2443 at gmail.com> wrote:
>>>
>>>> Following your comments,
>>>> I want to check below things.
>>>> For example, the global dense matrix are as below.
>>>> [image: image.png]
>>>> If I want to get first row ('1 2 0 0 3 0 0 4') in Proc 1.
>>>> Then I should put 'MatCreateSubMatrix
>>>> <https://petsc.org/main/docs/manualpages/Mat/MatCreateSubMatrix/>(mat,
>>>> isrow, NULL, MAT_INITIAL_MATRIX, *&*newmat)'
>>>> and isrow will be [0 1 2 3 4 5 6 7].
>>>>
>>>> In this case, How can I make isrow?
>>>> Actually I can't understand the procedure of handling isrow.
>>>>
>>>
>>> You create an IS object of type ISGENERAL and give it the array of
>>> global indices that you want to extract.
>>>
>>>   Thanks,
>>>
>>>      Matt
>>>
>>>
>>>> Hyung Kim
>>>>
>>>> 2023년 2월 3일 (금) 오후 9:03, Mark Adams <mfadams at lbl.gov>님이 작성:
>>>>
>>>>> https://petsc.org/main/docs/manualpages/Mat/MatCreateSubMatrix/
>>>>>
>>>>> Note, PETSc lets you give NULL arguments if there is a reasonable
>>>>> default.
>>>>> In this case give NULL for the column IS and you will get the whole
>>>>> columns.
>>>>>
>>>>> Mark
>>>>>
>>>>> On Fri, Feb 3, 2023 at 4:05 AM 김성익 <ksi2443 at gmail.com> wrote:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>>
>>>>>> By using MatGetRow, user can get vectors from local matrix (at each
>>>>>> process).
>>>>>>
>>>>>> However, I need other process's row values.
>>>>>> So I have 2 questions.
>>>>>>
>>>>>> 1. Is there any function for getting arrays from other process's??
>>>>>>
>>>>>> 2. Or is there any function like matrix version of vecscattertoall??
>>>>>>
>>>>>> Thanks,
>>>>>> Hyung Kim
>>>>>>
>>>>>
>>>
>>> --
>>> What most experimenters take for granted before they begin their
>>> experiments is infinitely more interesting than any results to which their
>>> experiments lead.
>>> -- Norbert Wiener
>>>
>>> https://www.cse.buffalo.edu/~knepley/
>>> <http://www.cse.buffalo.edu/~knepley/>
>>>
>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>
> https://www.cse.buffalo.edu/~knepley/
> <http://www.cse.buffalo.edu/~knepley/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230203/f0cd7de3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 6931 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230203/f0cd7de3/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7950 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230203/f0cd7de3/attachment-0003.png>


More information about the petsc-users mailing list