fix velocity not being tracked properly
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-15 22:27:48 -05:00
parent 757a4aa409
commit c50e22cfd3
4 changed files with 18 additions and 18 deletions

View File

@ -10,7 +10,7 @@
/**
* Spacing of cells
*/
#define FLUID_PRESSURECELL_SPACING (1.0f/DIM)
#define FLUID_PRESSURECELL_SPACING 1.0f
/**
* Multiplier applied to pressure calculations to encourage advection
@ -25,12 +25,12 @@
/**
* Diffusion constant
*/
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.01f
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.00001f
/**
* Viscosity constant
*/
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.01f
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.00001f
/**
* Amount of the residual to add to the pressure field each frame

View File

@ -13,7 +13,7 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
int x, y, z;
//values stored across frames
float * presureCache = chunk->pressureCache[CENTER_LOC];
float * divArr = chunk->divergenceCache[CENTER_LOC];
float * divCache = chunk->divergenceCache[CENTER_LOC];
float * uArr = chunk->u[CENTER_LOC];
float * vArr = chunk->v[CENTER_LOC];
float * wArr = chunk->w[CENTER_LOC];
@ -81,12 +81,12 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
for(z = 0; z < DIM; z++){
for(y = 0; y < DIM; y++){
for(x = 0; x < DIM; x++){
phi0[IX(x,y,z)] = divArr[IX(x,y,z)];
phi0[IX(x,y,z)] = divCache[IX(x,y,z)];
pressureTemp[IX(x,y,z)] = pressureCache[IX(x,y,z)];
// pressureTemp[IX(x,y,z)] = 0;
if(divArr[IX(x,y,z)] > 3){
if(divCache[IX(x,y,z)] > 3){
printf("invalid divergence!\n");
printf("%f \n", divArr[IX(x,y,z)]);
printf("%f \n", divCache[IX(x,y,z)]);
printf("\n");
}
}
@ -107,12 +107,12 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
// pressureTemp[IX(x,y,DIM-1)] = pressureCache[IX(x,y,DIM-1)];
//divergence borders
phi0[IX(0,x,y)] = divArr[IX(0,x,y)];
phi0[IX(DIM-1,x,y)] = divArr[IX(DIM-1,x,y)];
phi0[IX(x,0,y)] = divArr[IX(x,0,y)];
phi0[IX(x,DIM-1,y)] = divArr[IX(x,DIM-1,y)];
phi0[IX(x,y,0)] = divArr[IX(x,y,0)];
phi0[IX(x,y,DIM-1)] = divArr[IX(x,y,DIM-1)];
phi0[IX(0,x,y)] = divCache[IX(0,x,y)];
phi0[IX(DIM-1,x,y)] = divCache[IX(DIM-1,x,y)];
phi0[IX(x,0,y)] = divCache[IX(x,0,y)];
phi0[IX(x,DIM-1,y)] = divCache[IX(x,DIM-1,y)];
phi0[IX(x,y,0)] = divCache[IX(x,y,0)];
phi0[IX(x,y,DIM-1)] = divCache[IX(x,y,DIM-1)];
}
}
float a = 1;

View File

@ -90,7 +90,7 @@ LIBRARY_API void fluid_pressurecell_simulate(
// fflush(stdout);
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
//uTemp->u
//uTemp->u0
pressurecell_diffuse_velocity(environment,currentChunk);
}
@ -98,7 +98,7 @@ LIBRARY_API void fluid_pressurecell_simulate(
// fflush(stdout);
for(int i = 0; i < numChunks; i++){
Chunk * currentChunk = chunks[i];
//u->uTemp
//u0->uTemp
pressurecell_advect_velocity(environment,currentChunk);
}

View File

@ -54,9 +54,9 @@ LIBRARY_API void pressurecell_add_velocity(Environment * environment, Chunk * ch
LIBRARY_API void pressurecell_diffuse_velocity(Environment * environment, Chunk * chunk){
int x, y, z;
float * dArr = chunk->d[CENTER_LOC];
float * uArr = chunk->u[CENTER_LOC];
float * vArr = chunk->v[CENTER_LOC];
float * wArr = chunk->w[CENTER_LOC];
float * uArr = chunk->u0[CENTER_LOC];
float * vArr = chunk->v0[CENTER_LOC];
float * wArr = chunk->w0[CENTER_LOC];
float * uTemp = chunk->uTempCache;
float * vTemp = chunk->vTempCache;
float * wTemp = chunk->wTempCache;