[petsc-users] How to debug problem with MatSetValues
Matthew Knepley
knepley at gmail.com
Mon Jul 5 09:11:15 CDT 2010
On Mon, Jul 5, 2010 at 3:22 PM, Thomas Witkowski <
thomas.witkowski at tu-dresden.de> wrote:
> Hi,
>
> I've some trouble with matrix values that are set by MatSetValues, but are
> missing in the final matrix. I can reduce the problem to a 75x75 matrix that
> is created on four processors. I create it quite simple with:
>
> MatCreateMPIAIJ(PETSC_COMM_WORLD, 12, 12, 75, 75, petscMatrix) on p0
> MatCreateMPIAIJ(PETSC_COMM_WORLD, 18, 18, 75, 75, petscMatrix) on p1
> MatCreateMPIAIJ(PETSC_COMM_WORLD, 18, 18, 75, 75, petscMatrix) on p2
> MatCreateMPIAIJ(PETSC_COMM_WORLD, 27, 27, 75, 75, petscMatrix) on p3
>
> On all processors, the values are set with the following command:
>
> MatSetValues(petscMatrix, 1, &rowIndex, cols.size(), &(cols[0]),
> &(values[0]), ADD_VALUES);
>
> where rowIndex is an integer, cols is of type std::vector<int> and values
> if of type std::vector<double>. Before
I do not think this is always kosher. std::vector<> may store values however
it wants (perhaps in a
contiguous array). std::valarray<> I believe mandates a contiguous array,
however even it does not
give you access to the explicit pointer (you have to use &v[0] nonsense).
Reasons to hate the STL.
> MatSetValues is called, I run over the arrays and print all the entries
> that are added to the matrix. Finally,
>
> MatAssemblyBegin(petscMatrix, MAT_FINAL_ASSEMBLY);
> MatAssemblyEnd(petscMatrix, MAT_FINAL_ASSEMBLY);
>
> are called. To check the matrix, I use the option -mat_view_matlab. Okay,
> now some of the entries are missing and I've absolute no idea what I did
> wrong (i.e. entry row 48-col 69, which is only once by rank 3). What is the
> best way to debug the problem? I use petsc 3.0.0p11, which is compiled in
> debug mode. My code is also compiled in debug mode and valgrind does not
> report any errors. Thanks for any suggestions.
MatAssemble and MatView after every insertion.
Matt
>
> Thomas
>
>
--
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20100705/97f1b2e1/attachment.htm>
More information about the petsc-users
mailing list