41 #include <Epetra_Util.h> 43 #include <lifev/core/LifeV.hpp> 44 #include <lifev/core/array/MapEpetra.hpp> 62 Int* myGlobalElements,
66 ASSERT (M_commPtr.get()!=0,
"Error! The communicator pointer is not valid.\n");
68 createMap ( numGlobalElements,
79 ASSERT (M_commPtr.get()!=0,
"Error! The communicator pointer is not valid.\n");
81 M_uniqueMapEpetra.reset (
new Epetra_Map ( -1,
82 mapData.unique.size(),
83 mapData.unique.data(),
86 M_repeatedMapEpetra.reset (
new Epetra_Map ( -1,
87 mapData.repeated.size(),
88 mapData.repeated.data(),
100 ASSERT (M_commPtr.get()!=0,
"Error! The communicator pointer is not valid.\n");
102 std::vector<Int> myGlobalElements ( numGlobalElements );
104 for (
Int i = 0; i < numGlobalElements; ++i )
106 myGlobalElements[i] = i;
109 M_repeatedMapEpetra.reset (
new Epetra_Map ( -1, numGlobalElements, &myGlobalElements[0], 0, *commPtr ) );
110 M_uniqueMapEpetra.reset (
new Epetra_Map ( numGlobalElements, 0, *commPtr ) );
119 ASSERT (M_commPtr.get()!=0,
"Error! The communicator pointer is not valid.\n");
121 Int numGlobalElements ( size );
122 Int numMyElements ( numGlobalElements );
123 std::vector<Int> myGlobalElements ( size );
125 for (
Int i (0); i < numGlobalElements; ++i )
127 myGlobalElements[i] = i;
129 M_repeatedMapEpetra.reset (
new Epetra_Map ( numGlobalElements,
131 &myGlobalElements[0],
135 if ( commPtr->MyPID() != 0 )
140 M_uniqueMapEpetra.reset (
new Epetra_Map ( numGlobalElements,
142 &myGlobalElements[0],
157 std::vector<Int> myGlobalElements;
158 Int* sourceGlobalElements ( blockMap.MyGlobalElements() );
159 Int const startIdOrig ( offset );
160 Int const endIdOrig ( startIdOrig + maxId );
161 const Int maxMyElements = std::min ( maxId, blockMap.NumMyElements() );
162 myGlobalElements.reserve ( maxMyElements );
165 std::sort ( myGlobalElements.begin(), myGlobalElements.end() );
168 for ( Int i (0); i < blockMap.NumMyElements(); ++i )
169 if ( sourceGlobalElements[i] < endIdOrig && sourceGlobalElements[i] >= startIdOrig )
171 myGlobalElements.push_back ( sourceGlobalElements[i] - offset );
175 myGlobalElements.size(),
176 &myGlobalElements.front(),
186 if (
this != &epetraMap )
190 M_exporter = epetraMap.M_exporter;
191 M_importer = epetraMap.M_importer;
211 if (M_commPtr.get()==0)
218 std::vector<Int> map;
220 pointer = getRepeatedMap()->MyGlobalElements();
221 for ( Int ii = 0; ii < getRepeatedMap()->NumMyElements(); ++ii, ++pointer )
223 map.push_back ( *pointer );
226 Int numGlobalElements = getUniqueMap()->NumGlobalElements();
228 pointer = epetraMap.getRepeatedMap()->MyGlobalElements();
229 for (Int ii = 0; ii < epetraMap.getRepeatedMap()->NumMyElements(); ++ii, ++pointer)
231 map.push_back ( *pointer + numGlobalElements );
234 M_repeatedMapEpetra.reset (
new Epetra_Map (-1, map.size(), map.data(), 0, *M_commPtr ) );
237 pointer = getUniqueMap()->MyGlobalElements();
239 for ( Int ii = 0; ii < getUniqueMap()->NumMyElements(); ++ii, ++pointer )
241 map.push_back ( *pointer );
244 pointer = epetraMap.getUniqueMap()->MyGlobalElements();
245 for ( Int ii = 0; ii < epetraMap.getUniqueMap()->NumMyElements(); ++ii, ++pointer )
247 map.push_back ( *pointer + numGlobalElements );
250 M_uniqueMapEpetra.reset (
new Epetra_Map ( -1, map.size(), map.data(), 0, *M_commPtr ) );
252 M_exporter.reset (
new std::shared_ptr<Epetra_Export>());
253 M_importer.reset (
new std::shared_ptr<Epetra_Import>());
262 ASSERT (
this->getUniqueMap(),
"operator+=(const Int) works only for an existing MapEpetra" );
274 std::shared_ptr<MapEpetra> rootMap (
new MapEpetra ( Epetra_Util::Create_Root_Map ( *getUniqueMap(), root ) ) );
280 if (
this == &epetraMap )
285 return ( getUniqueMap()->SameAs ( *epetraMap.getUniqueMap() ) &&
286 getRepeatedMap()->SameAs ( *epetraMap.getRepeatedMap() ) );
293 ASSERT (
M_commPtr.
get()!=0,
"Error! The stored communicator pointer is not valid.\n");
327 ASSERT (
M_commPtr.
get()!=0,
"Error! The stored communicator pointer is not valid.\n");
363 output <<
"unique map:" << std::endl;
364 output << *getUniqueMap();
365 output <<
"repeated map:" << std::endl;
366 output << *getRepeatedMap();
387 ASSERT (M_uniqueMapEpetra.get()!=0 && M_repeatedMapEpetra.get()!=0,
"Error! One (or both) the map pointers are not valid.\n");
396 ASSERT (M_uniqueMapEpetra.get()!=0 && M_repeatedMapEpetra.get()!=0,
"Error! One (or both) the map pointers are not valid.\n");
409 ASSERT (commPtr.get()!=0,
"Error! The communicator pointer is not valid.\n");
436 Int* myGlobalElements,
439 if ( numMyElements != 0 && myGlobalElements == 0 )
440 M_repeatedMapEpetra.reset (
new Epetra_Map ( numGlobalElements,
445 M_repeatedMapEpetra.reset (
new Epetra_Map ( numGlobalElements,
456 M_uniqueMapEpetra.reset (
new Epetra_Map ( Epetra_Util::Create_OneToOne_Map ( *getRepeatedMap(),
false ) ) );
458 M_exporter.reset (
new std::shared_ptr<Epetra_Export>());
459 M_importer.reset (
new std::shared_ptr<Epetra_Import>());
469 if ( M_exporter->get() == 0 )
471 M_exporter->reset (
new Epetra_Export ( *getRepeatedMap(), *getUniqueMap() ) );
474 if ( M_importer->get() == 0 )
476 M_importer->reset (
new Epetra_Import ( *getRepeatedMap(), *getUniqueMap() ) );
485 for ( Int pass (0); pass < elements.Length() - 1; pass++ )
486 for ( Int j (0); j < elements.Length() - 1; j++ )
487 if ( elements[j] > elements[j + 1] )
490 elements[j] = elements[j + 1];
491 elements[j + 1] = hold;
517 return MapVector<MapEpetra> (map1, map2);
bool mapsAreSimilar(MapEpetra const &epetraMap) const
This method return true if both the unique map and the repeated map are identical.
MapEpetra(const MapEpetra &epetraMap)
Copy constructor.
MapEpetra(const map_Type map)
Constructor from raw Epetra_Map.
mapPtr_Type M_repeatedMapEpetra
MapEpetra & operator+=(const MapEpetra &epetraMap)
Addition operator.
MapEpetra(mapData_Type const &mapData, commPtr_Type const &commPtr)
Constructor.
MapEpetra()
Empty Constructor.
MapVector< MapEpetra > operator|(const MapEpetra &map1, const MapEpetra &map2)
Juxtaposition operator.
mapPtr_Type const & getUniqueMap() const
Getter for the unique map.
int32_type Int
Generic integer data.
MapEpetra & operator+=(Int const size)
Addition operator.
void bubbleSort(Epetra_IntSerialDenseVector &elements)
Sort the element given using a bubble sort algorithm.
void updateInverseJacobian(const UInt &iQuadPt)
void createMap(Int numGlobalElements, Int numMyElements, Int *myGlobalElements, const comm_Type &comm)
Create a map.
MapEpetra(Int numGlobalElements, Int numMyElements, Int *myGlobalElements, const commPtr_Type &commPtr)
Constructor.
void setMap(mapPtr_Type map, MapEpetraType mapType)
set the internal Epetra_Maps
MapEpetra(const Int numGlobalElements, const Int notUsed, const commPtr_Type &commPtr)
Constructor.
MapEpetra(const Epetra_BlockMap &blockMap, const Int offset, const Int maxId)
Constructor.
MapEpetra(const Int size, const commPtr_Type &commPtr)
Constructor.
mapPtr_Type M_uniqueMapEpetra
void createImportExport()
Reset and rebuild the importer and exporter for the map.
Epetra_Import const & importer()
Getter for the Epetra_Import.
MapEpetra operator+(const MapEpetra &map1, const MapEpetra &map2)
Addition operator.
std::shared_ptr< map_Type > mapPtr_Type
std::shared_ptr< MapEpetra > createRootMap(Int const root) const
This method creates a pointer to a MapEpetra that has points only on processor root.
void uniqueMap()
Reset the internal unique map and recompute it using the repeated map.
This class is used to store maps that will be used for block defined problems.
MapEpetraData mapData_Type
void showMe(std::ostream &output=std::cout) const
Show informations about the map.
MapEpetra & operator=(const MapEpetra &epetraMap)
Assignment operator.
MapEpetra operator+(const MapEpetra &map, Int size)
Addition operator.
void setComm(commPtr_Type const &commPtr)
Set the communicator.
std::shared_ptr< comm_Type > commPtr_Type
mapPtr_Type const & map(MapEpetraType mapType) const
Return a shared pointer on the internal Epetra_Map.
mapPtr_Type const & getRepeatedMap() const
Getter for the repeated map.