<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 3, 2017 at 5:12 PM, Fangbo Wang <span dir="ltr"><<a href="mailto:fangbowa@buffalo.edu" target="_blank">fangbowa@buffalo.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.<div>Newmark method is used to solve this problem with changing waves along time.</div><div><br></div><div>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.</div></div></blockquote><div><br></div><div>Since this is explicit, you should just be assembling the entire system directly in to one matrix, rather than making several matrices and doing algebra.</div><div><br></div><div>   Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 3, 2017 at 4:55 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
> On Mar 3, 2017, at 3:31 PM, Fangbo Wang <<a href="mailto:fangbowa@buffalo.edu" target="_blank">fangbowa@buffalo.edu</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I am a little bit confused on how to appropriately do matrix addition with different nonzeros patterns.<br>
><br>
> Suppose I want to do D=2*A+3*B+4*C, A, B and C all have different nonzero patterns.<br>
> I know I can use MatDuplicate, MatCopy, MatConvert to create a matrix D, which way is the right way?<br>
<br>
</span>   There is no particular "right way". You could use a MatDuplicate() then a MatScale and then two MatAXPY()<br>
<br>
   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.<br>
<span><br>
><br>
> What's the difference between MatDuplicate and MatCopy?<br>
<br>
</span>   MatDuplicate() CREATES a new matrix while MatCopy() copies values from an already existing matrix to another already existing matrix.<br>
<div class="m_1849165826823062631HOEnZb"><div class="m_1849165826823062631h5"><br>
<br>
><br>
> Thank you very much!<br>
><br>
> Best regards,<br>
><br>
> Fangbo<br>
><br>
><br>
> --<br>
> Fangbo Wang, PhD student<br>
> Stochastic Geomechanics Research Group<br>
> Department of Civil, Structural and Environmental Engineering<br>
> University at Buffalo<br>
> Email: <a href="mailto:fangbowa@buffalo.edu" target="_blank">fangbowa@buffalo.edu</a><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_1849165826823062631gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><font size="1" color="#9900ff">Fangbo Wang, PhD student</font></div><div><font size="1" color="#9900ff">Stochastic Geomechanics Research Group</font></div><div><span style="color:rgb(153,0,255);font-size:x-small">Department of Civil, Structural and Environmental Engineering</span></div><div><font size="1" color="#9900ff">University at Buffalo</font></div><div><font size="1" color="#9900ff">Email: <u><a href="mailto:fangbowa@buffalo.edu" target="_blank">fangbowa@buffalo.edu</a></u></font></div></div></div></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>