[petsc-users] design philosophy question

Gideon Simpson gideon.simpson at gmail.com
Mon Apr 20 19:45:27 CDT 2015

In cutting up a petsc code into subroutines, is there any design philosophy as to when to call global routines, like assemble?  The problem I have in mind is that I want to build up a matrix, allowing for it to be of MPIAIJ type.  Currently, I’m populating it row by row with a loop using MatSetValues.  Since this is an uninteresting piece of the code, and it may be reused elsewhere, I was thinking of writing, in a separate file:

PetscErrorCode ConstructMat(Mat A)

But within ConstructMat, should I only populate the entries? Is it better design to put MatAssemblyBegin/End in that, or in the main program, after this has been called?


More information about the petsc-users mailing list