[petsc-users] How can I do matrix addition with different nonzeros patterns correctly?

Fangbo Wang fangbowa at buffalo.edu
Fri Mar 3 16:12:09 CST 2017


I am doing analysis on wave propagation through a linear solid media using
finite element method. The PDE from the system can be discretized to a
system of linear equations.
Newmark method is used to solve this problem with changing waves along time.

Here, the A, B, C, D mean stiffness matrix, mass matrix, damping matrix,
effective stiffness matrix of the system, respectively.  The scalars are
just some random numbers I put.

On Fri, Mar 3, 2017 at 4:55 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> > On Mar 3, 2017, at 3:31 PM, Fangbo Wang <fangbowa at buffalo.edu> wrote:
> >
> > Hi,
> >
> > I am a little bit confused on how to appropriately do matrix addition
> with different nonzeros patterns.
> >
> > Suppose I want to do D=2*A+3*B+4*C, A, B and C all have different
> nonzero patterns.
> > I know I can use MatDuplicate, MatCopy, MatConvert to create a matrix D,
> which way is the right way?
>
>    There is no particular "right way". You could use a MatDuplicate() then
> a MatScale and then two MatAXPY()
>
>    D=2*A+3*B+4*C looks like a MATLAB thing, not something you would need
> to do when solving PDEs, where do you get this need? Perhaps there is an
> alternative way to get what you want.
>
> >
> > What's the difference between MatDuplicate and MatCopy?
>
>    MatDuplicate() CREATES a new matrix while MatCopy() copies values from
> an already existing matrix to another already existing matrix.
>
>
> >
> > Thank you very much!
> >
> > Best regards,
> >
> > Fangbo
> >
> >
> > --
> > Fangbo Wang, PhD student
> > Stochastic Geomechanics Research Group
> > Department of Civil, Structural and Environmental Engineering
> > University at Buffalo
> > Email: fangbowa at buffalo.edu
>
>


-- 
Fangbo Wang, PhD student
Stochastic Geomechanics Research Group
Department of Civil, Structural and Environmental Engineering
University at Buffalo
Email: *fangbowa at buffalo.edu <fangbowa at buffalo.edu>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170303/b47708e0/attachment.html>


More information about the petsc-users mailing list