<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div></div><div>Hi Jed, <br> <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 class="im">
<br>
</div>I would loop over the body points and classify them as being "within<br>
range" of the grid points that you own.  Ignore the points that are out<br>
of range.  From the interpolation patch size, you know analytically<br>
which owned grid points need to contribute values.  Call MatSetValues()<br>
or MatSetValuesLocal() for that partial row of C.  (Don't worry about<br>
whether you own the body point or not, and only set entries for velocity<br>
points that you own---because the other process will be setting the<br>
entries for the points they own.)<br></blockquote><div><br></div><div>That's exactly what I ended up doing. Thanks!<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">

How large are these rectangular regions?<br></blockquote><div><br></div><div>They encompass 3x4 grid points. The velocity grid could potentially have hundreds of nodes in each direction. So they're small compared to the rest of the grid.<br>

<br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Depending on the distribution and access pattern, it could make sense to<br>
assemble C^T instead, but it likely doesn't matter.</blockquote><div><br></div><div>Could you explain why it might be better to assemble C^T? As far as the code is concerned, I don't see any difference between the two, except interchanging the row and column when I call MatSetValues. <br>

<br>For memory allocation, I know that every row of C contains exactly 12 non-zeros (since I interpolate from a 3x4 grid). But I have no idea if they are in the diagonal or the off-diagonal region of the matrix. For C^T, I can't predict beforehand how many non-zeros will be present in each row. Most rows will in fact be empty. But if I assume a "nice" solid boundary, I would imagine each velocity grid point should not be influenced by more than ~4 body points.<br>

<br></div><div>Just to give you an idea of the values of d_nz and o_nz that I ended up using: <br>The test problem consisted of a 20x20 grid in a square domain, interpolating on to a circle in the center of the domain with diameter equal to half of the domain edge. The circle is represented by 32 boundary points.<br>

</div><div>For C^T, I used d_nz=5 and o_nz=5 (A smaller number for either would produce "Argument out of range!" errors)<br></div><div>For C, I needed d_nz=12 and o_nz=12.<br></div><div>(I should clarify: The test problem actually created the matrix [Cx Cy] to map from [u v]^T to [bx by]^T. u was of size 19x20, and v was 20x19.)<br>

</div><div><br></div></div></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div> What are you doing with the C once it is built?</div></blockquote>

<div><br></div><div>I need to compute the matrix C * C^T, and use that as the left-hand side matrix of a linear system. I will also have to include C^T as part of a bigger matrix Q, and calculate Q^T*Q, but I should probably ask questions about that on a different thread.<br>

<br></div><div>Thanks,<br></div><div>Anush<br></div></div><br></div></div>