[Trilinos-Users] [EXTERNAL] vectors on overlapped maps

Heroux, Michael A maherou at sandia.gov
Fri Jun 29 14:35:13 MDT 2012


The reason you are getting a result of zero is that the Norm2 method is checking if the global IDs in the vector map are unique.  This is the first line of executable code:

  if (!Map().UniqueGIDs()) {EPETRA_CHK_ERR(-1);}

Because this check fails, the method returns with a error code of -1.  If you were to check the return value of the method call, you should see -1 returned.

The bigger question of trying to compute norms of vectors with overlapped elements is supported in some situations.  In particular, if you create an overlap map such that shared global IDs are at the end of the global ID list on each processor, you can create an additional map with non-overlap IDs and two Epetra vectors where the non-overlap is a sub vector of the overlapped vector.

The following code (adapted from your code) is approximately correct.

I hope this helps.


  int NumGlobalElements = 4; // global dimension of the problem

  int NumMyElements; // local nodes

  Epetra_IntSerialDenseVector MyGlobalElements;

  if( Comm.MyPID() == 0 ) {

    NumMyElements = 3;


    MyGlobalElements[0] = 0;

    MyGlobalElements[1] = 1;

    MyGlobalElements[2] = 2;

  } else {

    NumMyElements = 3;


    MyGlobalElements[0] = 2;

    MyGlobalElements[1] = 3;

    MyGlobalElements[2] = 1;


  // create a overlap map

  Epetra_Map Map_overlap(-1,MyGlobalElements.Length(),

MyGlobalElements.Values(),0, Comm);

  // create a non-overlap map

  Epetra_Map Map_unique(-1,MyGlobalElements.Length()-1,

 MyGlobalElements.Values(),0, Comm);

  // Create importer to handle data replication

  Epetra_Import x_unique_to_overlap(Map_overlap, Map_unique);

  // create a vector based on overlap map

  Epetra_Vector x_overlap(Map_overlap);

  // create a vector based on non-overlap map

  // Passing in the pointer to the first element of x_overlap

  // means that x_unique and x_overlap share space

  Epetra_Vector x_unique(View, Map_unique,&x_overlap[0]);

  // Now set values in x_unique (trivial in this example, but generally not)


  // Now copy replicated values to overlap vector

  x_overlap.Import(x_unique, x_unique_to_overlap, Insert);

  double myNorm;



cout<<"norm is ="<<myNorm<< " over " << x_unique.GlobalLength()<< " elements"<<endl;

From: erhan turan <turane at gmail.com<mailto:turane at gmail.com>>
Date: Friday, June 29, 2012 10:38 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: [EXTERNAL] [Trilinos-Users] vectors on overlapped maps

Hello everyone,

I have a question regarding to vector overlapped maps. Attached code is a modification of example 9 in didasko/epetra folder. A vector is created with an overlapping map.

What to expect as a norm value on two cores is 2. what you get is 0 ! Of course, this was an example on Import and Export methods - there you are also playing win Epetra_CombineMode.

My question is, why is "0" the result?  And also, should we always use Export and Import methods to deal overlapped maps? So, it is not safe to use such a naive approach even if the map is created carefully.


Erhan Turan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20120629/f39a0526/attachment.html 

More information about the Trilinos-Users mailing list