chunk residual tracking
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-12-11 21:08:00 -05:00
parent c435126513
commit 78ed5b831e
7 changed files with 28 additions and 15 deletions

View File

@ -72,6 +72,16 @@ typedef struct {
* NOTE: This is not a spatial LOD. It is a simulation LOD
*/
int simLOD;
/**
* The convergence of this chunk
*/
float projectionResidual;
/**
* The number of iterations this chunk took to project
*/
int projectionIterations;
} Chunk;

View File

@ -4,6 +4,7 @@
#include <stdint.h>
#include "fluid/env/environment.h"
#include "fluid/queue/chunk.h"
@ -73,6 +74,7 @@ LIBRARY_API void fluid_grid2_setupProjection(
* @param jrv0 The first derivative field
*/
LIBRARY_API void fluid_grid2_solveProjection(
Chunk * chunk,
float ** jru0,
float ** jrv0,
float dt

View File

@ -88,7 +88,7 @@ LIBRARY_API void fluid_grid2_simulate(
//
//Perform main projection solver
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,timestep);
//Finalize projection
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
@ -104,7 +104,7 @@ LIBRARY_API void fluid_grid2_simulate(
//setup projection
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
//Perform main projection solver
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,timestep);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,timestep);
//Finalize projection
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,timestep);
}

View File

@ -164,9 +164,10 @@ LIBRARY_API void fluid_grid2_setupProjection(
* @param jrv0 The first derivative field
*/
LIBRARY_API void fluid_grid2_solveProjection(
float ** jru0,
float ** jrv0,
float dt
Chunk * chunk,
float ** jru0,
float ** jrv0,
float dt
){
float a = 1;
float c = 6;
@ -178,14 +179,14 @@ LIBRARY_API void fluid_grid2_solveProjection(
float * div = GET_ARR_RAW(jrv0,CENTER_LOC);
//perform iteration of v cycle multigrid method
float residual = 1;
int iteration = 0;
while(iteration < FLUID_GRID2_LINEARSOLVERTIMES && (residual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE || residual < -FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE)){
residual = solver_multigrid_parallel_iterate(p,div,a,c);
chunk->projectionResidual = 1;
chunk->projectionIterations = 0;
while(chunk->projectionIterations < FLUID_GRID2_LINEARSOLVERTIMES && (chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE)){
chunk->projectionResidual = solver_multigrid_parallel_iterate(p,div,a,c);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_NO_DIR,p);
iteration++;
chunk->projectionIterations++;
}
if(residual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE || residual < -FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){
if(chunk->projectionResidual > FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_PROJECTION_CONVERGENCE_TOLERANCE){
// printf("Projection residual didn't converge! %f \n",residual);
}

View File

@ -62,7 +62,7 @@ int fluid_sim_grid2_advect_projection_test1(){
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
@ -127,7 +127,7 @@ int fluid_sim_grid2_advect_projection_compute_error_over_time(){
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_DIR_U,currentChunk->u0[CENTER_LOC]);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_DIR_V,currentChunk->v0[CENTER_LOC]);
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
fluid_grid2_finalizeProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);

View File

@ -36,7 +36,7 @@ int fluid_sim_grid2_finalize_projection_test1(){
Chunk * currentChunk = queue[0];
currentChunk->u[CENTER_LOC][IX(3,3,3)] = 1.0f;
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_set_bounds(FLUID_GRID2_BOUND_NO_DIR,currentChunk->u0[CENTER_LOC]);
//finalize

View File

@ -38,7 +38,7 @@ int fluid_sim_grid2_solve_projection_test1(){
fluid_grid2_setupProjection(currentChunk->u,currentChunk->v,currentChunk->w,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
//actually solve
fluid_grid2_solveProjection(currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
fluid_grid2_solveProjection(currentChunk,currentChunk->u0,currentChunk->v0,FLUID_GRID2_SIM_STEP);
//test the result
float expected, actual;