breakout bounds cases
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-12 13:44:48 -05:00
parent fa50c32dfd
commit 344378485c
13 changed files with 281 additions and 100 deletions

View File

@ -29,3 +29,5 @@ TODO(?):
- Live reloading of scripts
- Async asset reloading (including data files)
- Maybe look into using PhysX bindings?

View File

@ -7,6 +7,77 @@
#include "fluid/env/environment.h"
/**
* Used for signaling the bounds setting method to not use adjacent cells when evaluating borders
*/
#define FLUID_GRID2_BOUND_NO_DIR 0
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating x axis borders
*/
#define FLUID_GRID2_DIRECTION_U 1
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating y axis borders
*/
#define FLUID_GRID2_DIRECTION_V 2
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating z axis borders
*/
#define FLUID_GRID2_DIRECTION_W 3
/**
* Setting the bounds when relaxing density diffusion
*/
#define BOUND_SET_DENSITY_PHI 4
/**
* Setting the hard bounds of the world
*/
#define BOUND_SET_DENSITY 5
/**
* Setting the bounds of phi when diffusing the u vector
*/
#define BOUND_SET_VECTOR_DIFFUSE_PHI_U 6
/**
* Setting the bounds of phi when diffusing the v vector
*/
#define BOUND_SET_VECTOR_DIFFUSE_PHI_V 7
/**
* Setting the bounds of phi when diffusing the w vector
*/
#define BOUND_SET_VECTOR_DIFFUSE_PHI_W 8
/**
* Setting the bounds of phi when projecting
*/
#define BOUND_SET_PROJECTION_PHI 9
/**
* Setting the bounds of phi0 projecting
*/
#define BOUND_SET_PROJECTION_PHI_0 10
/**
* Setting the bounds of the x-vector field
*/
#define BOUND_SET_VECTOR_U 11
/**
* Setting the bounds of the y-vector field
*/
#define BOUND_SET_VECTOR_V 12
/**
* Setting the bounds of the z-vector field
*/
#define BOUND_SET_VECTOR_W 13
/**
* Adds from a source array to a destination array

View File

@ -8,26 +8,6 @@
/**
* Used for signaling the bounds setting method to not use adjacent cells when evaluating borders
*/
#define FLUID_GRID2_BOUND_NO_DIR 0
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating x axis borders
*/
#define FLUID_GRID2_BOUND_DIR_U 1
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating y axis borders
*/
#define FLUID_GRID2_BOUND_DIR_V 2
/**
* Used for signaling the bounds setting method to use adjacent cells when evaluating z axis borders
*/
#define FLUID_GRID2_BOUND_DIR_W 3
/**
* Adds the sources to the destinations

View File

@ -8,7 +8,6 @@
#include "fluid/queue/chunk.h"
#include "fluid/sim/grid2/solver_consts.h"
#include "fluid/sim/grid2/utilities.h"
#include "fluid/sim/grid2/velocity.h"
#include "math/ode/multigrid.h"
#include "math/ode/multigrid_parallel.h"
#include "math/ode/gauss_seidel.h"
@ -73,7 +72,7 @@ LIBRARY_API void fluid_grid2_solveDiffuseDensity(
// int iterations = 0;
// while(iterations < FLUID_GRID2_LINEARSOLVERTIMES && (residual > FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE || residual < -FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE)){
// residual = solver_multigrid_parallel_iterate(x,x0,a,c);
// fluid_grid2_set_bounds(FLUID_GRID2_BOUND_NO_DIR,x);
// fluid_grid2_set_bounds(BOUND_SET_DENSITY_PHI,x);
// iterations++;
// }
@ -82,7 +81,7 @@ LIBRARY_API void fluid_grid2_solveDiffuseDensity(
solver_gauss_seidel_iterate_parallel(x,x0,a,c,DIM);
//set bounds
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,x);
fluid_grid2_set_bounds(environment,BOUND_SET_DENSITY_PHI,x);
}
}
@ -236,7 +235,7 @@ LIBRARY_API void fluid_grid2_advectDensity(Environment * environment, float ** d
}
}
//set bounds
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,center_d);
fluid_grid2_set_bounds(environment,BOUND_SET_DENSITY,center_d);
}
/**

View File

@ -214,7 +214,7 @@ LIBRARY_API void fluid_grid2_simulate(
Chunk * currentChunk = chunks[i];
//update the bounds arrays
fluid_grid2_rewrite_bounds(environment, currentChunk);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,currentChunk->d[CENTER_LOC]);
fluid_grid2_set_bounds(environment,BOUND_SET_DENSITY,currentChunk->d[CENTER_LOC]);
}
}

View File

@ -41,27 +41,75 @@ void fluid_grid2_add_source(float * x, float * s, float dt){
// }
}
/**
* Sets the bounds of this cube to those of its neighbor
*/
LIBRARY_API void fluid_grid2_set_bounds(
* Sets the bounds reflecting off hard borders and otherwise assuming continuity
*/
void fluid_grid2_set_bounds_reflection(
Environment * environment,
int vector_dir,
float * target
){
//set the faces bounds
float * boundsArr = environment->state.grid2.fluid_grid2_neighborArr_bounds;
//set the boundary planes
for(int x=1; x < DIM-1; x++){
for(int y = 1; y < DIM-1; y++){
//((x)+(DIM)*(y) + (DIM)*(DIM)*(z))
target[IX(0,x,y)] = vector_dir==FLUID_GRID2_BOUND_DIR_U ? -target[IX(1,x,y)] : target[IX(1,x,y)];
target[IX(DIM-1,x,y)] = vector_dir==FLUID_GRID2_BOUND_DIR_U ? -target[IX(DIM-2,x,y)] : target[IX(DIM-2,x,y)];
target[IX(x,0,y)] = vector_dir==FLUID_GRID2_BOUND_DIR_V ? -target[IX(x,1,y)] : target[IX(x,1,y)];
target[IX(x,DIM-1,y)] = vector_dir==FLUID_GRID2_BOUND_DIR_V ? -target[IX(x,DIM-2,y)] : target[IX(x,DIM-2,y)];
target[IX(x,y,0)] = vector_dir==FLUID_GRID2_BOUND_DIR_W ? -target[IX(x,y,1)] : target[IX(x,y,1)];
target[IX(x,y,DIM-1)] = vector_dir==FLUID_GRID2_BOUND_DIR_W ? -target[IX(x,y,DIM-2)] : target[IX(x,y,DIM-2)];
//x-direction boundary planes
if(vector_dir==BOUND_SET_VECTOR_DIFFUSE_PHI_U || vector_dir==BOUND_SET_VECTOR_U){
if(boundsArr[IX(0,x,y)] > 0){
target[IX(0,x,y)] = -target[IX(1,x,y)];
} else {
target[IX(0,x,y)] = target[IX(1,x,y)];
}
if(boundsArr[IX(DIM-1,x,y)] > 0){
target[IX(DIM-1,x,y)] = -target[IX(DIM-2,x,y)];
} else {
target[IX(DIM-1,x,y)] = target[IX(DIM-2,x,y)];
}
} else {
target[IX(0,x,y)] = target[IX(1,x,y)];
target[IX(DIM-1,x,y)] = target[IX(DIM-2,x,y)];
}
//y-direction boundary planes
if(vector_dir==BOUND_SET_VECTOR_DIFFUSE_PHI_V || vector_dir==BOUND_SET_VECTOR_V){
if(boundsArr[IX(x,0,y)] > 0){
target[IX(x,0,y)] = -target[IX(x,1,y)];
} else {
target[IX(x,0,y)] = target[IX(x,1,y)];
}
if(boundsArr[IX(x,DIM-1,y)] > 0){
target[IX(x,DIM-1,y)] = -target[IX(x,DIM-2,y)];
} else {
target[IX(x,DIM-1,y)] = target[IX(x,DIM-2,y)];
}
} else {
target[IX(x,0,y)] = target[IX(x,1,y)];
target[IX(x,DIM-1,y)] = target[IX(x,DIM-2,y)];
}
//z-direction boundary planes
if(vector_dir==BOUND_SET_VECTOR_DIFFUSE_PHI_W || vector_dir==BOUND_SET_VECTOR_W){
if(boundsArr[IX(x,y,0)] > 0){
target[IX(x,y,0)] = -target[IX(x,y,1)];
} else {
target[IX(x,y,0)] = target[IX(x,y,1)];
}
if(boundsArr[IX(x,y,DIM-1)] > 0){
target[IX(x,y,DIM-1)] = -target[IX(x,y,DIM-2)];
} else {
target[IX(x,y,DIM-1)] = -target[IX(x,y,DIM-2)];
}
} else {
target[IX(x,y,0)] = target[IX(x,y,1)];
target[IX(x,y,DIM-1)] = target[IX(x,y,DIM-2)];
}
}
}
//sets the edges of the chunk
//this should logically follow from how we're treating the boundary planes
for(int x = 1; x < DIM-1; x++){
target[IX(x,0,0)] = (float)(0.5f * (target[IX(x,1,0)] + target[IX(x,0,1)]));
target[IX(x,DIM-1,0)] = (float)(0.5f * (target[IX(x,DIM-2,0)] + target[IX(x,DIM-1,1)]));
@ -81,6 +129,7 @@ LIBRARY_API void fluid_grid2_set_bounds(
}
//sets the corners of the chunk
//this should logically follow from how we're treating the boundary planes
target[IX(0,0,0)] = (float)((target[IX(1,0,0)]+target[IX(0,1,0)]+target[IX(0,0,1)])/3.0);
target[IX(DIM-1,0,0)] = (float)((target[IX(DIM-2,0,0)]+target[IX(DIM-1,1,0)]+target[IX(DIM-1,0,1)])/3.0);
target[IX(0,DIM-1,0)] = (float)((target[IX(1,DIM-1,0)]+target[IX(0,DIM-2,0)]+target[IX(0,DIM-1,1)])/3.0);
@ -92,6 +141,85 @@ LIBRARY_API void fluid_grid2_set_bounds(
}
/**
* Sets the bounds assuming continuity
*/
void fluid_grid2_set_bounds_continuity(
Environment * environment,
float * target
){
float * boundsArr = environment->state.grid2.fluid_grid2_neighborArr_bounds;
//set the boundary planes
for(int x=1; x < DIM-1; x++){
for(int y = 1; y < DIM-1; y++){
target[IX(0,x,y)] = target[IX(1,x,y)];
target[IX(DIM-1,x,y)] = target[IX(DIM-2,x,y)];
target[IX(x,0,y)] = target[IX(x,1,y)];
target[IX(x,DIM-1,y)] = target[IX(x,DIM-2,y)];
target[IX(x,y,0)] = target[IX(x,y,1)];
target[IX(x,y,DIM-1)] = target[IX(x,y,DIM-2)];
}
}
//sets the edges of the chunk
//this should logically follow from how we're treating the boundary planes
for(int x = 1; x < DIM-1; x++){
target[IX(x,0,0)] = (float)(0.5f * (target[IX(x,1,0)] + target[IX(x,0,1)]));
target[IX(x,DIM-1,0)] = (float)(0.5f * (target[IX(x,DIM-2,0)] + target[IX(x,DIM-1,1)]));
target[IX(x,0,DIM-1)] = (float)(0.5f * (target[IX(x,1,DIM-1)] + target[IX(x,0,DIM-2)]));
target[IX(x,DIM-1,DIM-1)] = (float)(0.5f * (target[IX(x,DIM-2,DIM-1)] + target[IX(x,DIM-1,DIM-2)]));
target[IX(0,x,0)] = (float)(0.5f * (target[IX(1,x,0)] + target[IX(0,x,1)]));
target[IX(DIM-1,x,0)] = (float)(0.5f * (target[IX(DIM-2,x,0)] + target[IX(DIM-1,x,1)]));
target[IX(0,x,DIM-1)] = (float)(0.5f * (target[IX(1,x,DIM-1)] + target[IX(0,x,DIM-2)]));
target[IX(DIM-1,x,DIM-1)] = (float)(0.5f * (target[IX(DIM-2,x,DIM-1)] + target[IX(DIM-1,x,DIM-2)]));
target[IX(0,0,x)] = (float)(0.5f * (target[IX(1,0,x)] + target[IX(0,1,x)]));
target[IX(DIM-1,0,x)] = (float)(0.5f * (target[IX(DIM-2,0,x)] + target[IX(DIM-1,1,x)]));
target[IX(0,DIM-1,x)] = (float)(0.5f * (target[IX(1,DIM-1,x)] + target[IX(0,DIM-2,x)]));
target[IX(DIM-1,DIM-1,x)] = (float)(0.5f * (target[IX(DIM-2,DIM-1,x)] + target[IX(DIM-1,DIM-2,x)]));
}
//sets the corners of the chunk
//this should logically follow from how we're treating the boundary planes
target[IX(0,0,0)] = (float)((target[IX(1,0,0)]+target[IX(0,1,0)]+target[IX(0,0,1)])/3.0);
target[IX(DIM-1,0,0)] = (float)((target[IX(DIM-2,0,0)]+target[IX(DIM-1,1,0)]+target[IX(DIM-1,0,1)])/3.0);
target[IX(0,DIM-1,0)] = (float)((target[IX(1,DIM-1,0)]+target[IX(0,DIM-2,0)]+target[IX(0,DIM-1,1)])/3.0);
target[IX(0,0,DIM-1)] = (float)((target[IX(0,0,DIM-2)]+target[IX(1,0,DIM-1)]+target[IX(0,1,DIM-1)])/3.0);
target[IX(DIM-1,DIM-1,0)] = (float)((target[IX(DIM-2,DIM-1,0)]+target[IX(DIM-1,DIM-2,0)]+target[IX(DIM-1,DIM-1,1)])/3.0);
target[IX(0,DIM-1,DIM-1)] = (float)((target[IX(1,DIM-1,DIM-1)]+target[IX(0,DIM-2,DIM-1)]+target[IX(0,DIM-1,DIM-2)])/3.0);
target[IX(DIM-1,0,DIM-1)] = (float)((target[IX(DIM-1,0,DIM-2)]+target[IX(DIM-2,0,DIM-1)]+target[IX(DIM-1,1,DIM-1)])/3.0);
target[IX(DIM-1,DIM-1,DIM-1)] = (float)((target[IX(DIM-1,DIM-1,DIM-2)]+target[IX(DIM-1,DIM-2,DIM-1)]+target[IX(DIM-1,DIM-1,DIM-2)])/3.0);
}
/**
* Sets the bounds of this cube to those of its neighbor
*/
LIBRARY_API void fluid_grid2_set_bounds(
Environment * environment,
int vector_dir,
float * target
){
switch(vector_dir){
case BOUND_SET_VECTOR_DIFFUSE_PHI_U:
case BOUND_SET_VECTOR_DIFFUSE_PHI_V:
case BOUND_SET_VECTOR_DIFFUSE_PHI_W:
case BOUND_SET_VECTOR_U:
case BOUND_SET_VECTOR_V:
case BOUND_SET_VECTOR_W: {
fluid_grid2_set_bounds_reflection(environment,vector_dir,target);
} break;
case BOUND_SET_DENSITY_PHI:
case BOUND_SET_DENSITY:
case BOUND_SET_PROJECTION_PHI:
case BOUND_SET_PROJECTION_PHI_0: {
fluid_grid2_set_bounds_continuity(environment,target);
} break;
}
}
/**
* Sums the density of the chunk
*/

View File

@ -68,9 +68,9 @@ LIBRARY_API void fluid_grid2_solveVectorDiffuse(
solver_gauss_seidel_iterate_parallel(w,w0,a,c,DIM);
//set bounds
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_U,u);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_V,v);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_W,w);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_U,u);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_V,v);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_W,w);
}
}
@ -153,8 +153,8 @@ LIBRARY_API void fluid_grid2_setupProjection(
}
}
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,p);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,div);
fluid_grid2_set_bounds(environment,BOUND_SET_PROJECTION_PHI,p);
fluid_grid2_set_bounds(environment,BOUND_SET_PROJECTION_PHI_0,div);
}
/**
@ -184,7 +184,7 @@ LIBRARY_API void fluid_grid2_solveProjection(
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)){
chunk->projectionResidual = solver_multigrid_parallel_iterate(p,div,a,c);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,p);
fluid_grid2_set_bounds(environment,BOUND_SET_PROJECTION_PHI,p);
chunk->projectionIterations++;
}
// if(chunk->projectionResidual > FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE){
@ -202,7 +202,7 @@ LIBRARY_API void fluid_grid2_solveProjection(
//solve with CG
while(chunk->projectionIterations < FLUID_GRID2_SOLVER_CG_MAX_ITERATIONS && (chunk->projectionResidual > FLUID_GRID2_SOLVER_CG_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_SOLVER_CG_TOLERANCE)){
chunk->projectionResidual = solver_conjugate_gradient_iterate_parallel(p,div,a,c);;
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_NO_DIR,p);
fluid_grid2_set_bounds(environment,BOUND_SET_PROJECTION_PHI,p);
chunk->projectionIterations++;
}
if(chunk->projectionResidual > FLUID_GRID2_SOLVER_CG_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_SOLVER_CG_TOLERANCE){
@ -291,9 +291,9 @@ LIBRARY_API void fluid_grid2_finalizeProjection(
}
}
//set bounds
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_U,u);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_V,v);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_W,w);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_U,u);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_V,v);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_W,w);
}
/*
@ -309,9 +309,9 @@ LIBRARY_API void fluid_grid2_advectVectors(
float ** jrw0,
float dt
){
fluid_grid2_advect_velocity(environment,FLUID_GRID2_BOUND_DIR_U,jru,jru0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
fluid_grid2_advect_velocity(environment,FLUID_GRID2_BOUND_DIR_V,jrv,jrv0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
fluid_grid2_advect_velocity(environment,FLUID_GRID2_BOUND_DIR_W,jrw,jrw0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
fluid_grid2_advect_velocity(environment,FLUID_GRID2_DIRECTION_U,jru,jru0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
fluid_grid2_advect_velocity(environment,FLUID_GRID2_DIRECTION_V,jrv,jrv0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
fluid_grid2_advect_velocity(environment,FLUID_GRID2_DIRECTION_W,jrw,jrw0,GET_ARR_RAW(jru0,CENTER_LOC),GET_ARR_RAW(jrv0,CENTER_LOC),GET_ARR_RAW(jrw0,CENTER_LOC),dt);
}
/**
@ -464,7 +464,7 @@ void fluid_grid2_advect_velocity(Environment * environment, int b, float ** jrd,
}
}
//set bounds
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_U,u);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_V,v);
fluid_grid2_set_bounds(environment,FLUID_GRID2_BOUND_DIR_W,w);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_U,u);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_V,v);
fluid_grid2_set_bounds(environment,BOUND_SET_VECTOR_W,w);
}

View File

@ -60,10 +60,10 @@ int fluid_sim_grid2_advect_projection_test1(){
////project
fluid_grid2_setupProjection(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI_0,currentChunk->v0[CENTER_LOC]);
fluid_grid2_solveProjection(env,currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI,currentChunk->u0[CENTER_LOC]);
fluid_grid2_finalizeProjection(env,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(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI_0,currentChunk->v0[CENTER_LOC]);
fluid_grid2_solveProjection(env,currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI,currentChunk->u0[CENTER_LOC]);
fluid_grid2_finalizeProjection(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
//advect density

View File

@ -78,7 +78,7 @@ int fluid_sim_grid2_density_diffuse_test1(){
//diffuse density
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
fluid_grid2_solveDiffuseDensity(env,currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_NO_DIR,currentChunk->d[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_DENSITY_PHI,currentChunk->d[CENTER_LOC]);
}
//swap all density arrays
//swap vector fields
@ -136,7 +136,7 @@ int fluid_sim_grid2_density_diffuse_test2(){
//diffuse density
for(int l = 0; l < FLUID_GRID2_LINEARSOLVERTIMES; l++){
fluid_grid2_solveDiffuseDensity(env,currentChunk->d,currentChunk->d0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_NO_DIR,currentChunk->d[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_DENSITY_PHI,currentChunk->d[CENTER_LOC]);
}
//swap all density arrays
//swap vector fields

View File

@ -37,7 +37,7 @@ int fluid_sim_grid2_finalize_projection_test1(){
currentChunk->u[CENTER_LOC][IX(3,3,3)] = 1.0f;
fluid_grid2_setupProjection(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(env,currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_PROJECTION_PHI,currentChunk->u0[CENTER_LOC]);
//finalize
fluid_grid2_finalizeProjection(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);

View File

@ -37,9 +37,9 @@ int fluid_sim_grid2_velocity_advection_test1(){
Chunk * currentChunk = queue[0];
currentChunk->d[CENTER_LOC][IX(2,2,2)] = MAX_FLUID_VALUE;
advection_setup_convection_cell(queue, FLUID_GRID2_VELOCITY_ADVECTION_CELL_CENTER);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
//actually simulate
int frameCount = 50;
@ -54,9 +54,9 @@ int fluid_sim_grid2_velocity_advection_test1(){
}
//test the result
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
if(fabs(beforeSumX - afterSumX) > FLUID_GRID2_REALLY_SMALL_VALUE){
rVal += assertEqualsFloat(beforeSumX,afterSumX,"Velocity advection step changed x-velocity sum! %f %f \n");
}
@ -87,9 +87,9 @@ int fluid_sim_grid2_velocity_advection_test2(){
queue[0]->u[CENTER_LOC][IX(15,15,15)] = 1;
queue[0]->v[CENTER_LOC][IX(15,15,15)] = 1;
queue[0]->w[CENTER_LOC][IX(15,15,15)] = 1;
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
//actually simulate
int frameCount = 1;
@ -108,9 +108,9 @@ int fluid_sim_grid2_velocity_advection_test2(){
}
//test the result
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
if(fabs(beforeSumX - afterSumX) > FLUID_GRID2_REALLY_SMALL_VALUE){
rVal += assertEqualsFloat(beforeSumX,afterSumX,"Velocity advection step changed x-velocity sum! %f %f \n");
}
@ -141,9 +141,9 @@ int fluid_sim_grid2_velocity_advection_test3(){
Chunk * currentChunk = queue[0];
currentChunk->d[CENTER_LOC][IX(2,2,2)] = MAX_FLUID_VALUE;
advection_setup_convection_cell(queue, FLUID_GRID2_VELOCITY_ADVECTION_CELL_CENTER);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
//actually simulate
int frameCount = 50;
@ -158,9 +158,9 @@ int fluid_sim_grid2_velocity_advection_test3(){
}
//test the result
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
if(fabs(beforeSumX - afterSumX) > FLUID_GRID2_REALLY_SMALL_VALUE){
rVal += assertEqualsFloat(beforeSumX,afterSumX,"Velocity advection step changed x-velocity sum! %f %f \n");
}

View File

@ -41,9 +41,9 @@ int fluid_sim_grid2_velocity_diffuse_test1(){
currentChunk->v[CENTER_LOC][IX(3,2,2)] = FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL;
currentChunk->w[CENTER_LOC][IX(2,2,3)] = FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL;
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
rVal += assertEqualsFloat(beforeSumX,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"x-velocity diffuse step changed velocity sum! %f %f \n");
rVal += assertEqualsFloat(beforeSumY,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"y-velocity diffuse step changed velocity sum! %f %f \n");
rVal += assertEqualsFloat(beforeSumZ,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"z-velocity diffuse step changed velocity sum! %f %f \n");
@ -57,9 +57,9 @@ int fluid_sim_grid2_velocity_diffuse_test1(){
//solve vector diffusion
fluid_grid2_solveVectorDiffuse(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
//update array for vectors
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_U,currentChunk->u[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_V,currentChunk->v[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_W,currentChunk->w[CENTER_LOC]);
}
//swap all density arrays
//swap vector fields
@ -68,9 +68,9 @@ int fluid_sim_grid2_velocity_diffuse_test1(){
fluid_grid2_flip_arrays(currentChunk->w,currentChunk->w0);
//sum the result
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
//actually check
rVal += assertEqualsFloat(beforeSumX,afterSumX,"x-velocity diffuse step changed velocity sum! %f %f \n");
@ -99,9 +99,9 @@ int fluid_sim_grid2_velocity_diffuse_test2(){
currentChunk->v[CENTER_LOC][IX(3,2,2)] = FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL;
currentChunk->w[CENTER_LOC][IX(2,2,3)] = FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL;
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float beforeSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float beforeSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float beforeSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
rVal += assertEqualsFloat(beforeSumX,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"x-velocity diffuse step changed velocity sum! %f %f \n");
rVal += assertEqualsFloat(beforeSumY,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"y-velocity diffuse step changed velocity sum! %f %f \n");
rVal += assertEqualsFloat(beforeSumZ,FLUID_GRID2_VELOCITY_DIFFUSE_TESTS_PLACEMENT_VAL,"z-velocity diffuse step changed velocity sum! %f %f \n");
@ -117,9 +117,9 @@ int fluid_sim_grid2_velocity_diffuse_test2(){
//solve vector diffusion
fluid_grid2_solveVectorDiffuse(env,currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,currentChunk->w0,FLUID_GRID2_SIM_STEP);
//update array for vectors
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_U,currentChunk->u[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_V,currentChunk->v[CENTER_LOC]);
fluid_grid2_set_bounds(env,FLUID_GRID2_BOUND_DIR_W,currentChunk->w[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_U,currentChunk->u[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_V,currentChunk->v[CENTER_LOC]);
fluid_grid2_set_bounds(env,BOUND_SET_VECTOR_W,currentChunk->w[CENTER_LOC]);
}
//swap all density arrays
//swap vector fields
@ -129,9 +129,9 @@ int fluid_sim_grid2_velocity_diffuse_test2(){
}
//sum the result
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_BOUND_DIR_W);
float afterSumX = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_U);
float afterSumY = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_V);
float afterSumZ = chunk_queue_sum_velocity(queue,FLUID_GRID2_DIRECTION_W);
//actually check
rVal += assertEqualsFloat(beforeSumX,afterSumX,"x-velocity diffuse step changed velocity sum! %f %f \n");

View File

@ -8,6 +8,7 @@
#include "fluid/env/environment.h"
#include "fluid/env/utilities.h"
#include "fluid/sim/grid2/velocity.h"
#include "fluid/sim/grid2/utilities.h"
#include "chunk_test_utils.h"
@ -284,11 +285,11 @@ float chunk_queue_sum_velocity(Chunk ** chunks, int axis){
for(int x = 1; x < DIM - 1; x++){
for(int y = 1; y < DIM - 1; y++){
for(int z = 1; z < DIM - 1; z++){
if(axis == FLUID_GRID2_BOUND_DIR_U){
if(axis == FLUID_GRID2_DIRECTION_U){
sum = sum + current->u[CENTER_LOC][IX(x,y,z)];
} else if(axis == FLUID_GRID2_BOUND_DIR_V){
} else if(axis == FLUID_GRID2_DIRECTION_V){
sum = sum + current->v[CENTER_LOC][IX(x,y,z)];
} else if(axis == FLUID_GRID2_BOUND_DIR_W){
} else if(axis == FLUID_GRID2_DIRECTION_W){
sum = sum + current->w[CENTER_LOC][IX(x,y,z)];
}
}