From ff893bc86dd987c452a58b23d13b1eb54ac4be12 Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Mon, 3 May 2021 17:57:20 +0200 Subject: [PATCH] Add test case --- tests/sparsity/dynamic_sparsity_pattern_23.cc | 68 +++++++++++++++++++ ...ty_pattern_23.with_64bit_indices=on.output | 9 +++ 2 files changed, 77 insertions(+) create mode 100644 tests/sparsity/dynamic_sparsity_pattern_23.cc create mode 100644 tests/sparsity/dynamic_sparsity_pattern_23.with_64bit_indices=on.output diff --git a/tests/sparsity/dynamic_sparsity_pattern_23.cc b/tests/sparsity/dynamic_sparsity_pattern_23.cc new file mode 100644 index 0000000000..597abf9b6c --- /dev/null +++ b/tests/sparsity/dynamic_sparsity_pattern_23.cc @@ -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 + +#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 index 0000000000..dc96d5fa1d --- /dev/null +++ b/tests/sparsity/dynamic_sparsity_pattern_23.with_64bit_indices=on.output @@ -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 -- 2.39.5