[petsc-users] Equivalent to MatGetColumnVector for rows?

Matthew Knepley knepley at gmail.com
Wed Oct 19 04:49:24 CDT 2016


On Wed, Oct 19, 2016 at 4:38 AM, Jeremy Theler <jeremy at seamplex.com> wrote:

> Hi all
>
> Is there an equivalent to MatGetColumnVector() but for getting rows of a
> matrix as a vector?
>
> What I want to do is to compute the reactions of the nodes that belong
> to a Dirichlet boundary condition in a FEM linear elastic problem. I set
> these BCs with MatZeroRows() with a one in the diagonal and the desired
> displacement in the RHS vector. But before calling MatZeroRows(), I want
> to “remember” what the row looked like so after solving the problem, if
> I multipliy this original row by the solution vector I get the reaction
> corresponding to that row's DOF.
>
> I have implemented something with MatGetRow() that seems to work but it
> is some lame I am even embarrased of sharing with the list what I have
> done.
>

If you look at what that code is doing:


http://www.mcs.anl.gov/petsc/petsc-current/src/mat/utils/getcolv.c.html#MatGetColumnVector

it just puts a 1 in the vector at that column and does a MatMult(). He
codes the MatMult by hand
because no communication is necessary for in the input vector since we know
it.

You can do the same thing with MatMultTranspose() for rows, and it will do
the right thing in parallel.

   Matt


> Any suggestion is welcome.
>
> Thanks
> --
> jeremy theler
> www.seamplex.com
>
>
>


-- 
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20161019/8f5a32aa/attachment.html>


More information about the petsc-users mailing list