[Trilinos-Users] all global indices in a map
Mike Heroux
maherou at sandia.gov
Fri Mar 17 07:45:54 MST 2006
Bora,
I have done this kind of thing quite a bit using the following approach:
1) Create an Epetra_Map, map2, that has the same NumMyElements() value on
each processor as your original map, map1. This new map will have the same
number of elements but will have a contiguous list of global IDs from 0 to
NumGlobalElements()-1.
Epetra_Map map2(-1, map1.NumMyElements(), map1.IndexBase(),
map1.Comm());
2) Create another Epetra_Map, map3, that has NumMyElements on PE 0 set to
map2.NumGlobalElements(), and NumMyElements set to zero on all other
processors. This map will have a contiguous list of global IDs with the
same range as map2, but all IDs will be assigned to PE 0.
int ne = (map2.Comm().MyPID()==0) ? Map2.NumGlobalElements() : 0;
Epetra_Map map3(-1, ne, map2.IndexBase(), map2.Comm());
3) Create an Epetra_IntVector that contains the values of your original map:
Epetra_IntVector v1(View, map2, map1.MyGlobalElements());
4) Create an Epetra_IntVector using map3. This will be used to collect the
global IDs to PE 0:
Epetra_IntVector v2(map3);
5) Create importer to get global ids stored in v1 into v2:
Epetra_Import importer(map3, map2);
6) Do the import
v2.Import(v1, importer, Insert);
7) Construct the new map containing all original global ids on PE 0:
Epetra_Map map4(-1, v2.MyLength(), v2.Values(), map2.IndexBase(),
map2.Comm());
I hope this helps.
Mike
> -----Original Message-----
> From: trilinos-users-bounces at software.sandia.gov
> [mailto:trilinos-users-bounces at software.sandia.gov] On Behalf
> Of Bora Ucar
> Sent: Thursday, March 16, 2006 7:19 PM
> To: trilinos-users at software.sandia.gov
> Subject: [Trilinos-Users] all global indices in a map
>
> Hi,
>
> I need to gather global indices distributed with an
> Epetra_Map to a single processor.
> How can I do that? Is there an easy way, or do I have to call
> communication routines?
> Note: the global indices are not consecutive and are not
> linearly distributed.
>
> My scenario is the following. I have a distributed Epetra_CrsMatrix.
> Each processor extracts a set of rows and the corresponding
> columns to form a submatrix from its local matrix. Now, I
> need to gather all those extracted submatrices.
>
> Best wishes,
>
> Bora
>
>
> _______________________________________________
> Trilinos-Users mailing list
> Trilinos-Users at software.sandia.gov
> http://software.sandia.gov/mailman/listinfo/trilinos-users
>
More information about the Trilinos-Users
mailing list