I am a novice at PETSC, and I have been trying to write an FVM code for steady heat conduction in 2D using PETSC (square, regular grid, Dirichlet boundaries)
Since the large matrix , say A, will be sparse I declare 5 non-zeros per row and use MatCreateSeqAIJ()
My question is about assembling the entries of the matrix. In each CV, I call MatSetValues()
and add the 5 coefficients into A using local arrays II, JJ and Values_IJ
1) Is this the "right" or "usual" way to do this? I ask because, it seems to me, am assembling by implicitly using a COO type representation of sparsity in my loop while the matrix representation in PETSC is CSR.
2) If not, is there a way to create the local arrays II, JJ and Values_IJ to fit the CSR format of the matrix and then call MatSetValues()
?