[petsc-users] design philosophy question
Matthew Knepley
knepley at gmail.com
Tue Apr 21 10:00:26 CDT 2015
On Mon, Apr 20, 2015 at 7:45 PM, Gideon Simpson <gideon.simpson at gmail.com>
wrote:
> 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?
I think if you plan to compose functions like these, then leave the
Assembly() calls outside. However, if you plan to mix
ADD and INSERT calls, then you have to at least call Assembly(A,
FLUSH_ASSEMBLY) in the function.
Thanks,
Matt
> -gideon
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150421/76d5de81/attachment.html>
More information about the petsc-users
mailing list