<div dir="ltr"><div dir="ltr">On Tue, May 16, 2023 at 11:12 AM K. Wu <<a href="mailto:wuktsinghua@gmail.com">wuktsinghua@gmail.com</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"><p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">Hi Matt,</p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif"> </p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">I am using two PETSc DM, one for vertices (nodes), and one
for cells (elements).</p></div></blockquote><div><br></div><div>I assume you mean DMDA.</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"><p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif"> </p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">I want to do the following operation:</p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">x is a global vector generated from DM vertices, with length
Nn. y is a global vector generated from DM cells, with length Ne. I want to
generate a sparse matrix A with size Ne x Nn, so that y = A*x.</p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">The entry of A is set to a constant value, e.g., 1/4, if the
corresponding vertex belongs to the cell.</p></div></blockquote><div>Yes, this is straightforward. First create the matrix with the same local sizes as the vectors from the DMDAs.</div><div>Each row will have the same number of nonzeros (the number of vertices on each cell), so preallocation is</div><div>easy. Finally, I would loop over the vertex grid, and put in weights for (i, j, k) and +1 in each direction for cell (i, j, k).</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> <br></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"><p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif"><span style="font-size:11pt"> </span></p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">Hope I make it clear, thanks!</p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif"> </p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">Regards,</p>
<p class="MsoNormal" style="margin:0cm 0cm 8pt;line-height:107%;font-size:11pt;font-family:Calibri,sans-serif">Kai</p></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> 于2023年5月16日周二 16:29写道:<br></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 dir="ltr">On Tue, May 16, 2023 at 10:27 AM K. Wu <<a href="mailto:wuktsinghua@gmail.com" target="_blank">wuktsinghua@gmail.com</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">Hi all,<div><br></div><div>Good day!</div><div><br></div><div>I am currently working on interploating the nodal field vector I obtained to its corresponding elemental field vector. I am doing it in a simple way by using structured mesh, the element value is just the average of its corresponding nodal values.</div><div><br></div><div>Is it possible to generate a connectivity matrix to implement this function? I also need this matrix later on to do a reverse transformation. </div><div><br></div><div>I am wondering is there a way in PETSc to generate this connectivity matrix between nodal and elemental mesh. Or is there any better way to accomplish this?</div><div><br></div><div>Thanks for your kind help!</div></div></blockquote><div><br></div><div>1. Are you using a PETSc DM, or your own mesh?</div><div><br></div><div>2. In order to define what you mean, you have to attach function spaces (or something equivalent) to the</div><div> two representations. Do you mean linear interpolation between vertices and constants on cells?</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 dir="ltr"><div></div><div>Best regards,</div><div>Kai</div></div>
</blockquote></div><br clear="all"><div><br></div><span>-- </span><br><div dir="ltr"><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>
</blockquote></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>