<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>  This is a good question.<div><br></div><div> <font face="Calibri, sans-serif">MatZeroRowsColumns() removes the rows and columns from the matrix and (optionally) updates the right hand side (and inserts values in the prescribed solution locations). Thus repeated calls cannot continue to update the right hand side vector; since the needed matrix values are gone.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">The way I solve problems where the boundary solution depends on time is by replacing that term by differentiating that equation; and do not use MatZeroRowsColumns(). So let w be the solution at some grid point on the boundary and w(t) = f(t) then I write w'(t) = f'(t) and then code the f'(t) as the right hand side for that grid point. If f(t)= c is a constant then f'(t) is zero and I just code zero as the right hand side for that point and use the initial condition w(0) = c.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">There may be better ways to do this.</font></div><div><font face="Calibri, sans-serif"><br></font></div><div><font face="Calibri, sans-serif">Barry</font></div><div><font face="Calibri, sans-serif"><br></font><div><font face="Calibri, sans-serif"><span style="font-size: 14.666667px;"><br></span></font></div><div><font face="Calibri, sans-serif"><span style="font-size: 14.666667px;"><br></span></font><div><br><blockquote type="cite"><div>On Apr 13, 2023, at 9:40 AM, Karthikeyan Chockalingam - STFC UKRI via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Hi,</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I am trying to solve the below parabolic system for a constant time interval dt</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">(M + dt * K) x = M * x^(old)</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Where,</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">M – Mass matrix</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">K – Stiffness matrix<span class="Apple-converted-space"> </span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">A = M + dt * K  (remains constant)</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I apply the boundary condition using  MatZeroRowsColumns. For homogenous boundary conditions, I notice that the A matrix remains unmodified from one-time step to the next.</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">For the non-homogenous boundary condition, I supply ‘x’ with the prescribed boundary value and pass it to MatZeroRowsColumns as follows</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; background-color: white; font-size: 8.5pt; font-family: Menlo;"><span class="s1" style="color: rgb(108, 54, 169);">MatZeroRowsColumnsIS</span>(<span class="s2" style="color: rgb(50, 109, 116);">A</span>,<span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">is</span>,<span class="Apple-converted-space"> </span><span class="s3" style="color: rgb(28, 0, 207);">1</span>,<span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">x,</span><span class="Apple-converted-space"> </span><span class="s2" style="color: rgb(50, 109, 116);">b</span>);</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">After the linear solve, I find that A is modified. So I have to reassemble A again for every time step. Is it MatZeroRowsColumns or the solve itself that modifies A and why?</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Kind regards,</div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Karthik.</div></div></div></blockquote></div><br></div></div></body></html>