From 38543b079029c071cd1d8f088ad7a611251601bf Mon Sep 17 00:00:00 2001 From: Luke Roberts Date: Wed, 18 Sep 2024 09:11:30 -0600 Subject: [PATCH] explicitly set beta = 0 on first iter --- src/solvers/cg_solver.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/solvers/cg_solver.hpp b/src/solvers/cg_solver.hpp index 1f591bf1b4d1..ee20b422649f 100644 --- a/src/solvers/cg_solver.hpp +++ b/src/solvers/cg_solver.hpp @@ -181,7 +181,7 @@ class CGSolver { auto correct_p = itl.AddTask( get_ru, "p <- u + beta p", [](CGSolver *solver, std::shared_ptr> &md) { - Real beta = solver->ru.val / solver->ru_old; + Real beta = solver->iter_counter > 0 ? solver->ru.val / solver->ru_old : 0.0; return AddFieldsAndStore(md, 1.0, beta); }, this, md);