From: peterrum Date: Tue, 6 Aug 2019 16:00:46 +0000 (+0200) Subject: Add get_face_iterator X-Git-Tag: v9.2.0-rc1~971^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8909%2Fhead;p=dealii.git Add get_face_iterator Conflicts: include/deal.II/matrix_free/matrix_free.templates.h --- diff --git a/doc/news/changes/minor/20191016MartinKronbichlerPeterMunchMichalWichrowski b/doc/news/changes/minor/20191016MartinKronbichlerPeterMunchMichalWichrowski new file mode 100644 index 0000000000..8c3fc313d8 --- /dev/null +++ b/doc/news/changes/minor/20191016MartinKronbichlerPeterMunchMichalWichrowski @@ -0,0 +1,4 @@ +New: Provide cell iterators to interior and exterior cells of +a macro face through the function MatrixFree::get_face_iterator(). +
+(Martin Kronbichler, Peter Munch, Michal Wichrowski, 2019/10/16) diff --git a/include/deal.II/matrix_free/matrix_free.h b/include/deal.II/matrix_free/matrix_free.h index e70bdfbaaa..6377fa2ee9 100644 --- a/include/deal.II/matrix_free/matrix_free.h +++ b/include/deal.II/matrix_free/matrix_free.h @@ -1464,6 +1464,24 @@ public: get_cell_level_and_index(const unsigned int macro_cell_number, const unsigned int vector_number) const; + /** + * Return the cell iterator in deal.II speak to a interior/exterior cell of + * given face in the renumbering of this structure. The second element + * of the pair is the face number so that the face iterator can be accessed: + * pair.first()->face(pair.second() ); + * + * Note that the face iterators in deal.II go through cells differently to + * what the face/boundary loop of this class does. This is because several + * faces are worked on together (vectorization), and since faces with neighbor + * cells on different MPI processors need to be accessed at a certain time + * when accessing remote data and overlapping communication with computation. + */ + std::pair::cell_iterator, unsigned int> + get_face_iterator(const unsigned int face_batch_number, + const unsigned int vector_number, + const bool interior = true, + const unsigned int fe_component = 0) const; + /** * This returns the cell iterator in deal.II speak to a given cell in the * renumbering of this structure. This function returns an exception in case diff --git a/include/deal.II/matrix_free/matrix_free.templates.h b/include/deal.II/matrix_free/matrix_free.templates.h index 75ab6f44ab..387594387b 100644 --- a/include/deal.II/matrix_free/matrix_free.templates.h +++ b/include/deal.II/matrix_free/matrix_free.templates.h @@ -206,6 +206,59 @@ MatrixFree::get_cell_level_and_index( +template +std::pair::cell_iterator, unsigned int> +MatrixFree::get_face_iterator( + const unsigned int face_batch_number, + const unsigned int vector_number, + const bool interior, + const unsigned int fe_component) const +{ + AssertIndexRange(fe_component, dof_handlers.n_dof_handlers); + if (interior) + { + AssertIndexRange(face_batch_number, n_ghost_inner_face_batches()); + } + else + { + AssertIndexRange(face_batch_number, n_inner_face_batches()); + } + + AssertIndexRange(vector_number, + n_active_entries_per_face_batch(face_batch_number)); + + const DoFHandler *dofh = nullptr; + if (dof_handlers.active_dof_handler == DoFHandlers::usual) + { + AssertDimension(dof_handlers.dof_handler.size(), + dof_handlers.n_dof_handlers); + dofh = dof_handlers.dof_handler[fe_component]; + } + else + { + Assert(false, + ExcMessage("Cannot return DoFHandler::cell_iterator " + "for underlying DoFHandler!")); + } + + const internal::MatrixFreeFunctions::FaceToCellTopology< + VectorizedArrayType::n_array_elements> + face2cell_info = get_face_info(face_batch_number); + + const unsigned int cell_index = + interior ? face2cell_info.cells_interior[vector_number] : + face2cell_info.cells_exterior[vector_number]; + + std::pair index = cell_level_index[cell_index]; + + return {typename DoFHandler::cell_iterator( + &dofh->get_triangulation(), index.first, index.second, dofh), + interior ? face2cell_info.interior_face_no : + face2cell_info.exterior_face_no}; +} + + + template typename hp::DoFHandler::active_cell_iterator MatrixFree::get_hp_cell_iterator(