"Jin, Shuangshuang" <[email protected]> writes: > Hello, PETSc developers, I have a question regarding the usage of > MatGetRow and MatSetValues. > > As shown in the piece of code below. I have a matrix A with n rows and > N_Steps columns, for each time step I_Steps, I want to set A[x, > I_Steps+1] = A[x, I_Steps] + someComputedValue; > > As I understand, in order to read A[x, I_Steps], I have to get the x's > rows values in A by MatGetRow; In order to set the A[x, I_Steps+1], I > have to use the MatSetValues. And these operations require the > MatAssemblyBegin and MatAssemblyEnd as well.
Yes. > The problem is when I run the code, it only works when the number of > processors equal to 1 or n. Otherwise, it's hanging there forever. > > I feel like the MatAssemblyBegin and MatAssemblyEnd may be the source > of the problem. MatAssemblyBegin and MatAssemblyEnd are collective, but you are not calling them collectively when the process count is not 1 or evenly dividing the problem size. You can get all the values you need in one shot, then set all the values with MatSetValues, then call assembly once.
pgp5f_aLHjMl1.pgp
Description: PGP signature
