From: Jean-Paul Pelteret Date: Thu, 9 May 2019 13:14:59 +0000 (+0200) Subject: Add examples for mesh_loop() when filtered iterators are to be used. X-Git-Tag: v9.1.0-rc1~95^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8053%2Fhead;p=dealii.git Add examples for mesh_loop() when filtered iterators are to be used. --- diff --git a/include/deal.II/meshworker/mesh_loop.h b/include/deal.II/meshworker/mesh_loop.h index 5a75890050..7fbdf9038b 100644 --- a/include/deal.II/meshworker/mesh_loop.h +++ b/include/deal.II/meshworker/mesh_loop.h @@ -456,6 +456,71 @@ namespace MeshWorker /** * Same as the function above, but for iterator ranges (and, therefore, * filtered iterators). + * + * An example usage of the function for the serial case is given by + * @code + * + * using ScratchData = MeshWorker::ScratchData; + * using CopyData = MeshWorker::CopyData<1, 1, 1>; + * using CellIteratorType = decltype(dof_handler.begin_active()); + * + * ScratchData scratch(...); + * CopyData copy(...); + * + * auto cell_worker = [...] ( + * const CellIteratorType &cell, + * ScratchData &scratch_data, + * CopyData ©_data) + * { + * ... + * }; + * + * auto copier = [...](const CopyData ©_data) + * { + * ... + * }; + * + * MeshWorker::mesh_loop(dof_handler.active_cell_iterators(), + * cell_worker, copier, + * scratch, copy, + * MeshWorker::assemble_own_cells); + * @endcode + * + * and an example usage of the function for the parallel distributed case, + * where the copier is only to be called on locally owned cells, is given by + * @code + * + * using ScratchData = MeshWorker::ScratchData; + * using CopyData = MeshWorker::CopyData<1, 1, 1>; + * using CellIteratorType = decltype(dof_handler.begin_active()); + * + * ScratchData scratch(...); + * CopyData copy(...); + * + * auto cell_worker = [...] ( + * const CellIteratorType &cell, + * ScratchData &scratch_data, + * CopyData ©_data) + * { + * ... + * }; + * + * auto copier = [...](const CopyData ©_data) + * { + * ... + * }; + * + * const auto filtered_iterator_range = + * filter_iterators(dof_handler.active_cell_iterators(), + * IteratorFilters::LocallyOwnedCell()); + * + * MeshWorker::mesh_loop(filtered_iterator_range, + * cell_worker, copier, + * scratch, copy, + * MeshWorker::assemble_own_cells); + * @endcode + * + * @ingroup MeshWorker */ template + * class MyClass + * { + * public: + * void + * cell_worker(const CellIteratorType &cell, ScratchData &, CopyData &); + * + * void + * copier(const CopyData &); + * + * ... + * }; + * + * ... + * + * MyClass my_class; + * ScratchData scratch; + * CopyData copy; + * + * mesh_loop(tria.active_cell_iterators(), + * my_class, + * &MyClass::cell_worker, + * &MyClass::copier, + * scratch, + * copy, + * assemble_own_cells); + * @endcode + * + * and an example usage of the function for the parallel distributed case, + * where the copier is only to be called on locally owned cells, is given by + * @code + * + * struct ScratchData; + * struct CopyData; + * + * template + * class MyClass + * { + * public: + * void + * cell_worker(const CellIteratorType &cell, ScratchData &, CopyData &); + * + * void + * copier(const CopyData &); + * + * ... + * }; + * + * ... + * + * MyClass my_class; + * ScratchData scratch; + * CopyData copy; + * + * const auto filtered_iterator_range = + * filter_iterators(distributed_tria.active_cell_iterators(), + * IteratorFilters::LocallyOwnedCell()); + * + * mesh_loop(filtered_iterator_range, + * my_class, + * &MyClass::cell_worker, + * &MyClass::copier, + * scratch, + * copy, + * assemble_own_cells); + * @endcode + * + * @ingroup MeshWorker */ template