]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add test case 12113/head
authorMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 3 May 2021 15:57:20 +0000 (17:57 +0200)
committerMartin Kronbichler <kronbichler@lnm.mw.tum.de>
Mon, 3 May 2021 15:58:07 +0000 (17:58 +0200)
tests/sparsity/dynamic_sparsity_pattern_23.cc [new file with mode: 0644]
tests/sparsity/dynamic_sparsity_pattern_23.with_64bit_indices=on.output [new file with mode: 0644]

diff --git a/tests/sparsity/dynamic_sparsity_pattern_23.cc b/tests/sparsity/dynamic_sparsity_pattern_23.cc
new file mode 100644 (file)
index 0000000..597abf9
--- /dev/null
@@ -0,0 +1,68 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2021 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// test that iterating over a DynamicSparsityPattern with begin()/end() also
+// works for indices exceeding 32 bit integers
+
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  // take a bit more indices than we would have for 32 bit integers
+  IndexSet set((1ULL << 32) + 4);
+
+  // add range for the last six indices
+  set.add_range(set.size() - 6, set.size());
+
+  DynamicSparsityPattern sp;
+  sp.reinit(set.size(), set.size(), set);
+
+  for (const auto i : set)
+    {
+      sp.add(i, i);
+      sp.add(i, i - 1);
+      if (i + 1 < set.size())
+        sp.add(i, i + 1);
+    }
+
+  deallog << "Sparsity pattern has " << sp.n_rows() << " rows" << std::endl;
+  for (const auto row : set)
+    {
+      deallog << "Row " << row << " has the column indices: ";
+      for (auto it = sp.begin(row); it != sp.end(row); ++it)
+        {
+          deallog << it->column() << " ";
+        }
+      deallog << std::endl;
+    }
+
+  deallog << "OK" << std::endl;
+}
+
+
+
+int
+main()
+{
+  initlog();
+
+  test();
+}
diff --git a/tests/sparsity/dynamic_sparsity_pattern_23.with_64bit_indices=on.output b/tests/sparsity/dynamic_sparsity_pattern_23.with_64bit_indices=on.output
new file mode 100644 (file)
index 0000000..dc96d5f
--- /dev/null
@@ -0,0 +1,9 @@
+
+DEAL::Sparsity pattern has 4294967300 rows
+DEAL::Row 4294967294 has the column indices: 4294967293 4294967294 4294967295 
+DEAL::Row 4294967295 has the column indices: 4294967294 4294967295 4294967296 
+DEAL::Row 4294967296 has the column indices: 4294967295 4294967296 4294967297 
+DEAL::Row 4294967297 has the column indices: 4294967296 4294967297 4294967298 
+DEAL::Row 4294967298 has the column indices: 4294967297 4294967298 4294967299 
+DEAL::Row 4294967299 has the column indices: 4294967298 4294967299 
+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.