41 #ifndef EPETRAEXT_MIGRATE_H
42 #define EPETRAEXT_MIGRATE_H
64 template <
typename KT,
typename DT>
69 typedef typename std::map< KT, Teuchos::RCP<DT> >
DataMap;
82 typedef typename std::vector<char>
Buffer;
105 void operator()( std::vector<int>
const & pList,
106 std::vector<KT>
const & iKeys,
107 std::vector<KT> & oKeys );
109 void operator()( std::vector<int>
const & pList,
113 void rvs( std::vector<int>
const & pList,
114 std::vector<KT>
const & keys,
129 template <
typename DT>
142 typedef typename std::vector<char>
Buffer;
165 void operator()( std::vector<int>
const & pList,
169 void rvs( std::vector<int>
const & pList,
184 template <
typename KT,
typename DT>
188 std::vector<KT>
const & iKeys,
189 std::vector<KT> & oKeys )
194 int exportCnt = pList.size();
199 for( ; citKL != cendKL; ++citKL )
203 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
206 comm_.MaxAll( &max_size, &max_all, 1 );
208 exports_.resize( max_all * exportCnt );
210 if( importSize_ < (max_all*importCnt) )
212 if( importSize_ )
delete [] imports_;
213 importSize_ = (max_all*importCnt);
214 imports_ =
new char[importSize_];
218 citKL = iKeys.begin();
219 for(
int i = 0; citKL != cendKL; ++citKL, ++i )
225 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
227 oKeys.resize( importCnt );
228 for(
int i = 0; i < importCnt; ++i )
239 template <
typename KT,
typename DT>
249 int exportCnt = pList.size();
254 for( ; citDM != cendDM; ++citDM )
259 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
262 comm_.MaxAll( &max_size, &max_all, 1 );
264 exports_.resize( max_all * exportCnt );
266 if( importSize_ < (max_all*importCnt) )
268 if( importSize_ )
delete [] imports_;
269 importSize_ = (max_all*importCnt);
270 imports_ =
new char[importSize_];
274 citDM = iData.begin();
275 for(
int i = 0; citDM != cendDM; ++citDM, ++i )
282 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
286 for(
int i = 0; i < importCnt; ++i )
292 oData.insert(
DataPair( key, data ) );
298 for( ; citDM != cendDM; ++citDM )
299 oData.insert( *citDM );
303 template <
typename KT,
typename DT>
306 rvs( std::vector<int>
const & pList,
307 std::vector<KT>
const & keys,
314 int importCnt = pList.size();
317 distributor.
CreateFromSends( importCnt, &(pList[0]),
true, exportCnt );
319 if( exportCnt != keys.size() )
320 N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL,
321 "Xyce::Parallel::Migrate::rvs Failed Size Match!\n" );
326 for( ; citKL != cendKL; ++citKL )
331 comm_.MaxAll( &max_size, &max_all, 1 );
333 exports_.resize( max_all * exportCnt );
335 if( importSize_ < (max_all*importCnt) )
337 if( importSize_ )
delete [] imports_;
338 importSize_ = (max_all*importCnt);
339 imports_ =
new char[importSize_];
344 citKL = keys.begin();
345 for( ; citKL != cendKL; ++citKL, ++i )
352 distributor.
DoReverse( &(exports_[0]), max_all, importSize_, imports_ );
356 for(
int i = 0; i < importCnt; ++i )
369 template <
typename DT>
379 int exportCnt = pList.size();
384 for( ; citDC != cendDC; ++citDC )
388 distributor.
CreateFromSends( exportCnt, &(pList[0]),
true, importCnt );
391 comm_.MaxAll( &max_size, &max_all, 1 );
393 exports_.resize( max_all * exportCnt );
395 if( importSize_ < (max_all*importCnt) )
397 if( importSize_ )
delete [] imports_;
398 importSize_ = (max_all*importCnt);
399 imports_ =
new char[importSize_];
403 citDC = iData.begin();
404 for(
int i = 0; citDC != cendDC; ++citDC, ++i )
410 distributor.
Do( &(exports_[0]), max_all, importSize_, imports_ );
413 for(
int i = 0; i < importCnt; ++i )
418 oData.push_back( data );
426 template <
typename DT>
429 rvs( std::vector<int>
const & pList,
436 int importCnt = pList.size();
439 distributor.
CreateFromSends( importCnt, &(pList[0]),
true, exportCnt );
441 if( exportCnt != keys.size() )
442 N_ERH_ErrorMgr::report( N_ERH_ErrorMgr::DEV_FATAL,
443 "Xyce::Parallel::Migrate::rvs Failed Size Match!\n" );
448 for( ; citDC != cendDC; ++citDC )
452 comm_.MaxAll( &max_size, &max_all, 1 );
454 exports_.resize( max_all * exportCnt );
456 if( importSize_ < (max_all*importCnt) )
458 if( importSize_ )
delete [] imports_;
459 importSize_ = (max_all*importCnt);
460 imports_ =
new char[importSize_];
465 citDC = iData.begin();
466 for( ; citDC != cendDC; ++citDC, ++i )
472 distributor.
DoReverse( &(exports_[0]), max_all, importSize_, imports_ );
475 for(
int i = 0; i < importCnt; ++i )
480 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