[petsc-users] Construct Matrix based on row and column values

Elias Karabelas karabelaselias at gmail.com
Mon Mar 23 06:45:08 CDT 2020


Dear Users,

I want to implement a FCT (flux corrected transport) scheme with PETSc. 
To this end I have amongst other things create a Matrix whose entries 
are given by

L_ij = -max(0, A_ij, A_ji) for i neq j

L_ii = Sum_{j=0,..n, j neq i} L_ij

where Mat A is an (non-symmetric) Input Matrix created beforehand.

I was wondering how to do this. My first search brought me to 
https://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex16.c.html 


but this just goes over the rows of one matrix to set new values and now 
I would need to run over the rows and columns of the matrix. My Idea was 
to just create a transpose of A and do the same but then the row-layout 
will be different and I can't use the same for loop for A and AT and 
thus also won't be able to calculate the max's above.

Any help would be appreciated

Best regards

Elias



More information about the petsc-users mailing list