41 #ifndef EPETRAEXT_MIGRATE_H
42 #define EPETRAEXT_MIGRATE_H
44 #if defined(EpetraExt_SHOW_DEPRECATED_WARNINGS)
46 #warning "The EpetraExt package is deprecated"
70 template <
typename KT,
typename DT>
75 typedef typename std::map< KT, Teuchos::RCP<DT> >
DataMap;
88 typedef typename std::vector<char>
Buffer;
111 void operator()( std::vector<int>
const & pList,
112 std::vector<KT>
const & iKeys,
113 std::vector<KT> & oKeys );
115 void operator()( std::vector<int>
const & pList,
119 void rvs( std::vector<int>
const & pList,
120 std::vector<KT>
const & keys,
135 template <
typename DT>
148 typedef typename std::vector<char>
Buffer;
171 void operator()( std::vector<int>
const & pList,
175 void rvs( std::vector<int>
const & pList,
190 template <
typename KT,
typename DT>
194 std::vector<KT>
const & iKeys,
195 std::vector<KT> & oKeys )
200 int exportCnt = pList.size();
205 for( ; citKL != cendKL; ++citKL )
209 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
212 comm_.MaxAll( &max_size, &max_all, 1 );
214 exports_.resize( max_all * exportCnt );
216 if( importSize_ < (max_all*importCnt) )
218 if( importSize_ )
delete [] imports_;
219 importSize_ = (max_all*importCnt);
220 imports_ =
new char[importSize_];
224 citKL = iKeys.begin();
225 for(
int i = 0; citKL != cendKL; ++citKL, ++i )
231 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
233 oKeys.resize( importCnt );
234 for(
int i = 0; i < importCnt; ++i )
245 template <
typename KT,
typename DT>
255 int exportCnt = pList.size();
260 for( ; citDM != cendDM; ++citDM )
265 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
268 comm_.MaxAll( &max_size, &max_all, 1 );
270 exports_.resize( max_all * exportCnt );
272 if( importSize_ < (max_all*importCnt) )
274 if( importSize_ )
delete [] imports_;
275 importSize_ = (max_all*importCnt);
276 imports_ =
new char[importSize_];
280 citDM = iData.begin();
281 for(
int i = 0; citDM != cendDM; ++citDM, ++i )
288 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
292 for(
int i = 0; i < importCnt; ++i )
298 oData.insert(
DataPair( key, data ) );
304 for( ; citDM != cendDM; ++citDM )
305 oData.insert( *citDM );
309 template <
typename KT,
typename DT>
312 rvs( std::vector<int>
const & pList,
313 std::vector<KT>
const & keys,
320 int importCnt = pList.size();
323 distributor.
CreateFromSends( importCnt, &(pList[0]),
true, exportCnt );
325 if( exportCnt != keys.size() )
326 N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL,
327 "Xyce::Parallel::Migrate::rvs Failed Size Match!\n" );
332 for( ; citKL != cendKL; ++citKL )
337 comm_.MaxAll( &max_size, &max_all, 1 );
339 exports_.resize( max_all * exportCnt );
341 if( importSize_ < (max_all*importCnt) )
343 if( importSize_ )
delete [] imports_;
344 importSize_ = (max_all*importCnt);
345 imports_ =
new char[importSize_];
350 citKL = keys.begin();
351 for( ; citKL != cendKL; ++citKL, ++i )
358 distributor.
DoReverse( &(exports_[0]), max_all, importSize_, imports_ );
362 for(
int i = 0; i < importCnt; ++i )
375 template <
typename DT>
385 int exportCnt = pList.size();
390 for( ; citDC != cendDC; ++citDC )
394 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
397 comm_.MaxAll( &max_size, &max_all, 1 );
399 exports_.resize( max_all * exportCnt );
401 if( importSize_ < (max_all*importCnt) )
403 if( importSize_ )
delete [] imports_;
404 importSize_ = (max_all*importCnt);
405 imports_ =
new char[importSize_];
409 citDC = iData.begin();
410 for(
int i = 0; citDC != cendDC; ++citDC, ++i )
416 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
419 for(
int i = 0; i < importCnt; ++i )
424 oData.push_back( data );
432 template <
typename DT>
435 rvs( std::vector<int>
const & pList,
442 int importCnt = pList.size();
445 distributor.
CreateFromSends( importCnt, &(pList[0]),
true, exportCnt );
447 if( exportCnt != keys.size() )
448 N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL,
449 "Xyce::Parallel::Migrate::rvs Failed Size Match!\n" );
454 for( ; citDC != cendDC; ++citDC )
458 comm_.MaxAll( &max_size, &max_all, 1 );
460 exports_.resize( max_all * exportCnt );
462 if( importSize_ < (max_all*importCnt) )
464 if( importSize_ )
delete [] imports_;
465 importSize_ = (max_all*importCnt);
466 imports_ =
new char[importSize_];
471 citDC = iData.begin();
472 for( ; citDC != cendDC; ++citDC, ++i )
478 distributor.
DoReverse( &(exports_[0]), max_all, importSize_, imports_ );
481 for(
int i = 0; i < importCnt; ++i )
486 oData.push_back( data );
Traits for packing and unpacking of data into char buffers for communication.
bool operator==(Migrate1 const &right) const
std::vector< KT > KeyList
bool operator!=(Migrate1 const &right) const
void rvs(std::vector< int > const &pList, std::vector< KT > const &keys, std::map< KT, Teuchos::RCP< DT > > &iData, std::map< KT, Teuchos::RCP< DT > > &oData)
KeyList::const_iterator KeyListCIter
std::vector< int > ProcList
static void unpack(T &object, char *buf, size_t size, int &pos)
Unpacks object from char buffer.
DataMap::value_type DataPair
std::map< KT, Teuchos::RCP< DT > > DataMap
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
bool operator==(Migrate const &right) const
Teuchos::RCP< DT > DataPtr
DataMap::iterator DataMapIter
static void pack(T const &object, char *buf, size_t size, int &pos)
Packs object into char buffer.
std::vector< char > Buffer
int CreateFromSends(const int &NumExportIDs, const int *ExportPIDs, bool Deterministic, int &NumRemoteIDs)
ProcList::iterator ProcListIter
void rvs(std::vector< int > const &pList, std::vector< Teuchos::RCP< DT > > const &iData, std::vector< Teuchos::RCP< DT > > &oData)
Data Migration Utility used by EpetraExt::Directory.
bool operator!=(Migrate const &right) const
void operator()(std::vector< int > const &pList, std::vector< Teuchos::RCP< DT > > const &iData, std::vector< Teuchos::RCP< DT > > &oData)
std::vector< char > Buffer
ProcList::iterator ProcListIter
DataContainer::const_iterator DataContainerCIter
std::vector< DataPtr > DataContainer
Migrate1(Epetra_Comm &comm)
DataMap::const_iterator DataMapCIter
int Do(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
std::vector< int > ProcList
Migrate(Epetra_Comm &comm)
int DoReverse(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)
DataContainer::iterator DataContainerIter
void operator()(std::vector< int > const &pList, std::vector< KT > const &iKeys, std::vector< KT > &oKeys)
KeyList::iterator KeyListIter