--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Tests Trilinos sparsity iterators, specifically copy construction
+// and assignment operators
+
+#include "../tests.h"
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <fstream>
+#include <iomanip>
+
+
+void test ()
+{
+ TrilinosWrappers::SparsityPattern sp;
+
+ sp.reinit(5,7,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<7; ++j)
+ if ((i+2*j+1) % 3 == 0)
+ {
+ deallog << "Creating sparsity pattern entry "
+ << i << ' ' << j << std::endl;
+ sp.add (i,j);
+ }
+ sp.compress ();
+
+ for (TrilinosWrappers::SparsityPattern::const_iterator p = sp.begin(); p != sp.end(); ++p)
+ {
+ deallog << p->row() << ' ' << p->column() << std::endl;
+
+ // check copy construction
+ TrilinosWrappers::SparsityPattern::const_iterator q (p);
+ Assert (p == q, ExcInternalError());
+
+ // also check copy operation
+ q = p;
+ Assert (p == q, ExcInternalError());
+ }
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+ try
+ {
+ test ();
+ }
+ catch (std::exception &exc)
+ {
+ deallog << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ deallog << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ deallog << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ deallog << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::Creating sparsity pattern entry 0 1
+DEAL::Creating sparsity pattern entry 0 4
+DEAL::Creating sparsity pattern entry 1 2
+DEAL::Creating sparsity pattern entry 1 5
+DEAL::Creating sparsity pattern entry 2 0
+DEAL::Creating sparsity pattern entry 2 3
+DEAL::Creating sparsity pattern entry 2 6
+DEAL::Creating sparsity pattern entry 3 1
+DEAL::Creating sparsity pattern entry 3 4
+DEAL::Creating sparsity pattern entry 4 2
+DEAL::Creating sparsity pattern entry 4 5
+DEAL::0 1
+DEAL::0 4
+DEAL::1 2
+DEAL::1 5
+DEAL::2 0
+DEAL::2 3
+DEAL::2 6
+DEAL::3 1
+DEAL::3 4
+DEAL::4 2
+DEAL::4 5
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// Tests Trilinos sparsity iterators, specifically copy construction
+// and assignment operators
+//
+// The accessors keep a cache that is administered via a shared
+// pointer. make sure that copying these objects works as expected
+
+#include "../tests.h"
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+#include <fstream>
+#include <iomanip>
+
+
+void test ()
+{
+ TrilinosWrappers::SparsityPattern sp;
+
+ sp.reinit(5,7,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<7; ++j)
+ if ((i+2*j+1) % 3 == 0)
+ {
+ deallog << "Creating sparsity pattern entry "
+ << i << ' ' << j << std::endl;
+ sp.add (i,j);
+ }
+ sp.compress ();
+
+ // get an iterator to the first row, then copy it
+ TrilinosWrappers::SparsityPattern::const_iterator p = sp.begin(0);
+ TrilinosWrappers::SparsityPattern::const_iterator q (p);
+
+ // now reset 'p' to the second row, and output what elements both
+ // 'p' and 'q' point to
+ p = sp.begin(1);
+
+ for (unsigned int i=0; i<2; ++i, ++p)
+ deallog << "p[" << i << "]: "
+ << p->row() << ' ' << p->column()
+ << std::endl;
+
+ for (unsigned int i=0; i<2; ++i, ++q)
+ deallog << "q[" << i << "]: "
+ << q->row() << ' ' << q->column()
+ << std::endl;
+
+
+ // do the same with copy assignment
+ p = sp.begin(0);
+ q = p;
+ p = sp.begin(1);
+
+ for (unsigned int i=0; i<2; ++i, ++p)
+ deallog << "p[" << i << "]: "
+ << p->row() << ' ' << p->column()
+ << std::endl;
+
+ for (unsigned int i=0; i<2; ++i, ++q)
+ deallog << "q[" << i << "]: "
+ << q->row() << ' ' << q->column()
+ << std::endl;
+}
+
+
+
+int main (int argc, char **argv)
+{
+ std::ofstream logfile("output");
+ deallog.attach(logfile);
+ deallog.threshold_double(1.e-10);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv, testing_max_num_threads());
+
+ try
+ {
+ test ();
+ }
+ catch (std::exception &exc)
+ {
+ deallog << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ deallog << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ deallog << std::endl << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ deallog << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::Creating sparsity pattern entry 0 1
+DEAL::Creating sparsity pattern entry 0 4
+DEAL::Creating sparsity pattern entry 1 2
+DEAL::Creating sparsity pattern entry 1 5
+DEAL::Creating sparsity pattern entry 2 0
+DEAL::Creating sparsity pattern entry 2 3
+DEAL::Creating sparsity pattern entry 2 6
+DEAL::Creating sparsity pattern entry 3 1
+DEAL::Creating sparsity pattern entry 3 4
+DEAL::Creating sparsity pattern entry 4 2
+DEAL::Creating sparsity pattern entry 4 5
+DEAL::p[0]: 1 2
+DEAL::p[1]: 1 5
+DEAL::q[0]: 0 1
+DEAL::q[1]: 0 4
+DEAL::p[0]: 1 2
+DEAL::p[1]: 1 5
+DEAL::q[0]: 0 1
+DEAL::q[1]: 0 4