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

Array name is in plural.

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