/* * Pre-processor to generate signed distance function from segmented data * segmented data should be stored in a raw binary file as 1-byte integer (type char) * will output distance functions for phases */ #include #include #include #include #include #include #include "common/Array.h" #include "common/Domain.h" #include "analysis/TwoPhase.h" #include "analysis/eikonal.h" inline void MeanFilter(DoubleArray &Mesh){ for (int k=1; k<(int)Mesh.size(2)-1; k++){ for (int j=1; j<(int)Mesh.size(1)-1; j++){ for (int i=1; i<(int)Mesh.size(0)-1; i++){ double sum; sum=Mesh(i,j,k)+Mesh(i+1,j,k)+Mesh(i-1,j,k)+Mesh(i,j+1,k)+Mesh(i,j-1,k)+ +Mesh(i,j,k+1)+Mesh(i,j,k-1); Mesh(i,j,k) = sum/7.0; } } } } double ReadFromBlock( char *ID, int iproc, int jproc, int kproc, int Nx, int Ny, int Nz){ int x,y,z,i,j,k; // Get the list of blocks that contain the local rank int b0x =iproc*(Nx-2)/1024; int b0y =jproc*(Ny-2)/1024; int b0z =kproc*(Nz-2)/1024; int Bx =(iproc+1)*(Nx-2)/1024+1; int By =(jproc+1)*(Ny-2)/1024+1; int Bz =(kproc+1)*(Nz-2)/1024+1; // arrays to hold the strings char LocalRankFilename[40]; char sx[2]; char sy[2]; char sz[2]; char tmpstr[10]; // array to store ids read from block char *id; id = new char [1024*1024*1024]; for (int bz=b0z; bz 1){ MAXTIME=atoi(argv[1]); } if (argc > 2){ READ_FROM_BLOCK=atoi(argv[2]); } std::vector solidValues; std::vector nwpValues; std::string line; if (rank==0){ ifstream domain("Domain.in"); domain >> nprocx; domain >> nprocy; domain >> nprocz; domain >> nx; domain >> ny; domain >> nz; domain >> nspheres; domain >> Lx; domain >> Ly; domain >> Lz; } MPI_Barrier(comm); // Computational domain MPI_Bcast(&nx,1,MPI_INT,0,comm); MPI_Bcast(&ny,1,MPI_INT,0,comm); MPI_Bcast(&nz,1,MPI_INT,0,comm); MPI_Bcast(&nprocx,1,MPI_INT,0,comm); MPI_Bcast(&nprocy,1,MPI_INT,0,comm); MPI_Bcast(&nprocz,1,MPI_INT,0,comm); MPI_Bcast(&nspheres,1,MPI_INT,0,comm); MPI_Bcast(&Lx,1,MPI_DOUBLE,0,comm); MPI_Bcast(&Ly,1,MPI_DOUBLE,0,comm); MPI_Bcast(&Lz,1,MPI_DOUBLE,0,comm); //................................................. MPI_Barrier(comm); // Check that the number of processors >= the number of ranks if ( rank==0 ) { printf("Number of MPI ranks required: %i \n", nprocx*nprocy*nprocz); printf("Number of MPI ranks used: %i \n", nprocs); printf("Full domain size: %i x %i x %i \n",nx*nprocx,ny*nprocy,nz*nprocz); fflush(stdout); } if ( nprocs < nprocx*nprocy*nprocz ){ ERROR("Insufficient number of processors"); } char LocalRankFilename[40]; int N = (nx+2)*(ny+2)*(nz+2); Domain Dm(nx,ny,nz,rank,nprocx,nprocy,nprocz,Lx,Ly,Lz,BC); for (n=0; n