From 89f5e4f00df1e537848037dc9a2b53fa12c63b2c Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Mon, 4 Nov 2019 09:27:32 -0500 Subject: [PATCH] Implement face_iterators for DoFCellAccessors --- .../20190814PeterMunchBangerthDanielArndt | 4 +- include/deal.II/dofs/dof_accessor.h | 7 + include/deal.II/dofs/dof_accessor.templates.h | 22 + tests/dofs/range_based_for_dof_face.cc | 63 +++ tests/dofs/range_based_for_dof_face.output | 513 ++++++++++++++++++ 5 files changed, 607 insertions(+), 2 deletions(-) create mode 100644 tests/dofs/range_based_for_dof_face.cc create mode 100644 tests/dofs/range_based_for_dof_face.output diff --git a/doc/news/changes/minor/20190814PeterMunchBangerthDanielArndt b/doc/news/changes/minor/20190814PeterMunchBangerthDanielArndt index 10fdcf6850..b473458697 100644 --- a/doc/news/changes/minor/20190814PeterMunchBangerthDanielArndt +++ b/doc/news/changes/minor/20190814PeterMunchBangerthDanielArndt @@ -1,4 +1,4 @@ -New: Add CellAccessor::face_iterators(), which returns an iterator range over -the faces of a cell. +New: Add CellAccessor::face_iterators() and DoFCellAccessor::face_iterators() +which return an iterator range over the faces of a cell.
(Peter Munch, Wolfgang Bangerth, Daniel Arndt, 2019/08/14) diff --git a/include/deal.II/dofs/dof_accessor.h b/include/deal.II/dofs/dof_accessor.h index e1bd0a72c3..9f76c29489 100644 --- a/include/deal.II/dofs/dof_accessor.h +++ b/include/deal.II/dofs/dof_accessor.h @@ -1475,6 +1475,13 @@ public: face_iterator face(const unsigned int i) const; + /** + * Return an array of iterators to all faces of this cell. + */ + inline std::array::faces_per_cell> + face_iterators() const; + /** * Return the result of the @p neighbor_child_on_subface function of the * base class, but convert it so that one can also access the DoF data (the diff --git a/include/deal.II/dofs/dof_accessor.templates.h b/include/deal.II/dofs/dof_accessor.templates.h index ce84e10cce..86dd05e086 100644 --- a/include/deal.II/dofs/dof_accessor.templates.h +++ b/include/deal.II/dofs/dof_accessor.templates.h @@ -3805,6 +3805,28 @@ DoFCellAccessor::face( +template +inline std::array< + typename DoFCellAccessor::face_iterator, + GeometryInfo::faces_per_cell> +DoFCellAccessor::face_iterators() const +{ + std::array< + typename DoFCellAccessor::face_iterator, + GeometryInfo::faces_per_cell> + face_iterators; + + const unsigned int dim = DoFHandlerType::dimension; + for (unsigned int i = 0; i < GeometryInfo::faces_per_cell; ++i) + face_iterators[i] = + dealii::internal::DoFCellAccessorImplementation::get_face( + *this, i, std::integral_constant()); + + return face_iterators; +} + + + template inline void DoFCellAccessor::get_dof_indices( diff --git a/tests/dofs/range_based_for_dof_face.cc b/tests/dofs/range_based_for_dof_face.cc new file mode 100644 index 0000000000..2d5486656a --- /dev/null +++ b/tests/dofs/range_based_for_dof_face.cc @@ -0,0 +1,63 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2018 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + + +// Check face range-based for loops over DoFHandler objects + +#include +#include + +#include + +#include + +#include "../tests.h" + + +template +void +check() +{ + Triangulation tr; + GridGenerator::hyper_cube(tr); + tr.refine_global(2); + DoFHandler dh(tr); + FE_Q fe(1); + dh.distribute_dofs(fe); + + const unsigned int n_dofs_per_face = fe.n_dofs_per_face(); + std::vector face_dof_indices(n_dofs_per_face); + + for (const auto &cell : dh.active_cell_iterators()) + for (const auto &face : cell->face_iterators()) + { + face->get_dof_indices(face_dof_indices); + for (unsigned int i = 0; i < n_dofs_per_face; ++i) + deallog << face_dof_indices[i] << ' '; + deallog << std::endl; + } +} + + +int +main() +{ + initlog(); + + check<2, 2>(); + check<2, 3>(); + check<3, 3>(); +} diff --git a/tests/dofs/range_based_for_dof_face.output b/tests/dofs/range_based_for_dof_face.output new file mode 100644 index 0000000000..dfa7abc048 --- /dev/null +++ b/tests/dofs/range_based_for_dof_face.output @@ -0,0 +1,513 @@ + +DEAL::0 2 +DEAL::1 3 +DEAL::0 1 +DEAL::2 3 +DEAL::1 3 +DEAL::4 5 +DEAL::1 4 +DEAL::3 5 +DEAL::2 6 +DEAL::3 7 +DEAL::2 3 +DEAL::6 7 +DEAL::3 7 +DEAL::5 8 +DEAL::3 5 +DEAL::7 8 +DEAL::4 5 +DEAL::9 10 +DEAL::4 9 +DEAL::5 10 +DEAL::9 10 +DEAL::11 12 +DEAL::9 11 +DEAL::10 12 +DEAL::5 8 +DEAL::10 13 +DEAL::5 10 +DEAL::8 13 +DEAL::10 13 +DEAL::12 14 +DEAL::10 12 +DEAL::13 14 +DEAL::6 15 +DEAL::7 16 +DEAL::6 7 +DEAL::15 16 +DEAL::7 16 +DEAL::8 17 +DEAL::7 8 +DEAL::16 17 +DEAL::15 18 +DEAL::16 19 +DEAL::15 16 +DEAL::18 19 +DEAL::16 19 +DEAL::17 20 +DEAL::16 17 +DEAL::19 20 +DEAL::8 17 +DEAL::13 21 +DEAL::8 13 +DEAL::17 21 +DEAL::13 21 +DEAL::14 22 +DEAL::13 14 +DEAL::21 22 +DEAL::17 20 +DEAL::21 23 +DEAL::17 21 +DEAL::20 23 +DEAL::21 23 +DEAL::22 24 +DEAL::21 22 +DEAL::23 24 +DEAL::0 2 +DEAL::1 3 +DEAL::0 1 +DEAL::2 3 +DEAL::1 3 +DEAL::4 5 +DEAL::1 4 +DEAL::3 5 +DEAL::2 6 +DEAL::3 7 +DEAL::2 3 +DEAL::6 7 +DEAL::3 7 +DEAL::5 8 +DEAL::3 5 +DEAL::7 8 +DEAL::4 5 +DEAL::9 10 +DEAL::4 9 +DEAL::5 10 +DEAL::9 10 +DEAL::11 12 +DEAL::9 11 +DEAL::10 12 +DEAL::5 8 +DEAL::10 13 +DEAL::5 10 +DEAL::8 13 +DEAL::10 13 +DEAL::12 14 +DEAL::10 12 +DEAL::13 14 +DEAL::6 15 +DEAL::7 16 +DEAL::6 7 +DEAL::15 16 +DEAL::7 16 +DEAL::8 17 +DEAL::7 8 +DEAL::16 17 +DEAL::15 18 +DEAL::16 19 +DEAL::15 16 +DEAL::18 19 +DEAL::16 19 +DEAL::17 20 +DEAL::16 17 +DEAL::19 20 +DEAL::8 17 +DEAL::13 21 +DEAL::8 13 +DEAL::17 21 +DEAL::13 21 +DEAL::14 22 +DEAL::13 14 +DEAL::21 22 +DEAL::17 20 +DEAL::21 23 +DEAL::17 21 +DEAL::20 23 +DEAL::21 23 +DEAL::22 24 +DEAL::21 22 +DEAL::23 24 +DEAL::0 2 4 6 +DEAL::1 3 5 7 +DEAL::0 4 1 5 +DEAL::2 6 3 7 +DEAL::0 1 2 3 +DEAL::4 5 6 7 +DEAL::1 3 5 7 +DEAL::8 9 10 11 +DEAL::1 5 8 10 +DEAL::3 7 9 11 +DEAL::1 8 3 9 +DEAL::5 10 7 11 +DEAL::2 12 6 14 +DEAL::3 13 7 15 +DEAL::2 6 3 7 +DEAL::12 14 13 15 +DEAL::2 3 12 13 +DEAL::6 7 14 15 +DEAL::3 13 7 15 +DEAL::9 16 11 17 +DEAL::3 7 9 11 +DEAL::13 15 16 17 +DEAL::3 9 13 16 +DEAL::7 11 15 17 +DEAL::4 6 18 20 +DEAL::5 7 19 21 +DEAL::4 18 5 19 +DEAL::6 20 7 21 +DEAL::4 5 6 7 +DEAL::18 19 20 21 +DEAL::5 7 19 21 +DEAL::10 11 22 23 +DEAL::5 19 10 22 +DEAL::7 21 11 23 +DEAL::5 10 7 11 +DEAL::19 22 21 23 +DEAL::6 14 20 24 +DEAL::7 15 21 25 +DEAL::6 20 7 21 +DEAL::14 24 15 25 +DEAL::6 7 14 15 +DEAL::20 21 24 25 +DEAL::7 15 21 25 +DEAL::11 17 23 26 +DEAL::7 21 11 23 +DEAL::15 25 17 26 +DEAL::7 11 15 17 +DEAL::21 23 25 26 +DEAL::8 9 10 11 +DEAL::27 28 29 30 +DEAL::8 10 27 29 +DEAL::9 11 28 30 +DEAL::8 27 9 28 +DEAL::10 29 11 30 +DEAL::27 28 29 30 +DEAL::31 32 33 34 +DEAL::27 29 31 33 +DEAL::28 30 32 34 +DEAL::27 31 28 32 +DEAL::29 33 30 34 +DEAL::9 16 11 17 +DEAL::28 35 30 36 +DEAL::9 11 28 30 +DEAL::16 17 35 36 +DEAL::9 28 16 35 +DEAL::11 30 17 36 +DEAL::28 35 30 36 +DEAL::32 37 34 38 +DEAL::28 30 32 34 +DEAL::35 36 37 38 +DEAL::28 32 35 37 +DEAL::30 34 36 38 +DEAL::10 11 22 23 +DEAL::29 30 39 40 +DEAL::10 22 29 39 +DEAL::11 23 30 40 +DEAL::10 29 11 30 +DEAL::22 39 23 40 +DEAL::29 30 39 40 +DEAL::33 34 41 42 +DEAL::29 39 33 41 +DEAL::30 40 34 42 +DEAL::29 33 30 34 +DEAL::39 41 40 42 +DEAL::11 17 23 26 +DEAL::30 36 40 43 +DEAL::11 23 30 40 +DEAL::17 26 36 43 +DEAL::11 30 17 36 +DEAL::23 40 26 43 +DEAL::30 36 40 43 +DEAL::34 38 42 44 +DEAL::30 40 34 42 +DEAL::36 43 38 44 +DEAL::30 34 36 38 +DEAL::40 42 43 44 +DEAL::12 45 14 47 +DEAL::13 46 15 48 +DEAL::12 14 13 15 +DEAL::45 47 46 48 +DEAL::12 13 45 46 +DEAL::14 15 47 48 +DEAL::13 46 15 48 +DEAL::16 49 17 50 +DEAL::13 15 16 17 +DEAL::46 48 49 50 +DEAL::13 16 46 49 +DEAL::15 17 48 50 +DEAL::45 51 47 53 +DEAL::46 52 48 54 +DEAL::45 47 46 48 +DEAL::51 53 52 54 +DEAL::45 46 51 52 +DEAL::47 48 53 54 +DEAL::46 52 48 54 +DEAL::49 55 50 56 +DEAL::46 48 49 50 +DEAL::52 54 55 56 +DEAL::46 49 52 55 +DEAL::48 50 54 56 +DEAL::14 47 24 57 +DEAL::15 48 25 58 +DEAL::14 24 15 25 +DEAL::47 57 48 58 +DEAL::14 15 47 48 +DEAL::24 25 57 58 +DEAL::15 48 25 58 +DEAL::17 50 26 59 +DEAL::15 25 17 26 +DEAL::48 58 50 59 +DEAL::15 17 48 50 +DEAL::25 26 58 59 +DEAL::47 53 57 60 +DEAL::48 54 58 61 +DEAL::47 57 48 58 +DEAL::53 60 54 61 +DEAL::47 48 53 54 +DEAL::57 58 60 61 +DEAL::48 54 58 61 +DEAL::50 56 59 62 +DEAL::48 58 50 59 +DEAL::54 61 56 62 +DEAL::48 50 54 56 +DEAL::58 59 61 62 +DEAL::16 49 17 50 +DEAL::35 63 36 64 +DEAL::16 17 35 36 +DEAL::49 50 63 64 +DEAL::16 35 49 63 +DEAL::17 36 50 64 +DEAL::35 63 36 64 +DEAL::37 65 38 66 +DEAL::35 36 37 38 +DEAL::63 64 65 66 +DEAL::35 37 63 65 +DEAL::36 38 64 66 +DEAL::49 55 50 56 +DEAL::63 67 64 68 +DEAL::49 50 63 64 +DEAL::55 56 67 68 +DEAL::49 63 55 67 +DEAL::50 64 56 68 +DEAL::63 67 64 68 +DEAL::65 69 66 70 +DEAL::63 64 65 66 +DEAL::67 68 69 70 +DEAL::63 65 67 69 +DEAL::64 66 68 70 +DEAL::17 50 26 59 +DEAL::36 64 43 71 +DEAL::17 26 36 43 +DEAL::50 59 64 71 +DEAL::17 36 50 64 +DEAL::26 43 59 71 +DEAL::36 64 43 71 +DEAL::38 66 44 72 +DEAL::36 43 38 44 +DEAL::64 71 66 72 +DEAL::36 38 64 66 +DEAL::43 44 71 72 +DEAL::50 56 59 62 +DEAL::64 68 71 73 +DEAL::50 59 64 71 +DEAL::56 62 68 73 +DEAL::50 64 56 68 +DEAL::59 71 62 73 +DEAL::64 68 71 73 +DEAL::66 70 72 74 +DEAL::64 71 66 72 +DEAL::68 73 70 74 +DEAL::64 66 68 70 +DEAL::71 72 73 74 +DEAL::18 20 75 77 +DEAL::19 21 76 78 +DEAL::18 75 19 76 +DEAL::20 77 21 78 +DEAL::18 19 20 21 +DEAL::75 76 77 78 +DEAL::19 21 76 78 +DEAL::22 23 79 80 +DEAL::19 76 22 79 +DEAL::21 78 23 80 +DEAL::19 22 21 23 +DEAL::76 79 78 80 +DEAL::20 24 77 81 +DEAL::21 25 78 82 +DEAL::20 77 21 78 +DEAL::24 81 25 82 +DEAL::20 21 24 25 +DEAL::77 78 81 82 +DEAL::21 25 78 82 +DEAL::23 26 80 83 +DEAL::21 78 23 80 +DEAL::25 82 26 83 +DEAL::21 23 25 26 +DEAL::78 80 82 83 +DEAL::75 77 84 86 +DEAL::76 78 85 87 +DEAL::75 84 76 85 +DEAL::77 86 78 87 +DEAL::75 76 77 78 +DEAL::84 85 86 87 +DEAL::76 78 85 87 +DEAL::79 80 88 89 +DEAL::76 85 79 88 +DEAL::78 87 80 89 +DEAL::76 79 78 80 +DEAL::85 88 87 89 +DEAL::77 81 86 90 +DEAL::78 82 87 91 +DEAL::77 86 78 87 +DEAL::81 90 82 91 +DEAL::77 78 81 82 +DEAL::86 87 90 91 +DEAL::78 82 87 91 +DEAL::80 83 89 92 +DEAL::78 87 80 89 +DEAL::82 91 83 92 +DEAL::78 80 82 83 +DEAL::87 89 91 92 +DEAL::22 23 79 80 +DEAL::39 40 93 94 +DEAL::22 79 39 93 +DEAL::23 80 40 94 +DEAL::22 39 23 40 +DEAL::79 93 80 94 +DEAL::39 40 93 94 +DEAL::41 42 95 96 +DEAL::39 93 41 95 +DEAL::40 94 42 96 +DEAL::39 41 40 42 +DEAL::93 95 94 96 +DEAL::23 26 80 83 +DEAL::40 43 94 97 +DEAL::23 80 40 94 +DEAL::26 83 43 97 +DEAL::23 40 26 43 +DEAL::80 94 83 97 +DEAL::40 43 94 97 +DEAL::42 44 96 98 +DEAL::40 94 42 96 +DEAL::43 97 44 98 +DEAL::40 42 43 44 +DEAL::94 96 97 98 +DEAL::79 80 88 89 +DEAL::93 94 99 100 +DEAL::79 88 93 99 +DEAL::80 89 94 100 +DEAL::79 93 80 94 +DEAL::88 99 89 100 +DEAL::93 94 99 100 +DEAL::95 96 101 102 +DEAL::93 99 95 101 +DEAL::94 100 96 102 +DEAL::93 95 94 96 +DEAL::99 101 100 102 +DEAL::80 83 89 92 +DEAL::94 97 100 103 +DEAL::80 89 94 100 +DEAL::83 92 97 103 +DEAL::80 94 83 97 +DEAL::89 100 92 103 +DEAL::94 97 100 103 +DEAL::96 98 102 104 +DEAL::94 100 96 102 +DEAL::97 103 98 104 +DEAL::94 96 97 98 +DEAL::100 102 103 104 +DEAL::24 57 81 105 +DEAL::25 58 82 106 +DEAL::24 81 25 82 +DEAL::57 105 58 106 +DEAL::24 25 57 58 +DEAL::81 82 105 106 +DEAL::25 58 82 106 +DEAL::26 59 83 107 +DEAL::25 82 26 83 +DEAL::58 106 59 107 +DEAL::25 26 58 59 +DEAL::82 83 106 107 +DEAL::57 60 105 108 +DEAL::58 61 106 109 +DEAL::57 105 58 106 +DEAL::60 108 61 109 +DEAL::57 58 60 61 +DEAL::105 106 108 109 +DEAL::58 61 106 109 +DEAL::59 62 107 110 +DEAL::58 106 59 107 +DEAL::61 109 62 110 +DEAL::58 59 61 62 +DEAL::106 107 109 110 +DEAL::81 105 90 111 +DEAL::82 106 91 112 +DEAL::81 90 82 91 +DEAL::105 111 106 112 +DEAL::81 82 105 106 +DEAL::90 91 111 112 +DEAL::82 106 91 112 +DEAL::83 107 92 113 +DEAL::82 91 83 92 +DEAL::106 112 107 113 +DEAL::82 83 106 107 +DEAL::91 92 112 113 +DEAL::105 108 111 114 +DEAL::106 109 112 115 +DEAL::105 111 106 112 +DEAL::108 114 109 115 +DEAL::105 106 108 109 +DEAL::111 112 114 115 +DEAL::106 109 112 115 +DEAL::107 110 113 116 +DEAL::106 112 107 113 +DEAL::109 115 110 116 +DEAL::106 107 109 110 +DEAL::112 113 115 116 +DEAL::26 59 83 107 +DEAL::43 71 97 117 +DEAL::26 83 43 97 +DEAL::59 107 71 117 +DEAL::26 43 59 71 +DEAL::83 97 107 117 +DEAL::43 71 97 117 +DEAL::44 72 98 118 +DEAL::43 97 44 98 +DEAL::71 117 72 118 +DEAL::43 44 71 72 +DEAL::97 98 117 118 +DEAL::59 62 107 110 +DEAL::71 73 117 119 +DEAL::59 107 71 117 +DEAL::62 110 73 119 +DEAL::59 71 62 73 +DEAL::107 117 110 119 +DEAL::71 73 117 119 +DEAL::72 74 118 120 +DEAL::71 117 72 118 +DEAL::73 119 74 120 +DEAL::71 72 73 74 +DEAL::117 118 119 120 +DEAL::83 107 92 113 +DEAL::97 117 103 121 +DEAL::83 92 97 103 +DEAL::107 113 117 121 +DEAL::83 97 107 117 +DEAL::92 103 113 121 +DEAL::97 117 103 121 +DEAL::98 118 104 122 +DEAL::97 103 98 104 +DEAL::117 121 118 122 +DEAL::97 98 117 118 +DEAL::103 104 121 122 +DEAL::107 110 113 116 +DEAL::117 119 121 123 +DEAL::107 113 117 121 +DEAL::110 116 119 123 +DEAL::107 117 110 119 +DEAL::113 121 116 123 +DEAL::117 119 121 123 +DEAL::118 120 122 124 +DEAL::117 121 118 122 +DEAL::119 123 120 124 +DEAL::117 118 119 120 +DEAL::121 122 123 124 -- 2.39.5