[Trilinos-Users] MapColoring and Epetra_Vector views

Robert Crockett rkcrockett at txcorp.com
Thu Jun 20 09:41:29 MDT 2013


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
------------------------------------------------------------------------------------------------



More information about the Trilinos-Users mailing list