Commit 2359b00a authored by Cassio Kirch's avatar Cassio Kirch

Memory freeded if gamma is not calculeted.

parent a4ef49ab
......@@ -65,7 +65,10 @@ initializeBoid (struct Boid* const boid)
boid -> next = NULL;
boid -> previous = NULL;
#if defined (ENDO_GAMMA) || defined (ECTO_GAMMA)
boid -> gamma = 0.0;
#endif
if (boidCount < endoBoids)
boid -> type = ENDODERM;
else
......
......@@ -10,17 +10,20 @@ struct Boid
struct Boid* next; /* Considering on the same box... */
struct Boid* previous; /* ... (same list). */
unsigned int boxID;
unsigned int endoNeighbors;
unsigned int ectoNeighbors;
cellType type; /* Endo or ectoderm. */
double gamma;
double position[2];
double velocity[2];
double newVelocity[2];
#if defined(ENDO_GAMMA) || defined(ECTO_GAMMA) || defined(COUNT_NEIGHBORS)
double gamma;
unsigned int endoNeighbors;
unsigned int ectoNeighbors;
#endif
};
#define BOID_STRUCT
#endif
unsigned int getBoxID (struct Boid boid);
void initializeBoid (struct Boid* const boid);
......
......@@ -20,6 +20,7 @@
#endif
#endif
#ifdef COUNT_NEIGHBORS
double
getAverageNeighborsNo(const struct Boid* const boid)
{
......@@ -30,7 +31,9 @@ getAverageNeighborsNo(const struct Boid* const boid)
boid[boidCount].ectoNeighbors) / N;
return averageNeighborsNo;
}
#endif
#if defined(ENDO_GAMMA) || defined(ECTO_GAMMA)
double
getGamma (const struct Boid* const boids)
{
......@@ -86,6 +89,7 @@ for (boidCount = (unsigned)(ENDOPROP*N); boidCount < N; ++boidCount)
return gamma;
}
#endif /* #if defined(ENDO_GAMMA) || defined(ECTO_GAMMA) */
void
one_system ()
......
......@@ -89,10 +89,12 @@ setNextVelocity (struct Boid* const boid, const struct Box box[])
double sumFX = 0.0, sumFY = 0.0; /* For beta and force sum. */
double sum, sumX, sumY;
struct Boid *conductor;
#if defined (ENDO_GAMMA) || defined (ECTO_GAMMA)
boid -> endoNeighbors = 0u;
boid -> ectoNeighbors = 0u;
boid -> gamma = 0.0;
#endif
/* check neighbors in the same box */
conductor = box[boid -> boxID].first;
......@@ -141,9 +143,11 @@ setNextVelocity (struct Boid* const boid, const struct Box box[])
boid -> newVelocity[X] = V0 * sumX / sum;
boid -> newVelocity[Y] = V0 * sumY / sum;
#if defined (ENDO_GAMMA) || defined (ECTO_GAMMA)
if (boid -> ectoNeighbors != 0u || boid -> endoNeighbors != 0u)
boid -> gamma = (double)boid -> ectoNeighbors / \
(boid -> endoNeighbors + boid -> ectoNeighbors);
#endif
}
void
......
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