From a835ebb3eb53b13af1f6ba4abed4df78e14987dd Mon Sep 17 00:00:00 2001 From: austin Date: Wed, 11 Dec 2024 10:59:36 -0500 Subject: [PATCH] work on increating grid2 accuracy --- src/main/c/includes/fluid/sim/grid2/density.h | 1 - .../c/includes/fluid/sim/grid2/utilities.h | 2 +- src/main/c/src/fluid/sim/grid2/density.c | 3 +- src/main/c/src/fluid/sim/grid2/fluidsim.c | 42 ++++++------ src/main/c/src/fluid/sim/grid2/utilities.c | 3 +- src/main/c/src/fluid/sim/grid2/velocity.c | 6 +- src/main/c/src/math/ode/multigrid.c | 68 +++++++++++++++---- .../editor/ClientEditorMovementTree.java | 8 ++- .../fluid/sim/grid2/advect_projection_tests.c | 12 ++-- .../c/fluid/sim/grid2/density_diffuse_tests.c | 8 +-- .../sim/grid2/finalize_projection_tests.c | 2 +- .../fluid/sim/grid2/solve_projection_tests.c | 2 +- .../fluid/sim/grid2/velocity_diffuse_tests.c | 12 ++-- 13 files changed, 104 insertions(+), 65 deletions(-) diff --git a/src/main/c/includes/fluid/sim/grid2/density.h b/src/main/c/includes/fluid/sim/grid2/density.h index a5d1bd37..c80149f6 100644 --- a/src/main/c/includes/fluid/sim/grid2/density.h +++ b/src/main/c/includes/fluid/sim/grid2/density.h @@ -34,7 +34,6 @@ void fluid_grid2_addDensity( LIBRARY_API void fluid_grid2_solveDiffuseDensity( float ** d, float ** d0, - float DIFFUSION_CONST, float dt ); diff --git a/src/main/c/includes/fluid/sim/grid2/utilities.h b/src/main/c/includes/fluid/sim/grid2/utilities.h index 7bfefe42..6ac97210 100644 --- a/src/main/c/includes/fluid/sim/grid2/utilities.h +++ b/src/main/c/includes/fluid/sim/grid2/utilities.h @@ -18,7 +18,7 @@ void fluid_grid2_add_source(float * x, float * s, float dt); */ LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw( int vector_dir, - float ** neighborArray + float * target ); diff --git a/src/main/c/src/fluid/sim/grid2/density.c b/src/main/c/src/fluid/sim/grid2/density.c index 9bb3a175..0f12e922 100644 --- a/src/main/c/src/fluid/sim/grid2/density.c +++ b/src/main/c/src/fluid/sim/grid2/density.c @@ -41,10 +41,9 @@ void fluid_grid2_addDensity( LIBRARY_API void fluid_grid2_solveDiffuseDensity( float ** d, float ** d0, - float DIFFUSION_CONST, float dt ){ - float a=dt*DIFFUSION_CONST/(FLUID_GRID2_H*FLUID_GRID2_H); + float a=dt*FLUID_GRID2_DIFFUSION_CONSTANT/(FLUID_GRID2_H*FLUID_GRID2_H); float c=1+6*a; int i, j, k, l, m; float * x = GET_ARR_RAW(d,CENTER_LOC); diff --git a/src/main/c/src/fluid/sim/grid2/fluidsim.c b/src/main/c/src/fluid/sim/grid2/fluidsim.c index 345ed2af..87a6f622 100644 --- a/src/main/c/src/fluid/sim/grid2/fluidsim.c +++ b/src/main/c/src/fluid/sim/grid2/fluidsim.c @@ -82,16 +82,16 @@ LIBRARY_API void fluid_grid2_simulate( //solve vector diffusion fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep); //update array for vectors - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); } //setup projection fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep); //update array for vectors - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->v0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->v0[CENTER_LOC]); //samples u0, v0 //sets u0 @@ -99,7 +99,7 @@ LIBRARY_API void fluid_grid2_simulate( // //Perform main projection solver fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); //samples u,v,w,u0 //sets u,v,w //Finalize projection @@ -107,9 +107,9 @@ LIBRARY_API void fluid_grid2_simulate( //set boundaries a final time for u,v,w //... - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); //swap all vector fields //swap vector fields @@ -121,14 +121,14 @@ LIBRARY_API void fluid_grid2_simulate( //advect fluid_grid2_advectVectors(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,timestep); //update neighbor arr - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); //setup projection fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep); //update array for vectors - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]); //samples u0, v0 //sets u0 //these should have just been mirrored in the above @@ -136,7 +136,7 @@ LIBRARY_API void fluid_grid2_simulate( //Perform main projection solver for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){ fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); } //samples u,v,w,u0 //sets u,v,w @@ -144,9 +144,9 @@ LIBRARY_API void fluid_grid2_simulate( fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep); //set boundaries a final time for u,v,w //... - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); } @@ -178,8 +178,8 @@ LIBRARY_API void fluid_grid2_simulate( fluid_grid2_flip_arrays(currentChunk->d,currentChunk->d0); //diffuse density for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){ - fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,timestep); - fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d); + fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,timestep); + fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]); } //swap all density arrays //swap vector fields @@ -192,7 +192,7 @@ LIBRARY_API void fluid_grid2_simulate( { for(int i = 0; i < numChunks; i++){ Chunk * currentChunk = chunks[i]; - fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d); + fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]); } } //normalize densities diff --git a/src/main/c/src/fluid/sim/grid2/utilities.c b/src/main/c/src/fluid/sim/grid2/utilities.c index 17ce0562..6a7703d8 100644 --- a/src/main/c/src/fluid/sim/grid2/utilities.c +++ b/src/main/c/src/fluid/sim/grid2/utilities.c @@ -29,9 +29,8 @@ void fluid_grid2_add_source(float * x, float * s, float dt){ */ LIBRARY_API void fluid_grid2_setBoundsToNeighborsRaw( int vector_dir, - float ** neighborArray + float * target ){ - float * target = GET_ARR_RAW(neighborArray,CENTER_LOC); //set the faces bounds for(int x=1; x < DIM-1; x++){ for(int y = 1; y < DIM-1; y++){ diff --git a/src/main/c/src/fluid/sim/grid2/velocity.c b/src/main/c/src/fluid/sim/grid2/velocity.c index 6a343c3e..83f77ac2 100644 --- a/src/main/c/src/fluid/sim/grid2/velocity.c +++ b/src/main/c/src/fluid/sim/grid2/velocity.c @@ -242,7 +242,7 @@ LIBRARY_API void fluid_grid2_solveProjection( //perform iteration of v cycle multigrid method for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){ solver_multigrid_iterate(p,div,a,c); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,jru0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,jru0[CENTER_LOC]); } // solver_conjugate_gradient_solve_serial(p,div,a,c); @@ -360,7 +360,9 @@ void fluid_grid2_advect_velocity(int b, float ** jrd, float ** jrd0, float * u, int m,n,o; float x, y, z, s0, t0, s1, t1, u1, u0, dtx,dty,dtz; - dtx=dty=dtz=dt/FLUID_GRID2_H; + dtx = dt/FLUID_GRID2_H; + dty = dt/FLUID_GRID2_H; + dtz = dt/FLUID_GRID2_H; float * d = GET_ARR_RAW(jrd,CENTER_LOC); diff --git a/src/main/c/src/math/ode/multigrid.c b/src/main/c/src/math/ode/multigrid.c index 97023394..29f6fb6e 100644 --- a/src/main/c/src/math/ode/multigrid.c +++ b/src/main/c/src/math/ode/multigrid.c @@ -2,6 +2,7 @@ #include #include "fluid/queue/chunk.h" +#include "fluid/sim/grid2/utilities.h" #include "math/ode/gauss_seidel.h" #include "math/ode/multigrid.h" @@ -39,12 +40,23 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){ // //gauss-seidel at highest res solver_gauss_seidel_iterate_parallel(phi,phi0,a,c,DIM); + fluid_grid2_setBoundsToNeighborsRaw(0,phi); // //half res - for(int x = 1; x < halfDim - 2; x++){ - for(int y = 1; y < halfDim - 2; y++){ - for(int z = 1; z < halfDim - 2; z++){ + //clear grid + for(int x = 0; x < halfDim - 1; x++){ + for(int y = 0; y < halfDim - 1; y++){ + for(int z = 0; z < halfDim - 1; z++){ + halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0; + halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0; + } + } + } + //populate grid + for(int x = 1; x < halfDim - 1; x++){ + for(int y = 1; y < halfDim - 1; y++){ + for(int z = 1; z < halfDim - 1; z++){ halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)]; halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = phi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,DIM)]; } @@ -57,24 +69,51 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){ // //quarter res // - //half res - for(int x = 1; x < quarterDim - 2; x++){ - for(int y = 1; y < quarterDim - 2; y++){ - for(int z = 1; z < quarterDim - 2; z++){ + //clear grid + for(int x = 0; x < quarterDim - 1; x++){ + for(int y = 0; y < quarterDim - 1; y++){ + for(int z = 0; z < quarterDim - 1; z++){ + halfGridPhi[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = 0; + halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = 0; + } + } + } + //populate grid + for(int x = 1; x < quarterDim - 1; x++){ + for(int y = 1; y < quarterDim - 1; y++){ + for(int z = 1; z < quarterDim - 1; z++){ quarterGridPhi[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)]; quarterGridPhi0[solver_gauss_seidel_get_index(x,y,z,quarterDim)] = halfGridPhi0[solver_gauss_seidel_get_index(x*2,y*2,z*2,halfDim)]; } } } solver_gauss_seidel_iterate_parallel(quarterGridPhi,quarterGridPhi0,a,c,quarterDim); - for(int x = 1; x < halfDim - 2; x++){ - for(int y = 1; y < halfDim - 2; y++){ - for(int z = 1; z < halfDim - 2; z++){ + + + + + // + //half res + // + //clear grid + for(int x = 0; x < halfDim - 1; x++){ + for(int y = 0; y < halfDim - 1; y++){ + for(int z = 0; z < halfDim - 1; z++){ + halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0; + halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = 0; + } + } + } + //populate grid + for(int x = 1; x < halfDim - 1; x++){ + for(int y = 1; y < halfDim - 1; y++){ + for(int z = 1; z < halfDim - 1; z++){ halfGridPhi[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)]; halfGridPhi0[solver_gauss_seidel_get_index(x,y,z,halfDim)] = quarterGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,quarterDim)]; } } } + solver_gauss_seidel_iterate_parallel(halfGridPhi,halfGridPhi0,a,c,halfDim); @@ -83,11 +122,10 @@ void solver_multigrid_iterate(float * phi, float * phi0, float a, float c){ // - //half res - solver_gauss_seidel_iterate_parallel(halfGridPhi,halfGridPhi0,a,c,halfDim); - for(int x = 1; x < DIM - 2; x++){ - for(int y = 1; y < DIM - 2; y++){ - for(int z = 1; z < DIM - 2; z++){ + //full res + for(int x = 1; x < DIM - 1; x++){ + for(int y = 1; y < DIM - 1; y++){ + for(int z = 1; z < DIM - 1; z++){ phi[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)]; phi0[solver_gauss_seidel_get_index(x,y,z,DIM)] = halfGridPhi0[solver_gauss_seidel_get_index(x/2,y/2,z/2,halfDim)]; } diff --git a/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java b/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java index 4c627389..3632ac97 100644 --- a/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/editor/ClientEditorMovementTree.java @@ -2,6 +2,7 @@ package electrosphere.entity.state.movement.editor; import electrosphere.entity.state.gravity.GravityUtils; +import electrosphere.client.scene.ClientWorldData; import electrosphere.engine.Globals; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.game.data.creature.type.movement.EditorMovementSystem; @@ -196,6 +197,7 @@ public class ClientEditorMovementTree implements BehaviorTree { float maxNaturalVelocity = EDITOR_MAX_VELOCITY; Entity serverEntity = EntityLookupUtils.getEntityById(Globals.clientSceneWrapper.mapClientToServerId(parent.getId())); + ClientWorldData clientWorldData = Globals.clientWorldData; // //rotation update @@ -258,7 +260,7 @@ public class ClientEditorMovementTree implements BehaviorTree { rotation.set(movementQuaternion); position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity))); if(serverEntity != null){ - if(position.x >= 0 && position.y >= 0 && position.z >= 0){ + if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){ ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position)); } } @@ -275,7 +277,7 @@ public class ClientEditorMovementTree implements BehaviorTree { rotation.set(movementQuaternion); position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity))); if(serverEntity != null){ - if(position.x >= 0 && position.y >= 0 && position.z >= 0){ + if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){ ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position)); } } @@ -298,7 +300,7 @@ public class ClientEditorMovementTree implements BehaviorTree { rotation.set(movementQuaternion); position.set(new Vector3d(position).add(new Vector3d(movementVector).mul(velocity))); if(serverEntity != null){ - if(position.x >= 0 && position.y >= 0 && position.z >= 0){ + if(position.x >= 0 && position.y >= 0 && position.z >= 0 && position.x < clientWorldData.getWorldBoundMax().x && position.y < clientWorldData.getWorldBoundMax().y && position.z < clientWorldData.getWorldBoundMax().z){ ServerEntityUtils.repositionEntity(serverEntity, new Vector3d(position)); } } diff --git a/src/test/c/fluid/sim/grid2/advect_projection_tests.c b/src/test/c/fluid/sim/grid2/advect_projection_tests.c index 48f1ea2b..ae6fcdc1 100644 --- a/src/test/c/fluid/sim/grid2/advect_projection_tests.c +++ b/src/test/c/fluid/sim/grid2/advect_projection_tests.c @@ -60,10 +60,10 @@ int fluid_sim_grid2_advect_projection_test1(){ ////project fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]); fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); //advect density @@ -125,10 +125,10 @@ int fluid_sim_grid2_advect_projection_compute_error_over_time(){ ////project fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]); fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); //advect density diff --git a/src/test/c/fluid/sim/grid2/density_diffuse_tests.c b/src/test/c/fluid/sim/grid2/density_diffuse_tests.c index 340abd2a..da4151ec 100644 --- a/src/test/c/fluid/sim/grid2/density_diffuse_tests.c +++ b/src/test/c/fluid/sim/grid2/density_diffuse_tests.c @@ -76,8 +76,8 @@ int fluid_sim_grid2_density_diffuse_test1(){ } //diffuse density for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){ - fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d); + fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP); + fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]); } //swap all density arrays //swap vector fields @@ -134,8 +134,8 @@ int fluid_sim_grid2_density_diffuse_test2(){ } //diffuse density for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){ - fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_DIFFUSION_CONSTANT,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d); + fluid_grid2_solveDiffuseDensity(currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP); + fluid_grid2_setBoundsToNeighborsRaw(0,currentChunk->d[CENTER_LOC]); } //swap all density arrays //swap vector fields diff --git a/src/test/c/fluid/sim/grid2/finalize_projection_tests.c b/src/test/c/fluid/sim/grid2/finalize_projection_tests.c index ebe2c429..61c2f82d 100644 --- a/src/test/c/fluid/sim/grid2/finalize_projection_tests.c +++ b/src/test/c/fluid/sim/grid2/finalize_projection_tests.c @@ -37,7 +37,7 @@ int fluid_sim_grid2_finalize_projection_test1(){ currentChunk->u[CENTER_LOC][IX(3,3,3)] = 1.0f; fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); //finalize fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); diff --git a/src/test/c/fluid/sim/grid2/solve_projection_tests.c b/src/test/c/fluid/sim/grid2/solve_projection_tests.c index a97f1cca..829c8c7a 100644 --- a/src/test/c/fluid/sim/grid2/solve_projection_tests.c +++ b/src/test/c/fluid/sim/grid2/solve_projection_tests.c @@ -39,7 +39,7 @@ int fluid_sim_grid2_solve_projection_test1(){ //actually solve fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]); //test the result float expected, actual; diff --git a/src/test/c/fluid/sim/grid2/velocity_diffuse_tests.c b/src/test/c/fluid/sim/grid2/velocity_diffuse_tests.c index 9993d40c..af2dc905 100644 --- a/src/test/c/fluid/sim/grid2/velocity_diffuse_tests.c +++ b/src/test/c/fluid/sim/grid2/velocity_diffuse_tests.c @@ -57,9 +57,9 @@ int fluid_sim_grid2_velocity_diffuse_test1(){ //solve vector diffusion fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP); //update array for vectors - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); } //swap all density arrays //swap vector fields @@ -117,9 +117,9 @@ int fluid_sim_grid2_velocity_diffuse_test2(){ //solve vector diffusion fluid_grid2_solveVectorDiffuse(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP); //update array for vectors - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v); - fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]); + fluid_grid2_setBoundsToNeighborsRaw(FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]); } //swap all density arrays //swap vector fields