[petsc-users] Calculating the PETSc index of a DMComposite vector

Anush Krishnan anush at bu.edu
Tue Nov 12 18:42:20 CST 2013


Hi Jed,


>
> I would loop over the body points and classify them as being "within
> range" of the grid points that you own.  Ignore the points that are out
> of range.  From the interpolation patch size, you know analytically
> which owned grid points need to contribute values.  Call MatSetValues()
> or MatSetValuesLocal() for that partial row of C.  (Don't worry about
> whether you own the body point or not, and only set entries for velocity
> points that you own---because the other process will be setting the
> entries for the points they own.)
>

That's exactly what I ended up doing. Thanks!

How large are these rectangular regions?
>

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.

Depending on the distribution and access pattern, it could make sense to
> assemble C^T instead, but it likely doesn't matter.


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.

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.

Just to give you an idea of the values of d_nz and o_nz that I ended up
using:
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.
For C^T, I used d_nz=5 and o_nz=5 (A smaller number for either would
produce "Argument out of range!" errors)
For C, I needed d_nz=12 and o_nz=12.
(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.)

 What are you doing with the C once it is built?
>

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.

Thanks,
Anush
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20131112/cb6bb580/attachment.html>


More information about the petsc-users mailing list