/* * 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 #include inline void GenerateResidual(char *ID, int Nx, int Ny, int Nz, double Saturation) { //....................................................................... int i,j,k,n,Number,N; int x,y,z,ii,jj,kk; int sizeX,sizeY,sizeZ; int *SizeX, *SizeY, *SizeZ; #ifdef NORANDOM srand(10009); #else srand(time(NULL)); #endif // float bin; //....................................................................... N = Nx*Ny*Nz; int bin, binCount; ifstream Dist("BlobSize.in"); Dist >> binCount; // printf("Number of blob sizes: %i \n",binCount); SizeX = new int [binCount]; SizeY = new int [binCount]; SizeZ = new int [binCount]; for (bin=0; bin> SizeX[bin]; Dist >> SizeY[bin]; Dist >> SizeZ[bin]; // printf("Blob %i dimension: %i x %i x %i \n",bin, SizeX[bin], SizeY[bin], SizeZ[bin]); } Dist.close(); //....................................................................... // cout << "Generating blocks... " << endl; // Count for the total number of oil nodes int count = 0; // Count the total number of non-solid nodes int total = 0; for (i=0;i> nprocx; domain >> nprocy; domain >> nprocz; domain >> nx; domain >> ny; domain >> nz; domain >> nspheres; domain >> Lx; domain >> Ly; domain >> Lz; } MPI_Barrier(MPI_COMM_WORLD); // Computational domain MPI_Bcast(&nx,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&ny,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&nz,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&nprocx,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&nprocy,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&nprocz,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&nspheres,1,MPI_INT,0,MPI_COMM_WORLD); MPI_Bcast(&Lx,1,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_Bcast(&Ly,1,MPI_DOUBLE,0,MPI_COMM_WORLD); MPI_Bcast(&Lz,1,MPI_DOUBLE,0,MPI_COMM_WORLD); //................................................. MPI_Barrier(MPI_COMM_WORLD); // 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); } if ( nprocs < nprocx*nprocy*nprocz ){ ERROR("Insufficient number of processors"); } char LocalRankFilename[40]; nx+=2; ny+=2; nz+=2; int N = nx*ny*nz; char *id; id = new char[N]; DoubleArray SignDist(nx,ny,nz); // Read the signed distance from file sprintf(LocalRankFilename,"SignDist.%05i",rank); FILE *DIST = fopen(LocalRankFilename,"rb"); fread(SignDist.get(),8,N,DIST); fclose(DIST); for (int k=0; k