[petsc-users] How to debug problem with MatSetValues

Thomas Witkowski thomas.witkowski at tu-dresden.de
Mon Jul 5 08:22:50 CDT 2010


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 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.

Thomas



More information about the petsc-users mailing list