[Trilinos-Users] Epetra Import / Export
daniel.santos.olivan at upc.edu
daniel.santos.olivan at upc.edu
Wed Jun 14 11:40:10 EDT 2017
Hello,
I am trying to understand how the Import/Export functions work but I
have troubles to make it work. I have tried to reduce it to one
elemental problem to see it f you can help me with that.
I have a Epetra_Vector distributed in two different Images. 4 elements
in Image 0 and 2 elements in Image 1.
What I want is to communicate the two elements of Image 1 to all the
rest of the Images. Now it is only one but in general I want to
communicate from one image to all the rest. How can I do that?
I have tried to make it based in exameple9 of didaskos but it explodes:
Epetra_IntSerialDenseVector MyGlobalElements;
if(Comm.MyPID() == 0 ) {
NumMyElements = 4;
MyGlobalElements.Size(NumMyElements);
MyGlobalElements[0] = 0;
MyGlobalElements[1] = 1;
MyGlobalElements[2] = 2;
MyGlobalElements[3] = 3;
} else if(Comm.MyPID() == 1 )
{
NumMyElements = 2;
MyGlobalElements.Size(NumMyElements);
MyGlobalElements[0] = 4;
MyGlobalElements[1] = 5;
}
else
{
NumMyElements = 0;
MyGlobalElements.Size(NumMyElements);
}
// create a map
Epetra_Map Map(-1,MyGlobalElements.Length(),
MyGlobalElements.Values(),0, Comm);
Epetra_Vector x(Map);
for( int i=0 ; i<NumMyElements ; ++i )
x[i] = 10*( Comm.MyPID()+1 ) + i;
cout << x;
Epetra_IntSerialDenseVector SourceElements;
if(Comm.MyPID() == 0 ) {
NumMyElements = 2;
SourceElements.Size(NumMyElements);
SourceElements[0] = 4;
SourceElements[1] = 5;
} else if(Comm.MyPID() == 1 )
{
NumMyElements = 2;
SourceElements.Size(NumMyElements);
SourceElements[0] = 4;
SourceElements[1] = 5;
}
Epetra_Map SourceMap(-1,SourceElements.Length(),
SourceElements.Values(),0, Comm);
int Elements_p1 = 2;
Epetra_Map TargetMap(-1, Elements_p1, 0, Comm);
Epetra_Export Exporter(SourceMap,TargetMap);
// work on vectors
Epetra_Vector y(TargetMap);
y.Export(x,Exporter,Insert);
cout << y;
------------------
I have tried to search examples of the use of Import / Export but I
couldn't find any, there is some place I can look?
Thank you very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://trilinos.org/pipermail/trilinos-users/attachments/20170614/0d6facb1/attachment.html>
More information about the Trilinos-Users
mailing list