From a0aa755f1822556a985cf70d56f407175a695cc3 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 2 May 2024 23:39:49 +0530 Subject: [PATCH] Be uniform in the order of things we start the assembly loop with. --- examples/step-20/step-20.cc | 1 + examples/step-22/step-22.cc | 1 + examples/step-4/step-4.cc | 1 + examples/step-40/step-40.cc | 4 ++-- examples/step-5/step-5.cc | 4 ++-- examples/step-6/step-6.cc | 4 ++-- examples/step-7/step-7.cc | 4 ++-- examples/step-8/step-8.cc | 4 ++-- 8 files changed, 13 insertions(+), 10 deletions(-) diff --git a/examples/step-20/step-20.cc b/examples/step-20/step-20.cc index d90e8d493d..63285a2705 100644 --- a/examples/step-20/step-20.cc +++ b/examples/step-20/step-20.cc @@ -488,6 +488,7 @@ namespace Step20 for (const auto &cell : dof_handler.active_cell_iterators()) { fe_values.reinit(cell); + local_matrix = 0; local_rhs = 0; diff --git a/examples/step-22/step-22.cc b/examples/step-22/step-22.cc index 453f322966..bb3b712056 100644 --- a/examples/step-22/step-22.cc +++ b/examples/step-22/step-22.cc @@ -659,6 +659,7 @@ namespace Step22 for (const auto &cell : dof_handler.active_cell_iterators()) { fe_values.reinit(cell); + local_matrix = 0; local_preconditioner_matrix = 0; local_rhs = 0; diff --git a/examples/step-4/step-4.cc b/examples/step-4/step-4.cc index d0e622d7c6..4e3f6c9a24 100644 --- a/examples/step-4/step-4.cc +++ b/examples/step-4/step-4.cc @@ -354,6 +354,7 @@ void Step4::assemble_system() for (const auto &cell : dof_handler.active_cell_iterators()) { fe_values.reinit(cell); + cell_matrix = 0; cell_rhs = 0; diff --git a/examples/step-40/step-40.cc b/examples/step-40/step-40.cc index 622700234b..a0d3e51b67 100644 --- a/examples/step-40/step-40.cc +++ b/examples/step-40/step-40.cc @@ -399,11 +399,11 @@ namespace Step40 for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { + fe_values.reinit(cell); + cell_matrix = 0.; cell_rhs = 0.; - fe_values.reinit(cell); - for (unsigned int q_point = 0; q_point < n_q_points; ++q_point) { const double rhs_value = diff --git a/examples/step-5/step-5.cc b/examples/step-5/step-5.cc index bba78459f6..394e83629d 100644 --- a/examples/step-5/step-5.cc +++ b/examples/step-5/step-5.cc @@ -178,11 +178,11 @@ void Step5::assemble_system() // coefficient value at each quadrature point. for (const auto &cell : dof_handler.active_cell_iterators()) { + fe_values.reinit(cell); + cell_matrix = 0.; cell_rhs = 0.; - fe_values.reinit(cell); - for (const unsigned int q_index : fe_values.quadrature_point_indices()) { const double current_coefficient = diff --git a/examples/step-6/step-6.cc b/examples/step-6/step-6.cc index 3dd3c7153c..9522232af0 100644 --- a/examples/step-6/step-6.cc +++ b/examples/step-6/step-6.cc @@ -271,11 +271,11 @@ void Step6::assemble_system() for (const auto &cell : dof_handler.active_cell_iterators()) { + fe_values.reinit(cell); + cell_matrix = 0; cell_rhs = 0; - fe_values.reinit(cell); - for (const unsigned int q_index : fe_values.quadrature_point_indices()) { const double current_coefficient = diff --git a/examples/step-7/step-7.cc b/examples/step-7/step-7.cc index b13c306c5c..5be9442e22 100644 --- a/examples/step-7/step-7.cc +++ b/examples/step-7/step-7.cc @@ -583,11 +583,11 @@ namespace Step7 // previous examples, so we only comment on the things that have changed. for (const auto &cell : dof_handler.active_cell_iterators()) { + fe_values.reinit(cell); + cell_matrix = 0.; cell_rhs = 0.; - fe_values.reinit(cell); - right_hand_side.value_list(fe_values.get_quadrature_points(), rhs_values); diff --git a/examples/step-8/step-8.cc b/examples/step-8/step-8.cc index 517f37bda5..f9c29a9480 100644 --- a/examples/step-8/step-8.cc +++ b/examples/step-8/step-8.cc @@ -318,11 +318,11 @@ namespace Step8 // Now we can begin with the loop over all cells: for (const auto &cell : dof_handler.active_cell_iterators()) { + fe_values.reinit(cell); + cell_matrix = 0; cell_rhs = 0; - fe_values.reinit(cell); - // Next we get the values of the coefficients at the quadrature // points. Likewise for the right hand side: lambda.value_list(fe_values.get_quadrature_points(), lambda_values); -- 2.39.5