From 821beb5602e4cb4308608d8371da301161bc74c1 Mon Sep 17 00:00:00 2001 From: Jian Sun Date: Wed, 4 Sep 2024 13:47:31 -0600 Subject: [PATCH] remove the local copy of jaocbian matrix in the LinFactor function --- include/micm/solver/rosenbrock.inl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/micm/solver/rosenbrock.inl b/include/micm/solver/rosenbrock.inl index d3a421807..99d592eea 100644 --- a/include/micm/solver/rosenbrock.inl +++ b/include/micm/solver/rosenbrock.inl @@ -245,10 +245,9 @@ namespace micm singular = false; while (true) { - auto jacobian = state.jacobian_; double alpha = 1 / (H * gamma); - static_cast(this)->AlphaMinusJacobian(jacobian, alpha); - linear_solver_.Factor(jacobian, state.lower_matrix_, state.upper_matrix_, singular); + static_cast(this)->AlphaMinusJacobian(state.jacobian_, alpha); + linear_solver_.Factor(state.jacobian_, state.lower_matrix_, state.upper_matrix_, singular); stats.decompositions_ += 1; // if we are checking for singularity and the matrix is not singular, we can break the loop @@ -260,6 +259,10 @@ namespace micm if (++n_consecutive > 5) break; H /= 2; + // Reconstruct the Jacobian matrix if a substepping is performed here + state.jacobian_.Fill(0.0); + rates_.SubtractJacobianTerms(state.rate_constants_, number_densities, state.jacobian_); + stats.jacobian_updates_ += 1; } }