const change + promising results
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
06502e665e
commit
de3e29c99e
@ -10,7 +10,7 @@
|
|||||||
/**
|
/**
|
||||||
* Spacing of cells
|
* Spacing of cells
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_SPACING 1.0f
|
#define FLUID_PRESSURECELL_SPACING (1.0f/DIM)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Multiplier applied to pressure calculations to encourage advection
|
* Multiplier applied to pressure calculations to encourage advection
|
||||||
@ -25,12 +25,12 @@
|
|||||||
/**
|
/**
|
||||||
* Diffusion constant
|
* Diffusion constant
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.1f
|
#define FLUID_PRESSURECELL_DIFFUSION_CONSTANT 0.01f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Viscosity constant
|
* Viscosity constant
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.1f
|
#define FLUID_PRESSURECELL_VISCOSITY_CONSTANT 0.01f
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Amount of the residual to add to the pressure field each frame
|
* Amount of the residual to add to the pressure field each frame
|
||||||
@ -52,15 +52,15 @@
|
|||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_PROJECTION_CONVERGENCE_TOLERANCE 0.01f
|
#define FLUID_PRESSURECELL_PROJECTION_CONVERGENCE_TOLERANCE 0.01f
|
||||||
|
|
||||||
/**
|
|
||||||
* The minimum pressure allowed
|
|
||||||
*/
|
|
||||||
#define FLUID_PRESSURECELL_MIN_PRESSURE -10000.0f
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum pressure allowed
|
* The maximum pressure allowed
|
||||||
*/
|
*/
|
||||||
#define FLUID_PRESSURECELL_MAX_PRESSURE 10000.0f
|
#define FLUID_PRESSURECELL_MAX_PRESSURE 1000.0f
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimum pressure allowed
|
||||||
|
*/
|
||||||
|
#define FLUID_PRESSURECELL_MIN_PRESSURE -FLUID_PRESSURECELL_MAX_PRESSURE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Percentage of presure to keep from last frame
|
* Percentage of presure to keep from last frame
|
||||||
|
|||||||
@ -71,9 +71,9 @@ LIBRARY_API void fluid_pressurecell_normalize_chunk(Environment * env, Chunk * c
|
|||||||
LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk * chunk){
|
LIBRARY_API void fluid_pressurecell_recapture_density(Environment * env, Chunk * chunk){
|
||||||
int x, y;
|
int x, y;
|
||||||
float * dArr = chunk->d[CENTER_LOC];
|
float * dArr = chunk->d[CENTER_LOC];
|
||||||
float * uArr = chunk->u[CENTER_LOC];
|
float * uArr = chunk->uTempCache;
|
||||||
float * vArr = chunk->v[CENTER_LOC];
|
float * vArr = chunk->vTempCache;
|
||||||
float * wArr = chunk->w[CENTER_LOC];
|
float * wArr = chunk->wTempCache;
|
||||||
int ghostIndex, adjacentIndex;
|
int ghostIndex, adjacentIndex;
|
||||||
float overdraw, estimatedLoss, invertedForce;
|
float overdraw, estimatedLoss, invertedForce;
|
||||||
//clear neighbor outgoing values
|
//clear neighbor outgoing values
|
||||||
|
|||||||
@ -157,7 +157,7 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
|
|||||||
for(z = 1; z < DIM-1; z++){
|
for(z = 1; z < DIM-1; z++){
|
||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
for(x = 1; x < DIM; x++){
|
for(x = 1; x < DIM; x++){
|
||||||
if(pressureTemp[IX(x,y,z)] > 10000.0f){
|
if(pressureTemp[IX(x,y,z)] > FLUID_PRESSURECELL_MAX_PRESSURE){
|
||||||
printf("Invalid pressure!\n");
|
printf("Invalid pressure!\n");
|
||||||
printf("%f %f \n", phi0[IX(x-1,y,z)], phi0[IX(x+1,y,z)]);
|
printf("%f %f \n", phi0[IX(x-1,y,z)], phi0[IX(x+1,y,z)]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -202,17 +202,20 @@ LIBRARY_API void pressurecell_approximate_pressure(Environment * environment, Ch
|
|||||||
for(z = 1; z < DIM-1; z++){
|
for(z = 1; z < DIM-1; z++){
|
||||||
for(y = 1; y < DIM-1; y++){
|
for(y = 1; y < DIM-1; y++){
|
||||||
for(x = 1; x < DIM; x++){
|
for(x = 1; x < DIM; x++){
|
||||||
if(pressureTemp[IX(x,y,z)] > pressureMax){
|
if(fabs(pressureTemp[IX(x,y,z)]) > pressureMax){
|
||||||
pressureMax = pressureTemp[IX(x,y,z)];
|
pressureMax = pressureTemp[IX(x,y,z)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(z = 1; z < DIM-1; z++){
|
if(pressureMax > FLUID_PRESSURECELL_MAX_PRESSURE){
|
||||||
for(y = 1; y < DIM-1; y++){
|
printf("pressureMax: %f \n",pressureMax);
|
||||||
for(x = 1; x < DIM; x++){
|
for(z = 1; z < DIM-1; z++){
|
||||||
if(pressureTemp[IX(x,y,z)] > pressureMax){
|
for(y = 1; y < DIM-1; y++){
|
||||||
pressureTemp[IX(x,y,z)] = pressureTemp[IX(x,y,z)] / pressureMax;
|
for(x = 1; x < DIM; x++){
|
||||||
|
if(pressureTemp[IX(x,y,z)] > pressureMax){
|
||||||
|
pressureTemp[IX(x,y,z)] = pressureTemp[IX(x,y,z)] / pressureMax;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,12 +107,6 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
pressurecell_advect_velocity(environment,currentChunk);
|
pressurecell_advect_velocity(environment,currentChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < numChunks; i++){
|
|
||||||
Chunk * currentChunk = chunks[i];
|
|
||||||
//uTemp->div
|
|
||||||
pressurecell_enforce_bounds(environment,currentChunk);
|
|
||||||
}
|
|
||||||
|
|
||||||
// printf("approx div\n");
|
// printf("approx div\n");
|
||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
@ -144,8 +138,10 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
// printf("adv dens\n");
|
// printf("adv dens\n");
|
||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
|
//uTemp->d
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
pressurecell_advect_density(environment,currentChunk);
|
pressurecell_advect_density(environment,currentChunk);
|
||||||
|
fluid_pressurecell_recapture_density(environment,currentChunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -159,7 +155,6 @@ LIBRARY_API void fluid_pressurecell_simulate(
|
|||||||
for(int i = 0; i < numChunks; i++){
|
for(int i = 0; i < numChunks; i++){
|
||||||
Chunk * currentChunk = chunks[i];
|
Chunk * currentChunk = chunks[i];
|
||||||
fluid_pressurecell_normalize_chunk(environment,currentChunk);
|
fluid_pressurecell_normalize_chunk(environment,currentChunk);
|
||||||
fluid_pressurecell_recapture_density(environment,currentChunk);
|
|
||||||
pressurecell_copy_for_next_frame(environment,currentChunk);
|
pressurecell_copy_for_next_frame(environment,currentChunk);
|
||||||
fluid_pressurecell_clearArr(currentChunk->d0[CENTER_LOC]);
|
fluid_pressurecell_clearArr(currentChunk->d0[CENTER_LOC]);
|
||||||
fluid_pressurecell_clearArr(currentChunk->u0[CENTER_LOC]);
|
fluid_pressurecell_clearArr(currentChunk->u0[CENTER_LOC]);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user