]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Introduce Triangulation::as_dof_handler_level_iterator() 15817/head
authorPeter Munch <peterrmuench@gmail.com>
Tue, 1 Aug 2023 17:09:53 +0000 (19:09 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 6 Aug 2023 18:29:18 +0000 (20:29 +0200)
doc/news/changes/minor/20230801Munch_2 [new file with mode: 0644]
include/deal.II/grid/tria_accessor.h
source/grid/tria_accessor.cc

diff --git a/doc/news/changes/minor/20230801Munch_2 b/doc/news/changes/minor/20230801Munch_2
new file mode 100644 (file)
index 0000000..8025fb6
--- /dev/null
@@ -0,0 +1,4 @@
+New: The new function Triangulation::as_dof_handler_level_iterator()
+allows to create level iterators based on other cell iterators.
+<br>
+(Peter Munch, 2023/08/01)
index 65e1a020473b1c719f00b3f18fe224f86c3acd97..8d9265b90cfc43e2384bc8d7b4df0914f6219633 100644 (file)
@@ -3184,6 +3184,19 @@ public:
   TriaActiveIterator<DoFCellAccessor<dim, spacedim, false>>
   as_dof_handler_iterator(const DoFHandler<dim, spacedim> &dof_handler) const;
 
+  /**
+   * A function similar to as_dof_handler_iterator(). It converts
+   * a Triangulation active/level cell iterator to a
+   * DoFHandler active level cell iterator, or a DoFHandler level active/cell
+   * iterator to a level cell iterator of another DoFHandler. The
+   * @p iterator must be associated with the triangulation of the
+   * @p dof_handler.
+   */
+  TriaIterator<DoFCellAccessor<dim, spacedim, true>>
+  as_dof_handler_level_iterator(
+    const DoFHandler<dim, spacedim> &dof_handler) const;
+
+
   /**
    * @}
    */
index 98602affe26a40f393187caeef8a2924ca3288fb..3267aae53e99e623cb1357ac2f40c189bfd5fe22 100644 (file)
@@ -2071,6 +2071,25 @@ CellAccessor<dim, spacedim>::as_dof_handler_iterator(
 }
 
 
+
+template <int dim, int spacedim>
+TriaIterator<DoFCellAccessor<dim, spacedim, true>>
+CellAccessor<dim, spacedim>::as_dof_handler_level_iterator(
+  const DoFHandler<dim, spacedim> &dof_handler) const
+{
+  Assert(&this->get_triangulation() == &dof_handler.get_triangulation(),
+         ExcMessage("The triangulation associated with the iterator does not "
+                    "match that of the DoFHandler."));
+
+  return typename DoFHandler<dim, spacedim>::level_cell_iterator(
+    &dof_handler.get_triangulation(),
+    this->level(),
+    this->index(),
+    &dof_handler);
+}
+
+
+
 // For codim>0 we proceed as follows:
 // 1) project point onto manifold and
 // 2) transform to the unit cell with a Q1 mapping

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.