Hi,
This is the macro I use to save the numbering of the processes:
macro saveGlobal2LocalNumbering(infespace, inMat, inmeshName){
/* just a dummy vector */
real[int] tempPETSc;
infespace gendef(uTemp);
ChangeNumbering(inMat, uTemp[], tempPETSc);
/* for some reason PETSc can only export (n,1) matrices ... */
real[int, int] numExport(tempPETSc.n, 1);
real[int, int] numExportFF(uTemp[].n, 1);
/* mpiranks for the global indices */
int[int] index2mpirank(tempPETSc.n);
index2mpirank = mpirank;
/* exporting ranks */
for [i, ranki : index2mpirank] numExport(i,0) = ranki;
ObjectView(numExport, format = "binary", name = (wdir + "/" + inmeshName + "_mpiranks_PETSc"));
/* exporting vector space index 2 rank */
uTemp[] = mpirank;
numExportFF(:,0)= uTemp[];
ObjectView(numExportFF, format = "binary", name = (wdir + "/" + inmeshName + "_mpiranks_FE"));
}//EOM
This is the macro to load the numbering:
macro loadGlobal2LocalNumbering(vLocal2Global,inName,nGlobal){
int[int] rankNumbering;
/* loading the data */
if(mpirank==0) {
real[int, int] vecView(1, 1);
MatLoad(vecView, format = "binary", name = inName, communicator = mpiCommSelf);
nGlobal = vecView.n;
rankNumbering.resize(nGlobal);
for [i, numi:rankNumbering] numi = vecView(i,0);
}
/* broadcast and resize numbering */
broadcast(processor(0),nGlobal);
if(mpirank!=0)
rankNumbering.resize(nGlobal);
mpiBarrier(mpiCommWorld);
broadcast(processor(0),rankNumbering);
/* gettig the sizes of the local numberings */
int nLocal = 0;
for(int i=0; i<nGlobal; i++) {
if(rankNumbering[i] == mpirank)
nLocal++;
}
/* saving the actual global2local numberings */
vLocal2Global.resize(nLocal);
nLocal=-1;
for(int i=0; i<nGlobal; i++) {
if(rankNumbering[i] == mpirank)
vLocal2Global[++nLocal] = i;
}
mpiBarrier(mpiCommWorld);
} //EOM
These are the macros for writing and reading vectors:
macro exportPETScBinary(vecPETSc, outputFileName) {
real[int, int] solallView(vecPETSc.n, 1);
solallView(:, 0) = vecPETSc;
ObjectView(solallView, format = "binary", name = outputFileName);
} //EOM
macro loadPETScBinary(vec,loc2GlobNum,nGlob,fname){
real[int] vecGlobIn(nGlob);
if(mpirank==0) {
real[int, int] vecGlobView(1, 1);
MatLoad(vecGlobView, format = "binary", name = fname, communicator = mpiCommSelf);
vecGlobIn = vecGlobView.asarray;
}
broadcast(processor(0), vecGlobIn);
for(int i=0; i<loc2GlobNum.n; i++)
vec[i] = vecGlobIn[loc2GlobNum[i]];
} //EOM
I hope that these are helpful. Let me know if you have questions!