Skip to content

Commit

Permalink
Fix bug in inline BE solver (#714)
Browse files Browse the repository at this point in the history
fix bug in inline BE solver
  • Loading branch information
mattldawson authored Jan 25, 2025
1 parent b9264b2 commit 5e58246
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion include/micm/solver/solver_builder.inl
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,13 @@ namespace micm
auto nonzero_elements = rates.NonZeroJacobianElements();
auto jacobian = BuildJacobian<SparseMatrixPolicy>(nonzero_elements, this->number_of_grid_cells_, number_of_species);

rates.SetJacobianFlatIds(jacobian);
LinearSolverPolicy linear_solver(jacobian, 0);
if constexpr (LuDecompositionInPlaceConcept<LuDecompositionPolicy, SparseMatrixPolicy>)
{
auto lu = LuDecompositionPolicy::template GetLUMatrix<SparseMatrixPolicy>(jacobian, 0);
jacobian = std::move(lu);
}
rates.SetJacobianFlatIds(jacobian);

std::vector<std::string> variable_names{ number_of_species };
for (auto& species_pair : species_map)
Expand Down
8 changes: 8 additions & 0 deletions test/integration/test_analytical_backward_euler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ TEST(AnalyticalExamples, HIRES)
test_analytical_hires(backward_euler_vector_mozart_2, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_3, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_4, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_in_place_1, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_in_place_2, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_in_place_3, 1e-1);
test_analytical_hires(backward_euler_vector_mozart_in_place_4, 1e-1);
}

TEST(AnalyticalExamples, Oregonator)
Expand All @@ -277,4 +281,8 @@ TEST(AnalyticalExamples, Oregonator)
test_analytical_oregonator(backward_euler_vector_mozart_2, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_3, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_4, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_in_place_1, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_in_place_2, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_in_place_3, 1e-3);
test_analytical_oregonator(backward_euler_vector_mozart_in_place_4, 1e-3);
}

0 comments on commit 5e58246

Please sign in to comment.