confused
This commit is contained in:
parent
9f2840ccdc
commit
5299fd64ea
165
gpu/Color.cu
165
gpu/Color.cu
@ -1110,87 +1110,98 @@ __global__ void dvc_MassColorCollideD3Q7(char *ID, double *A_even, double *A_od
|
|||||||
id = ID[n];
|
id = ID[n];
|
||||||
if ( id != 0){
|
if ( id != 0){
|
||||||
|
|
||||||
//.....Load the Color gradient.........
|
//.....Load the Color gradient.........
|
||||||
nx = ColorGrad[n];
|
nx = ColorGrad[n];
|
||||||
ny = ColorGrad[N+n];
|
ny = ColorGrad[N+n];
|
||||||
nz = ColorGrad[2*N+n];
|
nz = ColorGrad[2*N+n];
|
||||||
C = sqrt(nx*nx+ny*ny+nz*nz);
|
C = sqrt(nx*nx+ny*ny+nz*nz);
|
||||||
if (C == 0.0) C=1.0;
|
if (C==0.0) C=1.0;
|
||||||
nx = nx/C;
|
nx = nx/C;
|
||||||
ny = ny/C;
|
ny = ny/C;
|
||||||
nz = nz/C;
|
nz = nz/C;
|
||||||
//....Load the flow velocity...........
|
//....Load the flow velocity...........
|
||||||
ux = Velocity[n];
|
ux = Velocity[n];
|
||||||
uy = Velocity[N+n];
|
uy = Velocity[N+n];
|
||||||
uz = Velocity[2*N+n];
|
uz = Velocity[2*N+n];
|
||||||
//........................................................................
|
//........................................................................
|
||||||
// READ THE DISTRIBUTIONS
|
// READ THE DISTRIBUTIONS
|
||||||
// (read from opposite array due to previous swap operation)
|
// (read from opposite array due to previous swap operation)
|
||||||
//........................................................................
|
//........................................................................
|
||||||
f2 = A_odd[n];
|
f2 = A_odd[n];
|
||||||
f4 = A_odd[N+n];
|
f4 = A_odd[N+n];
|
||||||
f6 = A_odd[2*N+n];
|
f6 = A_odd[2*N+n];
|
||||||
f0 = A_even[n];
|
f0 = A_even[n];
|
||||||
f1 = A_even[N+n];
|
f1 = A_even[N+n];
|
||||||
f3 = A_even[2*N+n];
|
f3 = A_even[2*N+n];
|
||||||
f5 = A_even[3*N+n];
|
f5 = A_even[3*N+n];
|
||||||
na = f0+f1+f2+f3+f4+f5+f6;
|
na = f0+f1+f2+f3+f4+f5+f6;
|
||||||
//........................................................................
|
//........................................................................
|
||||||
f2 = B_odd[n];
|
f2 = B_odd[n];
|
||||||
f4 = B_odd[N+n];
|
f4 = B_odd[N+n];
|
||||||
f6 = B_odd[2*N+n];
|
f6 = B_odd[2*N+n];
|
||||||
f0 = B_even[n];
|
f0 = B_even[n];
|
||||||
f1 = B_even[N+n];
|
f1 = B_even[N+n];
|
||||||
f3 = B_even[2*N+n];
|
f3 = B_even[2*N+n];
|
||||||
f5 = B_even[3*N+n];
|
f5 = B_even[3*N+n];
|
||||||
nb = f0+f1+f2+f3+f4+f5+f6;
|
nb = f0+f1+f2+f3+f4+f5+f6;
|
||||||
nab = 1.0/(na+nb);
|
nab = 1.0/(na+nb);
|
||||||
//........................................................................
|
//........................................................................
|
||||||
delta = beta*na*nb*nab*0.1111111111111111*nx;
|
//....Instantiate the density distributions
|
||||||
if (na*nb*nab<0.0)) delta=0.0;
|
// Generate Equilibrium Distributions and stream
|
||||||
|
// Stationary value - distribution 0
|
||||||
a1 = na*(0.1111111111111111*(1+4.5*ux))+delta;
|
A_even[n] = 0.3333333333333333*na;
|
||||||
b1 = nb*(0.1111111111111111*(1+4.5*ux))-delta;
|
B_even[n] = 0.3333333333333333*nb;
|
||||||
a2 = na*(0.1111111111111111*(1-4.5*ux))-delta;
|
// Non-Stationary equilibrium distributions
|
||||||
b2 = nb*(0.1111111111111111*(1-4.5*ux))+delta;
|
//feq[0] = 0.1111111111111111*(1+4.5*ux);
|
||||||
|
//feq[1] = 0.1111111111111111*(1-4.5*ux);
|
||||||
|
//feq[2] = 0.1111111111111111*(1+4.5*uy);
|
||||||
|
//feq[3] = 0.1111111111111111*(1-4.5*uy);
|
||||||
|
//feq[4] = 0.1111111111111111*(1+4.5*uz);
|
||||||
|
//feq[5] = 0.1111111111111111*(1-4.5*uz);
|
||||||
|
|
||||||
A_odd[n] = a1;
|
//...............................................
|
||||||
A_even[N+n] = a2;
|
// q = 0,2,4
|
||||||
B_odd[n] = b1;
|
// Cq = {1,0,0}, {0,1,0}, {0,0,1}
|
||||||
B_even[N+n] = b2;
|
delta = beta*na*nb*nab*0.1111111111111111*nx;
|
||||||
//........................................................................
|
if (!(na*nb*nab>0)) delta=0;
|
||||||
|
a1 = na*(0.1111111111111111*(1+4.5*ux))+delta;
|
||||||
// q = 2
|
b1 = nb*(0.1111111111111111*(1+4.5*ux))-delta;
|
||||||
// Cq = {0,1,0}
|
a2 = na*(0.1111111111111111*(1-4.5*ux))-delta;
|
||||||
delta = beta*na*nb*nab*0.1111111111111111*ny;
|
b2 = nb*(0.1111111111111111*(1-4.5*ux))+delta;
|
||||||
if (na*nb*nab<0.0)) delta=0.0;
|
|
||||||
|
|
||||||
a1 = na*(0.1111111111111111*(1+4.5*uy))+delta;
|
A_odd[n] = a1;
|
||||||
b1 = nb*(0.1111111111111111*(1+4.5*uy))-delta;
|
A_even[N+n] = a2;
|
||||||
a2 = na*(0.1111111111111111*(1-4.5*uy))-delta;
|
B_odd[n] = b1;
|
||||||
b2 = nb*(0.1111111111111111*(1-4.5*uy))+delta;
|
B_even[N+n] = b2;
|
||||||
|
//...............................................
|
||||||
|
// q = 2
|
||||||
|
// Cq = {0,1,0}
|
||||||
|
delta = beta*na*nb*nab*0.1111111111111111*ny;
|
||||||
|
if (!(na*nb*nab>0)) delta=0;
|
||||||
|
a1 = na*(0.1111111111111111*(1+4.5*uy))+delta;
|
||||||
|
b1 = nb*(0.1111111111111111*(1+4.5*uy))-delta;
|
||||||
|
a2 = na*(0.1111111111111111*(1-4.5*uy))-delta;
|
||||||
|
b2 = nb*(0.1111111111111111*(1-4.5*uy))+delta;
|
||||||
|
|
||||||
A_odd[N+n] = a1;
|
A_odd[N+n] = a1;
|
||||||
A_even[2*N+n] = a2;
|
A_even[2*N+n] = a2;
|
||||||
B_odd[N+n] = b1;
|
B_odd[N+n] = b1;
|
||||||
B_even[2*N+n] = b2;
|
B_even[2*N+n] = b2;
|
||||||
//........................................................................
|
//...............................................
|
||||||
// q = 4
|
// q = 4
|
||||||
// Cq = {0,0,1}
|
// Cq = {0,0,1}
|
||||||
delta = beta*na*nb*nab*0.1111111111111111*nz;
|
delta = beta*na*nb*nab*0.1111111111111111*nz;
|
||||||
if (na*nb*nab<0.0)) delta=0.0;
|
if (!(na*nb*nab>0)) delta=0;
|
||||||
|
a1 = na*(0.1111111111111111*(1+4.5*uz))+delta;
|
||||||
|
b1 = nb*(0.1111111111111111*(1+4.5*uz))-delta;
|
||||||
|
a2 = na*(0.1111111111111111*(1-4.5*uz))-delta;
|
||||||
|
b2 = nb*(0.1111111111111111*(1-4.5*uz))+delta;
|
||||||
|
|
||||||
|
A_odd[2*N+n] = a1;
|
||||||
|
A_even[3*N+n] = a2;
|
||||||
|
B_odd[2*N+n] = b1;
|
||||||
|
B_even[3*N+n] = b2;
|
||||||
|
|
||||||
a1 = na*(0.1111111111111111*(1+4.5*uz))+delta;
|
|
||||||
b1 = nb*(0.1111111111111111*(1+4.5*uz))-delta;
|
|
||||||
a2 = na*(0.1111111111111111*(1-4.5*uz))-delta;
|
|
||||||
b2 = nb*(0.1111111111111111*(1-4.5*uz))+delta;
|
|
||||||
|
|
||||||
A_odd[2*N+n] = a1;
|
|
||||||
A_even[3*N+n] = a2;
|
|
||||||
B_odd[2*N+n] = b1;
|
|
||||||
B_even[3*N+n] = b2;
|
|
||||||
//........................................................................
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
112
gpu/D3Q7.cu
112
gpu/D3Q7.cu
@ -109,57 +109,55 @@ __global__ void dvc_SwapD3Q7(char *ID, double *disteven, double *distodd, int N
|
|||||||
if (n<N ){
|
if (n<N ){
|
||||||
id = ID[n];
|
id = ID[n];
|
||||||
if (id > 0){
|
if (id > 0){
|
||||||
//.......Back out the 3-D indices for node n..............
|
//.......Back out the 3-D indices for node n..............
|
||||||
k = n/(Nx*Ny);
|
k = n/(Nx*Ny);
|
||||||
j = (n-Nx*Ny*k)/Nx;
|
j = (n-Nx*Ny*k)/Nx;
|
||||||
i = n-Nx*Ny*k-Nz*j;
|
i = n-Nx*Ny*k-Nz*j;
|
||||||
//........................................................................
|
//........................................................................
|
||||||
// Retrieve even distributions from the local node (swap convention)
|
// Retrieve even distributions from the local node (swap convention)
|
||||||
// f0 = disteven[n]; // Does not particupate in streaming
|
// f0 = disteven[n]; // Does not particupate in streaming
|
||||||
f1 = distodd[n];
|
f1 = distodd[n];
|
||||||
f3 = distodd[N+n];
|
f3 = distodd[N+n];
|
||||||
f5 = distodd[2*N+n];
|
f5 = distodd[2*N+n];
|
||||||
//........................................................................
|
//........................................................................
|
||||||
|
|
||||||
//........................................................................
|
//........................................................................
|
||||||
// Retrieve odd distributions from neighboring nodes (swap convention)
|
// Retrieve odd distributions from neighboring nodes (swap convention)
|
||||||
//........................................................................
|
//........................................................................
|
||||||
nn = n+1; // neighbor index (pull convention)
|
nn = n+1; // neighbor index (pull convention)
|
||||||
if (!(i+1<Nx)) nn -= Nx; // periodic BC along the x-boundary
|
if (!(i+1<Nx)) nn -= Nx; // periodic BC along the x-boundary
|
||||||
//if (i+1<Nx){
|
//if (i+1<Nx){
|
||||||
f2 = disteven[N+nn]; // pull neighbor for distribution 2
|
f2 = disteven[N+nn]; // pull neighbor for distribution 2
|
||||||
if (!(f2 < 0.0)){
|
if (!(f2 < 0.0)){
|
||||||
distodd[n] = f2;
|
distodd[n] = f2;
|
||||||
disteven[N+nn] = f1;
|
disteven[N+nn] = f1;
|
||||||
}
|
}
|
||||||
//}
|
//}
|
||||||
//........................................................................
|
//........................................................................
|
||||||
nn = n+Nx; // neighbor index (pull convention)
|
nn = n+Nx; // neighbor index (pull convention)
|
||||||
if (!(j+1<Ny)) nn -= Nx*Ny; // Perioidic BC along the y-boundary
|
if (!(j+1<Ny)) nn -= Nx*Ny; // Perioidic BC along the y-boundary
|
||||||
//if (j+1<Ny){
|
//if (j+1<Ny){
|
||||||
f4 = disteven[2*N+nn]; // pull neighbor for distribution 4
|
f4 = disteven[2*N+nn]; // pull neighbor for distribution 4
|
||||||
if (!(f4 < 0.0)){
|
if (!(f4 < 0.0)){
|
||||||
distodd[N+n] = f4;
|
distodd[N+n] = f4;
|
||||||
disteven[2*N+nn] = f3;
|
disteven[2*N+nn] = f3;
|
||||||
// }
|
}
|
||||||
}
|
//........................................................................
|
||||||
//........................................................................
|
nn = n+Nx*Ny; // neighbor index (pull convention)
|
||||||
nn = n+Nx*Ny; // neighbor index (pull convention)
|
if (!(k+1<Nz)) nn -= Nx*Ny*Nz; // Perioidic BC along the z-boundary
|
||||||
if (!(k+1<Nz)) nn -= Nx*Ny*Nz; // Perioidic BC along the z-boundary
|
//if (k+1<Nz){
|
||||||
//if (k+1<Nz){
|
f6 = disteven[3*N+nn]; // pull neighbor for distribution 6
|
||||||
f6 = disteven[3*N+nn]; // pull neighbor for distribution 6
|
if (!(f6 < 0.0)){
|
||||||
if (!(f6 < 0.0)){
|
distodd[2*N+n] = f6;
|
||||||
distodd[2*N+n] = f6;
|
disteven[3*N+nn] = f5;
|
||||||
disteven[3*N+nn] = f5;
|
}
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//*************************************************************************
|
//*************************************************************************
|
||||||
__global__ void dvc_ComputeDensityD3Q7(char *ID, double *disteven, double *distodd, double *Den,
|
__global__ void dvc_ComputeDensityD3Q7(char *ID, double *disteven, double *distodd, double *Den,
|
||||||
int Nx, int Ny, int Nz)
|
int Nx, int Ny, int Nz)
|
||||||
{
|
{
|
||||||
char id;
|
char id;
|
||||||
@ -172,19 +170,19 @@ __global__ void dvc_ComputeDensityD3Q7(char *ID, double *disteven, double *dist
|
|||||||
//........Get 1-D index for this thread....................
|
//........Get 1-D index for this thread....................
|
||||||
n = S*blockIdx.x*blockDim.x + s*blockDim.x + threadIdx.x;
|
n = S*blockIdx.x*blockDim.x + s*blockDim.x + threadIdx.x;
|
||||||
if (n<N){
|
if (n<N){
|
||||||
id = ID[n];
|
id = ID[n];
|
||||||
if ( id > 0 ){
|
if (id > 0 ){
|
||||||
// Read the distributions
|
// Read the distributions
|
||||||
f0 = disteven[n];
|
f0 = disteven[n];
|
||||||
f2 = disteven[N+n];
|
f2 = disteven[N+n];
|
||||||
f4 = disteven[2*N+n];
|
f4 = disteven[2*N+n];
|
||||||
f6 = disteven[3*N+n];
|
f6 = disteven[3*N+n];
|
||||||
f1 = distodd[n];
|
f1 = distodd[n];
|
||||||
f3 = distodd[N+n];
|
f3 = distodd[N+n];
|
||||||
f5 = distodd[2*N+n];
|
f5 = distodd[2*N+n];
|
||||||
// Compute the density
|
// Compute the density
|
||||||
Den[n] = f0+f1+f2+f3+f4+f5+f6;
|
Den[n] = f0+f1+f2+f3+f4+f5+f6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user