From 6a91d286aa680212928d1cdf573ac67bf6dcfb55 Mon Sep 17 00:00:00 2001 From: James McClure Date: Thu, 26 Jun 2014 13:57:27 -0400 Subject: [PATCH 1/3] Added Domain::VoxelConnection(x,y,z) --- common/Domain.h | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/common/Domain.h b/common/Domain.h index 8f88a3c1..1be48115 100755 --- a/common/Domain.h +++ b/common/Domain.h @@ -16,7 +16,7 @@ int MAX_BLOB_COUNT=500; using namespace std; struct Domain{ - + Domain(int nx, int ny, int nz, int rnk, int npx, int npy, int npz, double lx, double ly, double lz){ Nx = nx+2; Ny = ny+2; Nz = nz+2; @@ -28,7 +28,7 @@ struct Domain{ Blobs.New(Nx,Ny,Nz); BlobGraph.New(18,MAX_BLOB_COUNT); } - + // Basic domain information int Nx,Ny,Nz,N; int iproc,jproc,kproc; @@ -72,21 +72,26 @@ struct Domain{ int *recvBuf_xy, *recvBuf_yz, *recvBuf_xz, *recvBuf_Xy, *recvBuf_Yz, *recvBuf_xZ; int *recvBuf_xY, *recvBuf_yZ, *recvBuf_Xz, *recvBuf_XY, *recvBuf_YZ, *recvBuf_XZ; //...................................................................................... - + // Solid indicator function char *id; // Blob information IntArray Blobs; IntArray BlobGraph; - + void InitializeRanks(); void CommInit(MPI_Comm comm); void BlobComm(MPI_Comm comm); - + void getBlobConnections(); - + private: - int getRankForBlock( int i, int j, int k ) + int d[26][3] = {{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}, + {1,1,0},{1,-1,0},{-1,1,0},{-1,-1,0},{1,0,1},{-1,0,1}, + {1,0,-1},{-1,0,-1},{0,1,1},{0,-1,1},{0,1,-1},{0,-1,-1}, + {1,1,1},{1,1,-1},{1,-1,1},{1,-1,-1},{-1,1,1},{-1,1,-1}, + + int getRankForBlock( int i, int j, int k ) { int i2 = (i+nprocx)%nprocx; int j2 = (j+nprocy)%nprocy; @@ -111,6 +116,25 @@ private: data[n] = recvbuf[idx]; } } + int VoxelConnection(int x, int y, int z){ + int returnVal = -1; + int nodx,nody,nodz; + for (int p=0;p<26;p++){ + nodx=x+d[p][0]; + // Get the neighbor and guarantee it is in the domain + if (nodx < 0 ){ nodx = 0; } + if (nodx > Nx-1 ){ nodx = Nx-1; } + nody=y+d[p][1]; + if (nody < 0 ){ nody = 0; } + if (nody > Ny-1 ){ nody = Ny-1; } + nodz=z+d[p][2]; + if (nodz < 0 ){ nodz = 0; } + if (nodz > Nz-1 ){ nodz = Nz-1; } + + if (Blobs(nodx,nody,nodz) > returnVal ) returnVal = Blobs(nodx,nody,nodz); + } + return returnVal; + } }; From 98900a710d2e398c1eecc449bb0369aafe33350a Mon Sep 17 00:00:00 2001 From: James McClure Date: Thu, 26 Jun 2014 15:19:36 -0400 Subject: [PATCH 2/3] Edited common/Domain.h --- common/Domain.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/common/Domain.h b/common/Domain.h index 1be48115..d0c34bdd 100755 --- a/common/Domain.h +++ b/common/Domain.h @@ -116,8 +116,13 @@ private: data[n] = recvbuf[idx]; } } - int VoxelConnection(int x, int y, int z){ + int VoxelConnection(int n){ int returnVal = -1; + int x,y,z; + // Get the 3-D indices + x = n%Nx; + y = (n/Nx)%Ny; + z = n/(Nx*Ny); int nodx,nody,nodz; for (int p=0;p<26;p++){ nodx=x+d[p][0]; @@ -512,10 +517,11 @@ void Domain::BlobComm(MPI_Comm Communicator){ } void Domain::getBlobConnections(){ - // BlobGraph(0,nblob) = rank of the connecting blob; // BlobGraph(1,nblob) = ID of the connecting blob; + + } inline void ReadSpherePacking(int nspheres, double *List_cx, double *List_cy, double *List_cz, double *List_rad) From 35a4ed83265cbd428e0c6ab0bf3a76b8817b6e12 Mon Sep 17 00:00:00 2001 From: James McClure Date: Thu, 26 Jun 2014 17:01:26 -0400 Subject: [PATCH 3/3] Edited common/Domain.h --- common/Domain.h | 47 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/common/Domain.h b/common/Domain.h index d0c34bdd..dc8c7561 100755 --- a/common/Domain.h +++ b/common/Domain.h @@ -83,7 +83,26 @@ struct Domain{ void CommInit(MPI_Comm comm); void BlobComm(MPI_Comm comm); - void getBlobConnections(); + void AssignBlobConnections(){ + getBlobConnections(recvList_x, recvCount_x, rank_x); + getBlobConnections(recvList_y, recvCount_y, rank_y); + getBlobConnections(recvList_z, recvCount_z, rank_z); + getBlobConnections(recvList_X, recvCount_X, rank_X); + getBlobConnections(recvList_Y, recvCount_y, rank_Y); + getBlobConnections(recvList_Z, recvCount_Z, rank_Z); + getBlobConnections(recvList_xy, recvCount_xy, rank_xy); + getBlobConnections(recvList_xY, recvCount_xY, rank_xY); + getBlobConnections(recvList_Xy, recvCount_Xy, rank_Xy); + getBlobConnections(recvList_XY, recvCount_XY, rank_XY); + getBlobConnections(recvList_xz, recvCount_xz, rank_xz); + getBlobConnections(recvList_xZ, recvCount_xZ, rank_xZ); + getBlobConnections(recvList_Xz, recvCount_Xz, rank_Xz); + getBlobConnections(recvList_XZ, recvCount_XZ, rank_XZ); + getBlobConnections(recvList_yz, recvCount_yz, rank_yz); + getBlobConnections(recvList_yZ, recvCount_yZ, rank_yZ); + getBlobConnections(recvList_Yz, recvCount_Yz, rank_Yz); + getBlobConnections(recvList_YZ, recvCount_YZ, rank_YZ); + } private: int d[26][3] = {{1,0,0},{-1,0,0},{0,1,0},{0,-1,0},{0,0,1},{0,0,-1}, @@ -116,6 +135,7 @@ private: data[n] = recvbuf[idx]; } } + int VoxelConnection(int n){ int returnVal = -1; int x,y,z; @@ -141,6 +161,23 @@ private: return returnVal; } + void getBlobConnections(int * List, int count, int neighbor){ + + int idx,n,localValue,neighborValue; + int x,y,z; + for (idx=0; idx -1){ + localValue = VoxelConnection(n); + printf("Blob (%i,%i) connects to neighbor blob (%i,%i)", localValue, rank, neighborValue, neighbor); + } + } + } }; void Domain::InitializeRanks() @@ -514,14 +551,6 @@ void Domain::BlobComm(MPI_Comm Communicator){ UnpackBlobData(recvList_yZ, recvCount_yZ ,recvBuf_yZ, Blobs.data); UnpackBlobData(recvList_YZ, recvCount_YZ ,recvBuf_YZ, Blobs.data); //...................................................................................... -} - -void Domain::getBlobConnections(){ -// BlobGraph(0,nblob) = rank of the connecting blob; -// BlobGraph(1,nblob) = ID of the connecting blob; - - - } inline void ReadSpherePacking(int nspheres, double *List_cx, double *List_cy, double *List_cz, double *List_rad)