58 template<
typename int_type>
73 int_type *TargetGIDs = 0;
75 TargetGIDs =
new int_type[NumTargetIDs];
79 int_type * SourceGIDs = 0;
81 SourceGIDs =
new int_type[NumSourceIDs];
85 int MinIDs =
EPETRA_MIN(NumSourceIDs, NumTargetIDs);
88 for (i=0; i< MinIDs; i++)
if (TargetGIDs[i]==SourceGIDs[i])
NumSameIDs_++;
else break;
100 int_type * ExportGIDs = 0;
113 if (targetMap.
MyGID(SourceGIDs[i])) {
126 ReportError(
"Warning in Epetra_Export: Serial Export has remote IDs. (Exporting from Subset of Source Map)", 1);
135 if( ierr )
throw ReportError(
"Error in Epetra_BlockMap::RemoteIDList", ierr);
143 int_type * NewExportGIDs = 0;
144 int * NewExportPIDs = 0;
145 int * NewExportLIDs = 0;
146 int cnt1 = NumExportIDs_-cnt;
148 NewExportGIDs =
new int_type[cnt1];
149 NewExportPIDs =
new int[cnt1];
150 NewExportLIDs =
new int[cnt1];
155 NewExportGIDs[cnt] = ExportGIDs[i];
162 delete [] ExportGIDs;
165 ExportGIDs = NewExportGIDs;
168 ReportError(
"Warning in Epetra_Export: Source IDs not found in Target Map (Do you want to export from subset of Source Map?)", 1 );
187 throw ReportError(
"Epetra_Import::Epetra_Import: GlobalIndices Internal Error", -1);
196 if (ierr!=0)
throw ReportError(
"Error in Epetra_Distributor.CreateFromSends()", ierr);
204 char * cRemoteGIDs = 0;
205 int LenCRemoteGIDs = 0;
206 ierr =
Distor_->
Do(reinterpret_cast<char *> (ExportGIDs),
210 if (ierr)
throw ReportError(
"Error in Epetra_Distributor.Do()", ierr);
211 int_type * RemoteGIDs =
reinterpret_cast<int_type*
>(cRemoteGIDs);
220 if (LenCRemoteGIDs>0)
delete [] cRemoteGIDs;
223 if (NumTargetIDs>0)
delete [] TargetGIDs;
224 if (NumSourceIDs>0)
delete [] SourceGIDs;
248 throw ReportError(
"Epetra_Export::Epetra_Export: GlobalIndicesTypeMatch failed", -1);
251 #ifndef EPETRA_NO_32BIT_GLOBAL_INDICES
252 Construct<int>(sourceMap, targetMap);
254 throw ReportError(
"Epetra_Export::Epetra_Export: ERROR, GlobalIndicesInt but no API for it.",-1);
257 #ifndef EPETRA_NO_64BIT_GLOBAL_INDICES
258 Construct<long long>(sourceMap, targetMap);
260 throw ReportError(
"Epetra_Export::Epetra_Export: ERROR, GlobalIndicesLongLong but no API for it.",-1);
263 throw ReportError(
"Epetra_Export::Epetra_Export: Bad global indices type", -1);
270 TargetMap_(Exporter.TargetMap_),
271 SourceMap_(Exporter.SourceMap_),
272 NumSameIDs_(Exporter.NumSameIDs_),
273 NumPermuteIDs_(Exporter.NumPermuteIDs_),
276 NumRemoteIDs_(Exporter.NumRemoteIDs_),
278 NumExportIDs_(Exporter.NumExportIDs_),
281 NumSend_(Exporter.NumSend_),
282 NumRecv_(Exporter.NumRecv_),
331 TargetMap_(Importer.SourceMap_),
332 SourceMap_(Importer.TargetMap_),
333 NumSameIDs_(Importer.NumSameIDs_),
334 NumPermuteIDs_(Importer.NumPermuteIDs_),
337 NumRemoteIDs_(Importer.NumExportIDs_),
339 NumExportIDs_(Importer.NumRemoteIDs_),
342 NumSend_(Importer.NumRecv_),
343 NumRecv_(Importer.NumSend_),
371 if(!
D)
throw ReportError(
"Epetra_Export: Can't have ExportPIDs w/o an Epetra::MpiDistributor.",-1);
374 const int NumReceives =
D->NumReceives();
375 const int *ProcsFrom =
D->ProcsFrom();
376 const int *LengthsFrom =
D->LengthsFrom();
381 for (i = 0, j = 0; i < NumReceives; ++i) {
382 const int pid = ProcsFrom[i];
383 for (
int k = 0; k < LengthsFrom[i]; ++k) {
389 throw ReportError(
"Epetra_Export: Can't have ExportPIDs w/o an Epetra::MpiDistributor.",-2);
414 const bool sortIDs =
true;
417 const int myRank = comm.
MyPID();
418 const int numProcs = comm.
NumProc();
421 os <<
"Export Data Members:" << std::endl;
425 for (
int p = 0; p < numProcs; ++p) {
427 os <<
"Image ID : " << myRank << std::endl;
429 os <<
"permuteFromLIDs:";
435 permuteFromLIDs.begin());
437 std::sort (permuteFromLIDs.begin(), permuteFromLIDs.end());
441 os << permuteFromLIDs[i];
442 if (i < NumPermuteIDs_ - 1) {
450 os <<
"permuteToLIDs :";
456 permuteToLIDs.begin());
458 std::sort (permuteToLIDs.begin(), permuteToLIDs.end());
462 os << permuteToLIDs[i];
463 if (i < NumPermuteIDs_ - 1) {
471 os <<
"remoteLIDs :";
479 std::sort (remoteLIDs.begin(), remoteLIDs.end());
484 if (i < NumRemoteIDs_ - 1) {
502 int* intCompanions[1];
505 0, (
double**) NULL, 1, intCompanions, 0, 0);
509 os <<
"exportLIDs :";
516 if (i < NumExportIDs_ - 1) {
524 os <<
"exportImageIDs :";
531 if (i < NumExportIDs_ - 1) {
547 os <<
"Number of sends: " <<
NumSend_ << std::endl;
548 os <<
"Number of recvs: " <<
NumRecv_ << std::endl;
561 os << std::endl << std::endl <<
"Source Map:" << std::endl << std::flush;
568 os << std::endl << std::endl <<
"Target Map:" << std::endl << std::flush;
575 os << std::endl << std::endl <<
"Distributor:" << std::endl << std::flush;
580 os <<
" is NULL." << std::endl;
593 bool throw_err =
true;
595 throw ReportError(
"Epetra_Export::operator= not supported.",-1);
bool DistributedGlobal() const
Returns true if map is defined across more than one processor.
Epetra_BlockMap SourceMap_
bool GlobalIndicesLongLong() const
Returns true if map create with long long NumGlobalElements.
const Epetra_BlockMap & TargetMap() const
Returns the TargetMap used to construct this exporter.
int MyGlobalElements(int *MyGlobalElementList) const
Puts list of global elements on this processor into the user-provided array.
virtual void Print(std::ostream &os) const
Print object to an output stream.
virtual void Print(std::ostream &os) const =0
virtual int CreateFromSends(const int &NumExportIDs, const int *ExportPIDs, bool Deterministic, int &NumRemoteIDs)=0
Create Distributor object using list of process IDs to which we export.
T * Epetra_Util_data_ptr(std::vector< T > &vec)
Function that returns either a pointer to the first entry in the vector or, if the vector is empty...
Epetra_Export: This class builds an export object for efficient exporting of off-processor elements...
Epetra_Distributor & Distributor() const
bool GlobalIndicesInt() const
Returns true if map create with int NumGlobalElements.
MPI implementation of Epetra_Distributor.
Epetra_Import: This class builds an import object for efficient importing of off-processor elements...
virtual Epetra_Distributor * ReverseClone()=0
Create and extract the reverse version of the distributor.
virtual void Barrier() const =0
Epetra_Comm Barrier function.
virtual int MyPID() const =0
Return my process ID.
Epetra_Util: The Epetra Util Wrapper Class.
int NumMyElements() const
Number of elements on the calling processor.
Epetra_Comm: The Epetra Communication Abstract Base Class.
Epetra_Distributor * Distor_
Epetra_Object: The base Epetra class.
Epetra_BlockMap: A class for partitioning block element vectors and matrices.
virtual void Print(std::ostream &os) const
Print object to an output stream Print method.
int LID(int GID) const
Returns local ID of global ID, return -1 if not found on this processor.
bool MyGID(int GID_in) const
Returns true if the GID passed in belongs to the calling processor in this map, otherwise returns fal...
virtual ~Epetra_Export(void)
Epetra_Export destructor.
Epetra_Export & operator=(const Epetra_Export &src)
const Epetra_Comm & Comm() const
Access function for Epetra_Comm communicator.
virtual int Do(char *export_objs, int obj_size, int &len_import_objs, char *&import_objs)=0
Execute plan on buffer of export objects in a single step.
Epetra_BlockMap TargetMap_
Epetra_Distributor * Distor_
virtual int NumProc() const =0
Returns total number of processes.
virtual Epetra_Distributor * CreateDistributor() const =0
Create a distributor object.
static void EPETRA_LIB_DLL_EXPORT Sort(bool SortAscending, int NumKeys, T *Keys, int NumDoubleCompanions, double **DoubleCompanions, int NumIntCompanions, int **IntCompanions, int NumLongLongCompanions, long long **LongLongCompanions)
Epetra_Util Sort Routine (Shell sort)
int MaxElementSize() const
Maximum element size across all processors.
void Construct(const Epetra_BlockMap &SourceMap, const Epetra_BlockMap &TargetMap)
virtual int ReportError(const std::string Message, int ErrorCode) const
Error reporting method.
virtual Epetra_Distributor * Clone()=0
Epetra_Distributor clone constructor.
Epetra_Export(const Epetra_BlockMap &SourceMap, const Epetra_BlockMap &TargetMap)
Constructs a Epetra_Export object from the source and target maps.
int RemoteIDList(int NumIDs, const int *GIDList, int *PIDList, int *LIDList) const
Returns the processor IDs and corresponding local index value for a given list of global indices...
bool GlobalIndicesTypeMatch(const Epetra_BlockMap &other) const