3 #define MIN(x,y) ( (x)<(y) ? (x) : (y) ) 4 #define MAX(x,y) ( (x)>(y) ? (x) : (y) ) 8 dvector_t position[blockSide][blockSide][blockSide][densityFactor] )
13 TYPE dx, dy, dz, r2inv, r6inv, potential, f;
16 loop_grid0_x:
for( b0.
x=0; b0.
x<blockSide; b0.
x++ ) {
17 loop_grid0_y:
for( b0.
y=0; b0.
y<blockSide; b0.
y++ ) {
18 loop_grid0_z:
for( b0.
z=0; b0.
z<blockSide; b0.
z++ ) {
20 loop_grid1_x:
for( b1.
x=
MAX(0,b0.
x-1); b1.
x<
MIN(blockSide,b0.
x+2); b1.
x++ ) {
21 loop_grid1_y:
for( b1.
y=
MAX(0,b0.
y-1); b1.
y<
MIN(blockSide,b0.
y+2); b1.
y++ ) {
22 loop_grid1_z:
for( b1.
z=
MAX(0,b0.
z-1); b1.
z<
MIN(blockSide,b0.
z+2); b1.
z++ ) {
25 int q_idx_range = n_points[b1.
x][b1.
y][b1.
z];
26 loop_p:
for( p_idx=0; p_idx<n_points[b0.
x][b0.
y][b0.
z]; p_idx++ ) {
27 p = position[b0.
x][b0.
y][b0.
z][p_idx];
28 TYPE sum_x = force[b0.
x][b0.
y][b0.
z][p_idx].x;
29 TYPE sum_y = force[b0.
x][b0.
y][b0.
z][p_idx].y;
30 TYPE sum_z = force[b0.
x][b0.
y][b0.
z][p_idx].z;
32 loop_q:
for( q_idx=0; q_idx< q_idx_range ; q_idx++ ) {
33 q = *(base_q + q_idx);
36 if( q.
x!=p.
x || q.
y!=p.
y || q.
z!=p.
z ) {
41 r2inv = 1.0/( dx*dx + dy*dy + dz*dz );
42 r6inv = r2inv*r2inv*r2inv;
43 potential = r6inv*(
lj1*r6inv -
lj2);
51 force[b0.
x][b0.
y][b0.
z][p_idx].x = sum_x ;
52 force[b0.
x][b0.
y][b0.
z][p_idx].y = sum_y ;
53 force[b0.
x][b0.
y][b0.
z][p_idx].z = sum_z ;
void md(int n_points[blockSide][blockSide][blockSide], dvector_t force[blockSide][blockSide][blockSide][densityFactor], dvector_t position[blockSide][blockSide][blockSide][densityFactor])