]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test for copying FilteredOperator 3928/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 6 Feb 2017 16:50:21 +0000 (17:50 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 6 Feb 2017 23:53:14 +0000 (00:53 +0100)
include/deal.II/grid/filtered_iterator.h
tests/grid/filtered_iterator_05.cc [new file with mode: 0644]
tests/grid/filtered_iterator_05.output [new file with mode: 0644]

index 22d6dff9aa9472bca6e91ebf1b7bfe1912dfa441..6aea724cb29bb51e82a46334772de3ce4a4db840 100644 (file)
@@ -960,6 +960,11 @@ FilteredIterator<BaseIterator> &
 FilteredIterator<BaseIterator>::
 operator = (const FilteredIterator &fi)
 {
+  // Using equivalent code to the one for 'operator=(const BaseIterator &bi)'
+  // below, some compiler would not cast fi to the base class of type
+  // BaseIterator but try to go through constructing a new Accessor from fi
+  // which fails. Hence, we just use an explicit upcast and call the above-
+  // mentioned method.
   const BaseIterator &bi = fi;
   return operator = (bi);
 }
diff --git a/tests/grid/filtered_iterator_05.cc b/tests/grid/filtered_iterator_05.cc
new file mode 100644 (file)
index 0000000..ed5a04d
--- /dev/null
@@ -0,0 +1,50 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 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 at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+/*
+ * Test that copying a FilteredIterator works
+ */
+
+#include <deal.II/grid/tria.h>
+#include <deal.II/grid/filtered_iterator.h>
+#include <deal.II/grid/grid_generator.h>
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_accessor.h>
+#include "../tests.h"
+
+template<int dim>
+void
+test()
+{
+  Triangulation<dim> triangulation;
+  DoFHandler<dim> dof_handler(triangulation);
+  GridGenerator::hyper_cube(triangulation);
+
+  FilteredIterator<typename DoFHandler<dim>::level_cell_iterator> begin
+  (IteratorFilters::LocallyOwnedLevelCell(), dof_handler.begin());
+  FilteredIterator<typename DoFHandler<dim>::level_cell_iterator> end
+  (IteratorFilters::LocallyOwnedLevelCell(), dof_handler.end());
+  end = begin;
+
+  deallog << "OK" << std::endl;
+}
+
+int main()
+{
+  initlog();
+  test<2>();
+
+  return 0;
+}
diff --git a/tests/grid/filtered_iterator_05.output b/tests/grid/filtered_iterator_05.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

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.