[petsc-users] error in petsc-dev
Mohammad Mirzadeh
mirzadeh at gmail.com
Mon Apr 30 22:05:18 CDT 2012
Barry, Matt,
Thank you both.
Mohammad
On Mon, Apr 30, 2012 at 6:05 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> On Apr 30, 2012, at 6:57 PM, Matthew Knepley wrote:
>
> > On Mon, Apr 30, 2012 at 7:01 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>
> wrote:
> > Hi,
> >
> > Just a quick question. Following
> petsc-dev/src/ksp/ksp/examples/tutorials/ex2.c, it seems that I need to
> call both MatMPIAIJSetPreallocation and MatSeqAIJSetPreallocation to be
> able to preallocate for both MPI and Seq matrices. Does petsc automatically
> chose the relevant function when the code is run in serial and parallel?
>
> Yes, it uses the relevant one and ignores any not relevant.
>
> This is a common trick in PETSc. You can think of the calls as methods
> specific to a particular subclass of the Mat class. PETSc automatically
> uses all the methods that are appropriate for the particular subclass and
> ignores all the other ones.
>
> Barry
>
>
>
> > In other words, what is the effect of
> MatMPIAIJSetPreallocation(MatSeqAIJSetPreallocation) when the code is run
> in serial(parallel)?
> >
> > I like how several functions are abstract and can be used both in serial
> and parallel (like MatCreate). Is there a similar way to just call a single
> "MatSetPreallocation" function?
> >
> >
> http://www.mcs.anl.gov/petsc/petsc-dev/docs/manualpages/Mat/MatXAIJSetPreallocation.html
> >
> > Matt
> >
> > Thanks,
> > Mohammad
> >
> > On Wed, Apr 25, 2012 at 4:04 PM, Mohammad Mirzadeh <mirzadeh at gmail.com>
> wrote:
> > Thanks Hong; that fixed the problem.
> >
> >
> > On Wed, Apr 25, 2012 at 11:31 AM, Hong Zhang <hzhang at mcs.anl.gov> wrote:
> > Mohammad:
> >
> > MatCreate(comm, &A);
> > MatSetSizes(A, localRowSize, localColumnSize, globalRowSize,
> globalColumnSize);
> > MatSetType(A, MATMPIAIJ);
> > MatMPIAIJSetPreallocation(A, 0, d_nnz, 0, o_nnz);
> > MatSetFromOptions(A);
> > MatGetOwnershipRange(A, &rStart, &rEnd);
> >
> >
> > This (even without MatSetType(A, MATMPIAIJ);) works with 3.2-p6 but not
> dev. The only difference I can see is 1) the order of MatSetFromOptions and
> 2) I do not call MatSeqAIJSetPreallocation which I think I do not need
> anyway. Is there something I'm doing wrong?
> >
> > MatSetFromOptions() must be called before MatMPIAIJSetPreallocation().
> > If user set mattype at runtime, MatSetFromOptions() picks it and set the
> type accordingly. SetPreallocation()
> > will be called after the type is set.
> >
> > Hong
> >
> > Mohammd
> >
> >
> >
> >
> >
> >
> > --
> > 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/20120430/d97f0d2a/attachment.htm>
More information about the petsc-users
mailing list