updated lb2_Blob_wia_mpi

This commit is contained in:
James E McClure 2014-06-25 15:56:23 -04:00
parent ab132232c9
commit 27f52898ad

View File

@ -22,6 +22,142 @@
using namespace std;
struct BlobInfo{
BlobInfo(int Nx,int Ny,int Nz){
IntArray.New(Nx,Ny,Nz);
}
IntArray ID;
};
inline void PackBlobData(int *list, int count, int *sendbuf, int *data){
// Fill in the phase ID values from neighboring processors
// This packs up the values that need to be sent from one processor to another
int idx,n;
for (idx=0; idx<count; idx++){
n = list[idx];
sendbuf[idx] = data[n];
}
}
inline void UnpackBlobData(int *list, int count, int *recvbuf, int *data){
// Fill in the phase ID values from neighboring processors
// This unpacks the values once they have been recieved from neighbors
int idx,n;
for (idx=0; idx<count; idx++){
n = list[idx];
data[n] = recvbuf[idx];
}
}
inline void CommunicateBlobHalo(IntArray &Mesh, MPI_Comm Communicator,
int *sendbuf_x,int *sendbuf_y,int *sendbuf_z,int *sendbuf_X,int *sendbuf_Y,int *sendbuf_Z,
int *sendbuf_xy,int *sendbuf_XY,int *sendbuf_xY,int *sendbuf_Xy,
int *sendbuf_xz,int *sendbuf_XZ,int *sendbuf_xZ,int *sendbuf_Xz,
int *sendbuf_yz,int *sendbuf_YZ,int *sendbuf_yZ,int *sendbuf_Yz,
int *recvbuf_x,int *recvbuf_y,int *recvbuf_z,int *recvbuf_X,int *recvbuf_Y,int *recvbuf_Z,
int *recvbuf_xy,int *recvbuf_XY,int *recvbuf_xY,int *recvbuf_Xy,
int *recvbuf_xz,int *recvbuf_XZ,int *recvbuf_xZ,int *recvbuf_Xz,
int *recvbuf_yz,int *recvbuf_YZ,int *recvbuf_yZ,int *recvbuf_Yz,
int *sendList_x,int *sendList_y,int *sendList_z,int *sendList_X,int *sendList_Y,int *sendList_Z,
int *sendList_xy,int *sendList_XY,int *sendList_xY,int *sendList_Xy,
int *sendList_xz,int *sendList_XZ,int *sendList_xZ,int *sendList_Xz,
int *sendList_yz,int *sendList_YZ,int *sendList_yZ,int *sendList_Yz,
int sendCount_x,int sendCount_y,int sendCount_z,int sendCount_X,int sendCount_Y,int sendCount_Z,
int sendCount_xy,int sendCount_XY,int sendCount_xY,int sendCount_Xy,
int sendCount_xz,int sendCount_XZ,int sendCount_xZ,int sendCount_Xz,
int sendCount_yz,int sendCount_YZ,int sendCount_yZ,int sendCount_Yz,
int *recvList_x,int *recvList_y,int *recvList_z,int *recvList_X,int *recvList_Y,int *recvList_Z,
int *recvList_xy,int *recvList_XY,int *recvList_xY,int *recvList_Xy,
int *recvList_xz,int *recvList_XZ,int *recvList_xZ,int *recvList_Xz,
int *recvList_yz,int *recvList_YZ,int *recvList_yZ,int *recvList_Yz,
int recvCount_x,int recvCount_y,int recvCount_z,int recvCount_X,int recvCount_Y,int recvCount_Z,
int recvCount_xy,int recvCount_XY,int recvCount_xY,int recvCount_Xy,
int recvCount_xz,int recvCount_XZ,int recvCount_xZ,int recvCount_Xz,
int recvCount_yz,int recvCount_YZ,int recvCount_yZ,int recvCount_Yz,
int rank_x,int rank_y,int rank_z,int rank_X,int rank_Y,int rank_Z,int rank_xy,int rank_XY,int rank_xY,
int rank_Xy,int rank_xz,int rank_XZ,int rank_xZ,int rank_Xz,int rank_yz,int rank_YZ,int rank_yZ,int rank_Yz)
{
int sendtag, recvtag;
sendtag = recvtag = 12;
PackBlobData(sendList_x, sendCount_x ,sendbuf_x, Mesh.data);
PackBlobData(sendList_X, sendCount_X ,sendbuf_X, Mesh.data);
PackBlobData(sendList_y, sendCount_y ,sendbuf_y, Mesh.data);
PackBlobData(sendList_Y, sendCount_Y ,sendbuf_Y, Mesh.data);
PackBlobData(sendList_z, sendCount_z ,sendbuf_z, Mesh.data);
PackBlobData(sendList_Z, sendCount_Z ,sendbuf_Z, Mesh.data);
PackBlobData(sendList_xy, sendCount_xy ,sendbuf_xy, Mesh.data);
PackBlobData(sendList_Xy, sendCount_Xy ,sendbuf_Xy, Mesh.data);
PackBlobData(sendList_xY, sendCount_xY ,sendbuf_xY, Mesh.data);
PackBlobData(sendList_XY, sendCount_XY ,sendbuf_XY, Mesh.data);
PackBlobData(sendList_xz, sendCount_xz ,sendbuf_xz, Mesh.data);
PackBlobData(sendList_Xz, sendCount_Xz ,sendbuf_Xz, Mesh.data);
PackBlobData(sendList_xZ, sendCount_xZ ,sendbuf_xZ, Mesh.data);
PackBlobData(sendList_XZ, sendCount_XZ ,sendbuf_XZ, Mesh.data);
PackBlobData(sendList_yz, sendCount_yz ,sendbuf_yz, Mesh.data);
PackBlobData(sendList_Yz, sendCount_Yz ,sendbuf_Yz, Mesh.data);
PackBlobData(sendList_yZ, sendCount_yZ ,sendbuf_yZ, Mesh.data);
PackBlobData(sendList_YZ, sendCount_YZ ,sendbuf_YZ, Mesh.data);
//......................................................................................
MPI_Sendrecv(sendbuf_x,sendCount_x,MPI_INT,rank_x,sendtag,
recvbuf_X,recvCount_X,MPI_INT,rank_X,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_X,sendCount_X,MPI_INT,rank_X,sendtag,
recvbuf_x,recvCount_x,MPI_INT,rank_x,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_y,sendCount_y,MPI_INT,rank_y,sendtag,
recvbuf_Y,recvCount_Y,MPI_INT,rank_Y,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_Y,sendCount_Y,MPI_INT,rank_Y,sendtag,
recvbuf_y,recvCount_y,MPI_INT,rank_y,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_z,sendCount_z,MPI_INT,rank_z,sendtag,
recvbuf_Z,recvCount_Z,MPI_INT,rank_Z,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_Z,sendCount_Z,MPI_INT,rank_Z,sendtag,
recvbuf_z,recvCount_z,MPI_INT,rank_z,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_xy,sendCount_xy,MPI_INT,rank_xy,sendtag,
recvbuf_XY,recvCount_XY,MPI_INT,rank_XY,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_XY,sendCount_XY,MPI_INT,rank_XY,sendtag,
recvbuf_xy,recvCount_xy,MPI_INT,rank_xy,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_Xy,sendCount_Xy,MPI_INT,rank_Xy,sendtag,
recvbuf_xY,recvCount_xY,MPI_INT,rank_xY,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_xY,sendCount_xY,MPI_INT,rank_xY,sendtag,
recvbuf_Xy,recvCount_Xy,MPI_INT,rank_Xy,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_xz,sendCount_xz,MPI_INT,rank_xz,sendtag,
recvbuf_XZ,recvCount_XZ,MPI_INT,rank_XZ,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_XZ,sendCount_XZ,MPI_INT,rank_XZ,sendtag,
recvbuf_xz,recvCount_xz,MPI_INT,rank_xz,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_Xz,sendCount_Xz,MPI_INT,rank_Xz,sendtag,
recvbuf_xZ,recvCount_xZ,MPI_INT,rank_xZ,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_xZ,sendCount_xZ,MPI_INT,rank_xZ,sendtag,
recvbuf_Xz,recvCount_Xz,MPI_INT,rank_Xz,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_yz,sendCount_yz,MPI_INT,rank_yz,sendtag,
recvbuf_YZ,recvCount_YZ,MPI_INT,rank_YZ,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_YZ,sendCount_YZ,MPI_INT,rank_YZ,sendtag,
recvbuf_yz,recvCount_yz,MPI_INT,rank_yz,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_Yz,sendCount_Yz,MPI_INT,rank_Yz,sendtag,
recvbuf_yZ,recvCount_yZ,MPI_INT,rank_yZ,recvtag,Communicator,MPI_STATUS_IGNORE);
MPI_Sendrecv(sendbuf_yZ,sendCount_yZ,MPI_INT,rank_yZ,sendtag,
recvbuf_Yz,recvCount_Yz,MPI_INT,rank_Yz,recvtag,Communicator,MPI_STATUS_IGNORE);
//........................................................................................
UnpackBlobData(recvList_x, recvCount_x ,recvbuf_x, Mesh.data);
UnpackBlobData(recvList_X, recvCount_X ,recvbuf_X, Mesh.data);
UnpackBlobData(recvList_y, recvCount_y ,recvbuf_y, Mesh.data);
UnpackBlobData(recvList_Y, recvCount_Y ,recvbuf_Y, Mesh.data);
UnpackBlobData(recvList_z, recvCount_z ,recvbuf_z, Mesh.data);
UnpackBlobData(recvList_Z, recvCount_Z ,recvbuf_Z, Mesh.data);
UnpackBlobData(recvList_xy, recvCount_xy ,recvbuf_xy, Mesh.data);
UnpackBlobData(recvList_Xy, recvCount_Xy ,recvbuf_Xy, Mesh.data);
UnpackBlobData(recvList_xY, recvCount_xY ,recvbuf_xY, Mesh.data);
UnpackBlobData(recvList_XY, recvCount_XY ,recvbuf_XY, Mesh.data);
UnpackBlobData(recvList_xz, recvCount_xz ,recvbuf_xz, Mesh.data);
UnpackBlobData(recvList_Xz, recvCount_Xz ,recvbuf_Xz, Mesh.data);
UnpackBlobData(recvList_xZ, recvCount_xZ ,recvbuf_xZ, Mesh.data);
UnpackBlobData(recvList_XZ, recvCount_XZ ,recvbuf_XZ, Mesh.data);
UnpackBlobData(recvList_yz, recvCount_yz ,recvbuf_yz, Mesh.data);
UnpackBlobData(recvList_Yz, recvCount_Yz ,recvbuf_Yz, Mesh.data);
UnpackBlobData(recvList_yZ, recvCount_yZ ,recvbuf_yZ, Mesh.data);
UnpackBlobData(recvList_YZ, recvCount_YZ ,recvbuf_YZ, Mesh.data);
}
inline int ComputeLocalBlob(IntArray blobs, int &nblobs, int &ncubes, IntArray indicator,
DoubleArray F, DoubleArray S, double vf, double vs, int startx, int starty,
@ -1193,6 +1329,8 @@ int main(int argc, char **argv)
// double *Vel;
// Vel = new double[3*N]; // fluid velocity
// Press = new double[N]; // fluid pressure
BlobInfo LocalBlobs(Nx,Ny,Nz);
IntArray LocalBlobID(Nx,Ny,Nz);
DoubleArray Press(Nx,Ny,Nz);
@ -2311,7 +2449,7 @@ int main(int argc, char **argv)
for (k=0;k<Nz;k++){
for (j=0;j<Ny;j++){
for (i=0;i<Nx;i++){
LocalBlobID(i,j,k) = -1; // Initialize each time
LocalBlobs.ID(i,j,k) = -1; // Initialize each time
}
}
}
@ -2327,7 +2465,7 @@ int main(int argc, char **argv)
if ( SignDist(i,j,k) > 0.0 ){
// node i,j,k is in the porespace
// printf("Compute blob %i, \n",nblobs);
BlobSizes(nblobs) = ComputeBlob(BlobList,nblobs,nc,LocalBlobID,Phase,SignDist,vF,vS,i,j,k,temp);
BlobSizes(nblobs) = ComputeBlob(BlobList,nblobs,nc,LocalBlobs.ID,Phase,SignDist,vF,vS,i,j,k,temp);
nblobs++;
}
}