From 8a08c482bef47bedaae8d8c2859f08ab56d39d27 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 15 Nov 2021 18:37:19 -0700 Subject: [PATCH] Add a changelog entry. --- doc/news/changes/minor/20211115Bangerth-c | 42 +++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 doc/news/changes/minor/20211115Bangerth-c diff --git a/doc/news/changes/minor/20211115Bangerth-c b/doc/news/changes/minor/20211115Bangerth-c new file mode 100644 index 0000000000..f34e57c805 --- /dev/null +++ b/doc/news/changes/minor/20211115Bangerth-c @@ -0,0 +1,42 @@ +New: In the same spirit as provided by the C++20 [range +adaptors](https://en.cppreference.com/w/cpp/ranges) feature, it is now +possible to "filter" ranges over the active cells of Triangulation +and DoFHandler objects. +
+This allows to replace: +@code + DoFHandler dof_handler; + ... + for (const auto &cell : dof_handler.active_cell_iterators()) + { + if (cell->is_locally_owned()) + { + fe_values.reinit (cell); + ...do the local integration on 'cell'...; + } + } +@endcode +by: +@code + DoFHandler dof_handler; + ... + const auto filtered_iterators_range = + filter_iterators(); + for (const auto &cell : + dof_handler.active_cell_iterators() | IteratorFilters::LocallyOwnedCell()) + { + fe_values.reinit (cell); + ...do the local integration on 'cell'...; + } +@endcode +Here, the `operator|` is to be interpreted in the same way as is done in +the [range adaptors](https://en.cppreference.com/w/cpp/ranges) feature +that is part of [C++20](https://en.wikipedia.org/wiki/C%2B%2B20). It has +the same meaning as the `|` symbol on the command line: It takes what is +on its left as its inputs, and filters and transforms to produce some +output. In the example above, it "filters" all of the active cell iterators +and removes those that do not satisfy the predicate -- that is, it produces +a range of iterators that only contains those cells that are both active +and locally owned. +
+(Wolfgang Bangerth, 2021/11/03) -- 2.39.5