Skip to content
Snippets Groups Projects
Commit 1dc6966f authored by Pedro Gonnet's avatar Pedro Gonnet
Browse files

fixed same bug, yet in a different place.

parent 3ee481c2
No related branches found
No related tags found
No related merge requests found
...@@ -353,68 +353,69 @@ void iact_pair ( struct cell *ci , struct cell *cj ) { ...@@ -353,68 +353,69 @@ void iact_pair ( struct cell *ci , struct cell *cj ) {
for ( k = j+1 ; k < 8 ; k++ ) for ( k = j+1 ; k < 8 ; k++ )
iact_pair( ci->progeny[j] , cj->progeny[k] ); iact_pair( ci->progeny[j] , cj->progeny[k] );
/* Otherwise, compute interactions. */ /* Get the minimum distance between both cells. */
else { for ( r2 = 0.0, k = 0 ; k < 3 ; k++ ) {
dx[k] = fabs( ci->loc[k] - cj->loc[k] );
/* Get the minimum distance between both cells. */ if ( dx[k] > 0 )
for ( r2 = 0.0, k = 0 ; k < 3 ; k++ ) { dx[k] -= ci->h[k];
dx[k] = fabs( ci->loc[k] - cj->loc[k] ); r2 += dx[k]*dx[k];
if ( dx[k] > 0 ) }
dx[k] -= ci->h[k];
r2 += dx[k]*dx[k]; /* Sufficiently well-separated? */
} if ( r2/ci->h[0] > dist_min*dist_min ) {
/* Sufficiently well-separated? */ /* Compute the center of mass interactions. */
if ( r2/ci->h[0] < dist_min*dist_min ) { iact_pair_pc( ci , cj );
iact_pair_pc( cj , ci );
/* Compute the center of mass interactions. */
iact_pair_pc( ci , cj ); }
iact_pair_pc( cj , ci );
/* Recurse? */
} else if ( ci->split && cj->split )
for ( j = 0 ; j < 8 ; j++ )
/* Otherwise, do direct interactions. */ for ( k = j+1 ; k < 8 ; k++ )
else { iact_pair( ci->progeny[j] , cj->progeny[k] );
/* Loop over all particles... */ /* Otherwise, do direct interactions. */
for ( i = 0 ; i < count_i ; i++ ) { else {
/* Init the ith particle's data. */ /* Loop over all particles... */
for ( k = 0 ; k < 3 ; k++ ) { for ( i = 0 ; i < count_i ; i++ ) {
xi[k] = parts_i[i].x[k];
ai[k] = 0.0; /* Init the ith particle's data. */
} for ( k = 0 ; k < 3 ; k++ ) {
mi = parts_i[i].mass; xi[k] = parts_i[i].x[k];
ai[k] = 0.0;
}
mi = parts_i[i].mass;
/* Loop over every following particle. */ /* Loop over every following particle. */
for ( j = 0 ; j < count_j ; j++ ) { for ( j = 0 ; j < count_j ; j++ ) {
/* Compute the pairwise distance. */ /* Compute the pairwise distance. */
for ( r2 = 0.0 , k = 0 ; k < 3 ; k++ ) { for ( r2 = 0.0 , k = 0 ; k < 3 ; k++ ) {
dx[k] = xi[k] - parts_j[j].x[k]; dx[k] = xi[k] - parts_j[j].x[k];
r2 += dx[k]*dx[k]; r2 += dx[k]*dx[k];
} }
/* Apply the gravitational acceleration. */ /* Apply the gravitational acceleration. */
ir = 1.0 / sqrt( r2 ); ir = 1.0 / sqrt( r2 );
w = const_G * ir * ir * ir; w = const_G * ir * ir * ir;
mj = parts_j[j].mass; mj = parts_j[j].mass;
for ( k = 0 ; k < 3 ; k++ ) { for ( k = 0 ; k < 3 ; k++ ) {
parts_j[j].a[k] += w * dx[k] * mi; parts_j[j].a[k] += w * dx[k] * mi;
ai[k] -= w * dx[k] * mj; ai[k] -= w * dx[k] * mj;
} }
} /* loop over every other particle. */ } /* loop over every other particle. */
/* Store the accumulated acceleration on the ith part. */ /* Store the accumulated acceleration on the ith part. */
for ( k = 0 ; k < 3 ; k++ ) for ( k = 0 ; k < 3 ; k++ )
parts_i[i].a[k] += ai[k]; parts_i[i].a[k] += ai[k];
} /* loop over all particles. */ } /* loop over all particles. */
} /* otherwise, compute interactions directly. */ } /* otherwise, compute interactions directly. */
} /* otherwise, compute interactions. */
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment