From: Wolfgang Bangerth Date: Fri, 7 Jul 2017 21:40:17 +0000 (-0600) Subject: Simplify some code that parallelizes operations. X-Git-Tag: v9.0.0-rc1~1427^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0c6ffb68937a22ae3267600e64031495dba45b4;p=dealii.git Simplify some code that parallelizes operations. While there, make some other code more general if we ever get to spacedim>3. --- diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 88acf722ce..a4175d3c67 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -913,12 +913,12 @@ namespace internal } + template static std::map - compute_quad_dof_identities (hp::DoFHandler<3,3> &dof_handler) + compute_quad_dof_identities (hp::DoFHandler<3,spacedim> &dof_handler) { const int dim = 3; - const int spacedim = 3; std::map dof_identities; @@ -945,7 +945,7 @@ namespace internal quad_dof_identities (dof_handler.finite_elements->size(), dof_handler.finite_elements->size()); - for (hp::DoFHandler::active_cell_iterator + for (typename hp::DoFHandler::active_cell_iterator cell=dof_handler.begin_active(); cell!=dof_handler.end(); ++cell) for (unsigned int q=0; q::quads_per_cell; ++q) @@ -953,7 +953,7 @@ namespace internal && (cell->quad(q)->n_active_fe_indices() == 2)) { - const hp::DoFHandler::quad_iterator quad = cell->quad(q); + const typename hp::DoFHandler::quad_iterator quad = cell->quad(q); quad->set_user_flag (); // find out which is the most dominating finite @@ -1047,25 +1047,28 @@ namespace internal // compute the constraints that correspond to unifying // dof indices on vertices, lines, and quads. do so // in parallel - std::map - constrained_vertex_indices, constrained_line_indices, constrained_quad_indices; + std::map all_constrained_indices[dim]; { Threads::TaskGroup<> tasks; tasks += Threads::new_task ([&]() { - constrained_vertex_indices = compute_vertex_dof_identities (dof_handler); - }); - tasks += Threads::new_task ([&]() - { - constrained_line_indices = compute_line_dof_identities (dof_handler); - }); - tasks += Threads::new_task ([&]() - { - constrained_quad_indices = compute_quad_dof_identities (dof_handler); + all_constrained_indices[0] = compute_vertex_dof_identities (dof_handler); }); + if (dim > 1) + tasks += Threads::new_task ([&]() + { + all_constrained_indices[1] = compute_line_dof_identities (dof_handler); + }); + + if (dim > 2) + tasks += Threads::new_task ([&]() + { + all_constrained_indices[2] = compute_quad_dof_identities (dof_handler); + }); + tasks.join_all (); } @@ -1074,18 +1077,13 @@ namespace internal std::vector new_dof_indices (n_dofs_before_identification, numbers::invalid_dof_index); - for (const auto &constrained_dof_indices : - { - &constrained_vertex_indices, - &constrained_line_indices, - &constrained_quad_indices - }) - for (const auto &p : *constrained_dof_indices) - { - Assert (new_dof_indices[p.first] == numbers::invalid_dof_index, - ExcInternalError()); - new_dof_indices[p.first] = p.second; - } + for (const auto &constrained_dof_indices : all_constrained_indices) + for (const auto &p : constrained_dof_indices) + { + Assert (new_dof_indices[p.first] == numbers::invalid_dof_index, + ExcInternalError()); + new_dof_indices[p.first] = p.second; + } types::global_dof_index next_free_dof = 0; for (types::global_dof_index i=0; i