<div dir="ltr"><div dir="ltr">On Sun, Sep 10, 2023 at 1:48 PM Karthikeyan Chockalingam - STFC UKRI via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</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 class="msg-3021678537039376546">
<div lang="EN-GB" style="overflow-wrap: break-word;">
<div class="m_8670309824937278731WordSection1">
<p class="MsoNormal">Hello,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have so far solved scalar field problems using finite elements on a given (<b>unstructured</b>) mesh. I made use of
<span style="color:black">MATMPIAIJ</span> to create matrixes,
<span class="m_8670309824937278731s1">MatCreateVecs</span>(<span class="m_8670309824937278731s2">A</span>, &<span class="m_8670309824937278731s2">b</span>, &<span class="m_8670309824937278731s2">x</span>) to create vectors, and
<span style="color:rgb(108,54,169)">MatZeroRowsColumnsIS
</span>to set boundary conditions.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="background:white"><span style="color:black">Now, I would like to solve a coupled system of equations for the quantities u1 and u2 on the
</span><span style="color:black">(<b>unstructured</b>) </span><span style="color:black">mesh. I.e., the matrix should get the double number of rows and columns,
<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black">A = [A00 A01
<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black"> A10 A11]</span></p></div></div></div></blockquote><div><br></div><div>This is usually not a good way to think of it. This division means that all variables of one field come before</div><div>all those of another. It is much more common to group together all the unknowns at a given point.</div><div><br></div><div>You could, if the discretizations of u1 and u2 are the same, just enlarge the blocksize of your matrix. Then you set u1 and u2 for each vec location, or a 2x2 block for each Jacobian location.</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 class="msg-3021678537039376546"><div lang="EN-GB" style="overflow-wrap: break-word;"><div class="m_8670309824937278731WordSection1">
<p class="MsoNormal" style="background:white"><span style="color:black">the vectors contain twice the number of entries (e.g. first all u1s and then all u2s). I would like to be sure that the entries of u1 and u2,
which are associated with the same element are located on the same processor.<u></u><u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black"><u></u> <u></u></span></p>
<p class="MsoNormal" style="background:white"><span style="color:black">Is a pre-defined structure already available within PETSc to enlarge such a single equation to store the entries of coupled equations?<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">-\Delta u_1+c_{11} u_1+c_{12} u_2=f_1<u></u><u></u></p>
<p class="MsoNormal">-\Delta u_2+c_{21} u_1+c_{22} u_2=f_2<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="background:white"><span style="color:black">Would I still be able to use
</span><span style="color:rgb(108,54,169)">MatZeroRowsColumnsIS
</span><span style="color:black">u1 and u2 independently to enforce boundary conditions?
</span><span style="color:rgb(108,54,169)">MatZeroRowsColumnsIS</span><span style="color:black">(</span><span style="color:rgb(50,109,116)">A</span><span style="color:black">,
</span><span style="color:rgb(50,109,116)">is</span><span style="color:black">,
</span><span style="color:rgb(28,0,207)">1</span><span style="color:black">,
</span><span style="color:rgb(50,109,116)">x</span><span style="color:black">,
</span><span style="color:rgb(50,109,116)">b</span><span style="color:black">);<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I don’t know where to begin. I have so far only been exposed to using
<span style="color:black">MATMPIAIJ and MatSetValues to create and assign values to matrix entries respectively.
</span>I would be grateful if you could provide the stepwise guide.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Kind regards,</p>
<p class="MsoNormal">Karthik.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span>-- <u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(45,45,98)">Karthik Chockalingam, Ph.D.<u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">Senior Research Software Engineer</span><span style="font-size:10.5pt;color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">High Performance Systems Engineering Group</span><span style="font-size:10.5pt;color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:black">Hartree Centre | Science and Technology Facilities Council</span><span style="font-size:10.5pt;color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(33,33,33)"><a href="mailto:karthikeyan.chockalingam@stfc.ac.uk" target="_blank">karthikeyan.chockalingam@stfc.ac.uk</a></span><span style="color:rgb(33,33,33)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12pt;font-family:"Times New Roman",serif;color:black"> </span><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(65,65,65)"> </span><span style="color:rgb(33,33,33)"><u></u><u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:10.5pt;font-family:Arial,sans-serif;color:rgb(65,65,65)"> </span></b><span style="font-size:12pt;font-family:"Times New Roman",serif;color:rgb(31,73,125)"><img border="0" width="254" height="116" style="width: 2.6458in; height: 1.2083in;" id="m_8670309824937278731Picture_x0020_1" alt="signature_3970890138"></span><span style="color:rgb(33,33,33)"><u></u><u></u></span></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><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="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>