Commit 6595b33a authored by Cassio Kirch's avatar Cassio Kirch
Browse files

Array name is in plural.

parent 0d80246f
......@@ -76,8 +76,8 @@ getGamma (const struct Boid* const boids)
void
one_system ()
{
struct Boid boid[N];
struct Box box[BOXES];
struct Boid boids[N];
struct Box boxes[BOXES];
unsigned int boidCount, boxID, threadCount;
unsigned long long int step, continuousStep = 0;
......@@ -110,32 +110,32 @@ one_system ()
((int)N/(int)NUM_THREADS);
if (threadCount == NUM_THREADS-1)
parametersStruct[threadCount].right += N%NUM_THREADS;
parametersStruct[threadCount].boid = boid;
parametersStruct[threadCount].box = box;
parametersStruct[threadCount].boids = boids;
parametersStruct[threadCount].boxes = boxes;
parameters[threadCount] = &(parametersStruct[threadCount]);
}
for (boidCount=0; boidCount<N; boidCount++)
{
initializeBoid (&boid[boidCount]);
checkLimits(&(boid[boidCount]));
initializeBoid (&boids[boidCount]);
checkLimits(&(boids[boidCount]));
}
initializeBoxes(box);
initializeBoxes(boxes);
for (boidCount=0; boidCount<N; boidCount++)
appendBoid(&(boid[boidCount]), box);
appendBoid(&(boids[boidCount]), boxes);
for (step=0; step <= STEPS; ++step)
{
nextStep(parameters);
for (boidCount=0; boidCount<N; boidCount++)
{
checkLimits(&(boid[boidCount]));
boxID = getBoxID(boid[boidCount]);
if (boid[boidCount].boxID != boxID)
checkLimits(&(boids[boidCount]));
boxID = getBoxID(boids[boidCount]);
if (boids[boidCount].boxID != boxID)
{
removeBoid(&boid[boidCount], box);
appendBoid(&boid[boidCount], box);
removeBoid(&boids[boidCount], boxes);
appendBoid(&boids[boidCount], boxes);
}
}
if (step%EXIT_INTERVAL == 0)
......@@ -143,7 +143,7 @@ one_system ()
printf("Step: %llu\n", step);
#ifdef COUNT_NEIGHBORS
fprintf(averageNeighborsFile, "%llu\t%lf\n", step, getAverageNeighborsNo(boid));
fprintf(averageNeighborsFile, "%llu\t%lf\n", step, getAverageNeighborsNo(boids));
#endif
#ifdef PLOT_EXIT_FILES
......@@ -153,28 +153,28 @@ one_system ()
{
/*fprintf(godFile, "%llu\t" "%llu\t" "%u\t" "%u\t" \
"%lf\t" "%lf\n", continuousStep, step, \
boid[boidCount].type, boidCount, \
boid[boidCount].position[X], \
boid[boidCount].position[Y]);
boids[boidCount].type, boidCount, \
boids[boidCount].position[X], \
boids[boidCount].position[Y]);
*/
if (boid[boidCount].type == ENDODERM)
if (boids[boidCount].type == ENDODERM)
fprintf(endoFile, "%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, \
boidCount, boid[boidCount].position[X], \
boid[boidCount].position[Y]);
boids[boidCount].type, \
boidCount, boids[boidCount].position[X], \
boids[boidCount].position[Y]);
else
fprintf(ectoFile, "%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, \
boidCount, boid[boidCount].position[X], \
boid[boidCount].position[Y]);
boids[boidCount].type, \
boidCount, boids[boidCount].position[X], \
boids[boidCount].position[Y]);
}
fclose(endoFile);
fclose(ectoFile);
#endif
#ifdef GAMMA_FILE
fprintf(gammaFile, "%llu\t%lf\n", step, getGamma(boid));
fprintf(gammaFile, "%llu\t%lf\n", step, getGamma(boids));
#endif
++continuousStep;
}
......@@ -194,9 +194,9 @@ one_system ()
{
fprintf(finalConfigurationFile, \
"%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, boidCount, \
boid[boidCount].position[X], \
boid[boidCount].position[Y]);
boids[boidCount].type, boidCount, \
boids[boidCount].position[X], \
boids[boidCount].position[Y]);
}
fclose (finalConfigurationFile);
}
......
......@@ -7,9 +7,9 @@ struct Parameters
unsigned int threadID;
unsigned int left;
unsigned int right;
struct Boid* boid;
struct Boid* boids;
struct Boid* firstEndoBoid;
struct Box* box;
struct Box* boxes;
};
#define PARAMETERS_STRUCT
#endif
......@@ -80,8 +80,8 @@ makeSum (struct Boid* const boid, const struct Boid* conductor, \
}
void
setNextVelocity (struct Boid* const boid, const struct Box box[])
/* Where 'boid' is address of a single struct and box is a array. */
setNextVelocity (struct Boid* const boid, const struct Box* boxes)
/* Where 'boid' is address of a single struct and 'boxes' is a array. */
{
double sumV[] = {0.0, 0.0}; /* For alpha and velocity sum. */
double uAngle, u[2]; /* For eta and random things. */
......@@ -96,39 +96,39 @@ setNextVelocity (struct Boid* const boid, const struct Box box[])
#endif
/* check neighbors in the same box */
conductor = box[boid -> boxID].first;
conductor = boxes[boid -> boxID].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the north box */
conductor = box[getNorthBoxID (boid -> boxID)].first;
conductor = boxes[getNorthBoxID (boid -> boxID)].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the south box */
conductor = box[getSouthBoxID (boid -> boxID)].first;
conductor = boxes[getSouthBoxID (boid -> boxID)].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the west box */
conductor = box[getWestBoxID (boid -> boxID)].first;
conductor = boxes[getWestBoxID (boid -> boxID)].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the east box */
conductor = box[getEastBoxID (boid -> boxID)].first;
conductor = boxes[getEastBoxID (boid -> boxID)].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the northeast box */
conductor = box[getEastBoxID (getNorthBoxID (boid -> boxID))].first;
conductor = boxes[getEastBoxID (getNorthBoxID (boid -> boxID))].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the southeast box */
conductor = box[getEastBoxID (getSouthBoxID (boid -> boxID))].first;
conductor = boxes[getEastBoxID (getSouthBoxID (boid -> boxID))].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the northwest box */
conductor = box[getWestBoxID (getNorthBoxID (boid -> boxID))].first;
conductor = boxes[getWestBoxID (getNorthBoxID (boid -> boxID))].first;
makeSum(boid, conductor, sumF, sumV);
/* check neighbors in the southwest box */
conductor = box[getWestBoxID (getSouthBoxID (boid -> boxID))].first;
conductor = boxes[getWestBoxID (getSouthBoxID (boid -> boxID))].first;
makeSum(boid, conductor, sumF, sumV);
uAngle = RANDOM_0 (PI * 2.0);
......@@ -162,14 +162,14 @@ void*
callNextPositionThread (void* const input)
{
const struct Parameters* const parameters = input;
struct Boid* const boid = parameters -> boid; /* struct Boid array. */
//struct Box* const box = parameters -> box; /* struct Box array. */
struct Boid* const boids = parameters -> boids; /* struct Boid array. */
//struct Box* const boxes = parameters -> boxes; /* struct Box array. */
unsigned int boidCount;
for (boidCount = parameters -> left;
boidCount < parameters -> right; ++boidCount)
setNextPosition ((boid + boidCount));
setNextPosition ((boids + boidCount));
return NULL;
}
......@@ -177,13 +177,13 @@ void*
callNextVelocityThread (void *input)
{
const struct Parameters* const parameters = input;
struct Boid* const boid = parameters -> boid; /* struct Boid array. */
struct Box* const box = parameters -> box; /* struct Box array. */
struct Boid* const boids = parameters -> boids; /* struct Boid array. */
struct Box* const boxes = parameters -> boxes; /* struct Box array. */
unsigned int boidCount;
for (boidCount = parameters -> left;
boidCount < parameters -> right; ++boidCount)
setNextVelocity (boid + boidCount, box);
setNextVelocity (boids + boidCount, boxes);
return NULL;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment