From: Wolfgang Bangerth Date: Wed, 19 Jul 2017 16:55:01 +0000 (-0600) Subject: More DoFHandler policy cleanups. X-Git-Tag: v9.0.0-rc1~1398^2~8 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5d78fa147d05d33591b66f8f19d42fa958fae75;p=dealii.git More DoFHandler policy cleanups. Specifically, make function names more uniform. Also some control flow cleanups, and other minor improvements. --- diff --git a/source/dofs/dof_handler_policy.cc b/source/dofs/dof_handler_policy.cc index 4523734dc5..387e017e8a 100644 --- a/source/dofs/dof_handler_policy.cc +++ b/source/dofs/dof_handler_policy.cc @@ -2774,11 +2774,11 @@ namespace internal - template + template void - fill_dofindices_recursively (const typename parallel::distributed::Triangulation &tria, + get_dof_indices_recursively (const typename parallel::distributed::Triangulation &tria, const unsigned int tree_index, - const typename DoFHandler::level_cell_iterator &dealii_cell, + const CellIteratorType &dealii_cell, const typename dealii::internal::p4est::types::quadrant &p4est_cell, const std::map > &vertices_with_ghost_neighbors, std::map> &needs_to_get_cell) @@ -2792,77 +2792,77 @@ namespace internal for (unsigned int c=0; c::max_children_per_cell; ++c) - fill_dofindices_recursively(tria, - tree_index, - dealii_cell->child(c), - p4est_child[c], - vertices_with_ghost_neighbors, - needs_to_get_cell); - return; + get_dof_indices_recursively (tria, + tree_index, + dealii_cell->child(c), + p4est_child[c], + vertices_with_ghost_neighbors, + needs_to_get_cell); } - - // we're at a leaf cell. see if the cell is flagged as - // interesting. note that we have only flagged our own cells - // before - if (dealii_cell->user_flag_set() && !dealii_cell->is_ghost()) + else { - Assert (!dealii_cell->is_artificial(), ExcInternalError()); - - // check each vertex if it is interesting and push - // dofindices if yes - std::set send_to; - for (unsigned int v=0; v::vertices_per_cell; ++v) + // we're at a leaf cell. see if the cell is flagged as + // interesting. note that we have only flagged our own cells + // before + if (dealii_cell->user_flag_set() && !dealii_cell->is_ghost()) { - const std::map >::const_iterator - neighbor_subdomains_of_vertex - = vertices_with_ghost_neighbors.find (dealii_cell->vertex_index(v)); + Assert (!dealii_cell->is_artificial(), ExcInternalError()); - if (neighbor_subdomains_of_vertex == - vertices_with_ghost_neighbors.end()) - continue; - - Assert(neighbor_subdomains_of_vertex->second.size()!=0, - ExcInternalError()); + // check each vertex if it is interesting and push + // DoF indices if so + std::set send_to; + for (unsigned int v=0; v::vertices_per_cell; ++v) + { + const std::map >::const_iterator + neighbor_subdomains_of_vertex + = vertices_with_ghost_neighbors.find (dealii_cell->vertex_index(v)); - send_to.insert(neighbor_subdomains_of_vertex->second.begin(), - neighbor_subdomains_of_vertex->second.end()); - } + if (neighbor_subdomains_of_vertex == + vertices_with_ghost_neighbors.end()) + continue; - if (send_to.size() > 0) - { - // this cell's dof_indices need to be sent to - // someone - std::vector - local_dof_indices (dealii_cell->get_fe().dofs_per_cell); - dealii_cell->get_dof_indices (local_dof_indices); - - for (std::set::iterator it=send_to.begin(); - it!=send_to.end(); ++it) - { - const dealii::types::subdomain_id subdomain = *it; + Assert(neighbor_subdomains_of_vertex->second.size()!=0, + ExcInternalError()); - // get an iterator to what needs to be sent to - // that subdomain (if already exists), or create - // such an object - typename std::map>::iterator - p - = needs_to_get_cell.insert (std::make_pair(subdomain, - CellDataTransferBuffer())) - .first; + send_to.insert(neighbor_subdomains_of_vertex->second.begin(), + neighbor_subdomains_of_vertex->second.end()); + } - p->second.tree_index.push_back(tree_index); - p->second.quadrants.push_back(p4est_cell); + if (send_to.size() > 0) + { + // this cell's dof_indices need to be sent to + // someone + std::vector + local_dof_indices (dealii_cell->get_fe().dofs_per_cell); + dealii_cell->get_dof_indices (local_dof_indices); - p->second.dof_numbers_and_indices.push_back(dealii_cell->get_fe().dofs_per_cell); - p->second.dof_numbers_and_indices.insert(p->second.dof_numbers_and_indices.end(), - local_dof_indices.begin(), - local_dof_indices.end()); + for (auto recipient_subdomain : send_to) + { + // get an iterator to what needs to be sent to + // that subdomain (if already exists), or create + // such an object + typename std::map>::iterator + p + = needs_to_get_cell.insert (std::make_pair(recipient_subdomain, + CellDataTransferBuffer())) + .first; + + p->second.tree_index.push_back(tree_index); + p->second.quadrants.push_back(p4est_cell); + + p->second.dof_numbers_and_indices.push_back(dealii_cell->get_fe().dofs_per_cell); + p->second.dof_numbers_and_indices.insert(p->second.dof_numbers_and_indices.end(), + local_dof_indices.begin(), + local_dof_indices.end()); + } } } } } + + template void get_mg_dofindices_recursively ( @@ -3197,12 +3197,11 @@ namespace internal template void - set_dofindices_recursively ( - const parallel::distributed::Triangulation &tria, - const typename dealii::internal::p4est::types::quadrant &p4est_cell, - const CellIteratorType &dealii_cell, - const typename dealii::internal::p4est::types::quadrant &quadrant, - dealii::types::global_dof_index *dofs) + set_dof_indices_recursively (const parallel::distributed::Triangulation &tria, + const typename dealii::internal::p4est::types::quadrant &p4est_cell, + const CellIteratorType &dealii_cell, + const typename dealii::internal::p4est::types::quadrant &quadrant, + dealii::types::global_dof_index *dofs) { if (internal::p4est::quadrant_is_equal(p4est_cell, quadrant)) { @@ -3230,29 +3229,25 @@ namespace internal complete=false; if (!complete) - const_cast(dealii_cell)->set_user_flag(); + dealii_cell->set_user_flag(); else - const_cast(dealii_cell)->clear_user_flag(); + dealii_cell->clear_user_flag(); const_cast(dealii_cell)->set_dof_indices(dof_indices); - - return; } + else if (dealii_cell->has_children() + && + internal::p4est::quadrant_is_ancestor (p4est_cell, quadrant)) + { + typename dealii::internal::p4est::types::quadrant + p4est_child[GeometryInfo::max_children_per_cell]; + internal::p4est::init_quadrant_children(p4est_cell, p4est_child); - if (! dealii_cell->has_children()) - return; - - if (! internal::p4est::quadrant_is_ancestor (p4est_cell, quadrant)) - return; - - typename dealii::internal::p4est::types::quadrant - p4est_child[GeometryInfo::max_children_per_cell]; - internal::p4est::init_quadrant_children(p4est_cell, p4est_child); - - for (unsigned int c=0; c::max_children_per_cell; ++c) - set_dofindices_recursively (tria, p4est_child[c], - dealii_cell->child(c), - quadrant, dofs); + for (unsigned int c=0; c::max_children_per_cell; ++c) + set_dof_indices_recursively (tria, p4est_child[c], + dealii_cell->child(c), + quadrant, dofs); + } } @@ -3318,13 +3313,12 @@ namespace internal typename dealii::internal::p4est::types::quadrant p4est_coarse_cell; internal::p4est::init_coarse_quadrant(p4est_coarse_cell); - fill_dofindices_recursively - (*triangulation, - coarse_cell_to_p4est_tree_permutation[cell->index()], - cell, - p4est_coarse_cell, - vertices_with_ghost_neighbors, - needs_to_get_cells); + get_dof_indices_recursively (*triangulation, + coarse_cell_to_p4est_tree_permutation[cell->index()], + cell, + p4est_coarse_cell, + vertices_with_ghost_neighbors, + needs_to_get_cells); } @@ -3411,7 +3405,8 @@ namespace internal // the dofs pointer contains for each cell the number of // dofs on that cell (dofs[0]) followed by the dof - // indices itself. + // indices themselves. this is repeated for all cells + // in the buffer for (unsigned int c=0; cget_fe().dofs_per_cell==dofs[0], ExcInternalError()); - set_dofindices_recursively (*triangulation, - p4est_coarse_cell, - cell, - cell_data_transfer_buffer.quadrants[c], - (dofs+1)); + set_dof_indices_recursively (*triangulation, + p4est_coarse_cell, + cell, + cell_data_transfer_buffer.quadrants[c], + (dofs+1)); } }