src/mat/tests/ex9.c and other examples in that directory use it.


> On Mar 17, 2023, at 11:05 AM, user_gong Kim <ksi2...@gmail.com> wrote:
> 
> PETSC_COMM_SELF generates an error in more than 2 processes.

It should not


> 
> I would like to use the other method you said, matcreateredundantmatrix. 
> However, there is no example in the manual. Can you give an example using 
> this function?
> 
> 
> 
> 2023년 3월 17일 (금) 오후 11:53, Barry Smith <bsm...@petsc.dev 
> <mailto:bsm...@petsc.dev>>님이 작성:
>> 
>>    Use 
>> 
>>>> MatCreate(PETSC_COMM_SELF, &mat);
>>>>  PetscViewerBinaryOpen(PETSC_COMM_SELF, "mat.bin", FILE_MODE_READ, 
>>>> &viewer);
>> 
>> 
>>     If it one program running that both views and loads the matrix you can 
>> use MatCreateRedundantMatrix() to reproduce the entire matrix on each MPI 
>> rank. It is better than using the filesystem to do it.
>> 
>> 
>>> On Mar 17, 2023, at 9:45 AM, user_gong Kim <ksi2...@gmail.com 
>>> <mailto:ksi2...@gmail.com>> wrote:
>>> 
>>> Following your comments,  I did an test.
>>> However, if I run the application in parallel. 
>>> In all processes, it is not possible to obtain values at all positions in 
>>> the matrix through MatGetValue.
>>> As in the previous case of saving in binary, it is read in parallel divided 
>>> form.
>>> Is it impossible to want to get the all value in the whole process?
>>> 
>>> 
>>> Thanks,
>>> Hyung Kim
>>> 
>>> 2023년 3월 17일 (금) 오후 7:35, Matthew Knepley <knep...@gmail.com 
>>> <mailto:knep...@gmail.com>>님이 작성:
>>>> On Fri, Mar 17, 2023 at 5:51 AM user_gong Kim <ksi2...@gmail.com 
>>>> <mailto:ksi2...@gmail.com>> wrote:
>>>>> Hello,
>>>>> 
>>>>>  
>>>>> I have 2 questions about MatView.
>>>>> 
>>>>>  
>>>>> 1.    I would like to ask if the process below is possible.
>>>>> When running in parallel, is it possible to make the matrix of the mpiaij 
>>>>> format into a txt file, output it, and read it again so that the entire 
>>>>> process has the same matrix?
>>>>> 
>>>> No. However, you can do this with a binary viewer. I suggest using
>>>> 
>>>>   MatViewFromOptions(mat, NULL, "-my_view");
>>>> 
>>>> and then the command line argument
>>>> 
>>>>   -my_view binary:mat.bin
>>>> 
>>>> and then you can read this in using
>>>> 
>>>>   MatCreate(PETSC_COMM_WORLD, &mat);
>>>>   PetscViewerBinaryOpen(PETSC_COMM_WORLD, "mat.bin", FILE_MODE_READ, 
>>>> &viewer);
>>>>   MatLoad(mat, viewer);
>>>>   ViewerDestroy(&viewer);
>>>> 
>>>>   THanks,
>>>> 
>>>>      Matt
>>>> 
>>>>  
>>>>> 2.    If possible, please let me know which function can be used to 
>>>>> create a txt file and how to read the txt file.
>>>>> 
>>>>>  
>>>>> 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/>
>> 

Reply via email to