From 0f4379920b34d352722f69aea0d91d1d7b26ee19 Mon Sep 17 00:00:00 2001 From: austin Date: Thu, 12 Dec 2024 00:00:50 -0500 Subject: [PATCH] small CG solver work --- src/main/c/includes/fluid/sim/grid2/solver_consts.h | 8 ++++---- src/main/c/src/fluid/sim/grid2/velocity.c | 2 +- src/main/c/src/math/ode/conjugate_gradient.c | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/c/includes/fluid/sim/grid2/solver_consts.h b/src/main/c/includes/fluid/sim/grid2/solver_consts.h index f3d46f7f..ed38d94f 100644 --- a/src/main/c/includes/fluid/sim/grid2/solver_consts.h +++ b/src/main/c/includes/fluid/sim/grid2/solver_consts.h @@ -5,17 +5,17 @@ /** * The number of times to relax most solvers */ -#define FLUID_GRID2_LINEARSOLVERTIMES 10 +#define FLUID_GRID2_LINEARSOLVERTIMES 5 /** * The number of times to relax most solvers */ -#define FLUID_GRID2_SOLVER_MULTIGRID_MAX_ITERATIONS 5 +#define FLUID_GRID2_SOLVER_MULTIGRID_MAX_ITERATIONS 10 /** * Tolerance to target for multigrid precomputing in projection */ -#define FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE 1.0f +#define FLUID_GRID2_SOLVER_MULTIGRID_TOLERANCE 0.1f /** * The number of times to relax most solvers @@ -25,7 +25,7 @@ /** * Tolerance to target for conjugate gradient precomputing in projection */ -#define FLUID_GRID2_SOLVER_CG_TOLERANCE 0.1f +#define FLUID_GRID2_SOLVER_CG_TOLERANCE 0.01f /** * Width of a single grid cell diff --git a/src/main/c/src/fluid/sim/grid2/velocity.c b/src/main/c/src/fluid/sim/grid2/velocity.c index 75e449d4..deef888b 100644 --- a/src/main/c/src/fluid/sim/grid2/velocity.c +++ b/src/main/c/src/fluid/sim/grid2/velocity.c @@ -205,7 +205,7 @@ LIBRARY_API void fluid_grid2_solveProjection( chunk->projectionIterations++; } if(chunk->projectionResidual > FLUID_GRID2_SOLVER_CG_TOLERANCE || chunk->projectionResidual < -FLUID_GRID2_SOLVER_CG_TOLERANCE){ - // printf("Projection residual didn't converge! %f \n",chunk->projectionResidual); + printf("Projection residual didn't converge! %f \n",chunk->projectionResidual); } //finest grain iteration with conjugate gradient method diff --git a/src/main/c/src/math/ode/conjugate_gradient.c b/src/main/c/src/math/ode/conjugate_gradient.c index f3a9c00c..020f2b70 100644 --- a/src/main/c/src/math/ode/conjugate_gradient.c +++ b/src/main/c/src/math/ode/conjugate_gradient.c @@ -115,6 +115,7 @@ int solver_conjugate_gradient_init(float * phi, float * phi0, float a, float c){ * @param phi0 The phi array from the last frame * @param a The a const * @param c The c const + * @return The residual */ float solver_conjugate_gradient_iterate_parallel(float * phi, float * phi0, float a, float c){ int i, j, k;