43 #include "Epetra_Comm.h"
44 #include "Epetra_BlockMap.h"
45 #include "Epetra_Map.h"
46 #include "Epetra_IntVector.h"
47 #include "Epetra_IntSerialDenseVector.h"
48 #include "Epetra_Import.h"
50 using namespace Matlab;
62 int * elementSizeList = 0;
72 for (
int i=0; i<numRows; i++) allGids[i] = map.
GID(i);
75 for (
int i=0; i<numRows; i++) allSizes[i] = map.
ElementSize(i);
78 int numChunks = numProc;
85 int numImportGids = 0;
86 if (comm.
MyPID()==0) {
87 importGidList.
Size(stripSize+1);
88 if (doSizes) importSizeList.
Size(stripSize+1);
90 for (
int i=0; i<numChunks; i++) {
91 if (comm.
MyPID()==0) {
92 curStripSize = stripSize;
93 if (i<remainder) curStripSize++;
94 for (
int j=0; j<curStripSize; j++) importGidList[j] = j + curStart;
95 curStart += curStripSize;
102 if (importGids.Import(allGids, gidImporter,
Insert))
return(-1);
104 if (doSizes)
if (importSizes.Import(allSizes, gidImporter,
Insert))
return(-1);
109 int * myElements = importGids.
Values();
110 int * elementSizeList = 0;
111 if (doSizes) elementSizeList = importSizes.
Values();
113 if (comm.
MyPID()==0) {
120 int DoCopyBlockMap(mxArray* matlabA,
int& valueCount,
int length,
const int * v1,
const int * v2,
bool doSizes) {
122 double* matlabAvaluesPtr = mxGetPr(matlabA);
123 int* matlabAcolumnIndicesPtr = mxGetJc(matlabA);
124 int* matlabArowIndicesPtr = mxGetIr(matlabA);
127 matlabAvaluesPtr += valueCount;
128 matlabArowIndicesPtr += valueCount;
129 int numGidsDone = valueCount;
134 matlabAcolumnIndicesPtr += numGidsDone;
136 for (
int i=0; i<length; i++) {
137 *matlabAcolumnIndicesPtr++ = valueCount;
138 *matlabArowIndicesPtr++ = 0;
139 *matlabAvaluesPtr++ = v1[i];
142 *matlabAvaluesPtr++ = v2[i];
144 *matlabArowIndicesPtr++ = 1;
int NumGlobalElements() const
int CopyBlockMap(mxArray *matlabA, const Epetra_BlockMap &map)
int MyGlobalElements(int *MyGlobalElementList) const
bool ConstantElementSize() const
int DoCopyBlockMap(mxArray *matlabA, int &valueCount, int length, const int *v1, const int *v2, bool doSizes)
virtual int MyPID() const =0
int NumMyElements() const
int * ElementSizeList() const
const Epetra_Comm & Comm() const
virtual int NumProc() const =0