Commit 6ecd465d authored by Cassio Kirch's avatar Cassio Kirch

Replaced neighbors by endoNeighbors.

parent 1a0332e6
......@@ -10,32 +10,66 @@
#include "nextstep.h"
#include "main.h"
#ifdef ENDO_GAMMA
#define GAMMA_FILE
#endif
#ifdef ECTO_GAMMA
#ifndef GAMMA_FILE
#define GAMMA_FILE
#endif
#endif
double
getGamma (const struct Boid* const boids)
{
double gamma = 0.0;
unsigned int boidCount;
unsigned int endoBoids = (unsigned)(ENDOPROP*N);
#ifdef ENDO_GAMMA
for (boidCount = endoBoids; boidCount < N; --boidCount)
/* Considering overflow. */
gamma += boids[boidCount].gamma;
#endif
#ifdef ECTO_GAMMA
for (boidCount = endoBoids + 1; boidCount <= N; ++boidCount)
gamma += boids[boidCount].gamma;
#endif
#ifdef ENDO_GAMMA
#ifdef ECTO_GAMMA
gamma /= N;
#else
gamma /= endoBoids;
#endif
#else
#ifdef ECTO_GAMMA
gamma /= (N-endoBoids);
#endif
#endif
/*
double gamma = 0.0;
unsigned int endoBoids = (unsigned)(ENDOPROP*N);
unsigned int boidCount = endoBoids;
do
{
boidCount--;
if (boids[boidCount].gamma <= 1.01)
gamma += boids[boidCount].gamma/endoBoids;
#ifdef DEBUG
if (boids[boidCount].type == ECTODERM)
printf("Ecto cell treated as a endo one. %u\n", boidCount);
#endif
}
{
boidCount--;
if (boids[boidCount].gamma <= 1.01)
gamma += boids[boidCount].gamma/endoBoids;
}
while(boidCount != 0);
*/
#ifdef DEBUG
for (boidCount = endoBoids; boidCount < N; ++boidCount)
if (boids[boidCount].type == ENDODERM)
printf("Endo cell treated as a ecto one. %u\n", boidCount);
for (boidCount = (unsigned)(ENDOPROP*N); boidCount < N; ++boidCount)
if (boids[boidCount].type == ENDODERM)
printf("Endo cell treated as a ecto one. %u\n", boidCount);
#endif
return gamma;
}
......@@ -47,7 +81,7 @@ one_system ()
unsigned int boidCount, boxID, threadCount;
unsigned long long int step, continuousStep = 0;
//FILE* dat = initializeSingleFile();
FILE* godFile = initializeSingleFile();
FILE* finalConfigurationFile;
#ifdef PLOT_EXIT_FILES
......@@ -64,92 +98,93 @@ one_system ()
void* parameters[NUM_THREADS];
for (threadCount=0; threadCount<NUM_THREADS; ++threadCount)
{
parametersStruct[threadCount].threadID = threadCount;
parametersStruct[threadCount].left = threadCount * \
((int)N/(int)NUM_THREADS);
parametersStruct[threadCount].right = (threadCount+1) * \
((int)N/(int)NUM_THREADS);
if (threadCount == NUM_THREADS-1)
parametersStruct[threadCount].right += N%NUM_THREADS;
parametersStruct[threadCount].boid = boid;
parametersStruct[threadCount].box = box;
parameters[threadCount] = &(parametersStruct[threadCount]);
}
{
parametersStruct[threadCount].threadID = threadCount;
parametersStruct[threadCount].left = threadCount * \
((int)N/(int)NUM_THREADS);
parametersStruct[threadCount].right = (threadCount+1) * \
((int)N/(int)NUM_THREADS);
if (threadCount == NUM_THREADS-1)
parametersStruct[threadCount].right += N%NUM_THREADS;
parametersStruct[threadCount].boid = boid;
parametersStruct[threadCount].box = box;
parameters[threadCount] = &(parametersStruct[threadCount]);
}
for (boidCount=0; boidCount<N; boidCount++)
{
initializeBoid (&boid[boidCount]);
checkLimits(&(boid[boidCount]));
}
{
initializeBoid (&boid[boidCount]);
checkLimits(&(boid[boidCount]));
}
initializeBoxes(box);
for (boidCount=0; boidCount<N; boidCount++)
appendBoid(&(boid[boidCount]), box);
for (step=0; step<STEPS; ++step)
{
nextStep(parameters);
for (boidCount=0; boidCount<N; boidCount++)
{
nextStep(parameters);
for (boidCount=0; boidCount<N; boidCount++)
{
checkLimits(&(boid[boidCount]));
boxID = getBoxID(boid[boidCount]);
if (boid[boidCount].boxID != boxID)
{
removeBoid(&boid[boidCount], box);
appendBoid(&boid[boidCount], box);
}
}
if (step%EXIT_INTERVAL == 0)
{
printf("Step: %llu\n", step);
checkLimits(&(boid[boidCount]));
boxID = getBoxID(boid[boidCount]);
if (boid[boidCount].boxID != boxID)
{
removeBoid(&boid[boidCount], box);
appendBoid(&boid[boidCount], box);
}
}
if (step%EXIT_INTERVAL == 0)
{
printf("Step: %llu\n", step);
#ifdef PLOT_EXIT_FILES
endoFile = initializeStepAndTypeFile (continuousStep, ENDODERM);
ectoFile = initializeStepAndTypeFile (continuousStep, ECTODERM);
for (boidCount=0; boidCount<N; boidCount++)
{
/*fprintf(dat, "%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]);
*/
if (boid[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]);
else
fprintf(ectoFile, "%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, \
boidCount, boid[boidCount].position[X], \
boid[boidCount].position[Y]);
}
fclose(endoFile);
fclose(ectoFile);
endoFile = initializeStepAndTypeFile (continuousStep, ENDODERM);
ectoFile = initializeStepAndTypeFile (continuousStep, ECTODERM);
for (boidCount=0; boidCount<N; boidCount++)
{
/*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]);
*/
if (boid[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]);
else
fprintf(ectoFile, "%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, \
boidCount, boid[boidCount].position[X], \
boid[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(boid));
#endif
++continuousStep;
}
++continuousStep;
}
}
#ifdef GAMMA_FILE
fclose (gammaFile);
#endif
//fclose (dat);
fclose (godFile);
finalConfigurationFile = initializeFinalConfigurationFile();
for (boidCount=0; boidCount<N; boidCount++)
{
fprintf(finalConfigurationFile, \
"%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, boidCount, \
boid[boidCount].position[X], \
boid[boidCount].position[Y]);
}
{
fprintf(finalConfigurationFile, \
"%u\t" "%u\t" "%lf\t" "%lf\n", \
boid[boidCount].type, boidCount, \
boid[boidCount].position[X], \
boid[boidCount].position[Y]);
}
fclose (finalConfigurationFile);
}
......@@ -166,19 +201,19 @@ main (int argc, char** argv)
{
setDate();
if (argc > 1u)
{
if (strcmp(argv[1], "-p") == 0)
printParameters();
else
printHelp();
}
{
if (strcmp(argv[1], "-p") == 0)
printParameters();
else
printHelp();
}
else
{
int returned = checkParameters();
if (returned != 0)
return returned;
srand(time(NULL));
one_system();
}
{
int returned = checkParameters();
if (returned != 0)
return returned;
srand(time(NULL));
one_system();
}
return 0;
}
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