On 5 December 2016 at 16:49, Massoud Rezavand <msdrezav...@gmail.com> wrote:

> Dear Petsc team,
>
> In order to create a parallel matrix and solve by KSP, is it possible to
> directly use MatSetValues() in runtime when each matrix entry is just
> created  without MatMPIAIJSetPreallocation()?
>

Yes, but performance will be terrible without specify any preallocation
info.
See this note
http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatMPIAIJSetPreallocation.html

For a code example of for how to do the assembly without preallocation (not
recommended), you can refer to this (its the same pattern for MPIAIJ)

http://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex1.c.html


>
> I mean, when you only know the global size of Mat, and the number of
> nonzeros per row is not constant neither for all rows nor during time, is
> it possible to set the singular entries into Mat one by one after creating
> each one?
>

Why don't you just destroy the matrix and create a new one every time the
non-zero structure changes?
That's what I recommended last time.


Thanks,
  Dave


> Thanks
> Massoud
>
>
>
>
>
>
>

Reply via email to