[Trilinos-Users] gather a boost vector

Heroux, Mike MHeroux at CSBSJU.EDU
Tue Dec 30 15:21:02 MST 2014


Antonella,

Yes, assuming your original map and vector are distMap and distVector, resp, the basic steps are:


  1.  Create a new Epetra_Map object, say gatheredMap, such that the list of global IDs on each process consists of all global IDs in the original map.  For example, if you have 2 processes and four global IDs, such that your original map has myGlobalElements = {0, 1} on PE 0 and myGlobalElements = { 2, 3} on PE 1, then define a new array, say allGlobalElements = { 0, 1, 2, 3} on each process (both PE 0 and PE 1).
  2.  Create an Epetra_Import object, say importer, using the constructor Epetra_Import(gatheredMap, distMap).
  3.  Create an Epetra_Vector object, say gatheredVector using the gatheredMap.
  4.  Use the importer to copy the elements from distVector to gatheredVector.

The following rough code should be approximate:

Epetra_Map gatheredMap(-1, distMap.NumGlobalElements, allGlobalElements, 0, distMap.Comm());
Epetra_Import importer(gatheredMap, distMap);
Epetra_Vector gatheredVector(gatheredMap);
gatheredVector.Import(distVector, importer, Insert);

Defining the array allGlobalElements in Step 1 above is straightforward if your global IDs are contiguously.

If you are working with general global ID lists, you can create an Epetra_IntVector object with the distributed GiobalIDs as entries, then go through the above steps and create a new Epetra_IntVector on each process that contains all of the global IDs, and then go through the above four steps again as outlined.

If you have any problems, please let me know.  You should not need to write more than 10 or so lines of code to get this to work.

Mike

From: Antonella Longo <antonella.longo at ingv.it<mailto:antonella.longo at ingv.it>>
Date: Monday, December 29, 2014 at 4:08 AM
To: "trilinos-users at software.sandia.gov<mailto:trilinos-users at software.sandia.gov>" <trilinos-users at software.sandia.gov<mailto:trilinos-users at software.sandia.gov>>
Subject: [Trilinos-Users] gather a boost vector

I have a boost vector distributed according to an Epetra Map.
I need to gather on all processors this distributed boost vector.
Are there any functions in the Epetra Map for this?

--
-----------------------------------------------
Antonella Longo
Istituto Nazionale di Geofisica e Vulcanologia
Sezione di Pisa
Via Uguccione della Faggiola, 32
Pisa, Italy
email: antonella.longo at ingv.it<mailto:antonella.longo at ingv.it>
Tel. office: 050 8311939
Cell.: 339 7532089


More information about the Trilinos-Users mailing list