Re: [petsc-users] Question about MatGetRow

2023-02-04 Thread Barry Smith

> PETSC_OWN_POINTER,

indicates that the IS is to take ownership of the memory in indices, hence you 
are no longer reasonable for that memory and should not call PetscFree() on it. 
So the code is running correctly.


> On Feb 4, 2023, at 3:24 AM, 김성익  wrote:
> 
> Following your comments, that works in multi processes.
> After extracting procedure from 'newmat' which is submatrix.
> 
> PetscInt *indices;
> PetscMalloc1(1, );
> Indices[0] = 0;
> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
> (extract from newmat)
> 
> I did 'ISDestroy(); PetscFree(indices);'
> However I got an error 'double free'.
> So I deleted PetscFree. 
> Is this correct response of that error?
> If not, how should I deal with that error??
> 
> Thanks,
> Hyung Kim 
> 
> 
> 
> 
> 
> 
> 
> 2023년 2월 3일 (금) 오후 11:33, Matthew Knepley  >님이 작성:
>> On Fri, Feb 3, 2023 at 9:04 AM 김성익 > > wrote:
>>> Actually in the last mail, below scripts are running in all processes.
>>> 
>>> IS isrow;
>>> PetscInt *indices;
>>> PetscMalloc1(1, );
>>> Indices[0] = 0;
>>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
>>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>>> (extract from newmat)
>>> 
>>> However, you said it cannot get the values of first row of global matrix.
>>> Please let me know how can I fix this scripts for getting the 1st row of 
>>> global matrix in all processes.
>> 
>> Did you run and see what you get? If it is on all processes, it should work.
>> 
>>   Thanks,
>> 
>>  Matt
>>  
>>> Hyung Kim
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 2023년 2월 3일 (금) 오후 10:54, Matthew Knepley >> >님이 작성:
 On Fri, Feb 3, 2023 at 8:52 AM 김성익 >>> > wrote:
> I want to extract same row values of global matrix in all processes.
> Then how can I do this??
 
 Create the same IS on each process.
 
   THanks,
 
 Matt
  
> 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  >님이 작성:
>> On Fri, Feb 3, 2023 at 8:45 AM 김성익 > > wrote:
>>> Following your comments,
>>> If I extract first row of below matrix.
>>> 
>>> IS isrow;
>>> PetscInt *indices;
>>> PetscMalloc1(1, *indices);
>> 
>> That should be 
>>  
>>> Indices[0] = 0;
>>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES, 
>>> );
>> 
>> You should use PETSC_OWN_POINTER.
>>  
>>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>>> 
>>> 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 >> >님이 작성:
 On Fri, Feb 3, 2023 at 8:06 AM 김성익 >>> > wrote:
> Following your comments,
> I want to check below things.
> For example, the global dense matrix are as below.
> 
> If I want to get first row ('1 2 0 0 3 0 0 4') in Proc 1.
> Then I should put 'MatCreateSubMatrix 
> (mat,
>  isrow, NULL, MAT_INITIAL_MATRIX, )'
> 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  >님이 작성:
>> 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 김성익 > > 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 

Re: [petsc-users] Question about MatGetRow

2023-02-04 Thread 김성익
Following your comments, that works in multi processes.
After extracting procedure from 'newmat' which is submatrix.

PetscInt *indices;
PetscMalloc1(1, );
Indices[0] = 0;
ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
(extract from newmat)

I did 'ISDestroy(); PetscFree(indices);'
However I got an error 'double free'.
So I deleted PetscFree.
Is this correct response of that error?
If not, how should I deal with that error??

Thanks,
Hyung Kim







2023년 2월 3일 (금) 오후 11:33, Matthew Knepley 님이 작성:

> On Fri, Feb 3, 2023 at 9:04 AM 김성익  wrote:
>
>> Actually in the last mail, below scripts are running in all processes.
>>
>> IS isrow;
>> PetscInt *indices;
>> PetscMalloc1(1, );
>> Indices[0] = 0;
>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>> (extract from newmat)
>>
>> However, you said it cannot get the values of first row of global matrix.
>> Please let me know how can I fix this scripts for getting the 1st row of
>> global matrix in all processes.
>>
>
> Did you run and see what you get? If it is on all processes, it should
> work.
>
>   Thanks,
>
>  Matt
>
>
>> Hyung Kim
>>
>>
>>
>>
>>
>>
>>
>> 2023년 2월 3일 (금) 오후 10:54, Matthew Knepley 님이 작성:
>>
>>> On Fri, Feb 3, 2023 at 8:52 AM 김성익  wrote:
>>>
 I want to extract same row values of global matrix in all processes.
 Then how can I do this??

>>>
>>> Create the same IS on each process.
>>>
>>>   THanks,
>>>
>>> Matt
>>>
>>>
 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 님이 작성:

> On Fri, Feb 3, 2023 at 8:45 AM 김성익  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[0] = 0;
>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES,
>> );
>>
>
> You should use PETSC_OWN_POINTER.
>
>
>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>>
>> 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 님이 작성:
>>
>>> On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
 (
 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 님이 작성:

> 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 김성익  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/
>>> 
>>>
>>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which 

Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread Matthew Knepley
On Fri, Feb 3, 2023 at 9:04 AM 김성익  wrote:

> Actually in the last mail, below scripts are running in all processes.
>
> IS isrow;
> PetscInt *indices;
> PetscMalloc1(1, );
> Indices[0] = 0;
> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
> (extract from newmat)
>
> However, you said it cannot get the values of first row of global matrix.
> Please let me know how can I fix this scripts for getting the 1st row of
> global matrix in all processes.
>

Did you run and see what you get? If it is on all processes, it should work.

  Thanks,

 Matt


> Hyung Kim
>
>
>
>
>
>
>
> 2023년 2월 3일 (금) 오후 10:54, Matthew Knepley 님이 작성:
>
>> On Fri, Feb 3, 2023 at 8:52 AM 김성익  wrote:
>>
>>> I want to extract same row values of global matrix in all processes.
>>> Then how can I do this??
>>>
>>
>> Create the same IS on each process.
>>
>>   THanks,
>>
>> Matt
>>
>>
>>> 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 님이 작성:
>>>
 On Fri, Feb 3, 2023 at 8:45 AM 김성익  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[0] = 0;
> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES,
> );
>

 You should use PETSC_OWN_POINTER.


> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>
> 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 님이 작성:
>
>> On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
>>> (
>>> 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 님이 작성:
>>>
 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 김성익  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/
>> 
>>
>

 --
 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/
 

>>>
>>
>> --
>> 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/
>> 
>>
>

-- 
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/ 


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread 김성익
Actually in the last mail, below scripts are running in all processes.

IS isrow;
PetscInt *indices;
PetscMalloc1(1, );
Indices[0] = 0;
ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_OWN_POINTER, );
MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
(extract from newmat)

However, you said it cannot get the values of first row of global matrix.
Please let me know how can I fix this scripts for getting the 1st row of
global matrix in all processes.

Hyung Kim







2023년 2월 3일 (금) 오후 10:54, Matthew Knepley 님이 작성:

> On Fri, Feb 3, 2023 at 8:52 AM 김성익  wrote:
>
>> I want to extract same row values of global matrix in all processes.
>> Then how can I do this??
>>
>
> Create the same IS on each process.
>
>   THanks,
>
> Matt
>
>
>> 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 님이 작성:
>>
>>> On Fri, Feb 3, 2023 at 8:45 AM 김성익  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[0] = 0;
 ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES,
 );

>>>
>>> You should use PETSC_OWN_POINTER.
>>>
>>>
 MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);

 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 님이 작성:

> On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
>> (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 님이 작성:
>>
>>> 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 김성익  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/
> 
>

>>>
>>> --
>>> 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/
>>> 
>>>
>>
>
> --
> 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/
> 
>


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread Matthew Knepley
On Fri, Feb 3, 2023 at 8:52 AM 김성익  wrote:

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

Create the same IS on each process.

  THanks,

Matt


> 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 님이 작성:
>
>> On Fri, Feb 3, 2023 at 8:45 AM 김성익  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[0] = 0;
>>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES,
>>> );
>>>
>>
>> You should use PETSC_OWN_POINTER.
>>
>>
>>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>>>
>>> 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 님이 작성:
>>>
 On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
> (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 님이 작성:
>
>> 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 김성익  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/
 

>>>
>>
>> --
>> 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/
>> 
>>
>

-- 
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/ 


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread 김성익
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 님이 작성:

> On Fri, Feb 3, 2023 at 8:45 AM 김성익  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[0] = 0;
>> ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES, );
>>
>
> You should use PETSC_OWN_POINTER.
>
>
>> MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);
>>
>> 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 님이 작성:
>>
>>> On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
 (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 님이 작성:

> 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 김성익  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/
>>> 
>>>
>>
>
> --
> 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/
> 
>


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread 김성익
Following your comments,
If I extract first row of below matrix.
[image: image.png]
IS isrow;
PetscInt *indices;
PetscMalloc1(1, *indices);
Indices[0] = 0;
ISCreateGenreral(PETSC_COMM_WORLD, 1, indices, PETSC_COPY_VALUES, );
MatCreateSubMatrix(mat,isrow,NULL,MAT_INITIAL_MATRIX,);

Then can I get the array about first row of global matrix in all processes?

Hyung Kim

2023년 2월 3일 (금) 오후 10:26, Matthew Knepley 님이 작성:

> On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
>> (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 님이 작성:
>>
>>> 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 김성익  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/
> 
>


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread Matthew Knepley
On Fri, Feb 3, 2023 at 8:06 AM 김성익  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
> (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 님이 작성:
>
>> 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 김성익  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/ 


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread 김성익
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
(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.

Hyung Kim

2023년 2월 3일 (금) 오후 9:03, Mark Adams 님이 작성:

> 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 김성익  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
>>
>


Re: [petsc-users] Question about MatGetRow

2023-02-03 Thread Mark Adams
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 김성익  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
>