[petsc-users] Accessing Vector's ghost values

Bojan Niceno bojan.niceno at psi.ch
Thu Feb 23 16:32:18 CST 2012


Dear Mohammad,


it doesn't help me, or I did not understand your explanation.

If I do this:

   /* copy internal values (THIS WORKS, BUT COPIES NO BUFFER VALUES) */
   for(Int i=0; i<n; i++) {
     Int gi = mesh.nodes[i].global_number;
     VecGetValues(x, 1, &gi, &unk[i]);
   }

   /* copy ghost values (CREATES MANY WARNINGS */
   for(Int i=n; i<N; i++) {
     VecGetValues(x, 1, &i, &unk[i]);
   }

I get arnings are like this.

[0]PETSC ERROR: --------------------- Error Message 
------------------------------------
[0]PETSC ERROR: Argument out of range!
[0]PETSC ERROR: Can only get local values, trying 3518!
[3]PETSC ERROR: --------------------- Error Message 
------------------------------------
[3]PETSC ERROR: Argument out of range!
[3]PETSC ERROR: Can only get local values, trying 3511!
[3]PETSC ERROR: 
------------------------------------------------------------------------

What am I doing wrong here?


     Cheers,


     Bojan


On 2/23/2012 11:23 PM, Mohammad Mirzadeh wrote:
>
> just index x with the local numberings. if you have 'n' local nodes 
> and 'g' ghost nodes in x, ghost nodes indecies run from 'n' to 'n+g-1'
>
> On Feb 23, 2012 1:16 PM, "Bojan Niceno" <bojan.niceno at psi.ch 
> <mailto:bojan.niceno at psi.ch>> wrote:
>
>     Dear Jed,
>
>     thanks.
>
>     Now I have the following:
>
>     - Array unk, which should hold values inside the partition and in
>     ghost cells.  It is big enough to hold both
>     - Vec x, created by command VecCreateGhost, with proper padding
>     for ghost cells
>     - Successful call to linear solver in parallel.
>
>     But I need to copy ghost values from x to my array unk.
>
>     How can I do it?
>
>
>         Kind regards,
>
>
>         Bojan
>
>     On 2/23/2012 10:10 PM, Jed Brown wrote:
>>     On Thu, Feb 23, 2012 at 15:05, Bojan Niceno <bojan.niceno at psi.ch
>>     <mailto:bojan.niceno at psi.ch>> wrote:
>>
>>         No, I use global.
>>
>>
>>     The local form is just a local vector. It doesn't even know that
>>     a global problem exists. You can't index into it using global
>>     indices. (In general, there is no efficient way to look up
>>     information in the local vector (includes ghost points) using
>>     global indices.)
>>
>>
>>           for(Int i=0; i<n; i++) {
>>             Int gi = mesh.nodes[i].global_number;
>>             VecGetValues(x, 1, &gi, &unk[i]);
>>           }
>>
>>         "n" is defined as the number of cells inside, i.e. without
>>         buffers.  "unk" is my external array.  If I try to access
>>         buffer values, I use:
>>
>>           for(Int i=0; i<N; i++) {
>>             Int gi = mesh.nodes[i].global_number;
>>             VecGetValues(x, 1, &gi, &unk[i]);
>>           }
>>
>>         But then I end up with tons of warnings, presumably because I
>>         am going beyond "n".  Vector x was created with VecCreateGhost.
>>
>>
>
>
>     -- 
>


-- 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120223/c8c60080/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 6515 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120223/c8c60080/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Signature.png
Type: image/png
Size: 6515 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20120223/c8c60080/attachment-0001.png>


More information about the petsc-users mailing list