From: Fabian Castelli Date: Sat, 21 May 2022 09:53:30 +0000 (+0200) Subject: Minor code updates to create_right_hand_side X-Git-Tag: v9.4.0-rc1~186^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13770%2Fhead;p=dealii.git Minor code updates to create_right_hand_side --- diff --git a/include/deal.II/numerics/vector_tools_rhs.templates.h b/include/deal.II/numerics/vector_tools_rhs.templates.h index 471cfa1f2f..cf9c05183a 100644 --- a/include/deal.II/numerics/vector_tools_rhs.templates.h +++ b/include/deal.II/numerics/vector_tools_rhs.templates.h @@ -46,12 +46,10 @@ namespace VectorTools const std::set & boundary_ids) { const FiniteElement &fe = dof_handler.get_fe(); - Assert(fe.n_components() == rhs_function.n_components, - ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); - Assert(rhs_vector.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); + AssertDimension(fe.n_components(), rhs_function.n_components); + AssertDimension(rhs_vector.size(), dof_handler.n_dofs()); - rhs_vector = 0; + rhs_vector = typename VectorType::value_type(0.0); UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -64,15 +62,11 @@ namespace VectorTools std::vector dofs(dofs_per_cell); Vector cell_vector(dofs_per_cell); - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - if (n_components == 1) { std::vector rhs_values(n_q_points); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) for (unsigned int face : cell->face_indices()) if (cell->face(face)->at_boundary() && (boundary_ids.empty() || @@ -103,7 +97,7 @@ namespace VectorTools std::vector> rhs_values(n_q_points, Vector(n_components)); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) for (unsigned int face : cell->face_indices()) if (cell->face(face)->at_boundary() && (boundary_ids.empty() || @@ -193,12 +187,10 @@ namespace VectorTools const std::set & boundary_ids) { const hp::FECollection &fe = dof_handler.get_fe_collection(); - Assert(fe.n_components() == rhs_function.n_components, - ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); - Assert(rhs_vector.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); + AssertDimension(fe.n_components(), rhs_function.n_components); + AssertDimension(rhs_vector.size(), dof_handler.n_dofs()); - rhs_vector = 0; + rhs_vector = typename VectorType::value_type(0.0); UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -209,15 +201,11 @@ namespace VectorTools std::vector dofs(fe.max_dofs_per_cell()); Vector cell_vector(fe.max_dofs_per_cell()); - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - if (n_components == 1) { std::vector rhs_values; - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) for (unsigned int face : cell->face_indices()) if (cell->face(face)->at_boundary() && (boundary_ids.empty() || @@ -255,7 +243,7 @@ namespace VectorTools { std::vector> rhs_values; - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) for (unsigned int face : cell->face_indices()) if (cell->face(face)->at_boundary() && (boundary_ids.empty() || @@ -353,11 +341,9 @@ namespace VectorTools using Number = typename VectorType::value_type; const FiniteElement &fe = dof_handler.get_fe(); - Assert(fe.n_components() == rhs_function.n_components, - ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); - Assert(rhs_vector.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); - rhs_vector = typename VectorType::value_type(0.); + AssertDimension(fe.n_components(), rhs_function.n_components); + AssertDimension(rhs_vector.size(), dof_handler.n_dofs()); + rhs_vector = typename VectorType::value_type(0.0); UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -370,15 +356,11 @@ namespace VectorTools std::vector dofs(dofs_per_cell); Vector cell_vector(dofs_per_cell); - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - if (n_components == 1) { std::vector rhs_values(n_q_points); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { fe_values.reinit(cell); @@ -406,7 +388,7 @@ namespace VectorTools std::vector> rhs_values(n_q_points, Vector(n_components)); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { fe_values.reinit(cell); @@ -496,11 +478,9 @@ namespace VectorTools using Number = typename VectorType::value_type; const hp::FECollection &fe = dof_handler.get_fe_collection(); - Assert(fe.n_components() == rhs_function.n_components, - ExcDimensionMismatch(fe.n_components(), rhs_function.n_components)); - Assert(rhs_vector.size() == dof_handler.n_dofs(), - ExcDimensionMismatch(rhs_vector.size(), dof_handler.n_dofs())); - rhs_vector = 0; + AssertDimension(fe.n_components(), rhs_function.n_components); + AssertDimension(rhs_vector.size(), dof_handler.n_dofs()); + rhs_vector = typename VectorType::value_type(0.0); UpdateFlags update_flags = UpdateFlags(update_values | update_quadrature_points | update_JxW_values); @@ -514,15 +494,11 @@ namespace VectorTools std::vector dofs(fe.max_dofs_per_cell()); Vector cell_vector(fe.max_dofs_per_cell()); - typename DoFHandler::active_cell_iterator - cell = dof_handler.begin_active(), - endc = dof_handler.end(); - if (n_components == 1) { std::vector rhs_values; - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { x_fe_values.reinit(cell); @@ -558,7 +534,7 @@ namespace VectorTools { std::vector> rhs_values; - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { x_fe_values.reinit(cell);