[Trilinos-Users] Fwd: [EXTERNAL] MapColoring and Epetra_Vector views

Bill Spotz wfspotz at sandia.gov
Thu Jun 20 10:42:37 MDT 2013


Sorry, I meant to reply to the whole list.

Begin forwarded message:

> From: Bill Spotz <wfspotz at sandia.gov>
> Subject: Re: [EXTERNAL] [Trilinos-Users] MapColoring and Epetra_Vector views
> Date: June 20, 2013 10:23:27 AM MDT
> To: Robert Crockett <rkcrockett at txcorp.com>
> 
> Robert,
> 
> When you use _dataPtr as the array pointer in the constructor for _epInteriorVectorPtr, the resulting Epetra_Vector assumes a contiguous block of memory whose global IDs are specified by the BlockMap you construct.  There is no layer of indirection that redirects to the original map.
> 
> If this is an unstructured problem, then the best I can think to do is to reorder your BlockMap so that all of the interior elements are at the front of your array.  Then this approach would work.  If that is not possible, another approach would be to construct _epInteriorVectorPtr with new memory instead of View, create an Epetra_Import object using the two BlockMaps, and use that import object to move data between the Epetra_Vectors as needed.
> 
> -Bill
> 
> On Jun 20, 2013, at 9:41 AM, Robert Crockett wrote:
> 
>> Hello,
>> 
>> The problem: I want to be able to extract different views from within an 
>> Epetra_Vector without creating new memory. My question is whether these 
>> views, when created using a generated map (eg. from a MapColoring) can 
>> be used transparently, eg. for assignment.
>> 
>> The specifics: I am extracting views by coloring maps, as in the following:
>> 
>>  double* _dataPtr;
>>  std::vector<int> colors;
>>  // colors filled with NT_GRID_COLOR_T enumeration
>> 
>>  _epMapPtr = new Epetra_BlockMap(totalSize, _arraySize, 1, 0,
>>                                  *_epCommPtr);
>>  _epVectorPtr = new Epetra_Vector(*_epMapPtr);
>>  _epVectorPtr->ExtractView(&_dataPtr);
>>  _epMapColoringPtr =
>>    new Epetra_MapColoring(*_epMapPtr, &colors[0], NT_INVALID_COLOR);
>>  _epInteriorVectorPtr =
>>   new Epetra_Vector(View,
>>           *_epMapColoringPtr->GenerateBlockMap(NT_INTERIOR_COLOR),
>>                     _dataPtr);
>> 
>> However, when I try to assign to _epInteriorVectorPtr, eg
>>  Epetra_Vector v;
>>  // fill v with data
>>  *_epInteriorVectorPtr = v;
>> 
>> I am not getting the expected result, ie.
>>  _epInteriorVectorPtr->Print(std::cout);
>> still shows the old values.
>> 
>> For now, I have simply created a method to explicitly write data from v 
>> back into _epVectorPtr, which then shows up correctly in the view, 
>> _epInteriorVectorPtr.
>> 
>> Is there a more elegant way to do assignment (or the problem in 
>> general), so that I am not reimplementing vector operations in that 
>> not-so-unlikely case that more flexibility from the data holder managing 
>> the vectors is necessary?
>> 
>> Thanks in advance,
>> Robert
>> 
>> 
>> -- 
>> "The mind is not a vessel to be filled but a fire to be kindled."
>> -Plutarch
>> ------------------------------------------------------------------------------------------------
>> Robert Crockett, Ph.D.            Research Scientist, Tech-X Corporation
>> rkcrockett at txcorp.com             5621 Arapahoe Avenue, Suite A
>> 303/996-2037                      Boulder, CO 80303
>> ------------------------------------------------------------------------------------------------
>> 
>> _______________________________________________
>> Trilinos-Users mailing list
>> Trilinos-Users at software.sandia.gov
>> http://software.sandia.gov/mailman/listinfo/trilinos-users
> 
> ** Bill Spotz                                              **
> ** Sandia National Laboratories  Voice: (505)845-0170      **
> ** P.O. Box 5800                 Fax:   (505)284-0154      **
> ** Albuquerque, NM 87185-0370    Email: wfspotz at sandia.gov **




More information about the Trilinos-Users mailing list