From: rao Date: Mon, 6 Dec 2010 19:56:53 +0000 (+0000) Subject: Add new tests for serialization. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5761a1d10cbe48242470a785d5922af16c4664ae;p=dealii-svn.git Add new tests for serialization. git-svn-id: https://svn.dealii.org/trunk@22929 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/tests/serialization/parameter_handler.cc b/tests/serialization/parameter_handler.cc new file mode 100644 index 0000000000..144cd27e4e --- /dev/null +++ b/tests/serialization/parameter_handler.cc @@ -0,0 +1,131 @@ +//---------------------------- parameter_handler.cc --------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2002, 2003, 2004, 2005, 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. +// +//---------------------------- parameter_handler.cc --------------------------- + + +// check serialization for Parameter_handler + +#include "serialization.h" +#include +#include +#include + + +void test () +{ + ParameterHandler prm1; + prm1.declare_entry ("int1", + "1", + Patterns::Integer(), + "doc 1"); + prm1.declare_entry ("int2", + "2", + Patterns::Integer(), + "doc 2"); + prm1.enter_subsection ("ss1"); + { + prm1.declare_entry ("double 1", + "1.234", + Patterns::Double(), + "doc 3"); + + prm1.enter_subsection ("ss2"); + { + prm1.declare_entry ("double 2", + "4.321", + Patterns::Double(), + "doc 4"); + } + prm1.leave_subsection (); + } + prm1.leave_subsection (); + + // things with strange characters + prm1.enter_subsection ("Testing%testing"); + { + prm1.declare_entry ("string&list", + "< & > ; /", + Patterns::Anything(), + "docs 1"); + prm1.declare_entry ("int*int", + "2", + Patterns::Integer()); + prm1.declare_entry ("double+double", + "6.1415926", + Patterns::Double(), + "docs 3"); + } + prm1.leave_subsection (); + + ParameterHandler prm2; + prm2.enter_subsection ("s234s1"); + { + prm2.declare_entry ("dummy 1", + "19.4", + Patterns::Double(), + "paper 4"); + + prm2.enter_subsection ("s2skjds2"); + { + prm2.declare_entry ("var 2", + "6.321", + Patterns::Double(), + "invalid"); + } + prm2.leave_subsection (); + } + prm2.leave_subsection (); + + // things with strange characters + prm2.enter_subsection ("Testing%testing"); + { + prm2.declare_entry ("int*int", + "2", + Patterns::Integer()); + prm2.declare_entry ("string&list", + "< & > ; /", + Patterns::Anything(), + "docs 1"); + } + prm2.leave_subsection (); + + prm2.declare_entry ("int1", + "1.", + Patterns::Double(), + "doc 1"); + prm2.declare_entry ("int2", + "2", + Patterns::Anything(), + "doc 2"); + + ParameterHandler prm3; + + verify (prm1, prm2); + + verify (prm1, prm3); +} + + +int main () +{ + std::ofstream logfile("parameter_handler/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} + + diff --git a/tests/serialization/polynomial.cc b/tests/serialization/polynomial.cc new file mode 100644 index 0000000000..3d06770bf3 --- /dev/null +++ b/tests/serialization/polynomial.cc @@ -0,0 +1,52 @@ +//---------------------------- polynomial.cc --------------------------- +// $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. +// +//---------------------------- polynomial.cc --------------------------- + +// check serialization for Polynomial + +#include "serialization.h" +#include +#include + + +void test () +{ + double c1[3] = {1., 2., 3.}; + std::vector coefficients1(c1, &c1[3]); + + Polynomials::Polynomial p1(coefficients1); + + double c2[3] = {4., 5., 6.}; + std::vector coefficients2(c2, &c2[3]); + + Polynomials::Polynomial p2(coefficients2); + + Polynomials::Polynomial p3; + + verify (p1, p2); + + verify (p1, p3); +} + + +int main () +{ + std::ofstream logfile("polynomial/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/polynomial_hierarchical.cc b/tests/serialization/polynomial_hierarchical.cc new file mode 100644 index 0000000000..c3ac4d4d6c --- /dev/null +++ b/tests/serialization/polynomial_hierarchical.cc @@ -0,0 +1,43 @@ +//---------------------------- polynomial_hierarchical.cc --------------------------- +// $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. +// +//---------------------------- polynomial_hierarchical.cc --------------------------- + +// check serialization for Hierarchical + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int degree1 = 3; + Polynomials::Hierarchical p1(degree1); + + unsigned int degree2 = 7; + Polynomials::Hierarchical p2(degree2); + + verify (p1, p2); +} + + +int main () +{ + std::ofstream logfile("polynomial_hierarchical/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/polynomial_lagrange_equidistant.cc b/tests/serialization/polynomial_lagrange_equidistant.cc new file mode 100644 index 0000000000..fff4ccc4e9 --- /dev/null +++ b/tests/serialization/polynomial_lagrange_equidistant.cc @@ -0,0 +1,47 @@ +//---------------------------- polynomial_lagrange_equidistant.cc --------------- +// $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. +// +//---------------------------- polynomial_lagrange_equidistant.cc --------------- + +// check serialization for LagrangeEquidistant + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int n1 = 3; + unsigned int support_point1 = 1; + + Polynomials::LagrangeEquidistant p1(n1, support_point1); + + unsigned int n2 = 4; + unsigned int support_point2 = 2; + + Polynomials::LagrangeEquidistant p2(n2, support_point2); + + verify (p1, p2); +} + + +int main () +{ + std::ofstream logfile("polynomial_lagrange_equidistant/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/polynomial_legendre.cc b/tests/serialization/polynomial_legendre.cc new file mode 100644 index 0000000000..8913e06961 --- /dev/null +++ b/tests/serialization/polynomial_legendre.cc @@ -0,0 +1,44 @@ +//---------------------------- polynomial_legendre.cc --------------------------- +// $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. +// +//---------------------------- polynomial_legendre.cc --------------------------- + +// check serialization for Legendre + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int degree1 = 3; + Polynomials::Legendre p1(degree1); + + unsigned int degree2 = 5; + Polynomials::Legendre p2(degree2); + + verify (p1, p2); +} + + +int main () +{ + std::ofstream logfile("polynomial_legendre/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/polynomial_lobatto.cc b/tests/serialization/polynomial_lobatto.cc new file mode 100644 index 0000000000..6e3642e6f7 --- /dev/null +++ b/tests/serialization/polynomial_lobatto.cc @@ -0,0 +1,44 @@ +//---------------------------- polynomial.cc --------------------------- +// $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. +// +//---------------------------- polynomial.cc --------------------------- + +// check serialization for Polynomial + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int degree1 = 3; + Polynomials::Lobatto p1(degree1); + + unsigned int degree2 = 6; + Polynomials::Lobatto p2(degree2); + + verify (p1, p2); +} + + +int main () +{ + std::ofstream logfile("polynomial_lobatto/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/polynomial_monomial.cc b/tests/serialization/polynomial_monomial.cc new file mode 100644 index 0000000000..ec71b843ef --- /dev/null +++ b/tests/serialization/polynomial_monomial.cc @@ -0,0 +1,48 @@ +//---------------------------- polynomial_monomial.cc --------------------------- +// $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. +// +//---------------------------- polynomial_monomial.cc --------------------------- + +// check serialization for Monomial + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int n1 = 3; + double coefficient1 = 5.; + + Polynomials::Monomial m1(n1, coefficient1); + + unsigned int n2 = 3; + double coefficient2 = 2.; + + Polynomials::Monomial m2(n2, coefficient2); + + verify (m1, m2); +} + + +int main () +{ + std::ofstream logfile("polynomial_monomial/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/quadrature.cc b/tests/serialization/quadrature.cc new file mode 100644 index 0000000000..8975080ccd --- /dev/null +++ b/tests/serialization/quadrature.cc @@ -0,0 +1,65 @@ +//---------------------------- quadrature.cc --------------------------- +// $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. +// +//---------------------------- quadrature.cc --------------------------- + +// check serialization for Quadrature + +#include "serialization.h" +#include +#include + +void test () +{ + const unsigned int dim = 2; + + std::vector > points1; + points1.push_back(Point(0,0)); + points1.push_back(Point(0,1)); + points1.push_back(Point(1,1)); + points1.push_back(Point(1,0)); + + double w1[4] = {0.20, 0.30, 0.15, 0.35}; + std::vector weights1(w1, &w1[4]); + + Quadrature q1(points1, weights1); + + std::vector > points2; + points2.push_back(Point(1,1)); + points2.push_back(Point(1,0)); + points2.push_back(Point(0,0)); + points2.push_back(Point(0,1)); + + double w2[4] = {0.1, 0.2, 0.3, 0.4}; + std::vector weights2(w2, &w2[4]); + + Quadrature q2(points2, weights2); + + Quadrature q3; + + verify (q1, q2); + + verify (q1, q3); +} + + +int main () +{ + std::ofstream logfile("quadrature/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/quadrature_qanisotropic.cc b/tests/serialization/quadrature_qanisotropic.cc new file mode 100644 index 0000000000..54fbb9e436 --- /dev/null +++ b/tests/serialization/quadrature_qanisotropic.cc @@ -0,0 +1,58 @@ +//---------------------- quadrature_qanisotropic.cc -------------------- +// $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. +// +//---------------------- quadrature_qanisotropic.cc -------------------- + +// check serialization for QAnisotropic + +#include "serialization.h" +#include +#include + +void test () +{ + const unsigned int dim = 2; + + std::vector > points1; + points1.push_back(Point<1>(0.)); + points1.push_back(Point<1>(1.)); + double w1[2] = {0.5, 0.5}; + std::vector weights1(w1, &w1[2]); + + std::vector > points2; + points2.push_back(Point<1>(0.25)); + points2.push_back(Point<1>(0.75)); + double w2[2] = {0.4, 0.6}; + std::vector weights2(w2, &w2[2]); + + Quadrature<1> qx(points1, weights1); + Quadrature<1> qy(points2, weights2); + + QAnisotropic q1(qx, qy); + + QAnisotropic q2(qy, qx); + + verify (q1, q2); +} + + +int main () +{ + std::ofstream logfile("quadrature_qanisotropic/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/quadrature_qiterated.cc b/tests/serialization/quadrature_qiterated.cc new file mode 100644 index 0000000000..e5a0676ee9 --- /dev/null +++ b/tests/serialization/quadrature_qiterated.cc @@ -0,0 +1,59 @@ +//-------------------------- quadrature_qiterated.cc -------------------- +// $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. +// +//-------------------------- quadrature_qiterated.cc -------------------- + +// check serialization for QIterated + +#include "serialization.h" +#include +#include + +void test () +{ + const unsigned int dim = 2; + unsigned int n_copies = 3; + + std::vector > points1; + points1.push_back(Point<1>(0.)); + points1.push_back(Point<1>(1.)); + double w1[2] = {0.5, 0.5}; + std::vector weights1(w1, &w1[2]); + + std::vector > points2; + points2.push_back(Point<1>(0.25)); + points2.push_back(Point<1>(0.75)); + double w2[2] = {0.4, 0.6}; + std::vector weights2(w2, &w2[2]); + + Quadrature<1> qx(points1, weights1); + Quadrature<1> qy(points2, weights2); + + QIterated q1(qx, n_copies); + + QIterated q2(qy, n_copies); + + verify (q1, q2); +} + + +int main () +{ + std::ofstream logfile("quadrature_qiterated/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/sparsity_pattern.cc b/tests/serialization/sparsity_pattern.cc new file mode 100644 index 0000000000..d1909eb5a3 --- /dev/null +++ b/tests/serialization/sparsity_pattern.cc @@ -0,0 +1,52 @@ +//---------------------------- sparsity_pattern.cc --------------------------- +// $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. +// +//---------------------------- sparsity_pattern.cc --------------------------- + +// check serialization for SparsityPattern + +#include "serialization.h" +#include "../lac/testmatrix.h" +#include + + +void test () +{ + const unsigned int N1 = 5; + SparsityPattern sp1((N1-1)*(N1-1), (N1-1)*(N1-1), 5); + FDMatrix(N1,N1).five_point_structure (sp1); + sp1.compress (); + + const unsigned int N2 = 3; + SparsityPattern sp2((N2-1)*(N2-1), (N2-1)*(N2-1), 5); + FDMatrix(N2,N2).five_point_structure (sp2); + sp2.compress (); + + SparsityPattern sp3; + + verify (sp1, sp2); + + verify (sp1, sp3); +} + + +int main () +{ + std::ofstream logfile("sparsity_pattern/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/sparsity_pattern/cmp/generic b/tests/serialization/sparsity_pattern/cmp/generic new file mode 100644 index 0000000000..5c9f9c003f --- /dev/null +++ b/tests/serialization/sparsity_pattern/cmp/generic @@ -0,0 +1,6 @@ + +DEAL::22 serialization::archive 8 0 0 0 0 0 16 16 16 64 5 1 1 0 3 7 11 14 18 23 28 32 36 41 46 50 53 57 61 64 0 1 4 1 0 2 5 2 1 3 6 3 2 7 4 0 5 8 5 1 4 6 9 6 2 5 7 10 7 3 6 11 8 4 9 12 9 5 8 10 13 10 6 9 11 14 11 7 10 15 12 8 13 13 9 12 14 14 10 13 15 15 11 14 + +DEAL::22 serialization::archive 8 0 0 0 0 0 16 16 16 64 5 1 1 0 3 7 11 14 18 23 28 32 36 41 46 50 53 57 61 64 0 1 4 1 0 2 5 2 1 3 6 3 2 7 4 0 5 8 5 1 4 6 9 6 2 5 7 10 7 3 6 11 8 4 9 12 9 5 8 10 13 10 6 9 11 14 11 7 10 15 12 8 13 13 9 12 14 14 10 13 15 15 11 14 + +DEAL::OK diff --git a/tests/serialization/table_1.cc b/tests/serialization/table_1.cc new file mode 100644 index 0000000000..5c6452898a --- /dev/null +++ b/tests/serialization/table_1.cc @@ -0,0 +1,52 @@ +//---------------------------- table_1.cc --------------------------- +// $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. +// +//---------------------------- table_1.cc --------------------------- + +// check serialization for Table<1. int> + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int index1 = 3; + Table<1, int> t1(index1); + + Table<1, int> t2(index1); + + unsigned int index3 = 2; + Table<1, int> t3(index3); + + for (unsigned int i = 0; i< index1; i++) + { + t1[i] = i + 1; + t2[i] = i + 1 + index1; + } + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_1/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_2.cc b/tests/serialization/table_2.cc new file mode 100644 index 0000000000..e4f99b21fa --- /dev/null +++ b/tests/serialization/table_2.cc @@ -0,0 +1,59 @@ +//---------------------------- table_2.cc --------------------------- +// $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. +// +//---------------------------- table_2.cc --------------------------- + +// check serialization for Table<2, int> + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int index1 = 3, index2 = 4; + TableIndices<2> indices1(index1, index2); + unsigned int sum_of_indices = index1 + index2; + + Table<2, int> t1(index1, index2); + Table<2, int> t2(index1, index2); + + index1 = 2; index2 = 5; + Table<2, int> t3(index1, index2); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + t1[i1][i2] = counter ++; + t2[i1][i2] = counter + sum_of_indices; + } + } + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_2/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_3.cc b/tests/serialization/table_3.cc new file mode 100644 index 0000000000..ccae2d011a --- /dev/null +++ b/tests/serialization/table_3.cc @@ -0,0 +1,63 @@ +//---------------------------- table_3.cc --------------------------- +// $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. +// +//---------------------------- table_3.cc --------------------------- + +// check serialization for Table<3, int> + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int index1 = 3, index2 = 4, index3 = 2; + TableIndices<3> indices1(index1, index2, index3); + unsigned int sum_of_indices = index1 + index2 + index3; + + Table<3, int> t1(index1, index2, index3); + Table<3, int> t2(index1, index2, index3); + + index1 = 2; index2 = 5; index3 = 4; + Table<3, int> t3(index1, index2, index3); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + for (unsigned int i3 = 0; i3 < indices1[2]; ++i3) + { + t1[i1][i2][i3] = counter ++; + t2[i1][i2][i3] = counter + sum_of_indices; + } + } + } + + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_3/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_4.cc b/tests/serialization/table_4.cc new file mode 100644 index 0000000000..ed0134a385 --- /dev/null +++ b/tests/serialization/table_4.cc @@ -0,0 +1,66 @@ +//---------------------------- table_4.cc --------------------------- +// $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. +// +//---------------------------- table_4.cc --------------------------- + +// check serialization for Table<4, int> + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int index1 = 3, index2 = 4, index3 = 2, index4 = 5; + TableIndices<4> indices1(index1, index2, index3, index4); + unsigned int sum_of_indices = index1 + index2 + index3 + index4; + + Table<4, int> t1(index1, index2, index3, index4); + Table<4, int> t2(index1, index2, index3, index4); + + index1 = 2; index2 = 5; index3 = 4; index4 = 1; + Table<4, int> t3(index1, index2, index3, index4); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + for (unsigned int i3 = 0; i3 < indices1[2]; ++i3) + { + for (unsigned int i4 = 0; i4 < indices1[3]; ++i4) + { + t1[i1][i2][i3][i4] = counter ++; + t2[i1][i2][i3][i4] = counter + sum_of_indices; + } + } + } + } + + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_4/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_5.cc b/tests/serialization/table_5.cc new file mode 100644 index 0000000000..69f04902c3 --- /dev/null +++ b/tests/serialization/table_5.cc @@ -0,0 +1,68 @@ +//---------------------------- table_5.cc --------------------------- +// $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. +// +//---------------------------- table_5.cc --------------------------- + +// check serialization for Table<5, int> + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int index1 = 3, index2 = 4, index3 = 2, index4 = 5, index5 = 1; + TableIndices<5> indices1(index1, index2, index3, index4, index5); + unsigned int sum_of_indices = index1 + index2 + index3 + index4 + index5; + + Table<5, int> t1(index1, index2, index3, index4, index5); + Table<5, int> t2(index1, index2, index3, index4, index5); + + index1 = 2; index2 = 5; index3 = 4; index4 = 1; index5 = 5; + Table<5, int> t3(index1, index2, index3, index4, index5); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + for (unsigned int i3 = 0; i3 < indices1[2]; ++i3) + { + for (unsigned int i4 = 0; i4 < indices1[3]; ++i4) + { + for (unsigned int i5 = 0; i5 < indices1[4]; ++i5) + { + t1[i1][i2][i3][i4][i5] = counter ++; + t2[i1][i2][i3][i4][i5] = counter + sum_of_indices; + } + } + } + } + } + + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_5/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_6.cc b/tests/serialization/table_6.cc new file mode 100644 index 0000000000..3796fac3dd --- /dev/null +++ b/tests/serialization/table_6.cc @@ -0,0 +1,74 @@ +//---------------------------- table_6.cc --------------------------- +// $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. +// +//---------------------------- table_6.cc --------------------------- + +// check serialization for Table<6, int> + +#include "serialization.h" +#include +#include + + +void test () +{ + unsigned int index1 = 3, index2 = 4, index3 = 2, index4 = 5, index5 = 1, + index6 = 7; + TableIndices<6> indices1(index1, index2, index3, index4, index5, index6); + unsigned int sum_of_indices = index1 + index2 + index3 + index4 + index5 + + index6; + + Table<6, int> t1(index1, index2, index3, index4, index5, index6); + Table<6, int> t2(index1, index2, index3, index4, index5, index6); + + index1 = 2; index2 = 5; index3 = 4; index4 = 1; index5 = 5; index6 = 8; + Table<6, int> t3(index1, index2, index3, index4, index5, index6); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + for (unsigned int i3 = 0; i3 < indices1[2]; ++i3) + { + for (unsigned int i4 = 0; i4 < indices1[3]; ++i4) + { + for (unsigned int i5 = 0; i5 < indices1[4]; ++i5) + { + for (unsigned int i6 = 0; i6 < indices1[5]; ++i6) + { + t1[i1][i2][i3][i4][i5][i6] = counter ++; + t2[i1][i2][i3][i4][i5][i6] = counter + sum_of_indices; + } + } + } + } + } + } + + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_6/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/table_7.cc b/tests/serialization/table_7.cc new file mode 100644 index 0000000000..f2847fd10d --- /dev/null +++ b/tests/serialization/table_7.cc @@ -0,0 +1,76 @@ +//---------------------------- table_7.cc --------------------------- +// $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. +// +//---------------------------- table_7.cc --------------------------- + +// check serialization for Table<7, int> + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int index1 = 3, index2 = 4, index3 = 2, index4 = 5, index5 = 1, + index6 = 7, index7 = 6; + TableIndices<7> indices1(index1, index2, index3, index4, index5, index6, index7); + unsigned int sum_of_indices = index1 + index2 + index3 + index4 + index5 + + index6 + index7; + + Table<7, int> t1(index1, index2, index3, index4, index5, index6, index7); + Table<7, int> t2(index1, index2, index3, index4, index5, index6, index7); + + index1 = 2; index2 = 5; index3 = 4; index4 = 1; index5 = 5; index6 = 8; index7 = 6; + Table<7, int> t3(index1, index2, index3, index4, index5, index6, index7); + + unsigned int counter = 0; + for (unsigned int i1 = 0; i1 < indices1[0]; ++i1) + { + for (unsigned int i2 = 0; i2 < indices1[1]; ++i2) + { + for (unsigned int i3 = 0; i3 < indices1[2]; ++i3) + { + for (unsigned int i4 = 0; i4 < indices1[3]; ++i4) + { + for (unsigned int i5 = 0; i5 < indices1[4]; ++i5) + { + for (unsigned int i6 = 0; i6 < indices1[5]; ++i6) + { + for (unsigned int i7 = 0; i7 < indices1[6]; ++i7) + { + t1[i1][i2][i3][i4][i5][i6][i7] = counter ++; + t2[i1][i2][i3][i4][i5][i6][i7] = counter + sum_of_indices; + } + } + } + } + } + } + } + + verify (t1, t2); + + verify (t1, t3); +} + + +int main () +{ + std::ofstream logfile("table_7/output"); + deallog << std::setprecision(3); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test (); + + deallog << "OK" << std::endl; +} diff --git a/tests/serialization/vector.cc b/tests/serialization/vector.cc new file mode 100644 index 0000000000..0edaa58ef1 --- /dev/null +++ b/tests/serialization/vector.cc @@ -0,0 +1,53 @@ +//---------------------------- vector.cc ------------------------------- +// $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. +// +//---------------------------- vector.cc ------------------------------- + +// check serialization for Vector + +#include "serialization.h" +#include +#include + +void test () +{ + unsigned int n = 5; + + Vector v1(n); + Vector v2(n); + + Vector v3; + + for (unsigned int i = 0; i