[petsc-users] Questions about creation of matrix and setting its values

Cong Li solvercorleone at gmail.com
Wed Aug 5 04:47:53 CDT 2015


Thanks, Patrick.
I think I got it now.

Cong Li

On Wed, Aug 5, 2015 at 3:45 PM, Patrick Sanan <patrick.sanan at gmail.com>
wrote:

>
>
>
>
> Am 05.08.2015 um 08:23 schrieb Cong Li <solvercorleone at gmail.com>:
>
> Hi,
>
> I am wondering if it is necessary to call
> MatAssemblyBegin() and MatAssemblyEnd() after MatDuplicate() with the
> option of MAT_DO_NOT_COPY_VALUES.
> For example, if I have an assembled matrix A, and I call MatDuplicate() to
> create B, which is a duplication of A.
> Do I need to call MatAssemblyBegin() and MatAssemblyEnd() for B.
>
> And 2nd question is :
> just after the MatCreateDense() call and before MatAssemblyBegin()
> and MatAssemblyEnd() calls, can I use MatGetArray() ?
>
> The 3rd question is:
> before the MatAssemblyBegin() and MatAssemblyEnd() calls, should I use
> INSERT_VALUES or ADD_VALUES for MatSetValues call? And why ?
> Actually I have read the manual, but I still feel confused about the means
> of INSERT_VALUES and ADD_VALUES.
>
> There are a couple of reasons that you need to make these
> MatAssemblyBegin/End calls:
> - entries can be set which should be stored on a different process, so
> these need to be communicated
> - for compressed formats like CSR (as used in MATAIJ and others) the
> entries need to be processed into their compressed form
> In general, the entries of the matrix are not stored in their "usable"
> forms until you make the MatAssembleEnd call. Rather they are kept in some
> easy-to-insert-into intermediate storage. INSERT_VALUES means that old
> values that might be in the matrix are overwritten , and ADD_VALUES means
> that the new entries from intermediate storage are added to the old values.
>
>
>
> Thanks
>
> Cong Li
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150805/9bba1e91/attachment.html>


More information about the petsc-users mailing list