[petsc-dev] Vec set a block of values
Matthew Knepley
knepley at gmail.com
Fri Apr 20 15:36:39 CDT 2018
On Fri, Apr 20, 2018 at 4:33 PM, Junchao Zhang <jczhang at mcs.anl.gov> wrote:
>
> On Fri, Apr 20, 2018 at 3:18 PM, Matthew Knepley <knepley at gmail.com>
> wrote:
>
>> On Fri, Apr 20, 2018 at 4:10 PM, Junchao Zhang <jczhang at mcs.anl.gov>
>> wrote:
>>
>>> To pad a vector, i.e., copy a vector to a new one, I have to call
>>> VecSetValue(newb,1,&idx,...) for each element. But to be efficient, what I
>>> really needs is to set a block of values in one call. It looks PETSc does
>>> not have a routine for that(?). I looked at VecSetValuesBlocked, but it
>>> looks it is not for that purpose.
>>> Should we have something like VecSetValuesBlock(Vec
>>> <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/Vec.html#Vec>
>>> v,PetscInt
>>> <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscInt.html#PetscInt>
>>> i,PetscInt cnt,PetscScalar
>>> <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscScalar.html#PetscScalar> *value,
>>> InsertMode
>>> <http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/InsertMode.html#InsertMode>
>>> mode) to set cnt values starting at index i?
>>>
>>
>> Use VecGetArray().
>>
> Did you mean VecGetArray b and newb, do a memcpy from b to new and then
> restore them? If yes, it does not work since some of the values I want to
> set might be remote.
> E.g, I have 4 processors. b's size is 181 and is distributed as 46,
> 45,45,45, newb is distributed as 48,45,45,45 to match a matrix of block
> size 3.
>
If values are remote, use VecScatter or PetscSF.
Matt
>
>
>>
>> Matt
>>
>>
>>> --Junchao Zhang
>>>
>>
>>
>>
>> --
>> 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
>>
>> https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
>>
>
>
--
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
https://www.cse.buffalo.edu/~knepley/ <http://www.caam.rice.edu/~mk51/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20180420/054758bb/attachment-0001.html>
More information about the petsc-dev
mailing list