convergence speed testing
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
78ed5b831e
commit
7dd7dcfc4d
@ -30,7 +30,7 @@
|
||||
/**
|
||||
* The tolerance for convergence of the projection operator
|
||||
*/
|
||||
#define FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE 0.01f
|
||||
#define FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE 0.005f
|
||||
|
||||
/**
|
||||
* Diffusion constant
|
||||
|
||||
173
src/test/c/fluid/sim/grid2/convergence_tests.c
Normal file
173
src/test/c/fluid/sim/grid2/convergence_tests.c
Normal file
@ -0,0 +1,173 @@
|
||||
#include <math.h>
|
||||
|
||||
#include "stb/stb_ds.h"
|
||||
|
||||
#include "fluid/queue/boundsolver.h"
|
||||
#include "fluid/queue/chunkmask.h"
|
||||
#include "fluid/queue/chunk.h"
|
||||
#include "fluid/env/environment.h"
|
||||
#include "fluid/env/utilities.h"
|
||||
#include "fluid/sim/grid2/density.h"
|
||||
#include "fluid/sim/grid2/grid2.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 "../../../util/chunk_test_utils.h"
|
||||
#include "../../../util/test.h"
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Error margin for tests
|
||||
*/
|
||||
#define FLUID_GRID2_PROJECTION_ERROR_MARGIN 0.00001f
|
||||
|
||||
/**
|
||||
* Maximum convergence we want to see in any chunk
|
||||
*/
|
||||
#define FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS 10
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Testing full sim routine
|
||||
*/
|
||||
int fluid_sim_grid2_convergence_test1(){
|
||||
printf("fluid_sim_grid2_convergence_test1\n");
|
||||
int rVal = 0;
|
||||
Environment * env = fluid_environment_create();
|
||||
Chunk ** queue = NULL;
|
||||
queue = createChunkGrid(env,3,3,3);
|
||||
int chunkCount = arrlen(queue);
|
||||
|
||||
|
||||
|
||||
//setup chunk values
|
||||
Chunk * currentChunk = queue[0];
|
||||
currentChunk->d[CENTER_LOC][IX(4,4,4)] = MAX_FLUID_VALUE;
|
||||
currentChunk->u[CENTER_LOC][IX(4,4,4)] = MAX_FLUID_VALUE;
|
||||
float beforeSum = chunk_queue_sum_density(queue);
|
||||
|
||||
//actually simulate
|
||||
int frameCount = 1;
|
||||
for(int frame = 0; frame < frameCount; frame++){
|
||||
//sim
|
||||
fluid_grid2_simulate(chunkCount,queue,env,FLUID_GRID2_SIM_STEP);
|
||||
}
|
||||
|
||||
//test results
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
Chunk * chunk = queue[i];
|
||||
if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){
|
||||
printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount);
|
||||
printf("Residual: %f \n",chunk->projectionResidual);
|
||||
printf("Iterations: %d \n",chunk->projectionIterations);
|
||||
printf("\n");
|
||||
rVal++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing full sim routine
|
||||
*/
|
||||
int fluid_sim_grid2_convergence_test2(){
|
||||
printf("fluid_sim_grid2_convergence_test2\n");
|
||||
int rVal = 0;
|
||||
Environment * env = fluid_environment_create();
|
||||
Chunk ** queue = NULL;
|
||||
queue = createChunkGrid(env,3,3,3);
|
||||
int chunkCount = arrlen(queue);
|
||||
|
||||
|
||||
|
||||
//setup chunk values
|
||||
Chunk * currentChunk = queue[0];
|
||||
currentChunk->d[CENTER_LOC][IX(4,4,4)] = MAX_FLUID_VALUE;
|
||||
currentChunk->u[CENTER_LOC][IX(4,4,4)] = MAX_FLUID_VALUE;
|
||||
float beforeSum = chunk_queue_sum_density(queue);
|
||||
|
||||
//actually simulate
|
||||
int frameCount = 50;
|
||||
for(int frame = 0; frame < frameCount; frame++){
|
||||
//sim
|
||||
fluid_grid2_simulate(chunkCount,queue,env,FLUID_GRID2_SIM_STEP);
|
||||
}
|
||||
|
||||
//test results
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
Chunk * chunk = queue[i];
|
||||
if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){
|
||||
printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount);
|
||||
printf("Residual: %f \n",chunk->projectionResidual);
|
||||
printf("Iterations: %d \n",chunk->projectionIterations);
|
||||
printf("\n");
|
||||
rVal++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing full sim routine
|
||||
*/
|
||||
int fluid_sim_grid2_convergence_test3(){
|
||||
printf("fluid_sim_grid2_convergence_test3\n");
|
||||
int rVal = 0;
|
||||
Environment * env = fluid_environment_create();
|
||||
Chunk ** queue = NULL;
|
||||
queue = createChunkGrid(env,5,5,5);
|
||||
int chunkCount = arrlen(queue);
|
||||
|
||||
|
||||
|
||||
//setup chunk values
|
||||
Chunk * currentChunk = queue[0];
|
||||
chunk_fill_real(queue[13]->d[CENTER_LOC],MAX_FLUID_VALUE);
|
||||
chunk_fill_real(queue[13]->u[CENTER_LOC],MAX_FLUID_VALUE);
|
||||
float beforeSum = chunk_queue_sum_density(queue);
|
||||
|
||||
//actually simulate
|
||||
int frameCount = 50;
|
||||
for(int frame = 0; frame < frameCount; frame++){
|
||||
//sim
|
||||
fluid_grid2_simulate(chunkCount,queue,env,FLUID_GRID2_SIM_STEP);
|
||||
}
|
||||
|
||||
//test results
|
||||
for(int i = 0; i < chunkCount; i++){
|
||||
Chunk * chunk = queue[i];
|
||||
if(chunk->projectionIterations > FLUID_GRID2_CONVERGENCE_MAX_ITERATIONS || chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){
|
||||
printf("Chunk took too many iterations or had too high of a residual! (frames: %d, chunk count: %d) \n", frameCount, chunkCount);
|
||||
printf("Residual: %f \n",chunk->projectionResidual);
|
||||
printf("Iterations: %d \n",chunk->projectionIterations);
|
||||
printf("\n");
|
||||
rVal++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing full sim routines
|
||||
*/
|
||||
int fluid_sim_grid2_convergence_tests(){
|
||||
int rVal = 0;
|
||||
|
||||
fluid_grid2_allocate_arrays();
|
||||
|
||||
rVal += fluid_sim_grid2_convergence_test1();
|
||||
rVal += fluid_sim_grid2_convergence_test2();
|
||||
rVal += fluid_sim_grid2_convergence_test3();
|
||||
|
||||
return rVal;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user