[Trilinos-Users] Import to a map that is not 1 to 1

Heroux, Michael A maherou at sandia.gov
Tue Jun 1 11:39:51 MDT 2010


Jack,

If I make the following changes to your program, things appear to work:

30c30
< int numGlobalElem=15;
---
> int numGlobalElem=16;
52c52
< Epetra_Map map2( numGlobalElem+3, myElem.Length(), myElem.Values(), 0, MyComm );
---
> Epetra_Map map2( -1, myElem.Length(), myElem.Values(), 0, MyComm );
60a61,63
> #ifdef HAVE_MPI
> MPI_Finalize();
> #endif


You didn’t have a GID of 15, so the importer constructor was complaining.  Once I changed that, I also needed to change the number of global IDs in the map2 constructor, which is easier done by putting a “-1” in that slot.

Does this help?

Mike


On 5/30/10 8:09 PM, "Jack Chessa" <jfchessa at utep.edu> wrote:

#ifdef HAVE_MPI
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif

#include "Epetra_IntSerialDenseVector.h"
#include "Epetra_IntVector.h"
#include "Epetra_Export.h"
#include "Epetra_Import.h"

using namespace std;

int main( int argc, char* argv[] )
{

// Epetra Mpi or Serial Comm
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
Epetra_MpiComm MyComm(MPI_COMM_WORLD);
#else
Epetra_SerialComm MyComm;
#endif

if ( MyComm.MyPID()==0 )
cout << "\n--------------------------------------------\n";


// do some tests with import and export classes
int numGlobalElem=15;
Epetra_IntSerialDenseVector myElem(6);
switch ( MyComm.MyPID() )
{
case 0:
myElem[0]=0; myElem[1]=1; myElem[2]=2;
myElem[3]=3; myElem[4]=4; myElem[5]=5;
break;
case 1:
myElem[0]=5; myElem[1]=6; myElem[2]=7;
myElem[3]=8; myElem[4]=9; myElem[5]=10;
break;
case 2:
myElem[0]=10; myElem[1]=11; myElem[2]=12;
myElem[3]=13; myElem[4]=14; myElem[5]=15;
break;
}
/*
map1 is like an owning dof map and map2 is like a used on processor dof
map.  We need to communicate between these maps.
*/
Epetra_Map map1( numGlobalElem, 0, MyComm );
Epetra_Map map2( numGlobalElem+3, myElem.Length(), myElem.Values(), 0, MyComm );
// Define some vectors to operate on
Epetra_IntSerialDenseVector v1Data(map1.NumMyElements());
for ( int i=0; i<v1Data.Length(); ++i )
v1Data[i]=MyComm.MyPID();
Epetra_IntVector v1(View,map1,v1Data.Values()), v2(map2);
Epetra_Import importer( map2, map1 );
if ( v2.Import( v1, importer, Insert, 0 ) )
cout << "\nWe have a problem Houston\n";
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20100601/6320a646/attachment.html 


More information about the Trilinos-Users mailing list