<div dir="ltr"><div dir="ltr">On Fri, May 29, 2020 at 12:16 PM Lucas Banting <<a href="mailto:bantingl@myumanitoba.ca">bantingl@myumanitoba.ca</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 dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hello,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have a structured grid problem with 5 unknowns per cell: U,V,P,T,F, this is a CFD code but I don't think these details are necessary to answer my question.
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I was wondering how exactly I should use MatSetValuesStencil() to fill my matrix.</div>
<div>I<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> have 5 degrees of freedom, so I need to set up to 25 coefficients per grid cell. I don't understand how i,j, and
c map to all coefficients.</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"><br>
</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">For a 1 degree of freedom system to fill my 9 point stencil I did:</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"><br>
</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"></span><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">
values(1)= ASW(II,JJ)</span><span><br>
</span>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(2)= AS (II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(3)= ASE(II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(4)= AW (II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(5)= AP (II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(6)= AE (II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(7)= ANW(II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(8)= AN (II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> values(9)= ANE(II,JJ)</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">
</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxm(MatStencil_i,1) = II;idxm(MatStencil_j,1) = JJ</span></div>
<div><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,1) = II-1;idxn(MatStencil_j,1) = JJ-1</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,2) = II ;idxn(MatStencil_j,2) = JJ-1</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,3) = II+1;idxn(MatStencil_j,3) = JJ-1</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,4) = II-1 ;idxn(MatStencil_j,4) = JJ</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,5) = II ;idxn(MatStencil_j,5) = JJ</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,6) = II+1;idxn(MatStencil_j,6) = JJ</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,7) = II-1 ;idxn(MatStencil_j,7) = JJ+1</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,8) = II ;idxn(MatStencil_j,8) = JJ+1</span><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> idxn(MatStencil_i,9) = II+1;idxn(MatStencil_j,9) = JJ+1</span><br>
</div>
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"> call MatSetValuesStencil(A,1,idxm,9,idxn,values,INSERT_VALUES,ierr)</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"><br>
</span></div>
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">Which seemed to work just fine. For 5 degrees of freedom, instead of just having a single AP coefficient for example,
I have an AP matrix:</span>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"><br>
</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">
<table style="border-collapse:collapse" cellspacing="0" cellpadding="1">
<tbody>
<tr style="background-color:rgb(255,255,255)">
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_uu</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_uv</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_up</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_ut</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_uf</span><br>
</td>
</tr>
<tr style="background-color:rgb(255,255,255)">
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_vu</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_vv</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_vp</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_vt</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_vf</span><br>
</td>
</tr>
<tr style="background-color:rgb(255,255,255)">
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_pu</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_pv</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_pp</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_pt</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_pf</span><br>
</td>
</tr>
<tr style="background-color:rgb(255,255,255)">
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_tu</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_tv</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_tp</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_tt</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_tf</span><br>
</td>
</tr>
<tr style="background-color:rgb(255,255,255)">
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_fu</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_fv</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_fp</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_ft</span><br>
</td>
<td style="width:100px;border-color:rgb(171,171,171);border-style:solid;border-width:1px">
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">ap_ff</span><br>
</td>
</tr>
</tbody>
</table>
</span></div>
<div><br>
</div>
<div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">In 1 degree of freedom, i and j corresponded to the solution variable in the grid. For multi degree of freedom, I
don't understand how values of i, j, and c could distinguish from an ap_uv and ap_vv coefficent for example, wouldn't they both be at i, j ,c=2?<br>
</span></div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)"></span></div>
<span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">Is there anyway I can use MatSetValuesStencil() to fill in my 9 point stencil with my 5x5 matrix coefficients? To clarify
I have nine 5x5 matrices for each cell which correspond to the 5 unknowns per cell.</span></div></div></blockquote><div><br></div><div>In MatSetValuesStencil(), I think it is best to think of the Stencils as another way of providing row/col numbers. So each MatStencil corresponds</div><div>to some row number. So your ap_uv is some entry in the input matrix, and thus corresponds to some row number (a MatStencil) and some</div><div>column number (another MatStencil). Since ap is one point, it appears that</div><div><br></div><div> ap_uv --> row = i,j,0 col = i,j,1</div><div> ap_vv --> row = i,j,1 col = i,j,1</div><div><br></div><div>So you line up your MatStencil arguments to match the order of your input. It sounds like you want the field index to be the fastest in your input.</div><div><br></div><div>Does that make sense?</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </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 dir="ltr">
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">Thanks,</span></div>
<div><br>
</div>
<div><span style="font-family:calibri,arial,helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgba(0,0,0,0)">Lucas</span><br>
</div>
</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="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>