Cleaning up Color.cu/.cpp
This commit is contained in:
@@ -1416,31 +1416,7 @@ extern "C" void DensityStreamD3Q7(char *ID, double *Den, double *Copy, double *P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
extern "C" void ComputePhi(char *ID, double *Phi, double *Copy, double *Den, int N, int S)
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
double Na,Nb;
|
|
||||||
//...................................................................
|
|
||||||
// Update Phi
|
|
||||||
for (n=0; n<N; n++){
|
|
||||||
|
|
||||||
if (ID[n] > 0 && n<N){
|
|
||||||
// Get the density value (Streaming already performed)
|
|
||||||
Na = Den[2*n];
|
|
||||||
Nb = Den[2*n+1];
|
|
||||||
Phi[n] = (Na-Nb)/(Na+Nb);
|
|
||||||
// Store the copy of the current density
|
|
||||||
Copy[2*n] = Na;
|
|
||||||
Copy[2*n+1] = Nb;
|
|
||||||
// Zero the Density value to get ready for the next streaming
|
|
||||||
Den[2*n] = 0.0;
|
|
||||||
Den[2*n+1] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//...................................................................
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
extern "C" void ComputePhi(char *ID, double *Phi, double *Den, int N)
|
extern "C" void ComputePhi(char *ID, double *Phi, double *Den, int N)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
@@ -1449,7 +1425,7 @@ extern "C" void ComputePhi(char *ID, double *Phi, double *Den, int N)
|
|||||||
// Update Phi
|
// Update Phi
|
||||||
for (n=0; n<N; n++){
|
for (n=0; n<N; n++){
|
||||||
|
|
||||||
if (ID[n] > 0 && n<N){
|
if (ID[n] > 0 ){
|
||||||
// Get the density value (Streaming already performed)
|
// Get the density value (Streaming already performed)
|
||||||
Na = Den[n];
|
Na = Den[n];
|
||||||
Nb = Den[N+n];
|
Nb = Den[N+n];
|
||||||
|
|||||||
13
gpu/Color.cu
13
gpu/Color.cu
@@ -7,7 +7,7 @@ __global__ void dvc_InitDenColor(char *ID, double *Den, double *Phi, double das
|
|||||||
{
|
{
|
||||||
//int i,j,k;
|
//int i,j,k;
|
||||||
int n,N;
|
int n,N;
|
||||||
|
char id;
|
||||||
N = Nx*Ny*Nz;
|
N = Nx*Ny*Nz;
|
||||||
|
|
||||||
int S = N/NBLOCKS/NTHREADS + 1;
|
int S = N/NBLOCKS/NTHREADS + 1;
|
||||||
@@ -15,18 +15,19 @@ __global__ void dvc_InitDenColor(char *ID, double *Den, double *Phi, double das
|
|||||||
//........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];
|
||||||
//.......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-Nx*j;
|
//i = n-Nx*Ny*k-Nx*j;
|
||||||
|
|
||||||
if ( ID[n] == 1){
|
if ( id == 1){
|
||||||
Den[n] = 1.0;
|
Den[n] = 1.0;
|
||||||
Den[N+n] = 0.0;
|
Den[N+n] = 0.0;
|
||||||
Phi[n] = 1.0;
|
Phi[n] = 1.0;
|
||||||
}
|
}
|
||||||
else if ( ID[n] == 2){
|
else if ( id == 2){
|
||||||
Den[n] = 0.0;
|
Den[n] = 0.0;
|
||||||
Den[N+n] = 1.0;
|
Den[N+n] = 1.0;
|
||||||
Phi[n] = -1.0;
|
Phi[n] = -1.0;
|
||||||
@@ -706,7 +707,7 @@ __global__ void dvc_ColorCollideOpt( char *ID, double *disteven, double *distod
|
|||||||
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){
|
||||||
|
|
||||||
//.......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);
|
||||||
@@ -1388,7 +1389,7 @@ __global__ void dvc_ComputePhi(char *ID, double *Phi, double *Den, int N)
|
|||||||
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){
|
||||||
// Get the density value (Streaming already performed)
|
// Get the density value (Streaming already performed)
|
||||||
Na = Den[n];
|
Na = Den[n];
|
||||||
Nb = Den[N+n];
|
Nb = Den[N+n];
|
||||||
|
|||||||
Reference in New Issue
Block a user