[petsc-users] How to create and assemble matrices for DA vectors??

Алексей Рязанов ram at ibrae.ac.ru
Sat Apr 16 15:26:47 CDT 2011


>
>
>> Create u,b with DAGetGlobalVector() and A with DAGetMatrix() and they
>> will match the DA. For eg: check: src/snes/examples/tutorials/ex5.c
>> [or some of the examples in src/dm/da/examples]
>>
>> Satish
>>
>>
Hello again!

1. Please tell me, what's the principal difference between procedures
DAGetGlobalVector and DACreateGlobalVector? I cant catch it from man pages.

2. As I can read from DAGetMatrix man page, this procedure:

Creates a matrix with the correct parallel layout and nonzero structure
required for computing the Jacobian on a function defined using the stencil
set in the
 DA

Notes: This properly preallocates the number of nonzeros in the sparse
matrix so you do not need to do it yourself.

By default it also sets the nonzero structure and puts in the zero entries.
To prevent setting the nonzero pattern call
DASetMatPreallocateOnly<../DA/DASetMatPreallocateOnly.html#DASetMatPreallocateOnly>
()

So I use DASetMatPreallocateOnly. But I dont need a Jacobian. I need a
matrix of my linear system with its original number of nonzeros per row and
its original nonzero pattern. So I use MatSetValues and MatAsseblyBegin/End
to assemble it. And -info key on runtime tells me that there were additional
mallocs during runtime. As it said in manual, this is very expensive to
allocate memory dynamically. MatMPIAIJSetPreallocation doesnt help me. How
should I preallocate memory for DAMatrix?

Thank you!

Alexey Ryazanov
______________________________________
Nuclear Safety Institute of Russian Academy of Sciences
<http://www.ibrae.ac.ru/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110417/244e98d4/attachment.htm>


More information about the petsc-users mailing list