<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta content="text/html; charset=utf-8">
</head>
<body>
<div dir="auto">thanks for the info.
<div dir="auto"><br>
</div>
<div dir="auto">regards,</div>
<div dir="auto">kun</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Aug 31, 2020 2:20 PM, Matthew Knepley <knepley@gmail.com> wrote:<br type="attribution">
</div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Mon, Aug 31, 2020 at 3:12 PM Barry Smith <<a href="mailto:bsmith@petsc.dev">bsmith@petsc.dev</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div style="">
<div>
<blockquote type="cite">
<div>On Aug 31, 2020, at 2:08 PM, Kun Jiao <<a href="mailto:KJiao@slb.com" target="_blank">KJiao@slb.com</a>> wrote:</div>
<br>
<div>
<div style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
If I am correct, to do this, it will double the peak memory usage.</div>
</div>
</div>
</blockquote>
<div><br>
</div>
  Yes</div>
<div><br>
<blockquote type="cite">
<div>
<div style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u><u></u></div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Is there any way no to double the peak memory usage?</div>
</div>
</div>
</blockquote>
<div><br>
</div>
  The only way would be to destroy the old matrix, allocate a new one and recompute the entries. </div>
<div><br>
</div>
<div>  Barry</div>
<div><br>
</div>
<div>  Depending on the application etc the extra memory for storing two copies of the matrix may not be a fundamental problem<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>The other thing is to look at why you are adding rows. If you know how many will eventually show up you can allocate them, but fill</div>
<div>with zeros, etc. until you get the values.</div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>     Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex">
<div style="">
<div>
<blockquote type="cite">
<div style="font-family:Helvetica; font-size:18px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; text-decoration:none">
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u><u></u></div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif; text-align:center">
<span style="font-size:10pt">Schlumberger-Private</span><u></u><u></u></div>
<div>
<div style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(225,225,225); padding:3pt 0in 0in">
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<b>From:</b><span> </span>Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank" style="color:purple; text-decoration:underline">bsmith@petsc.dev</a>><span> </span><br>
<b>Sent:</b><span> </span>Monday, August 31, 2020 1:56 PM<br>
<b>To:</b><span> </span>Kun Jiao <<a href="mailto:KJiao@slb.com" target="_blank" style="color:purple; text-decoration:underline">KJiao@slb.com</a>><br>
<b>Cc:</b><span> </span>petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" style="color:purple; text-decoration:underline">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span> </span>[Ext] Re: [petsc-users] change matrix<u></u><u></u></div>
</div>
</div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
</div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
  Kun,<u></u><u></u></div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
   This is not possible, PETSc matrices have a static size (resizing in parallel is tricky so we don't support it). <u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
   If it is more efficient to reuse the matrix entries than recompute them you can create a larger matrix and then loop over the old matrix calling MatGetRow() and then call MatSetValues() to copy that row into the new matrix.<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
  Barry<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div>
<p class="MsoNormal" style="margin:0in 0in 12pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></p>
<blockquote style="margin-top:5pt; margin-bottom:5pt">
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
On Aug 31, 2020, at 1:51 PM, Kun Jiao via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" style="color:purple; text-decoration:underline">petsc-users@mcs.anl.gov</a>> wrote:<u></u><u></u></div>
</div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Hi Petsc Experts,<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 <u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Trying to do something like appending some rows (~100 rows) to an already created matrix, but could not find any document about it.<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 <u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Could anyone provide some information about it?<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
 <u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Regards,<u></u><u></u></div>
</div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
Kun<u></u><u></u></div>
</div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span style="font-size:13.5pt; font-family:Helvetica,sans-serif"><u></u> <u></u></span></div>
<div>
<div style="margin:0in 0in 0.0001pt; font-size:11pt; font-family:Calibri,sans-serif">
<span style="font-size:10pt">Schlumberger-Private</span></div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>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><br>
</div>
<div><a href="https://urldefense.com/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!Kjv0uj3L4nM6H-I!1DsOzqE1FW189HX-Sf5RdMH_Xn_54Njs61iBLPQPM1_zafyhfPLOB8cdOlY$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>