[Trilinos-Users] vectors on overlapped maps

erhan turan turane at gmail.com
Sat Jun 30 11:10:23 MDT 2012


Thanks! That function is handy.

Erhan

On Sat, Jun 30, 2012 at 6:43 PM, Heroux, Michael A <maherou at sandia.gov>wrote:

>  I forgot to mention that you can make a non-overlapping map using a
> utility from Epetra.  By default it will assign shared GIDs to the
> processor with the lowest ID number.  Here is the function:
>
>
> http://trilinos.sandia.gov/packages/docs/dev/packages/epetra/doc/html/classEpetra__Util.html#a603340e974a58a652eea0c4815e4acf7
>
>  Mike
>
>   From: erhan turan <turane at gmail.com>
> Date: Saturday, June 30, 2012 11:23 AM
> To: Michael Heroux <maherou at sandia.gov>
> Cc: "trilinos-users at software.sandia.gov" <
> trilinos-users at software.sandia.gov>
> Subject: Re: [Trilinos-Users] [EXTERNAL] vectors on overlapped maps
>
>  Hi Mike,
>
>  Thanks for your advice. You're right, I forgot to check the return value
> of Norm2().  Let me think something that can be performed for non-trivial
> distribution. Maybe I can figure something out.
>
>  Erhan
>
> On Fri, Jun 29, 2012 at 10:35 PM, Heroux, Michael A <maherou at sandia.gov>wrote:
>
>>  Erhan,
>>
>>  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.
>>
>>  Mike
>>
>>    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] = 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)
>>
>>   x_unique.PutScalar(1.0);
>>
>>
>>    // Now copy replicated values to overlap vector
>>
>>   x_overlap.Import(x_unique, x_unique_to_overlap, Insert);
>>
>>
>>    double myNorm;
>>
>>
>>    assert(x_overlap.Norm2(&myNorm)==-1);
>>
>>
>>    x_unique.Norm2(&myNorm);
>>
>>
>>
>>  cout<<"norm is ="<<myNorm<< " over " << x_unique.GlobalLength()<< "
>> elements"<<endl;
>>
>>
>>
>>   From: erhan turan <turane at gmail.com>
>> Date: Friday, June 29, 2012 10:38 AM
>> To: "trilinos-users at software.sandia.gov" <
>> 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.
>>
>>  Regards,
>>
>>  Erhan Turan
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://software.sandia.gov/pipermail/trilinos-users/attachments/20120630/bae7d61b/attachment.html 


More information about the Trilinos-Users mailing list