#include #include #include #include #include #include #include "pmmc.h" #include "Domain.h" #include "Extras.h" #include "D3Q19.h" #include "D3Q7.h" #include "Color.h" //#include "common/MPI_Helpers.h" //#include "Communication.h" //#define CBUB #define NC 2 using namespace std; inline double NormProb(short int value, short int *mu, short int *sigma, int k) { double sum,m,s; for (int i=0; i 0 ){ //.....Load the Color gradient......... nx = ColorGrad[n]; ny = ColorGrad[N+n]; nz = ColorGrad[2*N+n]; C = sqrt(nx*nx+ny*ny+nz*nz); nx = nx/C; ny = ny/C; nz = nz/C; //........................................................................ // READ THE DISTRIBUTIONS // (read from opposite array due to previous swap operation) //........................................................................ f2 = A_odd[n]; f4 = A_odd[N+n]; f6 = A_odd[2*N+n]; f0 = A_even[n]; f1 = A_even[N+n]; f3 = A_even[2*N+n]; f5 = A_even[3*N+n]; na = f0+f1+f2+f3+f4+f5+f6; //........................................................................ f2 = B_odd[n]; f4 = B_odd[N+n]; f6 = B_odd[2*N+n]; f0 = B_even[n]; f1 = B_even[N+n]; f3 = B_even[2*N+n]; f5 = B_even[3*N+n]; nb = f0+f1+f2+f3+f4+f5+f6; //........................................................................ //....Instantiate the density distributions // Generate Equilibrium Distributions and stream // Stationary value - distribution 0 A_even[n] = 0.3333333333333333*na; B_even[n] = 0.3333333333333333*nb; // Non-Stationary equilibrium distributions feq[0] = 0.1111111111111111*(1+3*ux); feq[1] = 0.1111111111111111*(1-3*ux); feq[2] = 0.1111111111111111*(1+3*uy); feq[3] = 0.1111111111111111*(1-3*uy); feq[4] = 0.1111111111111111*(1+3*uz); feq[5] = 0.1111111111111111*(1-3*uz); // Construction and streaming for the components for (idx=0; idx<3; idx++){ //............................................... // Distribution index q = 2*idx; // Associated discrete velocity Cqx = D3Q7[idx][0]; Cqy = D3Q7[idx][1]; Cqz = D3Q7[idx][2]; // Generate the Equilibrium Distribution a1 = na*feq[q]; b1 = nb*feq[q]; a2 = na*feq[q+1]; b2 = nb*feq[q+1]; // Recolor the distributions if (C > 0.0){ sp = nx*double(Cqx)+ny*double(Cqy)+nz*double(Cqz); //if (idx > 2) sp = 0.7071067811865475*sp; //delta = sp*min( min(a1,a2), min(b1,b2) ); delta = na*nb/(na+nb)*0.1111111111111111*sp; //if (a1>0 && b1>0){ a1 += beta*delta; a2 -= beta*delta; b1 -= beta*delta; b2 += beta*delta; } // Save the re-colored distributions A_odd[N*idx+n] = a1; A_even[N*(idx+1)+n] = a2; B_odd[N*idx+n] = b1; B_even[N*(idx+1)+n] = b2; //............................................... } } } } int main(int argc, char **argv) { // Initialize MPI Utilities::startup( argc, argv ); int n,N,Nx,Ny,Nz; Nx = Ny = Nz = 202; int rank = 12; char LocalRankString[8]; char LocalRankFilename[40]; char LocalRestartFile[40]; sprintf(LocalRankString,"%05d",rank); sprintf(LocalRestartFile,"%s%s","Solid.",LocalRankString); // Peaks of the standard normal distributions that approximate the data distribution double beta = 0.99; short int *mu; short int *sigma; mu = new short int [NC]; sigma = new short int [NC]; mu[0] = 27200; sigma[0] = 1500; mu[1] = -29000; sigma[1] = 1200; printf("Nx, Ny, Nz: %i, %i %i \n", Nx,Ny,Nz); printf("Filename = %s \n",LocalRestartFile); printf("Number of components = %i \n",NC); N = Nx*Ny*Nz; int dist_mem_size = N*sizeof(double); /* //......................device distributions................................. double *f_even,*f_odd; double *A_even,*A_odd,*B_even,*B_odd; //........................................................................... ScaLBL_AllocateDeviceMemory((void **) &f_even, 10*dist_mem_size); // Allocate device memory ScaLBL_AllocateDeviceMemory((void **) &f_odd, 9*dist_mem_size); // Allocate device memory ScaLBL_AllocateDeviceMemory((void **) &A_even, 4*dist_mem_size); // Allocate device memory ScaLBL_AllocateDeviceMemory((void **) &A_odd, 3*dist_mem_size); // Allocate device memory ScaLBL_AllocateDeviceMemory((void **) &B_even, 4*dist_mem_size); // Allocate device memory ScaLBL_AllocateDeviceMemory((void **) &B_odd, 3*dist_mem_size); // Allocate device memory */ printf("Set up ID \n"); char *ID; ScaLBL_AllocateDeviceMemory((void **) &ID, N); for (int k=0; k