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?

-gideon

Reply via email to