[Trilinos-Users] Ghost nodes in Epetra_Vector

Charles Boivin charles.boivin at mayahtt.com
Wed Apr 8 09:52:03 MDT 2009


Hello,

I am trying to perform a simple task, and I think I am not getting something 
that should be relatively obvious. I am trying to accomodate having 'ghost 
values' in a distributed vector.

Say I have a total of 6 elements in the vector, and 2 processes. A 
"standard" map would be to have the elements distributed:

Process 0: 1 2 3
Process 1: 4 5 6

However, when working on element 3, access to the value at element 4 is 
needed, and similarly, access to node 3 is needed when working on node 4. 
So, really, the 'work' vector should be:

Process 0: 1 2 3 4
Process 1: 3 4 5 6

If I were to code this without Trilinos, I'd define vector of size 4, and 
make sure the value for element 3 on process 1 is copied from process 0, and 
the value of element 4 on process 1 is copied from process 1. Then whatever 
operates on my values wouldn't have to know where the actual values came 
from, just that they are available in the same vector, and it would only 
change the values of (1,2,3) and (4,5,6) on the respective processes. On the 
next cycle, the ghost values are fetched again and so on.

My question is how to accomplish the same thing elegantly using Trilinos. I 
have gone through the Epetra_Import and Epetra_Export examples, and it 
always seems like I need two vectors.

I created a map, say Map1, with elements (1,2,3) on one process and elements 
(4,5,6) on the other process. I then created a vector, let's call it X, 
based on that map. I created another map, say Map2, with elements (1,2,3,4) 
on process0 and (3,4,5,6) on process1. I created vector Y based on that map.

Using an Epetra_Import object, I can then call Y.Import() to get the proper 
values in vector Y. That works. It would imply that Y is now the vector that 
I work on, since it has the proper size. Any changes made to Y, however, are 
not automatically reflected on X; I'd then do a X.Export() using the 
importer to get the new values back in X.

It seems like I now have two copies of elements 1, 2, 3 on process 0 and 
elements 4, 5, 6 on process 1. Is that the case? Also, if I do have two 
copies, both the import and export calls are effectively copying values 
between two arrays on the same process.

Am I missing something, or is what I want to do not possible? I'd like one 
vector defined, but with room for the ghost nodes, and some mechanism to 
fetch the values of these ghost nodes from where they are "local". I guess I 
only need a 'one-way' transfer of data, i.e. from the local value to the 
ghost value. Changes to the ghost values on other processes would be 
ignored. Can this be done with Epetra?

Thanks a lot,

Charles Boivin 




More information about the Trilinos-Users mailing list