cellular determinism verification
This commit is contained in:
parent
0091f94daf
commit
6ee0a1b2c5
@ -1268,6 +1268,8 @@ Cellular transfer behavior work
|
||||
Native math utils
|
||||
Frame tracking on native side
|
||||
Fix memory leak in client fluid data chunks
|
||||
Work on cellular sim determinism
|
||||
More cellular determinism verification
|
||||
|
||||
|
||||
# TODO
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
|
||||
|
||||
static inline void fluid_solve_bounds_checker(float ** arrays, int fillVal){
|
||||
static inline void fluid_solve_bounds_checker(float ** arrays, float fillVal){
|
||||
int i, j;
|
||||
int neighborIndex;
|
||||
//x+ face
|
||||
|
||||
@ -204,6 +204,55 @@ int fluid_sim_cellular_stability_test1(){
|
||||
return rVal;
|
||||
}
|
||||
|
||||
int fluid_sim_cellular_stability_test2(){
|
||||
int rVal = 0;
|
||||
printf("fluid_sim_cellular_stability_test2\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 13th chunk
|
||||
chunk_fill(queue[13],CELLULAR_TEST_PLACE_VAL);
|
||||
|
||||
//check sum beforehand
|
||||
float originalSum = chunk_queue_sum(queue);
|
||||
|
||||
//dispatch and simulate
|
||||
int frameCount = 50;
|
||||
for(int i = 0; i < frameCount; i++){
|
||||
fluid_solve_bounds(chunkCount,queue,env);
|
||||
fluid_dispatch(chunkCount,queue,env);
|
||||
fluid_simulate(env);
|
||||
env->state.frame++;
|
||||
}
|
||||
|
||||
//check sum beforehand
|
||||
float afterSum = chunk_queue_sum(queue);
|
||||
|
||||
rVal += assertEqualsFloat(originalSum,afterSum,"cellular sim was unstable! %f %f \n");
|
||||
|
||||
printf("\n");
|
||||
return rVal;
|
||||
}
|
||||
|
||||
|
||||
int fluid_sim_cellular_cellular_tests(int argc, char **argv){
|
||||
int rVal = 0;
|
||||
@ -211,6 +260,7 @@ int fluid_sim_cellular_cellular_tests(int argc, char **argv){
|
||||
rVal += fluid_sim_cellular_bounds_test1();
|
||||
rVal += fluid_sim_cellular_bounds_test2();
|
||||
rVal += fluid_sim_cellular_stability_test1();
|
||||
rVal += fluid_sim_cellular_stability_test2();
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ void chunk_free_queue(Chunk ** chunks){
|
||||
* @param chunk The chunk to fill
|
||||
* @param val The value to fill
|
||||
*/
|
||||
void chunk_fill(Chunk * chunk, int val){
|
||||
void chunk_fill(Chunk * chunk, float val){
|
||||
for(int i = 0; i < DIM*DIM*DIM; i++){
|
||||
chunk->d[CENTER_LOC][i] = val;
|
||||
chunk->d0[CENTER_LOC][i] = val;
|
||||
@ -219,8 +219,8 @@ void chunk_link_neighbors(Chunk ** chunks){
|
||||
*/
|
||||
float chunk_queue_sum(Chunk ** chunks){
|
||||
float sum = 0;
|
||||
int num = arrlen(chunks);
|
||||
for(int i = 0; i < num; i++){
|
||||
int chunkCount = arrlen(chunks);
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
Chunk * current = chunks[i];
|
||||
for(int x = 1; x < DIM - 2; x++){
|
||||
for(int y = 1; y < DIM - 2; y++){
|
||||
|
||||
@ -76,7 +76,7 @@ Chunk ** chunk_create_queue(int size);
|
||||
* @param chunk The chunk to fill
|
||||
* @param val The value to fill
|
||||
*/
|
||||
void chunk_fill(Chunk * chunk, int val);
|
||||
void chunk_fill(Chunk * chunk, float val);
|
||||
|
||||
/**
|
||||
* Frees a chunk queue
|
||||
|
||||
Loading…
Reference in New Issue
Block a user