[petsc-users] Converting a Parallel(MPI) Matrix to a Sequential Matrix

Matthew Knepley knepley at gmail.com
Mon Sep 7 10:25:04 CDT 2020


On Mon, Sep 7, 2020 at 11:21 AM Anthony Dowling <dowlinah at clarkson.edu>
wrote:

> But in theory, should I be able to get the rows or values from the
> sequential matrix and insert them into a parallel matrix manually? I think
> that would do what I need.
>

Sure, that will always work. There just isn't a function that moves
directly from a serial matrix to a parallel matrix. You could use
MatCreateSubMatrix() if you first
swapped the communicator with the parallel one, which is what we would have
to write.

  Thanks,

     Matt


> Thanks,
> Anthony Dowling
>
>
> On Mon, Sep 7, 2020 at 11:20 AM Matthew Knepley <knepley at gmail.com> wrote:
>
>> On Mon, Sep 7, 2020 at 11:17 AM Anthony Dowling <dowlinah at clarkson.edu>
>> wrote:
>>
>>> Thank you for your help, Matthew.
>>>
>>> With those methods, will I be able to copy the contents of the created
>>> serial matrices back to a parallel matrix if needed? If so, what is a good
>>> way to do that?
>>>
>>
>> There is nothing that does that right now. We would have to write it.
>>
>>   Thanks,
>>
>>      Matt
>>
>>
>>> Thanks,
>>> Anthony Dowling
>>>
>>>
>>> On Mon, Sep 7, 2020 at 11:12 AM Matthew Knepley <knepley at gmail.com>
>>> wrote:
>>>
>>>> On Mon, Sep 7, 2020 at 11:00 AM Anthony Dowling <dowlinah at clarkson.edu>
>>>> wrote:
>>>>
>>>>> Hello all,
>>>>>
>>>>> Is there a method to convert a parallel(MPI) dense matrix to a
>>>>> sequential dense matrix? Also to do the same in reverse? The code I am
>>>>> using needs to be able to convert a float** matrix to a Petsc matrix, and
>>>>> then later convert that Petsc matrix between MPI dense and sequential
>>>>> dense. How might this be achieved? The code seems to be converting float**
>>>>> matrices to Petsc properly, but I am unable to find a method to convert
>>>>> between MPI and sequential matrices.
>>>>>
>>>>
>>>> If you want the serial matrix everywhere, this is easy:
>>>> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateRedundantMatrix.html
>>>> If you want it just on 1 process, you can use:
>>>> https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatCreateSubMatrices.html
>>>>
>>>>   Thanks,
>>>>
>>>>     Matt
>>>>
>>>>
>>>>> Thanks in advance,
>>>>> Anthony Dowling
>>>>>
>>>>
>>>>
>>>> --
>>>> 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/>
>>
>

-- 
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/20200907/d1c769aa/attachment.html>


More information about the petsc-users mailing list