From 617dd2d910a0dac09e0d8579540d8be801d2a91f Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 26 Aug 2010 09:48:24 +0000 Subject: [PATCH] Test function n_intervals, get_view and fill_index_vector in IndexSet. git-svn-id: https://svn.dealii.org/trunk@21718 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/index_set_17.cc | 59 ++++++++++++++++++++++++++ tests/base/index_set_17/cmp/generic | 4 ++ tests/base/index_set_18.cc | 59 ++++++++++++++++++++++++++ tests/base/index_set_18/cmp/generic | 6 +++ tests/base/index_set_19.cc | 64 +++++++++++++++++++++++++++++ tests/base/index_set_19/cmp/generic | 6 +++ 6 files changed, 198 insertions(+) create mode 100644 tests/base/index_set_17.cc create mode 100644 tests/base/index_set_17/cmp/generic create mode 100644 tests/base/index_set_18.cc create mode 100644 tests/base/index_set_18/cmp/generic create mode 100644 tests/base/index_set_19.cc create mode 100644 tests/base/index_set_19/cmp/generic diff --git a/tests/base/index_set_17.cc b/tests/base/index_set_17.cc new file mode 100644 index 0000000000..fbe797dc9a --- /dev/null +++ b/tests/base/index_set_17.cc @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------------------------- + +// test IndexSet::n_intervals + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + + +void test () +{ + IndexSet is1 (100); + + // randomly add 90 elements to each + // set, some of which may be + // repetitions of previous ones + for (unsigned int i=0; i<9*is1.size()/10; ++i) + { + is1.add_index (rand() % is1.size()); + } + + is1.compress(); + + deallog << "Number of intervals: " + << is1.n_intervals() << std::endl; + + is1.print(deallog); + + deallog << "OK" << std::endl; +} + + + + +int main() +{ + std::ofstream logfile("index_set_17/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); +} diff --git a/tests/base/index_set_17/cmp/generic b/tests/base/index_set_17/cmp/generic new file mode 100644 index 0000000000..c4cf6c7969 --- /dev/null +++ b/tests/base/index_set_17/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::Number of intervals: 24 +DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]} +DEAL::OK diff --git a/tests/base/index_set_18.cc b/tests/base/index_set_18.cc new file mode 100644 index 0000000000..69d5d1a92d --- /dev/null +++ b/tests/base/index_set_18.cc @@ -0,0 +1,59 @@ +//----------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------------------------- + +// test IndexSet::get_view + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + + +void test () +{ + IndexSet is1 (100); + + // randomly add 90 elements to each + // set, some of which may be + // repetitions of previous ones + for (unsigned int i=0; i<9*is1.size()/10; ++i) + is1.add_index (rand() % is1.size()); + + is1.compress(); + + IndexSet is2 = is1.get_view (20, 50); + + deallog << "Original index set: " << std::endl; + is1.print(deallog); + deallog << "View of index set between 20 and 50: " << std::endl; + is2.print(deallog); + + deallog << "OK" << std::endl; +} + + + + +int main() +{ + std::ofstream logfile("index_set_18/output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); +} diff --git a/tests/base/index_set_18/cmp/generic b/tests/base/index_set_18/cmp/generic new file mode 100644 index 0000000000..d7c72c7ae3 --- /dev/null +++ b/tests/base/index_set_18/cmp/generic @@ -0,0 +1,6 @@ + +DEAL::Original index set: +DEAL::{[2,3], 5, 8, 11, [13,15], 19, [21,27], [29,30], [34,37], 40, [42,43], [45,46], [49,51], 54, [56,59], [62,64], [67,70], [72,73], [76,78], [80,84], [86,88], [90,93], [95,96], [98,99]} +DEAL::View of index set between 20 and 50: +DEAL::{[1,7], [9,10], [14,17], 20, [22,23], [25,26], 29} +DEAL::OK diff --git a/tests/base/index_set_19.cc b/tests/base/index_set_19.cc new file mode 100644 index 0000000000..5ce5e1d4ca --- /dev/null +++ b/tests/base/index_set_19.cc @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2010 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------------------------- + +// test IndexSet::fill_index_vector + +#include "../tests.h" +#include +#include +#include +#include +#include + +#include + + +void test () +{ + IndexSet is1 (100); + + // randomly add 90 elements to each + // set, some of which may be + // repetitions of previous ones + for (unsigned int i=0; i<9*is1.size()/10; ++i) + is1.add_index (rand() % is1.size()); + + std::vector indices; + is1.fill_index_vector (indices); + + deallog << "Original index set: " << std::endl; + is1.print(deallog); + + deallog << "List of indices: " << std::endl; + for (unsigned int i=0; i