Beispiel #1
0
void doCollision(double *collideField, int *flagField, const double * const tau,int xlength){
  double density;
  double velocity[3];
  double feq[Q];
  double* currentCell;
  int currentIndex;

  /* Set pointer to first cell that is not a boundary */
  currentIndex = (xlength+3);

  /* Last row is a border */
  while(currentIndex < (xlength+2)*(xlength+2)*(xlength+2) - (xlength+2))
  {
	  /* No left and right border, only inner cells */
	  if(flagField[currentIndex] == FLUID)
	  {
			currentCell = &collideField[currentIndex*Q];
			computeDensity(currentCell, &density);
			computeVelocity(currentCell, &density, velocity);
			computeFeq(&density, velocity, feq);
			computePostCollisionDistributions(currentCell, tau, feq);
	  }
	  currentIndex++;
  }
}
Beispiel #2
0
void doCollision(double *collideField, int *flagField, const double * const tau, int * length){
    /* 
     * For each inner grid cell in collideField, compute the post-collide
     * distribution
     */
 
    double density;
    double velocity[D];
    double feq[Q];

    double * currentCell;

    int x,y,z;
    int node[3];
    int n[3] = { length[0] + 2, length[1] + 2, length[2] + 2 };

    // Loop over inner cells: compare to streaming.c
    for (z = 1; z <= length[2]; z++) {
        node[2] = z;
        for (y = 1; y <= length[1]; y++) {
            node[1] = y;
            for (x = 1; x <= length[0]; x++) {
                node[0] = x;

                currentCell = getEl(collideField, node, 0, n);

                computeDensity(currentCell, &density);
                computeVelocity(currentCell, &density, velocity);
                computeFeq(&density, velocity, feq);
                computePostCollisionDistributions(currentCell, tau, feq);
            }
        }
    }
}
Beispiel #3
0
void doCollision(double *collideField, int *flagField, const double * const tau,
        const int * const sublength)
{
    for (int z = 1; z < sublength[0] + 1; ++z) {
        for (int y = 1; y < sublength[1] + 1; ++y) {
            for (int x = 1; x < sublength[2] + 1; ++x) {
                double *currentCell = &collideField[idx(sublength, x, y, z, 0)];
                /*Updating values for velocity, density and Feq for Current cell*/
                double density;
                computeDensity(currentCell, &density);
                double velocity[D];
                computeVelocity(currentCell, &density, velocity);
                double feq[Q];
                computeFeq(&density, velocity, feq);
                computePostCollisionDistributions(currentCell, tau, feq);
            }
        }
    }
}
void doCollision(double *collideField, int *flagField,const double * const tau,int xlength)
{
    double velocity[3], density,  feq[PARAMQ], *currentCell;
    for (int z = 1; z <= xlength; z++)
        for (int y = 1; y <= xlength ; y++)
            for (int x = 1; x <= xlength; x++)
            {
                currentCell = collideField + PARAMQ * (z * (xlength + 2) * (xlength + 2) + y * (xlength + 2) + x);
                density = 0.0;
                computeDensitySSE(currentCell, &density);

                if (__builtin_expect(fabs(1.0 - density) > 0.1, 0))
                    fprintf(stderr, "WARNING: Density is %.3f in cell (%d, %d, %d)\n", density, x, y, z);

                computeVelocitySSE(currentCell, &density, velocity);
                computeFeq(&density, velocity, feq);
                computePostCollisionDistributions(currentCell, tau, feq);

            }
}
Beispiel #5
0
void doCollision(double *collideField, int *flagField,const double * const tau, int *subdomain){


	double density;
	double velocity[D];
	double feq[Q];
	double *currentCell = NULL; // currentCell points to the first distribution function within the respective cell
        for (int iz=1; iz<=subdomain[2]; iz++){
		for (int iy=1; iy<=subdomain[1]; iy++){
			for (int ix=1; ix<=subdomain[0]; ix++){
				// set pointer to current cell
				currentCell = collideField + Q * compute_index(ix, iy, iz, subdomain);

				// compute density, velocity and equilibrium prob. distrib. for this cell
				computeDensity ( currentCell, &density );
				computeVelocity ( currentCell, &density, velocity );
				computeFeq ( &density, velocity, feq );

				computePostCollisionDistributions ( currentCell, tau, feq );
			}
		}
	}
}
Beispiel #6
0
/** carries out the whole local collision process. Computes density and velocity and
 *  equilibrium distributions. Carries out BGK update.
 */
void doCollision(double *collideField, int *flagField,const double * const tau,int xlength){

	int x,y,z ;
	int counter;
	double density;
	double velocity[3] ;
	double feq[Q] ;

    /* we loop over all the inner cells i.e. fluid cells */
	for (z = 1; z < xlength+1; z++) {
		for (y = 1; y < xlength+1; y++) {
			for (x = 1; x < xlength+1; x++) {
                /* get the current index */
				counter  = Q*(z*(xlength+2)*(xlength+2) + y * (xlength+2) + x );
				/* Compute density, velocity, f_eq to finally get the postcollision distribution */
				computeDensity (&collideField[counter], &density) ;
                computeVelocity(&collideField[counter], &density,velocity) ;
				computeFeq(&density,velocity,feq) ;
				computePostCollisionDistributions(&collideField[counter],tau,feq);
			}
		}
	}
}