[Trilinos-Users] vectors on overlapped maps
erhan turan
turane at gmail.com
Fri Jun 29 09:38:06 MDT 2012
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.
Regards,
Erhan Turan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20120629/ffba624e/attachment.html
-------------- next part --------------
#include "Epetra_ConfigDefs.h"
#ifdef HAVE_MPI
#include "mpi.h"
#include "Epetra_MpiComm.h"
#else
#include "Epetra_SerialComm.h"
#endif
#include "Epetra_Map.h"
#include "Epetra_Vector.h"
#include "Epetra_Export.h"
int main(int argc, char *argv[]) {
#ifdef HAVE_MPI
MPI_Init(&argc, &argv);
Epetra_MpiComm Comm(MPI_COMM_WORLD);
#else
Epetra_SerialComm Comm;
#endif
int NumGlobalElements = 4; // global dimension of the problem
int NumMyElements; // local nodes
Epetra_IntSerialDenseVector MyGlobalElements;
if( Comm.MyPID() == 0 ) {
NumMyElements = 3;
MyGlobalElements.Size(NumMyElements);
MyGlobalElements[0] = 0;
MyGlobalElements[1] = 1;
MyGlobalElements[2] = 2;
} else {
NumMyElements = 3;
MyGlobalElements.Size(NumMyElements);
MyGlobalElements[0] = 1;
MyGlobalElements[1] = 2;
MyGlobalElements[2] = 3;
}
// create a map
Epetra_Map Map(-1,MyGlobalElements.Length(),
MyGlobalElements.Values(),0, Comm);
// create a vector based on map
Epetra_Vector x(Map);
/*
for( int i=0 ; i<NumMyElements ; ++i ){
x[i] = 1.0;
}
*/
x.PutScalar(1.0);
double myNorm;
x.Norm2(&myNorm);
cout<<"norm is ="<<myNorm<< " over " << x.GlobalLength()<< " elements"<<endl;
#ifdef HAVE_MPI
MPI_Finalize();
#endif
return(EXIT_SUCCESS);
}
More information about the Trilinos-Users
mailing list