diff --git a/src/main/c/includes/fluid/sim/grid2/flux.h b/src/main/c/includes/fluid/sim/grid2/flux.h index e7d4f710..53ceaf53 100644 --- a/src/main/c/includes/fluid/sim/grid2/flux.h +++ b/src/main/c/includes/fluid/sim/grid2/flux.h @@ -14,10 +14,5 @@ */ void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk); -/** - * Estimaates the ghost flux for this chunk - */ -void fluid_grid2_estimate_ghost_flux(float ** arrays); - #endif \ No newline at end of file diff --git a/src/main/c/src/fluid/sim/grid2/flux.c b/src/main/c/src/fluid/sim/grid2/flux.c index c9c19fa8..e43db040 100644 --- a/src/main/c/src/fluid/sim/grid2/flux.c +++ b/src/main/c/src/fluid/sim/grid2/flux.c @@ -17,13 +17,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(DIM-1, i, j)] = arrays[neighborIndex][IX( 1, i, j)]; + // arrays[CENTER_LOC][IX(DIM-1, i, j)] = arrays[neighborIndex][IX( 1, i, j)]; + arrays[CENTER_LOC][IX(DIM-1, i, j)] = (arrays[neighborIndex][IX( 1, i, j)] + arrays[CENTER_LOC][IX(DIM-2, i, j)])/2.0f; } } } else { for(i = 1; i < DIM; i++){ for(j = 1; j < DIM; j++){ - arrays[CENTER_LOC][IX(DIM-1, i, j)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, i, j)] = arrays[CENTER_LOC][IX(DIM-2, i, j)]; } } } @@ -33,13 +34,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(0, i, j)] = arrays[neighborIndex][IX(DIM-2, i, j)]; + // arrays[CENTER_LOC][IX(0, i, j)] = arrays[neighborIndex][IX(DIM-2, i, j)]; + arrays[CENTER_LOC][IX(0, i, j)] = (arrays[neighborIndex][IX(DIM-2, i, j)] + arrays[CENTER_LOC][IX(1, i, j)])/2.0f; } } } else { for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(0, i, j)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(0, i, j)] = arrays[CENTER_LOC][IX(1, i, j)]; } } } @@ -49,13 +51,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX( i, DIM-1, j)] = arrays[neighborIndex][IX( i, 1, j)]; + // arrays[CENTER_LOC][IX( i, DIM-1, j)] = arrays[neighborIndex][IX( i, 1, j)]; + arrays[CENTER_LOC][IX( i, DIM-1, j)] = (arrays[neighborIndex][IX( i, 1, j)] + arrays[CENTER_LOC][IX( i, DIM-2, j)])/2.0f; } } } else { for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX( i, DIM-1, j)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i, DIM-1, j)] = arrays[CENTER_LOC][IX( i, DIM-2, j)]; } } } @@ -65,13 +68,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(i, 0, j)] = arrays[neighborIndex][IX( i, DIM-2, j)]; + // arrays[CENTER_LOC][IX(i, 0, j)] = arrays[neighborIndex][IX( i, DIM-2, j)]; + arrays[CENTER_LOC][IX(i, 0, j)] = (arrays[neighborIndex][IX( i, DIM-2, j)] + arrays[CENTER_LOC][IX(i, 1, j)])/2.0f; } } } else { for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(i, 0, j)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(i, 0, j)] = arrays[CENTER_LOC][IX(i, 1, j)]; } } } @@ -81,13 +85,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX( i, j, DIM-1)] = arrays[neighborIndex][IX( i, j, 1)]; + // arrays[CENTER_LOC][IX( i, j, DIM-1)] = arrays[neighborIndex][IX( i, j, 1)]; + arrays[CENTER_LOC][IX( i, j, DIM-1)] = (arrays[neighborIndex][IX( i, j, 1)] + arrays[CENTER_LOC][IX( i, j, DIM-2)])/2.0f; } } } else { for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX( i, j, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i, j, DIM-1)] = arrays[CENTER_LOC][IX( i, j, DIM-2)]; } } } @@ -97,13 +102,14 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(i, j, 0)] = arrays[neighborIndex][IX( i, j, DIM-2)]; + // arrays[CENTER_LOC][IX(i, j, 0)] = arrays[neighborIndex][IX( i, j, DIM-2)]; + arrays[CENTER_LOC][IX(i, j, 0)] = (arrays[neighborIndex][IX( i, j, DIM-2)] + arrays[CENTER_LOC][IX(i, j, 1)])/2.0f; } } } else { for(i = 1; i < DIM-1; i++){ for(j = 1; j < DIM-1; j++){ - arrays[CENTER_LOC][IX(i, j, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(i, j, 0)] = arrays[CENTER_LOC][IX(i, j, 1)]; } } } @@ -117,11 +123,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(2,2,1); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = arrays[neighborIndex][IX( 1, 1, i)]; + // arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = arrays[neighborIndex][IX( 1, 1, i)]; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = (arrays[neighborIndex][IX( 1, 1, i)] + arrays[CENTER_LOC][IX(DIM-2, DIM-2, i)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, i)] = arrays[CENTER_LOC][IX(DIM-2, DIM-2, i)]; } } @@ -129,11 +136,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(2,0,1); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX(DIM-1, 0, i)] = arrays[neighborIndex][IX( 1, DIM-2, i)]; + // arrays[CENTER_LOC][IX(DIM-1, 0, i)] = arrays[neighborIndex][IX( 1, DIM-2, i)]; + arrays[CENTER_LOC][IX(DIM-1, 0, i)] = (arrays[neighborIndex][IX( 1, DIM-2, i)] + arrays[CENTER_LOC][IX(DIM-2, 1, i)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX(DIM-1, 0, i)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, 0, i)] = arrays[CENTER_LOC][IX(DIM-2, 1, i)]; } } @@ -141,11 +149,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(0,2,1); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( 0, DIM-1, i)] = arrays[neighborIndex][IX( DIM-2, 1, i)]; + // arrays[CENTER_LOC][IX( 0, DIM-1, i)] = arrays[neighborIndex][IX( DIM-2, 1, i)]; + arrays[CENTER_LOC][IX( 0, DIM-1, i)] = (arrays[neighborIndex][IX( DIM-2, 1, i)] + arrays[CENTER_LOC][IX( 1, DIM-2, i)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( 0, DIM-1, i)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( 0, DIM-1, i)] = arrays[CENTER_LOC][IX( 1, DIM-2, i)]; } } @@ -153,11 +162,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(0,0,1); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( 0, 0, i)] = arrays[neighborIndex][IX( DIM-2, DIM-2, i)]; + // arrays[CENTER_LOC][IX( 0, 0, i)] = arrays[neighborIndex][IX( DIM-2, DIM-2, i)]; + arrays[CENTER_LOC][IX( 0, 0, i)] = (arrays[neighborIndex][IX( DIM-2, DIM-2, i)] + arrays[CENTER_LOC][IX( 1, 1, i)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( 0, 0, i)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( 0, 0, i)] = arrays[CENTER_LOC][IX( 1, 1, i)]; } } @@ -173,11 +183,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(2,1,2); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = arrays[neighborIndex][IX( 1, i, 1)]; + // arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = arrays[neighborIndex][IX( 1, i, 1)]; + arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = (arrays[neighborIndex][IX( 1, i, 1)] + arrays[CENTER_LOC][IX(DIM-2, i, DIM-2)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, i, DIM-1)] = arrays[CENTER_LOC][IX(DIM-2, i, DIM-2)]; } } @@ -185,11 +196,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(2,1,0); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX(DIM-1, i, 0)] = arrays[neighborIndex][IX( 1, i, DIM-2)]; + // arrays[CENTER_LOC][IX(DIM-1, i, 0)] = arrays[neighborIndex][IX( 1, i, DIM-2)]; + arrays[CENTER_LOC][IX(DIM-1, i, 0)] = (arrays[neighborIndex][IX( 1, i, DIM-2)] + arrays[CENTER_LOC][IX(DIM-2, i, 1)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX(DIM-1, i, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, i, 0)] = arrays[CENTER_LOC][IX(DIM-2, i, 1)]; } } @@ -197,11 +209,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(0,1,2); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( 0, i, DIM-1)] = arrays[neighborIndex][IX( DIM-2, i, 1)]; + // arrays[CENTER_LOC][IX( 0, i, DIM-1)] = arrays[neighborIndex][IX( DIM-2, i, 1)]; + arrays[CENTER_LOC][IX( 0, i, DIM-1)] = (arrays[neighborIndex][IX( DIM-2, i, 1)] + arrays[CENTER_LOC][IX( 1, i, DIM-2)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( 0, i, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( 0, i, DIM-1)] = arrays[CENTER_LOC][IX( 1, i, DIM-2)]; } } @@ -209,11 +222,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(0,1,0); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( 0, i, 0)] = arrays[neighborIndex][IX( DIM-2, i, DIM-2)]; + // arrays[CENTER_LOC][IX( 0, i, 0)] = arrays[neighborIndex][IX( DIM-2, i, DIM-2)]; + arrays[CENTER_LOC][IX( 0, i, 0)] = (arrays[neighborIndex][IX( DIM-2, i, DIM-2)] + arrays[CENTER_LOC][IX( 1, i, 1)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( 0, i, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( 0, i, 0)] = arrays[CENTER_LOC][IX( 1, i, 1)]; } } @@ -228,11 +242,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(1,2,2); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = arrays[neighborIndex][IX( i, 1, 1)]; + // arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = arrays[neighborIndex][IX( i, 1, 1)]; + arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = (arrays[neighborIndex][IX( i, 1, 1)] + arrays[CENTER_LOC][IX( i, DIM-2, DIM-2)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i, DIM-1, DIM-1)] = arrays[CENTER_LOC][IX( i, DIM-2, DIM-2)]; } } @@ -240,11 +255,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(1,2,0); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( i,DIM-1, 0)] = arrays[neighborIndex][IX( i, 1, DIM-2)]; + // arrays[CENTER_LOC][IX( i,DIM-1, 0)] = arrays[neighborIndex][IX( i, 1, DIM-2)]; + arrays[CENTER_LOC][IX( i,DIM-1, 0)] = (arrays[neighborIndex][IX( i, 1, DIM-2)] + arrays[CENTER_LOC][IX( i,DIM-2, 1)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( i,DIM-1, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i,DIM-1, 0)] = arrays[CENTER_LOC][IX( i,DIM-2, 1)]; } } @@ -252,11 +268,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(1,0,2); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( i, 0, DIM-1)] = arrays[neighborIndex][IX( i, DIM-2, 1)]; + // arrays[CENTER_LOC][IX( i, 0, DIM-1)] = arrays[neighborIndex][IX( i, DIM-2, 1)]; + arrays[CENTER_LOC][IX( i, 0, DIM-1)] = (arrays[neighborIndex][IX( i, DIM-2, 1)] + arrays[CENTER_LOC][IX( i, 1, DIM-2)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( i, 0, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i, 0, DIM-1)] = arrays[CENTER_LOC][IX( i, 1, DIM-2)]; } } @@ -264,11 +281,12 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ neighborIndex = CK(1,0,0); if(arrays[neighborIndex] != NULL){ for(i = 1; i < DIM-1; i++){ - arrays[CENTER_LOC][IX( i, 0, 0)] = arrays[neighborIndex][IX( i, DIM-2, DIM-2)]; + // arrays[CENTER_LOC][IX( i, 0, 0)] = arrays[neighborIndex][IX( i, DIM-2, DIM-2)]; + arrays[CENTER_LOC][IX( i, 0, 0)] = (arrays[neighborIndex][IX( i, DIM-2, DIM-2)] + arrays[CENTER_LOC][IX( i, 1, 1)])/2.0f; } } else { for(i = 1; i < DIM; i++){ - arrays[CENTER_LOC][IX( i, 0, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX( i, 0, 0)] = arrays[CENTER_LOC][IX( i, 1, 1)]; } } @@ -280,17 +298,19 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ //x+ y+ z+ corner neighborIndex = CK(2,2,2); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = arrays[neighborIndex][IX( 1, 1, 1)]; + // arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = arrays[neighborIndex][IX( 1, 1, 1)]; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = (arrays[neighborIndex][IX( 1, 1, 1)] + arrays[CENTER_LOC][IX(DIM-2, DIM-2, DIM-2)])/2.0f; } else { - arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, DIM-1)] = arrays[CENTER_LOC][IX(DIM-2, DIM-2, DIM-2)]; } //x+ y+ z- corner neighborIndex = CK(2,2,0); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = arrays[neighborIndex][IX( 1, 1, DIM-2)]; + // arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = arrays[neighborIndex][IX( 1, 1, DIM-2)]; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = (arrays[neighborIndex][IX( 1, 1, DIM-2)] + arrays[CENTER_LOC][IX(DIM-2, DIM-2, 1)])/2.0f; } else { - arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, DIM-1, 0)] = arrays[CENTER_LOC][IX(DIM-2, DIM-2, 1)]; } @@ -298,17 +318,19 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ //x+ y- z+ corner neighborIndex = CK(2,0,2); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = arrays[neighborIndex][IX( 1, DIM-2, 1)]; + // arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = arrays[neighborIndex][IX( 1, DIM-2, 1)]; + arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = (arrays[neighborIndex][IX( 1, DIM-2, 1)] + arrays[CENTER_LOC][IX(DIM-2, 1, DIM-2)])/2.0f; } else { - arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, 0, DIM-1)] = arrays[CENTER_LOC][IX(DIM-2, 1, DIM-2)]; } //x+ y- z- corner neighborIndex = CK(2,0,0); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = arrays[neighborIndex][IX( 1, DIM-2, DIM-2)]; + // arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = arrays[neighborIndex][IX( 1, DIM-2, DIM-2)]; + arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = (arrays[neighborIndex][IX( 1, DIM-2, DIM-2)] + arrays[CENTER_LOC][IX(DIM-2, 1, 1)])/2.0f; } else { - arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(DIM-1, 0, 0)] = arrays[CENTER_LOC][IX(DIM-2, 1, 1)]; } @@ -316,17 +338,19 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ //x- y+ z+ corner neighborIndex = CK(0,2,2); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = arrays[neighborIndex][IX( DIM-2, 1, 1)]; + // arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = arrays[neighborIndex][IX( DIM-2, 1, 1)]; + arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = (arrays[neighborIndex][IX( DIM-2, 1, 1)] + arrays[CENTER_LOC][IX(1, DIM-2, DIM-2)])/2.0f; } else { - arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(0, DIM-1, DIM-1)] = arrays[CENTER_LOC][IX(1, DIM-2, DIM-2)]; } //x- y+ z- corner neighborIndex = CK(0,2,0); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(0, DIM-1, 0)] = arrays[neighborIndex][IX( DIM-2, 1, DIM-2)]; + // arrays[CENTER_LOC][IX(0, DIM-1, 0)] = arrays[neighborIndex][IX( DIM-2, 1, DIM-2)]; + arrays[CENTER_LOC][IX(0, DIM-1, 0)] = (arrays[neighborIndex][IX( DIM-2, 1, DIM-2)] + arrays[CENTER_LOC][IX(1, DIM-2, 1)])/2.0f; } else { - arrays[CENTER_LOC][IX(0, DIM-1, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(0, DIM-1, 0)] = arrays[CENTER_LOC][IX(1, DIM-2, 1)]; } @@ -334,17 +358,19 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ //x- y- z+ corner neighborIndex = CK(0,0,2); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(0, 0, DIM-1)] = arrays[neighborIndex][IX( DIM-2, DIM-2, 1)]; + // arrays[CENTER_LOC][IX(0, 0, DIM-1)] = arrays[neighborIndex][IX( DIM-2, DIM-2, 1)]; + arrays[CENTER_LOC][IX(0, 0, DIM-1)] = (arrays[neighborIndex][IX( DIM-2, DIM-2, 1)] + arrays[CENTER_LOC][IX(1, 1, DIM-2)])/2.0f; } else { - arrays[CENTER_LOC][IX(0, 0, DIM-1)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(0, 0, DIM-1)] = arrays[CENTER_LOC][IX(1, 1, DIM-2)]; } //x- y- z- corner neighborIndex = CK(0,0,0); if(arrays[neighborIndex] != NULL){ - arrays[CENTER_LOC][IX(0, 0, 0)] = arrays[neighborIndex][IX( DIM-2, DIM-2, DIM-2)]; + // arrays[CENTER_LOC][IX(0, 0, 0)] = arrays[neighborIndex][IX( DIM-2, DIM-2, DIM-2)]; + arrays[CENTER_LOC][IX(0, 0, 0)] = (arrays[neighborIndex][IX( DIM-2, DIM-2, DIM-2)] + arrays[CENTER_LOC][IX(1, 1, 1)])/2.0f; } else { - arrays[CENTER_LOC][IX(0, 0, 0)] = NO_PRESSURE; + arrays[CENTER_LOC][IX(0, 0, 0)] = arrays[CENTER_LOC][IX(1, 1, 1)]; } } @@ -354,4 +380,5 @@ void fluid_grid2_estimate_ghost_flux(float ** arrays){ */ void fluid_grid2_update_ghost_flux(Environment * environment, Chunk * chunk){ fluid_grid2_estimate_ghost_flux(chunk->scalarPotentialCache); + fluid_grid2_estimate_ghost_flux(chunk->divergenceCache); } \ No newline at end of file diff --git a/src/main/c/src/fluid/sim/grid2/utilities.c b/src/main/c/src/fluid/sim/grid2/utilities.c index 368c2f8f..0e8ba2a0 100644 --- a/src/main/c/src/fluid/sim/grid2/utilities.c +++ b/src/main/c/src/fluid/sim/grid2/utilities.c @@ -345,8 +345,8 @@ LIBRARY_API void fluid_grid2_set_bounds( float * target ){ switch(vector_dir){ - case BOUND_SET_PROJECTION_PHI: - case BOUND_SET_PROJECTION_PHI_0: + // case BOUND_SET_PROJECTION_PHI: + // case BOUND_SET_PROJECTION_PHI_0: case BOUND_SET_VECTOR_DIFFUSE_PHI_U: case BOUND_SET_VECTOR_DIFFUSE_PHI_V: case BOUND_SET_VECTOR_DIFFUSE_PHI_W: @@ -371,8 +371,8 @@ LIBRARY_API void fluid_grid2_set_bounds( // fluid_grid2_set_bounds_continuity(environment,target); // break; - // case BOUND_SET_PROJECTION_PHI: - // case BOUND_SET_PROJECTION_PHI_0: + case BOUND_SET_PROJECTION_PHI: + case BOUND_SET_PROJECTION_PHI_0: // case BOUND_SET_VECTOR_DIFFUSE_PHI_U: // case BOUND_SET_VECTOR_DIFFUSE_PHI_V: // case BOUND_SET_VECTOR_DIFFUSE_PHI_W: diff --git a/src/main/c/src/fluid/sim/grid2/velocity.c b/src/main/c/src/fluid/sim/grid2/velocity.c index b8773e61..3ad54e46 100644 --- a/src/main/c/src/fluid/sim/grid2/velocity.c +++ b/src/main/c/src/fluid/sim/grid2/velocity.c @@ -253,7 +253,7 @@ LIBRARY_API void fluid_grid2_solveProjection( //perform iteration of v cycle multigrid method chunk->projectionResidual = 1; chunk->projectionIterations = 0; - while(chunk->projectionIterations < FLUID_GRID2_SOLVER_MULTIGRID_MAX_ITERATIONS && (chunk->projectionResidual > FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE)){ + while(chunk->projectionIterations < FLUID_GRID2_SOLVER_MULTIGRID_MAX_ITERATIONS && (chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE)){ chunk->projectionResidual = solver_multigrid_parallel_iterate(p,div,a,c); fluid_grid2_set_bounds(environment,BOUND_SET_PROJECTION_PHI,p); chunk->projectionIterations++; diff --git a/src/test/c/fluid/sim/grid2/convergence_tests.c b/src/test/c/fluid/sim/grid2/convergence_tests.c index c7ef9bce..cef83f6b 100644 --- a/src/test/c/fluid/sim/grid2/convergence_tests.c +++ b/src/test/c/fluid/sim/grid2/convergence_tests.c @@ -27,7 +27,9 @@ /** * Maximum convergence we want to see in any chunk */ -#define FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS 10 +#define FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS 20 + +#define FLUID_GRID2_CONVERVGENCE_FAILURE_THRESHOLD 0.1f @@ -60,8 +62,8 @@ int fluid_sim_grid2_convergence_test1(){ //test results for(int i = 0; i < chunkCount; i++){ Chunk * chunk = queue[i]; - if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){ - printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount); + if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_CONVERVGENCE_FAILURE_THRESHOLD){ + printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d, chunk: %d) \n", frameCount, chunkCount, i); printf("Residual: %f \n",chunk->projectionResidual); printf("Iterations: %d \n",chunk->projectionIterations); printf("\n"); @@ -102,8 +104,8 @@ int fluid_sim_grid2_convergence_test2(){ //test results for(int i = 0; i < chunkCount; i++){ Chunk * chunk = queue[i]; - if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){ - printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount); + if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_CONVERVGENCE_FAILURE_THRESHOLD){ + printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d, chunk: %d) \n", frameCount, chunkCount, i); printf("Residual: %f \n",chunk->projectionResidual); printf("Iterations: %d \n",chunk->projectionIterations); printf("\n"); @@ -144,8 +146,8 @@ int fluid_sim_grid2_convergence_test3(){ //test results for(int i = 0; i < chunkCount; i++){ Chunk * chunk = queue[i]; - if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){ - printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount); + if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_CONVERVGENCE_FAILURE_THRESHOLD){ + printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d, chunk: %d) \n", frameCount, chunkCount, i); printf("Residual: %f \n",chunk->projectionResidual); printf("Iterations: %d \n",chunk->projectionIterations); printf("\n");