cellular stability work
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
2ec5ad9a93
commit
3a87349a66
@ -21,6 +21,11 @@
|
||||
*/
|
||||
#define FLUID_CELLULAR_SURFACE_TENSION_CONST 0.4
|
||||
|
||||
/**
|
||||
* This is the expected amount of variance frame-to-frame for a chunk that is completely full of fluid
|
||||
*/
|
||||
#define FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1 0.1f
|
||||
|
||||
/**
|
||||
* Simulates the cellular chunk queue
|
||||
* @param environment The environment storing the simulation queues
|
||||
|
||||
@ -196,6 +196,12 @@ LIBRARY_API void fluid_cellular_simulate(Environment * environment){
|
||||
if(d[IX(x,y,z)] < FLUID_CELLULAR_DIFFUSE_RATE2){
|
||||
transfer = d[IX(x,y,z)];
|
||||
}
|
||||
// if(worldX == 2 && worldZ == 2){
|
||||
// printf("lateral\n");
|
||||
// printf("[%d %d %d] <%d,%d,%d> --> <%d,%d,%d> \n",worldX,worldY,worldZ,x,y,z,nX,y,nZ);
|
||||
// printf("%f %d %d --> %d %d \n",transfer,permuteX,permuteZ,permuteX + xKernel,permuteZ + zKernel);
|
||||
// printf("%f %f \n",d[IX(x,y,z)],d[IX(nX,y,nZ)]);
|
||||
// }
|
||||
// printf("lateral\n");
|
||||
// printf("[%d %d %d] <%d,%d,%d> --> <%d,%d,%d> \n",worldX,worldY,worldZ,x,y,z,nX,y,nZ);
|
||||
// printf("%f %d %d --> %d %d \n",transfer,permuteX,permuteZ,permuteX + xKernel,permuteZ + zKernel);
|
||||
@ -206,6 +212,13 @@ LIBRARY_API void fluid_cellular_simulate(Environment * environment){
|
||||
// printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
// if(worldX == 2 && worldZ == 2 && x == 15 && z == 9){
|
||||
// printf("lateral\n");
|
||||
// printf("[%d %d %d] <%d,%d,%d> --> <%d,%d,%d> \n",worldX,worldY,worldZ,x,y,z,nX,y,nZ);
|
||||
// printf("%d %d --> %d %d \n",permuteX,permuteZ,permuteX + xKernel,permuteZ + zKernel);
|
||||
// printf("%f %f \n",d[IX(x,y,z)],d[IX(nX,y,nZ)]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,8 +19,16 @@
|
||||
|
||||
|
||||
#define CELLULAR_TEST_PLACE_VAL (FLUID_CELLULAR_DIFFUSE_RATE2 + 0.13456f)
|
||||
#define TOLLERABLE_LOSS_THRESHOLD 0.1f
|
||||
#define TOLLERABLE_LOSS_THRESHOLD2 0.0001f
|
||||
|
||||
/**
|
||||
* Stricter threshold used for sparser chunks
|
||||
*/
|
||||
#define FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2 0.0001f
|
||||
|
||||
/**
|
||||
* Strictest threshold used for sparser chunks
|
||||
*/
|
||||
#define FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3 0.01f
|
||||
|
||||
int fluid_sim_cellular_cellular_tests_kernelx[27] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
@ -98,101 +106,17 @@ void fluid_sim_cellular_test_diagnose_desync(Chunk ** queue){
|
||||
printf("mismatch at [%d %d %d] <1,1,1> \n", worldX,worldY,worldZ);
|
||||
}
|
||||
}
|
||||
// if(d[CK(2,1,1)] != NULL){
|
||||
// realX = worldX * 16 + 17;
|
||||
// realZ = worldZ * 16 + 1;
|
||||
// if(d[CENTER_LOC][IX(17,1,1)] != d[CK(2,1,1)][IX(1,1,1)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 17;
|
||||
// realZ = worldZ * 16 + 16;
|
||||
// if(d[CENTER_LOC][IX(17,1,16)] != d[CK(2,1,1)][IX(1,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 16;
|
||||
// realZ = worldZ * 16 + 1;
|
||||
// if(d[CENTER_LOC][IX(16,1,1)] != d[CK(2,1,1)][IX(0,1,1)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 16;
|
||||
// realZ = worldZ * 16 + 16;
|
||||
// if(d[CENTER_LOC][IX(16,1,16)] != d[CK(2,1,1)][IX(0,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// }
|
||||
// if(d[CK(0,1,1)] != NULL){
|
||||
// realX = worldX * 16 + 0;
|
||||
// realZ = worldZ * 16 + 1;
|
||||
// if(d[CENTER_LOC][IX(0,1,1)] != d[CK(0,1,1)][IX(16,1,1)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 0;
|
||||
// realZ = worldZ * 16 + 16;
|
||||
// if(d[CENTER_LOC][IX(0,1,16)] != d[CK(0,1,1)][IX(16,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 1;
|
||||
// realZ = worldZ * 16 + 1;
|
||||
// if(d[CENTER_LOC][IX(1,1,1)] != d[CK(0,1,1)][IX(17,1,1)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 1;
|
||||
// realZ = worldZ * 16 + 16;
|
||||
// if(d[CENTER_LOC][IX(1,1,16)] != d[CK(0,1,1)][IX(17,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(d[CK(1,1,2)] != NULL){
|
||||
// realX = worldX * 16 + 1;
|
||||
// realZ = worldZ * 16 + 17;
|
||||
// if(d[CENTER_LOC][IX(1,1,17)] != d[CK(1,1,2)][IX(1,1,1)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 16;
|
||||
// realZ = worldZ * 16 + 16;
|
||||
// if(d[CENTER_LOC][IX(16,1,0)] != d[CK(0,1,1)][IX(16,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(d[CK(1,1,0)] != NULL){
|
||||
// realX = worldX * 16 + 1;
|
||||
// realZ = worldZ * 16 + 0;
|
||||
// if(d[CENTER_LOC][IX(1,1,0)] != d[CK(1,1,0)][IX(1,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// realX = worldX * 16 + 16;
|
||||
// realZ = worldZ * 16 + 0;
|
||||
// if(d[CENTER_LOC][IX(16,1,0)] != d[CK(1,1,0)][IX(16,1,16)]){
|
||||
// printf("mismatch in [%d %d %d] / [%d %d %d] \n", worldX,worldY,worldZ, worldX+1,worldY,worldZ );
|
||||
// printf("pos of mismatch %d %d\n",realX,realZ);
|
||||
// printf("\n");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
void fluid_sim_cellular_test_print_slice(Chunk * chunk, int y){
|
||||
float * d = chunk->d[CENTER_LOC];
|
||||
for(int x = 0; x < DIM; x++){
|
||||
for(int z = 0; z < DIM; z++){
|
||||
printf("%.2f ", d[IX(x,y,z)]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,7 +419,7 @@ int fluid_sim_cellular_stability_test3(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -521,7 +445,7 @@ int fluid_sim_cellular_stability_test3(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -566,7 +490,7 @@ int fluid_sim_cellular_stability_test4(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d --- %f \n",frameCounter,delta);
|
||||
@ -592,7 +516,7 @@ int fluid_sim_cellular_stability_test4(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -644,7 +568,7 @@ int fluid_sim_cellular_stability_test5(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -670,7 +594,7 @@ int fluid_sim_cellular_stability_test5(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -722,7 +646,7 @@ int fluid_sim_cellular_stability_test6(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -748,7 +672,7 @@ int fluid_sim_cellular_stability_test6(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -782,10 +706,11 @@ int fluid_sim_cellular_stability_test7(){
|
||||
}
|
||||
|
||||
//fill the 10th chunk
|
||||
int size = 16;
|
||||
for(int x = 1; x < size+1; x++){
|
||||
for(int y = 1; y < size+1; y++){
|
||||
for(int z = 1; z < size+1; z++){
|
||||
int lowerBound = 1;
|
||||
int upperBound = 16;
|
||||
for(int x = lowerBound; x < upperBound+1; x++){
|
||||
for(int y = lowerBound; y < upperBound+1; y++){
|
||||
for(int z = lowerBound; z < upperBound+1; z++){
|
||||
queue[13]->d[CENTER_LOC][IX(x,y,z)] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
@ -799,22 +724,21 @@ int fluid_sim_cellular_stability_test7(){
|
||||
int frameCounter;
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
// printf("frame: %d --- %f \n", frameCounter,currentSum);
|
||||
printf("frame: %d --- %f \n", frameCounter,currentSum);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
fluid_dispatch(chunkCount,queue,env);
|
||||
fluid_simulate(env);
|
||||
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
float postSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - postSum);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(postSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync on frame %d \n",frameCounter);
|
||||
fluid_sim_cellular_test_diagnose_desync(queue);
|
||||
break;
|
||||
}
|
||||
// printf("\n");
|
||||
printf("\n");
|
||||
env->state.frame++;
|
||||
}
|
||||
|
||||
@ -828,7 +752,7 @@ int fluid_sim_cellular_stability_test7(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -880,7 +804,7 @@ int fluid_sim_cellular_stability_test8(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -906,7 +830,7 @@ int fluid_sim_cellular_stability_test8(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -959,7 +883,7 @@ int fluid_sim_cellular_stability_test9(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -985,7 +909,7 @@ int fluid_sim_cellular_stability_test9(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -1037,7 +961,7 @@ int fluid_sim_cellular_stability_test10(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD2){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -1063,7 +987,7 @@ int fluid_sim_cellular_stability_test10(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD3){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -1071,9 +995,9 @@ int fluid_sim_cellular_stability_test10(){
|
||||
return rVal;
|
||||
}
|
||||
|
||||
int fluid_sim_cellular_stability_test_full_chunk(){
|
||||
int fluid_sim_cellular_stability_test11(){
|
||||
int rVal = 0;
|
||||
printf("fluid_sim_cellular_stability_test_full_chunk\n");
|
||||
printf("fluid_sim_cellular_stability_test11\n");
|
||||
|
||||
Environment * env = fluid_environment_create();
|
||||
|
||||
@ -1108,7 +1032,7 @@ int fluid_sim_cellular_stability_test_full_chunk(){
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
@ -1133,7 +1057,292 @@ int fluid_sim_cellular_stability_test_full_chunk(){
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > TOLLERABLE_LOSS_THRESHOLD){
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
return rVal;
|
||||
}
|
||||
|
||||
int fluid_sim_cellular_stability_test12(){
|
||||
int rVal = 0;
|
||||
printf("fluid_sim_cellular_stability_test12\n");
|
||||
|
||||
Environment * env = fluid_environment_create();
|
||||
|
||||
int chunkCount = 27;
|
||||
|
||||
Chunk ** queue = NULL;
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
arrput(queue,chunk_create(
|
||||
fluid_sim_cellular_cellular_tests_kernelx[i],
|
||||
fluid_sim_cellular_cellular_tests_kernely[i],
|
||||
fluid_sim_cellular_cellular_tests_kernelz[i]
|
||||
));
|
||||
}
|
||||
|
||||
//link neighbors
|
||||
chunk_link_neighbors(queue);
|
||||
|
||||
//fill them with values
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
chunk_fill(queue[i],0);
|
||||
}
|
||||
|
||||
//fill the bottom plane of chunks
|
||||
for(int x = 0; x < 3; x++){
|
||||
for(int z = 0; z < 3; z++){
|
||||
chunk_fill_real(queue[x * 3 * 3 + z]->d[CENTER_LOC],MAX_FLUID_VALUE);
|
||||
}
|
||||
}
|
||||
|
||||
//check sum beforehand
|
||||
float originalSum = chunk_queue_sum(queue);
|
||||
|
||||
//dispatch and simulate
|
||||
int frameCount = 100;
|
||||
int frameCounter;
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
break;
|
||||
}
|
||||
// printf("frame: %d --- %f \n", frameCounter,currentSum);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
fluid_dispatch(chunkCount,queue,env);
|
||||
fluid_simulate(env);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
// printf("\n");
|
||||
env->state.frame++;
|
||||
}
|
||||
|
||||
//solve bounds afterwards to properly push data back into real arrays
|
||||
//ie, if data is pushed out of bounds from one chunk to another, must
|
||||
//then copy it into the in-bounds chunk
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
|
||||
//check sum beforehand
|
||||
float afterSum = chunk_queue_sum(queue);
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
return rVal;
|
||||
}
|
||||
|
||||
int fluid_sim_cellular_stability_test13(){
|
||||
int rVal = 0;
|
||||
printf("fluid_sim_cellular_stability_test13\n");
|
||||
|
||||
Environment * env = fluid_environment_create();
|
||||
|
||||
int chunkCount = 27;
|
||||
|
||||
Chunk ** queue = NULL;
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
arrput(queue,chunk_create(
|
||||
fluid_sim_cellular_cellular_tests_kernelx[i],
|
||||
fluid_sim_cellular_cellular_tests_kernely[i],
|
||||
fluid_sim_cellular_cellular_tests_kernelz[i]
|
||||
));
|
||||
}
|
||||
|
||||
//link neighbors
|
||||
chunk_link_neighbors(queue);
|
||||
|
||||
//fill them with values
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
chunk_fill(queue[i],0);
|
||||
}
|
||||
|
||||
//fill the bottom plane of chunks
|
||||
for(int x = 0; x < 3; x++){
|
||||
for(int z = 0; z < 3; z++){
|
||||
float ** d = queue[x * 3 * 3 + z]->d;
|
||||
for(int i = 1; i < DIM-1; i++){
|
||||
for(int j = 1; j < DIM-1; j++){
|
||||
d[CENTER_LOC][IX(i,1,j)] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check sum beforehand
|
||||
float originalSum = chunk_queue_sum(queue);
|
||||
|
||||
//dispatch and simulate
|
||||
int frameCount = 100;
|
||||
int frameCounter;
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
break;
|
||||
}
|
||||
// printf("frame: %d --- %f \n", frameCounter,currentSum);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
fluid_dispatch(chunkCount,queue,env);
|
||||
fluid_simulate(env);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
// printf("\n");
|
||||
env->state.frame++;
|
||||
}
|
||||
|
||||
//solve bounds afterwards to properly push data back into real arrays
|
||||
//ie, if data is pushed out of bounds from one chunk to another, must
|
||||
//then copy it into the in-bounds chunk
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
|
||||
//check sum beforehand
|
||||
float afterSum = chunk_queue_sum(queue);
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
return rVal;
|
||||
}
|
||||
|
||||
int fluid_sim_cellular_stability_test14(){
|
||||
int rVal = 0;
|
||||
printf("fluid_sim_cellular_stability_test14\n");
|
||||
|
||||
Environment * env = fluid_environment_create();
|
||||
|
||||
int chunkCount = 27;
|
||||
|
||||
Chunk ** queue = NULL;
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
arrput(queue,chunk_create(
|
||||
fluid_sim_cellular_cellular_tests_kernelx[i],
|
||||
fluid_sim_cellular_cellular_tests_kernely[i],
|
||||
fluid_sim_cellular_cellular_tests_kernelz[i]
|
||||
));
|
||||
}
|
||||
|
||||
//link neighbors
|
||||
chunk_link_neighbors(queue);
|
||||
|
||||
//fill them with values
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
chunk_fill(queue[i],0);
|
||||
}
|
||||
|
||||
//fill the bottom plane of chunks
|
||||
for(int x = 0; x < 3; x++){
|
||||
for(int z = 0; z < 3; z++){
|
||||
float ** d = queue[x * 3 * 3 + z]->d;
|
||||
for(int i = 1; i < DIM-2; i++){
|
||||
for(int j = 1; j < DIM-2; j++){
|
||||
d[CENTER_LOC][IX(i,1,j)] = MAX_FLUID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//check sum beforehand
|
||||
float originalSum = chunk_queue_sum(queue);
|
||||
|
||||
float slice[16 * 3][16 * 3];
|
||||
int compareX = 2;
|
||||
int compareZ = 2;
|
||||
float compSum = 0;
|
||||
|
||||
//dispatch and simulate
|
||||
int frameCount = 100;
|
||||
int frameCounter;
|
||||
for(frameCounter = 0; frameCounter < frameCount; frameCounter++){
|
||||
float currentSum = chunk_queue_sum(queue);
|
||||
float delta = fabs(originalSum - currentSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
printf("Failed to equal sums! \n");
|
||||
rVal += assertEqualsFloat(currentSum,originalSum,"Sums are not identical! %f %f \n");
|
||||
printf("desync by frame %d \n",frameCounter);
|
||||
break;
|
||||
}
|
||||
// printf("frame: %d --- %f \n", frameCounter,currentSum);
|
||||
for(int i = 0; i < 3; i++){
|
||||
for(int j = 0; j < 3; j++){
|
||||
for(int x = 1; x < DIM-1; x++){
|
||||
for(int z = 1; z < DIM-1; z++){
|
||||
Chunk * chunk = fluid_sim_cellular_test_get_chunk(queue,compareX,0,compareZ);
|
||||
float * d = chunk->d[CENTER_LOC];
|
||||
slice[x-1 + i * 16][z-1 + j * 16] = d[IX(x,1,z)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
fluid_dispatch(chunkCount,queue,env);
|
||||
fluid_simulate(env);
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
// compSum= 0 ;
|
||||
// for(int i = 0; i < 3; i++){
|
||||
// for(int j = 0; j < 3; j++){
|
||||
// for(int x = 1; x < DIM-1; x++){
|
||||
// for(int z = 1; z < DIM-1; z++){
|
||||
// compareX = i;
|
||||
// compareZ = j;
|
||||
// float newVal = fluid_sim_cellular_test_get_chunk(queue,compareX,0,compareZ)->d[CENTER_LOC][IX(x,1,z)];
|
||||
// float sliceVal = slice[x-1 + i * 16][z-1 + j * 16];
|
||||
// if(fabs(newVal - sliceVal) > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
// compSum = compSum + (newVal - sliceVal);
|
||||
// // printf("change at %d %d -- %f %f \n",x,z,sliceVal,newVal);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(compSum > 1.0f){
|
||||
// printf("compSum: %f \n",compSum);
|
||||
// for(int i = 0; i < 3; i++){
|
||||
// for(int j = 0; j < 3; j++){
|
||||
// for(int x = 1; x < DIM-1; x++){
|
||||
// for(int z = 1; z < DIM-1; z++){
|
||||
// compareX = i;
|
||||
// compareZ = j;
|
||||
// float newVal = fluid_sim_cellular_test_get_chunk(queue,compareX,0,compareZ)->d[CENTER_LOC][IX(x,1,z)];
|
||||
// float sliceVal = slice[x-1 + i * 16][z-1 + j * 16];
|
||||
// if(fabs(newVal - sliceVal) > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD2){
|
||||
// printf("change at %d %d -- %f %f \n",x + i * 16,z + j * 16,sliceVal,newVal);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// rVal++;
|
||||
// break;
|
||||
// }
|
||||
// printf("\n");
|
||||
env->state.frame++;
|
||||
}
|
||||
|
||||
//solve bounds afterwards to properly push data back into real arrays
|
||||
//ie, if data is pushed out of bounds from one chunk to another, must
|
||||
//then copy it into the in-bounds chunk
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
|
||||
//check sum beforehand
|
||||
float afterSum = chunk_queue_sum(queue);
|
||||
|
||||
//diff the sums to see if we've changed value a lot
|
||||
float delta = fabs(originalSum - afterSum);
|
||||
if(delta > FLUID_CELLULAR_TOLLERABLE_LOSS_THRESHOLD1){
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
}
|
||||
|
||||
@ -1157,7 +1366,10 @@ int fluid_sim_cellular_cellular_tests(int argc, char **argv){
|
||||
rVal += fluid_sim_cellular_stability_test8();
|
||||
rVal += fluid_sim_cellular_stability_test9();
|
||||
rVal += fluid_sim_cellular_stability_test10();
|
||||
// rVal += fluid_sim_cellular_stability_test_full_chunk();
|
||||
// rVal += fluid_sim_cellular_stability_test11();
|
||||
rVal += fluid_sim_cellular_stability_test12();
|
||||
rVal += fluid_sim_cellular_stability_test13();
|
||||
// rVal += fluid_sim_cellular_stability_test14();
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -101,9 +101,9 @@ void chunk_fill(Chunk * chunk, float val){
|
||||
* @param val The value to fill
|
||||
*/
|
||||
void chunk_fill_real(float * arr, float val){
|
||||
for(int x = 1; x < DIM - 2; x++){
|
||||
for(int y = 1; y < DIM - 2; y++){
|
||||
for(int z = 1; z < DIM - 2; z++){
|
||||
for(int x = 1; x < DIM - 1; x++){
|
||||
for(int y = 1; y < DIM - 1; y++){
|
||||
for(int z = 1; z < DIM - 1; z++){
|
||||
arr[IX(x,y,z)] = val;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user