--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::SparseMatrix<double>::operator /=
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::SparseMatrix<double> &m)
+{
+ // first set a few entries
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ if ((i + 2 * j + 1) % 3 == 0)
+ m.set(i, j, i * j * .5 + .5);
+
+ m.compress(VectorOperation::insert);
+
+ // then divide everything by 4/3 and
+ // make sure we retrieve the values we
+ // expect
+ m /= 4. / 3.;
+
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ if ((i + 2 * j + 1) % 3 == 0)
+ {
+ AssertThrow(m(i, j) == (i * j * .5 + .5) / 4 * 3, ExcInternalError());
+ AssertThrow(m.el(i, j) == (i * j * .5 + .5) / 4 * 3,
+ ExcInternalError());
+ }
+ else
+ {
+ AssertThrow(m.el(i, j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(5U, 5U, 3U);
+ test(m);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::size()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the vector
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) = i;
+
+ v.compress(VectorOperation::insert);
+
+ AssertThrow(v.size() == 100, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set-mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+
+ v.compress(VectorOperation::insert);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in add-mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress(VectorOperation::add);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in
+// set/add-mode alternatingly. this test doesn't really make sense any more --
+// at least one a single processor. on multiple processors, one has to call
+// compress() and it used to be that we had code that called compress() either
+// with VectorOperation::insert or VectorOperation::add automatically whenever
+// we switched from one kind of operation to the other. this is no longer the
+// case -- the user has to select which operation herself. on the other hand, as
+// long as we're working on a single processor, it doesn't matter
+// anyway.
+//
+// so the test doesn't make much sense any more for the original
+// purpose, but it's still worth keeping it around just to test that
+// set and write operations on a single processor go right through to
+// the stored data, rather than ending up in separate caches that only
+// get flushed when the right kind of compress() function is called.
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ bool flag = false;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ if (flag == true)
+ v(i) += i;
+ else
+ v(i) = i;
+ flag = !flag;
+
+ pattern[i] = true;
+ }
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in
+// set/add-mode alternatingly, but writing to the same elements
+//
+// this test doesn't really make sense any more -- at least one a
+// single processor. on multiple processors, one has to call
+// compress() and it used to be that we had code that called
+// compress() either with VectorOperation::insert or
+// VectorOperation::add automatically whenever we switched from one
+// kind of operation to the other. this is no longer the case -- the
+// user has to select which operation herself. on the other hand, as
+// long as we're working on a single processor, it doesn't matter
+// anyway.
+//
+// so the test doesn't make much sense any more for the original
+// purpose, but it's still worth keeping it around just to test that
+// set and write operations on a single processor go right through to
+// the stored data, rather than ending up in separate caches that only
+// get flushed when the right kind of compress() function is called.
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress(VectorOperation::insert);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) += i;
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == 2 * i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in
+// set/add-mode alternatingly, but writing and overwriting the same elements
+//
+// this test doesn't really make sense any more -- at least one a
+// single processor. on multiple processors, one has to call
+// compress() and it used to be that we had code that called
+// compress() either with VectorOperation::insert or
+// VectorOperation::add automatically whenever we switched from one
+// kind of operation to the other. this is no longer the case -- the
+// user has to select which operation herself. on the other hand, as
+// long as we're working on a single processor, it doesn't matter
+// anyway.
+//
+// so the test doesn't make much sense any more for the original
+// purpose, but it's still worth keeping it around just to test that
+// set and write operations on a single processor go right through to
+// the stored data, rather than ending up in separate caches that only
+// get flushed when the right kind of compress() function is called.
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) += i;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) = i;
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::l1_norm()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ norm += std::fabs(1. * i);
+ }
+ v.compress(VectorOperation::insert);
+
+ // then check the norm
+ AssertThrow(v.l1_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::l2_norm()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ TrilinosScalar norm = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ norm += std::fabs(1. * i) * std::fabs(1. * i);
+ }
+ v.compress(VectorOperation::insert);
+
+ // then check the norm
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ AssertThrow(fabs(v.l2_norm() - std::sqrt(norm)) < eps, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::linfty_norm()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ norm = std::max(norm, fabs(i));
+ }
+ v.compress(VectorOperation::insert);
+
+ // then check the norm
+ AssertThrow(v.linfty_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator *=
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress(VectorOperation::insert);
+
+ // multiply v with 5/4
+ v *= 5. / 4.;
+
+ // check that the entries are ok
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i * 5. / 4.)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator /=
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress(VectorOperation::insert);
+
+ // multiply v with 3/4
+ v /= 4. / 3.;
+
+ // check that the entries are ok
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i * 3. / 4.)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator*(Vector) on two
+// vectors that are orthogonal
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector, but disjoint sets of elements
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i;
+ else
+ w(i) = i;
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ // make sure the scalar product is zero
+ AssertThrow(v * w == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator*(Vector) on two
+// vectors that are not orthogonal
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector, and record the expected scalar
+ // product
+ double product = 0;
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ if (i % 3 == 0)
+ {
+ w(i) = i + 1.;
+ product += i * (i + 1);
+ }
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ // make sure the scalar product is zero
+ AssertThrow(v * w == product, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this test used to check for
+// LinearAlgebra::TpetraWrappers::Vector<double>::clear(). However, this
+// function has since been removed, so we test for v=0 instead, although that
+// may be covered by one of the other tests
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i + 1.;
+ v.compress(VectorOperation::insert);
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v = 0;
+ AssertThrow(v.size() == sz, ExcInternalError());
+ AssertThrow(v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator = (Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i + 1.;
+ v.compress(VectorOperation::insert);
+
+ // then copy it
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(v.size()), MPI_COMM_WORLD);
+ w = v;
+
+ // make sure they're equal
+ deallog << v * w << ' ' << v.l2_norm() * w.l2_norm() << ' '
+ << v * w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ Assert(std::fabs(v * w - v.l2_norm() * w.l2_norm()) < eps * (v * w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator = (Vector),
+// except that we don't resize the vector to be copied to beforehand
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i + 1.;
+ v.compress(VectorOperation::insert);
+
+ // then copy it to a vector of different
+ // size
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(1), MPI_COMM_WORLD);
+ w = v;
+
+ // make sure they're equal
+ deallog << v * w << ' ' << v.l2_norm() * w.l2_norm() << ' '
+ << v * w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ Assert(std::fabs(v * w - v.l2_norm() * w.l2_norm()) < eps * (v * w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::reinit(fast)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ v.reinit(complete_index_set(13), MPI_COMM_WORLD);
+
+ AssertThrow(v.size() == 13, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::reinit(!fast)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i + 1.;
+ v.compress(VectorOperation::insert);
+
+ // then resize with setting to zero
+ v.reinit(complete_index_set(13), MPI_COMM_WORLD);
+
+ AssertThrow(v.size() == 13, ExcInternalError());
+ AssertThrow(v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::l2_norm()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ TrilinosScalar norm = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ norm += std::fabs(1. * i) * std::fabs(1. * i);
+ }
+ v.compress(VectorOperation::insert);
+
+ // then check the norm
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ AssertThrow(std::fabs(v.norm_sqr() - norm) < eps * norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::mean_value()
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ TrilinosScalar sum = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ sum += i;
+ }
+ v.compress(VectorOperation::insert);
+
+ // then check the norm
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ AssertThrow(std::fabs(v.mean_value() - sum / v.size()) < eps * sum / v.size(),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::all_zero
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ sum += i * i * i;
+ }
+ v.compress(VectorOperation::insert);
+
+ // set them to zero again
+ v = 0;
+
+ // then check all_zero
+ AssertThrow(v.all_zero() == true, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator+=(Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ if (i % 3 == 0)
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v += w;
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ if (i % 3 == 0)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == i + i + 1., ExcInternalError());
+ }
+ else
+ {
+ AssertThrow(w(i) == 0, ExcInternalError());
+ AssertThrow(v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator-=(Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ if (i % 3 == 0)
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v -= w;
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ if (i % 3 == 0)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == i - (i + 1.), ExcInternalError());
+ }
+ else
+ {
+ AssertThrow(w(i) == 0, ExcInternalError());
+ AssertThrow(v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::add (scalar)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ v(i) = i;
+
+ v.compress(VectorOperation::insert);
+
+ v.add(1.);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow(v(i) == i + 1., ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::add(scalar, Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v.add(2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == i + 2 * (i + 1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::add(s,V,s,V)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w,
+ LinearAlgebra::TpetraWrappers::Vector<double> &x)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i + 1.;
+ x(i) = i + 2.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+ x.compress(VectorOperation::insert);
+
+ v.add(2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(x(i) == i + 2., ExcInternalError());
+ AssertThrow(v(i) == i + 2 * (i + 1.) + 3 * (i + 2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> x;
+ x.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w, x);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::sadd(scalar, scalar,
+// Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v.sadd(3, 2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == 3 * i + 2 * (i + 1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::scale
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v.scale(w);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == i * (i + 1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::equ (s,V)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i + 1.;
+ }
+
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ v.equ(2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(w(i) == i + 1., ExcInternalError());
+ AssertThrow(v(i) == 2 * (i + 1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check copy constructor
+// LinearAlgebra::TpetraWrappers::Vector<double>::Vector(Vector)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i = 0; i < v.size(); ++i)
+ if (i % 3 == 0)
+ v(i) = i + 1.;
+ v.compress(VectorOperation::insert);
+
+ // then copy it
+ LinearAlgebra::TpetraWrappers::Vector<double> w(v);
+ w.compress(VectorOperation::insert);
+
+ // make sure they're equal
+ deallog << v * w << ' ' << v.l2_norm() * w.l2_norm() << ' '
+ << v * w - v.l2_norm() * w.l2_norm() << std::endl;
+ const double eps = typeid(TrilinosScalar) == typeid(double) ? 1e-14 : 1e-5;
+ Assert(std::fabs(v * w - v.l2_norm() * w.l2_norm()) < eps * (v * w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::116161. 116161. 0
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check setting elements in a petsc matrix using
+// LinearAlgebra::TpetraWrappers::SparseMatrix<double>::set(). like trilinos_01,
+// but use a different constructor for the sparse matrix
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::SparseMatrix<double> &m)
+{
+ // first set a few entries
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ if ((i + 2 * j + 1) % 3 == 0)
+ m.set(i, j, i * j * .5 + .5);
+
+ m.compress(VectorOperation::insert);
+
+ // then make sure we retrieve the same ones
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ if ((i + 2 * j + 1) % 3 == 0)
+ {
+ AssertThrow(m(i, j) == i * j * .5 + .5, ExcInternalError());
+ AssertThrow(m.el(i, j) == i * j * .5 + .5, ExcInternalError());
+ }
+ else
+ {
+ AssertThrow(m.el(i, j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ std::vector<unsigned int> row_lengths(5, 3U);
+ row_lengths.back() = 2;
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(
+ static_cast<types::global_dof_index>(5U),
+ static_cast<types::global_dof_index>(5U),
+ row_lengths);
+ test(m);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set, and
+// later in add-mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress(VectorOperation::insert);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) += i;
+
+ v.compress(VectorOperation::add);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == 2 * i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set, and
+// later in -= mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = 2 * i;
+ pattern[i] = true;
+ }
+ v.compress(VectorOperation::insert);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) -= i;
+
+ v.compress(VectorOperation::add);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set, and
+// later in *= mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) *= 2;
+
+ v.compress(VectorOperation::insert);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == 2 * i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator() in set, and
+// later in /= mode
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern(v.size(), false);
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ {
+ v(i) = 2 * i;
+ pattern[i] = true;
+ }
+ for (unsigned int i = 0; i < v.size(); i += 1 + i)
+ v(i) /= 2;
+
+ v.compress(VectorOperation::insert);
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i = 0; i < v.size(); ++i)
+ AssertThrow((((pattern[i] == true) && (v(i) == i)) ||
+ ((pattern[i] == false) && (v(i) == 0))),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::SparseMatrix<double> &m)
+{
+ AssertThrow(m.m() == 100, ExcInternalError());
+ AssertThrow(m.n() == 100, ExcInternalError());
+
+ m = 0;
+
+ AssertThrow(m.m() == 100, ExcInternalError());
+ AssertThrow(m.n() == 100, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> v(100U, 100U, 5U);
+ test(v);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check TrilinosScalar
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include "../tests.h"
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ if (typeid(TrilinosScalar) == typeid(double))
+ deallog << "double" << std::endl;
+ else if (typeid(TrilinosScalar) == typeid(float))
+ deallog << "float" << std::endl;
+ else
+ DEAL_II_NOT_IMPLEMENTED();
+}
--- /dev/null
+
+DEAL::double
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2016 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check that make_trilinos_map always uses the same constructor all the
+// processor. If we don't the code will hang like reported on the mailing list
+// by Nicola Giuliani.
+
+#include <deal.II/base/index_set.h>
+#include <deal.II/base/utilities.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+
+void
+test()
+{
+ IndexSet my_set;
+ my_set.set_size(654);
+ int this_mpi_process, n_mpi_processes;
+ n_mpi_processes = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+ this_mpi_process = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ if (this_mpi_process == 0)
+ {
+ my_set.add_range(0, 86);
+ }
+ else if (this_mpi_process == 1)
+ {
+ my_set.add_range(86, 400);
+ my_set.add_range(529, 654);
+ }
+ else
+ {
+ my_set.add_range(400, 529);
+ }
+ my_set.compress();
+ my_set.make_tpetra_map(MPI_COMM_WORLD, false);
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+ test();
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2022 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// LinearAlgebra::TpetraWrappers::SparseMatrix<double>::reinit(DynamicSparsityPattern)
+// should create a matrix that, when filled with elements that match the
+// sparsity pattern, doesn't require any more memory allocation any more. This
+// is tricky to get right, though, and took a while until it worked.
+//
+// the test itself can only check this when run in parallel, but we can add it
+// anyway to the testsuite. in order to check that the library actually does
+// what it is supposed to do, run this program with more than one MPI process
+// and with the option -log_info. All the output should say that no additional
+// malloc calls have been performed
+
+#include <deal.II/base/mpi.h>
+#include <deal.II/base/trilinos_utilities.h>
+
+#include <deal.II/lac/dynamic_sparsity_pattern.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ // create a parallel matrix where the first
+ // process has 10 rows, the second one 20,
+ // the third one 30, and so on
+ unsigned int N = 0;
+ std::vector<unsigned int> local_rows_per_process(
+ Utilities::Trilinos::get_n_mpi_processes(
+ Utilities::Trilinos::comm_world()));
+ std::vector<unsigned int> start_row(Utilities::Trilinos::get_n_mpi_processes(
+ Utilities::Trilinos::comm_world()));
+ for (unsigned int i = 0; i < Utilities::Trilinos::get_n_mpi_processes(
+ Utilities::Trilinos::comm_world());
+ ++i)
+ {
+ N += (i + 1) * 10;
+ local_rows_per_process[i] = (i + 1) * 10;
+ start_row[i] += i * 10;
+ }
+
+ // here is a sparsity pattern for which we
+ // used to allocate additional memory for 2
+ // processes. note that only one of the
+ // four blocks uses Inodes
+ DynamicSparsityPattern csp(N, N);
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < N; ++j)
+ {
+ csp.add(i, i);
+ if (i + local_rows_per_process.back() < N)
+ csp.add(i, i + local_rows_per_process.back());
+ if (i > local_rows_per_process.back())
+ csp.add(i, i - local_rows_per_process.back());
+ }
+
+ // here is a sparsity pattern for which no
+ // Inodes are used, but it doesn't allocate
+ // additional memory
+ // for (unsigned int bi=0; bi<get_n_mpi_processes(); ++bi)
+ // for (unsigned int bj=0; bj<get_n_mpi_processes(); ++bj)
+ // for (unsigned int i=0; i<local_rows_per_process[bi]; ++i)
+ // for (unsigned int k=0; k<6; ++k)
+ // csp.add (start_row[bi] + i,
+ // start_row[bj] + (i+2*k) % local_rows_per_process[bj]);
+
+
+ // now create a matrix with this sparsity
+ // pattern
+ const unsigned int my_id = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ IndexSet locally_owned_dofs(N);
+ locally_owned_dofs.add_range(start_row[my_id], local_rows_per_process[my_id]);
+
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m;
+ m.reinit(locally_owned_dofs, locally_owned_dofs, csp, MPI_COMM_WORLD);
+ // now write into the exact same matrix
+ // entries as have been created by the
+ // sparsity pattern above
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < csp.row_length(i); ++j)
+ m.add(i, csp.column_number(i, j), 1.);
+
+ m.compress(VectorOperation::add);
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ test();
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this is part of a whole suite of tests that checks the relative speed of
+// using Trilinos for sparse matrices as compared to the speed of our own
+// library. the tests therefore may not all actually use Trilinos, but they are
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ const unsigned int N = 200;
+
+ // first build the sparsity pattern
+ SparsityPattern sparsity(N * N, N * N, 5);
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < N; ++j)
+ {
+ const unsigned int global = i * N + j;
+ sparsity.add(global, global);
+ if (j > 0)
+ {
+ sparsity.add(global - 1, global);
+ sparsity.add(global, global - 1);
+ }
+ if (j < N - 1)
+ {
+ sparsity.add(global + 1, global);
+ sparsity.add(global, global + 1);
+ }
+ if (i > 0)
+ {
+ sparsity.add(global - N, global);
+ sparsity.add(global, global - N);
+ }
+ if (i < N - 1)
+ {
+ sparsity.add(global + N, global);
+ sparsity.add(global, global + N);
+ }
+ }
+ sparsity.compress();
+
+
+ // next build the sparse matrix itself
+ SparseMatrix<double> matrix(sparsity);
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < N; ++j)
+ {
+ const unsigned int global = i * N + j;
+ matrix.add(global, global, 4);
+ if (j > 0)
+ {
+ matrix.add(global - 1, global, -1);
+ matrix.add(global, global - 1, -1);
+ }
+ if (j < N - 1)
+ {
+ matrix.add(global + 1, global, -1);
+ matrix.add(global, global + 1, -1);
+ }
+ if (i > 0)
+ {
+ matrix.add(global - N, global, -1);
+ matrix.add(global, global - N, -1);
+ }
+ if (i < N - 1)
+ {
+ matrix.add(global + N, global, -1);
+ matrix.add(global, global + N, -1);
+ }
+ }
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ Vector<double> v1(N * N), v2(N * N);
+ for (unsigned int i = 0; i < N * N; ++i)
+ v1(i) = i;
+ matrix.vmult(v2, v1);
+
+ deallog << v1 * v2 << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ try
+ {
+ {
+ test();
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+ return 0;
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this is part of a whole suite of tests that checks the relative speed of
+// using Trilinos for sparse matrices as compared to the speed of our own
+// library. the tests therefore may not all actually use Trilinos, but they are
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ const unsigned int N = 200;
+
+ // build the sparse matrix
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> matrix(N * N, N * N, 5U);
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < N; ++j)
+ {
+ const unsigned int global = i * N + j;
+ matrix.set(global, global, 4);
+ if (j > 0)
+ {
+ matrix.set(global - 1, global, -1);
+ matrix.set(global, global - 1, -1);
+ }
+ if (j < N - 1)
+ {
+ matrix.set(global + 1, global, -1);
+ matrix.set(global, global + 1, -1);
+ }
+ if (i > 0)
+ {
+ matrix.set(global - N, global, -1);
+ matrix.set(global, global - N, -1);
+ }
+ if (i < N - 1)
+ {
+ matrix.set(global + N, global, -1);
+ matrix.set(global, global + N, -1);
+ }
+ }
+ matrix.compress(VectorOperation::insert);
+
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ LinearAlgebra::TpetraWrappers::Vector<double> v1;
+ v1.reinit(complete_index_set(N * N), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> v2;
+ v2.reinit(complete_index_set(N * N), MPI_COMM_WORLD);
+ for (unsigned int i = 0; i < N * N; ++i)
+ v1(i) = i;
+ matrix.vmult(v2, v1);
+
+ deallog << v1 * v2 << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ try
+ {
+ {
+ test();
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+ return 0;
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this is part of a whole suite of tests that checks the relative speed of
+// using Trilinos for sparse matrices as compared to the speed of our own
+// library. the tests therefore may not all actually use Trilinos, but they are
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ const unsigned int N = 200;
+
+ // build the sparse matrix
+ IndexSet indices = complete_index_set(N * N);
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> matrix(indices,
+ MPI_COMM_WORLD,
+ 5);
+ for (unsigned int i = 0; i < N; ++i)
+ for (unsigned int j = 0; j < N; ++j)
+ {
+ const unsigned int global = i * N + j;
+ matrix.set(global, global, 4);
+ if (j > 0)
+ {
+ matrix.set(global - 1, global, -1);
+ matrix.set(global, global - 1, -1);
+ }
+ if (j < N - 1)
+ {
+ matrix.set(global + 1, global, -1);
+ matrix.set(global, global + 1, -1);
+ }
+ if (i > 0)
+ {
+ matrix.set(global - N, global, -1);
+ matrix.set(global, global - N, -1);
+ }
+ if (i < N - 1)
+ {
+ matrix.set(global + N, global, -1);
+ matrix.set(global, global + N, -1);
+ }
+ }
+ matrix.compress(VectorOperation::insert);
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ LinearAlgebra::TpetraWrappers::Vector<double> v1(indices, MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> v2(indices, MPI_COMM_WORLD);
+ for (unsigned int i = 0; i < N * N; ++i)
+ v1(i) = i;
+ matrix.vmult(v2, v1);
+
+ deallog << v1 * v2 << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ try
+ {
+ {
+ test();
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+
+ return 0;
+}
--- /dev/null
+
+DEAL::-8.42635e+13
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2005 - 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// this is part of a whole suite of tests that checks the relative speed of
+// using Trilinos for sparse matrices as compared to the speed of our own
+// library. the tests therefore may not all actually use Trilinos, but they are
+// meant to compare it
+//
+// the tests build the 5-point stencil matrix for a uniform grid of size N*N
+//
+// this test does the same as the _03 test, except that it does not allocate
+// the entries in consecutive order, but in pseudo-random order. the reason is
+// that in usual finite element programs, we do not write to the elements of a
+// matrix in a consecutive fashion, but rather according to the order of
+// degrees of freedom in the sequence of cells that we traverse
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ const unsigned int N = 200;
+
+ // first find a random permutation of the
+ // indices
+ std::vector<unsigned int> permutation(N);
+ {
+ std::vector<unsigned int> unused_indices(N);
+ for (unsigned int i = 0; i < N; ++i)
+ unused_indices[i] = i;
+
+ for (unsigned int i = 0; i < N; ++i)
+ {
+ // pick a random element among the
+ // unused indices
+ const unsigned int k = Testing::rand() % (N - i);
+ permutation[i] = unused_indices[k];
+
+ // then swap this used element to the
+ // end where we won't consider it any
+ // more
+ std::swap(unused_indices[k], unused_indices[N - i - 1]);
+ }
+ }
+
+ // build the sparse matrix
+ IndexSet indices = complete_index_set(N * N);
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> matrix(indices,
+ MPI_COMM_WORLD,
+ 5);
+ for (unsigned int i_ = 0; i_ < N; ++i_)
+ for (unsigned int j_ = 0; j_ < N; ++j_)
+ {
+ const unsigned int i = permutation[i_];
+ const unsigned int j = permutation[j_];
+
+ const unsigned int global = i * N + j;
+ matrix.set(global, global, Testing::rand());
+ if (j > 0)
+ {
+ matrix.set(global - 1, global, Testing::rand());
+ matrix.set(global, global - 1, Testing::rand());
+ }
+ if (j < N - 1)
+ {
+ matrix.set(global + 1, global, Testing::rand());
+ matrix.set(global, global + 1, Testing::rand());
+ }
+ if (i > 0)
+ {
+ matrix.set(global - N, global, Testing::rand());
+ matrix.set(global, global - N, Testing::rand());
+ }
+ if (i < N - 1)
+ {
+ matrix.set(global + N, global, Testing::rand());
+ matrix.set(global, global + N, Testing::rand());
+ }
+ }
+ matrix.compress(VectorOperation::insert);
+
+ // then do a single matrix-vector
+ // multiplication with subsequent formation
+ // of the matrix norm
+ LinearAlgebra::TpetraWrappers::Vector<double> v1(indices, MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> v2(indices, MPI_COMM_WORLD);
+ for (unsigned int i = 0; i < N * N; ++i)
+ v1(i) = i;
+ matrix.vmult(v2, v1);
+
+ deallog << v1 * v2 << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ try
+ {
+ {
+ test();
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+ return 0;
+}
--- /dev/null
+
+DEAL::2.04928e+23
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::vmult
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(v.size(),
+ v.size(),
+ v.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ v(i) = i;
+
+ m.compress(VectorOperation::insert);
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ // w:=Mv
+ m.vmult(w, v);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (i + 2 * j) * j;
+ AssertThrow(w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::Tvmult
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(v.size(),
+ v.size(),
+ v.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ v(i) = i;
+
+ m.compress(VectorOperation::insert);
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ // w:=Mv
+ m.Tvmult(w, v);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (j + 2 * i) * j;
+ AssertThrow(w(i) == result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::vmult_add
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(v.size(),
+ v.size(),
+ v.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress(VectorOperation::insert);
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+
+ // w:=Mv
+ m.vmult_add(w, v);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (i + 2 * j) * j;
+ AssertThrow(w(i) == i + result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::Tvmult_add
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(v.size(),
+ v.size(),
+ v.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.m(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i;
+ }
+
+ m.compress(VectorOperation::insert);
+ v.compress(VectorOperation::insert);
+ w.compress(VectorOperation::insert);
+ // w:=Mv
+ m.Tvmult_add(w, v);
+
+ // make sure we get the expected result
+ for (unsigned int i = 0; i < v.size(); ++i)
+ {
+ AssertThrow(v(i) == i, ExcInternalError());
+
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (j + 2 * i) * j;
+ AssertThrow(w(i) == i + result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(100), MPI_COMM_WORLD);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2013 - 2023 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::vmult, vmult_add with
+// LinearAlgebra::TpetraWrappers::Vector<double>
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/la_parallel_vector.h>
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::ReadWriteVector<double> read_write_v(v.size());
+ LinearAlgebra::ReadWriteVector<double> read_write_w(w.size());
+
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(w.size(),
+ v.size(),
+ v.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.n(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ read_write_v(i) = i;
+
+ m.compress(VectorOperation::insert);
+ v.import_elements(read_write_v, VectorOperation::insert);
+
+ // w:=Mv
+ m.vmult(w, v);
+
+ // make sure we get the expected result
+ read_write_w.import_elements(w, VectorOperation::insert);
+ for (unsigned int i = 0; i < m.m(); ++i)
+ {
+ double result = 0;
+ for (unsigned int j = 0; j < m.n(); ++j)
+ result += (i + 2 * j) * j;
+ AssertThrow(read_write_w(i) == result, ExcInternalError());
+ }
+
+ m.vmult_add(w, v);
+
+ // make sure we get the expected result
+ read_write_w.import_elements(w, VectorOperation::insert);
+ for (unsigned int i = 0; i < m.m(); ++i)
+ {
+ double result = 0;
+ for (unsigned int j = 0; j < m.n(); ++j)
+ result += (i + 2 * j) * j;
+ AssertThrow(read_write_w(i) == result + result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v(complete_index_set(100),
+ MPI_COMM_SELF);
+ LinearAlgebra::TpetraWrappers::Vector<double> w(complete_index_set(95),
+ MPI_COMM_SELF);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2013 - 2023 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check SparseMatrix::Tvmult, Tvmult_add with
+// LinearAlgebra::TpetraWrappers::Vector<double>
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/la_parallel_vector.h>
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v,
+ LinearAlgebra::TpetraWrappers::Vector<double> &w)
+{
+ LinearAlgebra::ReadWriteVector<double> read_write_v(v.size());
+ LinearAlgebra::ReadWriteVector<double> read_write_w(w.size());
+
+ LinearAlgebra::TpetraWrappers::SparseMatrix<double> m(v.size(),
+ w.size(),
+ w.size());
+ for (unsigned int i = 0; i < m.m(); ++i)
+ for (unsigned int j = 0; j < m.n(); ++j)
+ m.set(i, j, i + 2 * j);
+
+ for (unsigned int i = 0; i < v.size(); ++i)
+ read_write_v(i) = i;
+
+ m.compress(VectorOperation::insert);
+ v.import_elements(read_write_v, VectorOperation::insert);
+
+ // w:=Mv
+ m.Tvmult(w, v);
+
+ // make sure we get the expected result
+ read_write_w.import_elements(w, VectorOperation::insert);
+ for (unsigned int i = 0; i < m.n(); ++i)
+ {
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (j + 2 * i) * j;
+ AssertThrow(read_write_w(i) == result, ExcInternalError());
+ }
+
+ m.Tvmult_add(w, v);
+ // make sure we get the expected result
+ read_write_w.import_elements(w, VectorOperation::insert);
+ for (unsigned int i = 0; i < m.n(); ++i)
+ {
+ double result = 0;
+ for (unsigned int j = 0; j < m.m(); ++j)
+ result += (j + 2 * i) * j;
+ AssertThrow(read_write_w(i) == result + result, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ {
+ LinearAlgebra::TpetraWrappers::Vector<double> v(complete_index_set(95),
+ MPI_COMM_SELF);
+ LinearAlgebra::TpetraWrappers::Vector<double> w(complete_index_set(100),
+ MPI_COMM_SELF);
+ test(v, w);
+ }
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::SparsityPattern::row_length
+
+#include <deal.II/base/utilities.h>
+
+#include "sparsity_pattern_common.h"
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+ initlog();
+ deallog << std::setprecision(3) << std::fixed;
+
+ row_length();
+}
--- /dev/null
+
+DEAL::196 196 14 924
+DEAL::3
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::3
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::4
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::5
+DEAL::4
+DEAL::3
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::4
+DEAL::3
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::SparsityPattern::print_gnuplot
+
+#include <deal.II/base/utilities.h>
+
+#include "sparsity_pattern_common.h"
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+ initlog();
+ deallog << std::setprecision(3) << std::fixed;
+
+ print_gnuplot();
+}
--- /dev/null
+
+DEAL::196 196 14 924
+0 0
+1 0
+14 0
+0 -1
+1 -1
+2 -1
+15 -1
+1 -2
+2 -2
+3 -2
+16 -2
+2 -3
+3 -3
+4 -3
+17 -3
+3 -4
+4 -4
+5 -4
+18 -4
+4 -5
+5 -5
+6 -5
+19 -5
+5 -6
+6 -6
+7 -6
+20 -6
+6 -7
+7 -7
+8 -7
+21 -7
+7 -8
+8 -8
+9 -8
+22 -8
+8 -9
+9 -9
+10 -9
+23 -9
+9 -10
+10 -10
+11 -10
+24 -10
+10 -11
+11 -11
+12 -11
+25 -11
+11 -12
+12 -12
+13 -12
+26 -12
+12 -13
+13 -13
+27 -13
+0 -14
+14 -14
+15 -14
+28 -14
+1 -15
+14 -15
+15 -15
+16 -15
+29 -15
+2 -16
+15 -16
+16 -16
+17 -16
+30 -16
+3 -17
+16 -17
+17 -17
+18 -17
+31 -17
+4 -18
+17 -18
+18 -18
+19 -18
+32 -18
+5 -19
+18 -19
+19 -19
+20 -19
+33 -19
+6 -20
+19 -20
+20 -20
+21 -20
+34 -20
+7 -21
+20 -21
+21 -21
+22 -21
+35 -21
+8 -22
+21 -22
+22 -22
+23 -22
+36 -22
+9 -23
+22 -23
+23 -23
+24 -23
+37 -23
+10 -24
+23 -24
+24 -24
+25 -24
+38 -24
+11 -25
+24 -25
+25 -25
+26 -25
+39 -25
+12 -26
+25 -26
+26 -26
+27 -26
+40 -26
+13 -27
+26 -27
+27 -27
+41 -27
+14 -28
+28 -28
+29 -28
+42 -28
+15 -29
+28 -29
+29 -29
+30 -29
+43 -29
+16 -30
+29 -30
+30 -30
+31 -30
+44 -30
+17 -31
+30 -31
+31 -31
+32 -31
+45 -31
+18 -32
+31 -32
+32 -32
+33 -32
+46 -32
+19 -33
+32 -33
+33 -33
+34 -33
+47 -33
+20 -34
+33 -34
+34 -34
+35 -34
+48 -34
+21 -35
+34 -35
+35 -35
+36 -35
+49 -35
+22 -36
+35 -36
+36 -36
+37 -36
+50 -36
+23 -37
+36 -37
+37 -37
+38 -37
+51 -37
+24 -38
+37 -38
+38 -38
+39 -38
+52 -38
+25 -39
+38 -39
+39 -39
+40 -39
+53 -39
+26 -40
+39 -40
+40 -40
+41 -40
+54 -40
+27 -41
+40 -41
+41 -41
+55 -41
+28 -42
+42 -42
+43 -42
+56 -42
+29 -43
+42 -43
+43 -43
+44 -43
+57 -43
+30 -44
+43 -44
+44 -44
+45 -44
+58 -44
+31 -45
+44 -45
+45 -45
+46 -45
+59 -45
+32 -46
+45 -46
+46 -46
+47 -46
+60 -46
+33 -47
+46 -47
+47 -47
+48 -47
+61 -47
+34 -48
+47 -48
+48 -48
+49 -48
+62 -48
+35 -49
+48 -49
+49 -49
+50 -49
+63 -49
+36 -50
+49 -50
+50 -50
+51 -50
+64 -50
+37 -51
+50 -51
+51 -51
+52 -51
+65 -51
+38 -52
+51 -52
+52 -52
+53 -52
+66 -52
+39 -53
+52 -53
+53 -53
+54 -53
+67 -53
+40 -54
+53 -54
+54 -54
+55 -54
+68 -54
+41 -55
+54 -55
+55 -55
+69 -55
+42 -56
+56 -56
+57 -56
+70 -56
+43 -57
+56 -57
+57 -57
+58 -57
+71 -57
+44 -58
+57 -58
+58 -58
+59 -58
+72 -58
+45 -59
+58 -59
+59 -59
+60 -59
+73 -59
+46 -60
+59 -60
+60 -60
+61 -60
+74 -60
+47 -61
+60 -61
+61 -61
+62 -61
+75 -61
+48 -62
+61 -62
+62 -62
+63 -62
+76 -62
+49 -63
+62 -63
+63 -63
+64 -63
+77 -63
+50 -64
+63 -64
+64 -64
+65 -64
+78 -64
+51 -65
+64 -65
+65 -65
+66 -65
+79 -65
+52 -66
+65 -66
+66 -66
+67 -66
+80 -66
+53 -67
+66 -67
+67 -67
+68 -67
+81 -67
+54 -68
+67 -68
+68 -68
+69 -68
+82 -68
+55 -69
+68 -69
+69 -69
+83 -69
+56 -70
+70 -70
+71 -70
+84 -70
+57 -71
+70 -71
+71 -71
+72 -71
+85 -71
+58 -72
+71 -72
+72 -72
+73 -72
+86 -72
+59 -73
+72 -73
+73 -73
+74 -73
+87 -73
+60 -74
+73 -74
+74 -74
+75 -74
+88 -74
+61 -75
+74 -75
+75 -75
+76 -75
+89 -75
+62 -76
+75 -76
+76 -76
+77 -76
+90 -76
+63 -77
+76 -77
+77 -77
+78 -77
+91 -77
+64 -78
+77 -78
+78 -78
+79 -78
+92 -78
+65 -79
+78 -79
+79 -79
+80 -79
+93 -79
+66 -80
+79 -80
+80 -80
+81 -80
+94 -80
+67 -81
+80 -81
+81 -81
+82 -81
+95 -81
+68 -82
+81 -82
+82 -82
+83 -82
+96 -82
+69 -83
+82 -83
+83 -83
+97 -83
+70 -84
+84 -84
+85 -84
+98 -84
+71 -85
+84 -85
+85 -85
+86 -85
+99 -85
+72 -86
+85 -86
+86 -86
+87 -86
+100 -86
+73 -87
+86 -87
+87 -87
+88 -87
+101 -87
+74 -88
+87 -88
+88 -88
+89 -88
+102 -88
+75 -89
+88 -89
+89 -89
+90 -89
+103 -89
+76 -90
+89 -90
+90 -90
+91 -90
+104 -90
+77 -91
+90 -91
+91 -91
+92 -91
+105 -91
+78 -92
+91 -92
+92 -92
+93 -92
+106 -92
+79 -93
+92 -93
+93 -93
+94 -93
+107 -93
+80 -94
+93 -94
+94 -94
+95 -94
+108 -94
+81 -95
+94 -95
+95 -95
+96 -95
+109 -95
+82 -96
+95 -96
+96 -96
+97 -96
+110 -96
+83 -97
+96 -97
+97 -97
+111 -97
+84 -98
+98 -98
+99 -98
+112 -98
+85 -99
+98 -99
+99 -99
+100 -99
+113 -99
+86 -100
+99 -100
+100 -100
+101 -100
+114 -100
+87 -101
+100 -101
+101 -101
+102 -101
+115 -101
+88 -102
+101 -102
+102 -102
+103 -102
+116 -102
+89 -103
+102 -103
+103 -103
+104 -103
+117 -103
+90 -104
+103 -104
+104 -104
+105 -104
+118 -104
+91 -105
+104 -105
+105 -105
+106 -105
+119 -105
+92 -106
+105 -106
+106 -106
+107 -106
+120 -106
+93 -107
+106 -107
+107 -107
+108 -107
+121 -107
+94 -108
+107 -108
+108 -108
+109 -108
+122 -108
+95 -109
+108 -109
+109 -109
+110 -109
+123 -109
+96 -110
+109 -110
+110 -110
+111 -110
+124 -110
+97 -111
+110 -111
+111 -111
+125 -111
+98 -112
+112 -112
+113 -112
+126 -112
+99 -113
+112 -113
+113 -113
+114 -113
+127 -113
+100 -114
+113 -114
+114 -114
+115 -114
+128 -114
+101 -115
+114 -115
+115 -115
+116 -115
+129 -115
+102 -116
+115 -116
+116 -116
+117 -116
+130 -116
+103 -117
+116 -117
+117 -117
+118 -117
+131 -117
+104 -118
+117 -118
+118 -118
+119 -118
+132 -118
+105 -119
+118 -119
+119 -119
+120 -119
+133 -119
+106 -120
+119 -120
+120 -120
+121 -120
+134 -120
+107 -121
+120 -121
+121 -121
+122 -121
+135 -121
+108 -122
+121 -122
+122 -122
+123 -122
+136 -122
+109 -123
+122 -123
+123 -123
+124 -123
+137 -123
+110 -124
+123 -124
+124 -124
+125 -124
+138 -124
+111 -125
+124 -125
+125 -125
+139 -125
+112 -126
+126 -126
+127 -126
+140 -126
+113 -127
+126 -127
+127 -127
+128 -127
+141 -127
+114 -128
+127 -128
+128 -128
+129 -128
+142 -128
+115 -129
+128 -129
+129 -129
+130 -129
+143 -129
+116 -130
+129 -130
+130 -130
+131 -130
+144 -130
+117 -131
+130 -131
+131 -131
+132 -131
+145 -131
+118 -132
+131 -132
+132 -132
+133 -132
+146 -132
+119 -133
+132 -133
+133 -133
+134 -133
+147 -133
+120 -134
+133 -134
+134 -134
+135 -134
+148 -134
+121 -135
+134 -135
+135 -135
+136 -135
+149 -135
+122 -136
+135 -136
+136 -136
+137 -136
+150 -136
+123 -137
+136 -137
+137 -137
+138 -137
+151 -137
+124 -138
+137 -138
+138 -138
+139 -138
+152 -138
+125 -139
+138 -139
+139 -139
+153 -139
+126 -140
+140 -140
+141 -140
+154 -140
+127 -141
+140 -141
+141 -141
+142 -141
+155 -141
+128 -142
+141 -142
+142 -142
+143 -142
+156 -142
+129 -143
+142 -143
+143 -143
+144 -143
+157 -143
+130 -144
+143 -144
+144 -144
+145 -144
+158 -144
+131 -145
+144 -145
+145 -145
+146 -145
+159 -145
+132 -146
+145 -146
+146 -146
+147 -146
+160 -146
+133 -147
+146 -147
+147 -147
+148 -147
+161 -147
+134 -148
+147 -148
+148 -148
+149 -148
+162 -148
+135 -149
+148 -149
+149 -149
+150 -149
+163 -149
+136 -150
+149 -150
+150 -150
+151 -150
+164 -150
+137 -151
+150 -151
+151 -151
+152 -151
+165 -151
+138 -152
+151 -152
+152 -152
+153 -152
+166 -152
+139 -153
+152 -153
+153 -153
+167 -153
+140 -154
+154 -154
+155 -154
+168 -154
+141 -155
+154 -155
+155 -155
+156 -155
+169 -155
+142 -156
+155 -156
+156 -156
+157 -156
+170 -156
+143 -157
+156 -157
+157 -157
+158 -157
+171 -157
+144 -158
+157 -158
+158 -158
+159 -158
+172 -158
+145 -159
+158 -159
+159 -159
+160 -159
+173 -159
+146 -160
+159 -160
+160 -160
+161 -160
+174 -160
+147 -161
+160 -161
+161 -161
+162 -161
+175 -161
+148 -162
+161 -162
+162 -162
+163 -162
+176 -162
+149 -163
+162 -163
+163 -163
+164 -163
+177 -163
+150 -164
+163 -164
+164 -164
+165 -164
+178 -164
+151 -165
+164 -165
+165 -165
+166 -165
+179 -165
+152 -166
+165 -166
+166 -166
+167 -166
+180 -166
+153 -167
+166 -167
+167 -167
+181 -167
+154 -168
+168 -168
+169 -168
+182 -168
+155 -169
+168 -169
+169 -169
+170 -169
+183 -169
+156 -170
+169 -170
+170 -170
+171 -170
+184 -170
+157 -171
+170 -171
+171 -171
+172 -171
+185 -171
+158 -172
+171 -172
+172 -172
+173 -172
+186 -172
+159 -173
+172 -173
+173 -173
+174 -173
+187 -173
+160 -174
+173 -174
+174 -174
+175 -174
+188 -174
+161 -175
+174 -175
+175 -175
+176 -175
+189 -175
+162 -176
+175 -176
+176 -176
+177 -176
+190 -176
+163 -177
+176 -177
+177 -177
+178 -177
+191 -177
+164 -178
+177 -178
+178 -178
+179 -178
+192 -178
+165 -179
+178 -179
+179 -179
+180 -179
+193 -179
+166 -180
+179 -180
+180 -180
+181 -180
+194 -180
+167 -181
+180 -181
+181 -181
+195 -181
+168 -182
+182 -182
+183 -182
+169 -183
+182 -183
+183 -183
+184 -183
+170 -184
+183 -184
+184 -184
+185 -184
+171 -185
+184 -185
+185 -185
+186 -185
+172 -186
+185 -186
+186 -186
+187 -186
+173 -187
+186 -187
+187 -187
+188 -187
+174 -188
+187 -188
+188 -188
+189 -188
+175 -189
+188 -189
+189 -189
+190 -189
+176 -190
+189 -190
+190 -190
+191 -190
+177 -191
+190 -191
+191 -191
+192 -191
+178 -192
+191 -192
+192 -192
+193 -192
+179 -193
+192 -193
+193 -193
+194 -193
+180 -194
+193 -194
+194 -194
+195 -194
+181 -195
+194 -195
+195 -195
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::SparsityPattern::print
+
+#include <deal.II/base/utilities.h>
+
+#include "sparsity_pattern_common.h"
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ initlog();
+ deallog << std::setprecision(3) << std::fixed;
+
+ print();
+}
--- /dev/null
+
+DEAL::196 196 14 924
+(0,0)
+(0,1)
+(0,14)
+(1,0)
+(1,1)
+(1,2)
+(1,15)
+(2,1)
+(2,2)
+(2,3)
+(2,16)
+(3,2)
+(3,3)
+(3,4)
+(3,17)
+(4,3)
+(4,4)
+(4,5)
+(4,18)
+(5,4)
+(5,5)
+(5,6)
+(5,19)
+(6,5)
+(6,6)
+(6,7)
+(6,20)
+(7,6)
+(7,7)
+(7,8)
+(7,21)
+(8,7)
+(8,8)
+(8,9)
+(8,22)
+(9,8)
+(9,9)
+(9,10)
+(9,23)
+(10,9)
+(10,10)
+(10,11)
+(10,24)
+(11,10)
+(11,11)
+(11,12)
+(11,25)
+(12,11)
+(12,12)
+(12,13)
+(12,26)
+(13,12)
+(13,13)
+(13,27)
+(14,0)
+(14,14)
+(14,15)
+(14,28)
+(15,1)
+(15,14)
+(15,15)
+(15,16)
+(15,29)
+(16,2)
+(16,15)
+(16,16)
+(16,17)
+(16,30)
+(17,3)
+(17,16)
+(17,17)
+(17,18)
+(17,31)
+(18,4)
+(18,17)
+(18,18)
+(18,19)
+(18,32)
+(19,5)
+(19,18)
+(19,19)
+(19,20)
+(19,33)
+(20,6)
+(20,19)
+(20,20)
+(20,21)
+(20,34)
+(21,7)
+(21,20)
+(21,21)
+(21,22)
+(21,35)
+(22,8)
+(22,21)
+(22,22)
+(22,23)
+(22,36)
+(23,9)
+(23,22)
+(23,23)
+(23,24)
+(23,37)
+(24,10)
+(24,23)
+(24,24)
+(24,25)
+(24,38)
+(25,11)
+(25,24)
+(25,25)
+(25,26)
+(25,39)
+(26,12)
+(26,25)
+(26,26)
+(26,27)
+(26,40)
+(27,13)
+(27,26)
+(27,27)
+(27,41)
+(28,14)
+(28,28)
+(28,29)
+(28,42)
+(29,15)
+(29,28)
+(29,29)
+(29,30)
+(29,43)
+(30,16)
+(30,29)
+(30,30)
+(30,31)
+(30,44)
+(31,17)
+(31,30)
+(31,31)
+(31,32)
+(31,45)
+(32,18)
+(32,31)
+(32,32)
+(32,33)
+(32,46)
+(33,19)
+(33,32)
+(33,33)
+(33,34)
+(33,47)
+(34,20)
+(34,33)
+(34,34)
+(34,35)
+(34,48)
+(35,21)
+(35,34)
+(35,35)
+(35,36)
+(35,49)
+(36,22)
+(36,35)
+(36,36)
+(36,37)
+(36,50)
+(37,23)
+(37,36)
+(37,37)
+(37,38)
+(37,51)
+(38,24)
+(38,37)
+(38,38)
+(38,39)
+(38,52)
+(39,25)
+(39,38)
+(39,39)
+(39,40)
+(39,53)
+(40,26)
+(40,39)
+(40,40)
+(40,41)
+(40,54)
+(41,27)
+(41,40)
+(41,41)
+(41,55)
+(42,28)
+(42,42)
+(42,43)
+(42,56)
+(43,29)
+(43,42)
+(43,43)
+(43,44)
+(43,57)
+(44,30)
+(44,43)
+(44,44)
+(44,45)
+(44,58)
+(45,31)
+(45,44)
+(45,45)
+(45,46)
+(45,59)
+(46,32)
+(46,45)
+(46,46)
+(46,47)
+(46,60)
+(47,33)
+(47,46)
+(47,47)
+(47,48)
+(47,61)
+(48,34)
+(48,47)
+(48,48)
+(48,49)
+(48,62)
+(49,35)
+(49,48)
+(49,49)
+(49,50)
+(49,63)
+(50,36)
+(50,49)
+(50,50)
+(50,51)
+(50,64)
+(51,37)
+(51,50)
+(51,51)
+(51,52)
+(51,65)
+(52,38)
+(52,51)
+(52,52)
+(52,53)
+(52,66)
+(53,39)
+(53,52)
+(53,53)
+(53,54)
+(53,67)
+(54,40)
+(54,53)
+(54,54)
+(54,55)
+(54,68)
+(55,41)
+(55,54)
+(55,55)
+(55,69)
+(56,42)
+(56,56)
+(56,57)
+(56,70)
+(57,43)
+(57,56)
+(57,57)
+(57,58)
+(57,71)
+(58,44)
+(58,57)
+(58,58)
+(58,59)
+(58,72)
+(59,45)
+(59,58)
+(59,59)
+(59,60)
+(59,73)
+(60,46)
+(60,59)
+(60,60)
+(60,61)
+(60,74)
+(61,47)
+(61,60)
+(61,61)
+(61,62)
+(61,75)
+(62,48)
+(62,61)
+(62,62)
+(62,63)
+(62,76)
+(63,49)
+(63,62)
+(63,63)
+(63,64)
+(63,77)
+(64,50)
+(64,63)
+(64,64)
+(64,65)
+(64,78)
+(65,51)
+(65,64)
+(65,65)
+(65,66)
+(65,79)
+(66,52)
+(66,65)
+(66,66)
+(66,67)
+(66,80)
+(67,53)
+(67,66)
+(67,67)
+(67,68)
+(67,81)
+(68,54)
+(68,67)
+(68,68)
+(68,69)
+(68,82)
+(69,55)
+(69,68)
+(69,69)
+(69,83)
+(70,56)
+(70,70)
+(70,71)
+(70,84)
+(71,57)
+(71,70)
+(71,71)
+(71,72)
+(71,85)
+(72,58)
+(72,71)
+(72,72)
+(72,73)
+(72,86)
+(73,59)
+(73,72)
+(73,73)
+(73,74)
+(73,87)
+(74,60)
+(74,73)
+(74,74)
+(74,75)
+(74,88)
+(75,61)
+(75,74)
+(75,75)
+(75,76)
+(75,89)
+(76,62)
+(76,75)
+(76,76)
+(76,77)
+(76,90)
+(77,63)
+(77,76)
+(77,77)
+(77,78)
+(77,91)
+(78,64)
+(78,77)
+(78,78)
+(78,79)
+(78,92)
+(79,65)
+(79,78)
+(79,79)
+(79,80)
+(79,93)
+(80,66)
+(80,79)
+(80,80)
+(80,81)
+(80,94)
+(81,67)
+(81,80)
+(81,81)
+(81,82)
+(81,95)
+(82,68)
+(82,81)
+(82,82)
+(82,83)
+(82,96)
+(83,69)
+(83,82)
+(83,83)
+(83,97)
+(84,70)
+(84,84)
+(84,85)
+(84,98)
+(85,71)
+(85,84)
+(85,85)
+(85,86)
+(85,99)
+(86,72)
+(86,85)
+(86,86)
+(86,87)
+(86,100)
+(87,73)
+(87,86)
+(87,87)
+(87,88)
+(87,101)
+(88,74)
+(88,87)
+(88,88)
+(88,89)
+(88,102)
+(89,75)
+(89,88)
+(89,89)
+(89,90)
+(89,103)
+(90,76)
+(90,89)
+(90,90)
+(90,91)
+(90,104)
+(91,77)
+(91,90)
+(91,91)
+(91,92)
+(91,105)
+(92,78)
+(92,91)
+(92,92)
+(92,93)
+(92,106)
+(93,79)
+(93,92)
+(93,93)
+(93,94)
+(93,107)
+(94,80)
+(94,93)
+(94,94)
+(94,95)
+(94,108)
+(95,81)
+(95,94)
+(95,95)
+(95,96)
+(95,109)
+(96,82)
+(96,95)
+(96,96)
+(96,97)
+(96,110)
+(97,83)
+(97,96)
+(97,97)
+(97,111)
+(98,84)
+(98,98)
+(98,99)
+(98,112)
+(99,85)
+(99,98)
+(99,99)
+(99,100)
+(99,113)
+(100,86)
+(100,99)
+(100,100)
+(100,101)
+(100,114)
+(101,87)
+(101,100)
+(101,101)
+(101,102)
+(101,115)
+(102,88)
+(102,101)
+(102,102)
+(102,103)
+(102,116)
+(103,89)
+(103,102)
+(103,103)
+(103,104)
+(103,117)
+(104,90)
+(104,103)
+(104,104)
+(104,105)
+(104,118)
+(105,91)
+(105,104)
+(105,105)
+(105,106)
+(105,119)
+(106,92)
+(106,105)
+(106,106)
+(106,107)
+(106,120)
+(107,93)
+(107,106)
+(107,107)
+(107,108)
+(107,121)
+(108,94)
+(108,107)
+(108,108)
+(108,109)
+(108,122)
+(109,95)
+(109,108)
+(109,109)
+(109,110)
+(109,123)
+(110,96)
+(110,109)
+(110,110)
+(110,111)
+(110,124)
+(111,97)
+(111,110)
+(111,111)
+(111,125)
+(112,98)
+(112,112)
+(112,113)
+(112,126)
+(113,99)
+(113,112)
+(113,113)
+(113,114)
+(113,127)
+(114,100)
+(114,113)
+(114,114)
+(114,115)
+(114,128)
+(115,101)
+(115,114)
+(115,115)
+(115,116)
+(115,129)
+(116,102)
+(116,115)
+(116,116)
+(116,117)
+(116,130)
+(117,103)
+(117,116)
+(117,117)
+(117,118)
+(117,131)
+(118,104)
+(118,117)
+(118,118)
+(118,119)
+(118,132)
+(119,105)
+(119,118)
+(119,119)
+(119,120)
+(119,133)
+(120,106)
+(120,119)
+(120,120)
+(120,121)
+(120,134)
+(121,107)
+(121,120)
+(121,121)
+(121,122)
+(121,135)
+(122,108)
+(122,121)
+(122,122)
+(122,123)
+(122,136)
+(123,109)
+(123,122)
+(123,123)
+(123,124)
+(123,137)
+(124,110)
+(124,123)
+(124,124)
+(124,125)
+(124,138)
+(125,111)
+(125,124)
+(125,125)
+(125,139)
+(126,112)
+(126,126)
+(126,127)
+(126,140)
+(127,113)
+(127,126)
+(127,127)
+(127,128)
+(127,141)
+(128,114)
+(128,127)
+(128,128)
+(128,129)
+(128,142)
+(129,115)
+(129,128)
+(129,129)
+(129,130)
+(129,143)
+(130,116)
+(130,129)
+(130,130)
+(130,131)
+(130,144)
+(131,117)
+(131,130)
+(131,131)
+(131,132)
+(131,145)
+(132,118)
+(132,131)
+(132,132)
+(132,133)
+(132,146)
+(133,119)
+(133,132)
+(133,133)
+(133,134)
+(133,147)
+(134,120)
+(134,133)
+(134,134)
+(134,135)
+(134,148)
+(135,121)
+(135,134)
+(135,135)
+(135,136)
+(135,149)
+(136,122)
+(136,135)
+(136,136)
+(136,137)
+(136,150)
+(137,123)
+(137,136)
+(137,137)
+(137,138)
+(137,151)
+(138,124)
+(138,137)
+(138,138)
+(138,139)
+(138,152)
+(139,125)
+(139,138)
+(139,139)
+(139,153)
+(140,126)
+(140,140)
+(140,141)
+(140,154)
+(141,127)
+(141,140)
+(141,141)
+(141,142)
+(141,155)
+(142,128)
+(142,141)
+(142,142)
+(142,143)
+(142,156)
+(143,129)
+(143,142)
+(143,143)
+(143,144)
+(143,157)
+(144,130)
+(144,143)
+(144,144)
+(144,145)
+(144,158)
+(145,131)
+(145,144)
+(145,145)
+(145,146)
+(145,159)
+(146,132)
+(146,145)
+(146,146)
+(146,147)
+(146,160)
+(147,133)
+(147,146)
+(147,147)
+(147,148)
+(147,161)
+(148,134)
+(148,147)
+(148,148)
+(148,149)
+(148,162)
+(149,135)
+(149,148)
+(149,149)
+(149,150)
+(149,163)
+(150,136)
+(150,149)
+(150,150)
+(150,151)
+(150,164)
+(151,137)
+(151,150)
+(151,151)
+(151,152)
+(151,165)
+(152,138)
+(152,151)
+(152,152)
+(152,153)
+(152,166)
+(153,139)
+(153,152)
+(153,153)
+(153,167)
+(154,140)
+(154,154)
+(154,155)
+(154,168)
+(155,141)
+(155,154)
+(155,155)
+(155,156)
+(155,169)
+(156,142)
+(156,155)
+(156,156)
+(156,157)
+(156,170)
+(157,143)
+(157,156)
+(157,157)
+(157,158)
+(157,171)
+(158,144)
+(158,157)
+(158,158)
+(158,159)
+(158,172)
+(159,145)
+(159,158)
+(159,159)
+(159,160)
+(159,173)
+(160,146)
+(160,159)
+(160,160)
+(160,161)
+(160,174)
+(161,147)
+(161,160)
+(161,161)
+(161,162)
+(161,175)
+(162,148)
+(162,161)
+(162,162)
+(162,163)
+(162,176)
+(163,149)
+(163,162)
+(163,163)
+(163,164)
+(163,177)
+(164,150)
+(164,163)
+(164,164)
+(164,165)
+(164,178)
+(165,151)
+(165,164)
+(165,165)
+(165,166)
+(165,179)
+(166,152)
+(166,165)
+(166,166)
+(166,167)
+(166,180)
+(167,153)
+(167,166)
+(167,167)
+(167,181)
+(168,154)
+(168,168)
+(168,169)
+(168,182)
+(169,155)
+(169,168)
+(169,169)
+(169,170)
+(169,183)
+(170,156)
+(170,169)
+(170,170)
+(170,171)
+(170,184)
+(171,157)
+(171,170)
+(171,171)
+(171,172)
+(171,185)
+(172,158)
+(172,171)
+(172,172)
+(172,173)
+(172,186)
+(173,159)
+(173,172)
+(173,173)
+(173,174)
+(173,187)
+(174,160)
+(174,173)
+(174,174)
+(174,175)
+(174,188)
+(175,161)
+(175,174)
+(175,175)
+(175,176)
+(175,189)
+(176,162)
+(176,175)
+(176,176)
+(176,177)
+(176,190)
+(177,163)
+(177,176)
+(177,177)
+(177,178)
+(177,191)
+(178,164)
+(178,177)
+(178,178)
+(178,179)
+(178,192)
+(179,165)
+(179,178)
+(179,179)
+(179,180)
+(179,193)
+(180,166)
+(180,179)
+(180,180)
+(180,181)
+(180,194)
+(181,167)
+(181,180)
+(181,181)
+(181,195)
+(182,168)
+(182,182)
+(182,183)
+(183,169)
+(183,182)
+(183,183)
+(183,184)
+(184,170)
+(184,183)
+(184,184)
+(184,185)
+(185,171)
+(185,184)
+(185,185)
+(185,186)
+(186,172)
+(186,185)
+(186,186)
+(186,187)
+(187,173)
+(187,186)
+(187,187)
+(187,188)
+(188,174)
+(188,187)
+(188,188)
+(188,189)
+(189,175)
+(189,188)
+(189,189)
+(189,190)
+(190,176)
+(190,189)
+(190,190)
+(190,191)
+(191,177)
+(191,190)
+(191,191)
+(191,192)
+(192,178)
+(192,191)
+(192,192)
+(192,193)
+(193,179)
+(193,192)
+(193,193)
+(193,194)
+(194,180)
+(194,193)
+(194,194)
+(194,195)
+(195,181)
+(195,194)
+(195,195)
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2008 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// check
+
+#include <deal.II/lac/trilinos_sparsity_pattern.h>
+
+#include "../tests.h"
+
+#include "../testmatrix.h"
+
+const unsigned int N = 15;
+
+
+// reinitialize sparsity patterns for 5-point star
+void
+do_reinit(TrilinosWrappers::SparsityPattern &sp)
+{
+ sp.reinit((N - 1) * (N - 1), (N - 1) * (N - 1));
+}
+
+
+
+void
+build_sparsity(TrilinosWrappers::SparsityPattern &sparsity_pattern)
+{
+ // generate usual 5-point sparsity pattern
+ do_reinit(sparsity_pattern);
+ FDMatrix(N, N).five_point_structure(sparsity_pattern);
+ sparsity_pattern.compress();
+
+ deallog << sparsity_pattern.n_rows() << " " << sparsity_pattern.n_cols()
+ << " " << sparsity_pattern.bandwidth() << " "
+ << sparsity_pattern.n_nonzero_elements() << std::endl;
+}
+
+
+
+void
+row_length()
+{
+ TrilinosWrappers::SparsityPattern sparsity_pattern;
+ build_sparsity(sparsity_pattern);
+
+ for (unsigned int i = 0; i < sparsity_pattern.n_rows(); ++i)
+ deallog << sparsity_pattern.row_length(i) << std::endl;
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+void
+print_gnuplot()
+{
+ TrilinosWrappers::SparsityPattern sparsity_pattern;
+ build_sparsity(sparsity_pattern);
+
+ sparsity_pattern.print_gnuplot(deallog.get_file_stream());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+void
+print()
+{
+ TrilinosWrappers::SparsityPattern sparsity_pattern;
+ build_sparsity(sparsity_pattern);
+
+ sparsity_pattern.print(deallog.get_file_stream());
+
+ deallog << "OK" << std::endl;
+}
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 - 2023 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.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+// Check LinearAlgebra::TpetraWrappers::Vector assignment and import
+
+template <typename Number>
+void
+test()
+{
+ IndexSet parallel_partitioner_1(10);
+ IndexSet parallel_partitioner_2(10);
+ unsigned int rank = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ if (rank == 0)
+ {
+ parallel_partitioner_1.add_range(0, 5);
+ parallel_partitioner_2.add_range(0, 3);
+ }
+ else
+ {
+ parallel_partitioner_1.add_range(5, 10);
+ parallel_partitioner_2.add_range(3, 10);
+ }
+ parallel_partitioner_1.compress();
+ parallel_partitioner_2.compress();
+ LinearAlgebra::TpetraWrappers::Vector<Number> a;
+ LinearAlgebra::TpetraWrappers::Vector<Number> b(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> c(b);
+
+ AssertThrow(a.size() == 0, ExcMessage("Vector has the wrong size."));
+ AssertThrow(b.size() == 10, ExcMessage("Vector has the wrong size."));
+ AssertThrow(c.size() == 10, ExcMessage("Vector has the wrong size."));
+
+ a.reinit(parallel_partitioner_2, MPI_COMM_WORLD);
+ AssertThrow(a.size() == 10, ExcMessage("Vector has the wrong size."));
+
+ AssertThrow(parallel_partitioner_1 == b.locally_owned_elements(),
+ ExcMessage("IndexSet has been modified."));
+ AssertThrow(parallel_partitioner_2 == a.locally_owned_elements(),
+ ExcMessage("IndexSet has been modified."));
+
+ IndexSet read_write_index_set(10);
+ if (rank == 0)
+ read_write_index_set.add_range(0, 6);
+ else
+ read_write_index_set.add_range(4, 10);
+ read_write_index_set.compress();
+
+ LinearAlgebra::ReadWriteVector<Number> read_write_1(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_2(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_3(read_write_index_set);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ {
+ read_write_1[i] = i;
+ read_write_2[i] = 5. + i;
+ }
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ {
+ read_write_1[i] = i;
+ read_write_2[i] = 5. + i;
+ }
+ }
+
+ a.import_elements(read_write_2, VectorOperation::insert);
+ AssertThrow(a.size() == 10, ExcMessage("Vector has the wrong size."));
+
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ {
+ AssertThrow(read_write_2[i] == read_write_3[i],
+ ExcMessage("Vector a has been modified."));
+ }
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(read_write_2[i] == read_write_3[i],
+ ExcMessage("Vector a has been modified."));
+ }
+
+ b.import_elements(read_write_1, VectorOperation::insert);
+ AssertThrow(b.size() == 10, ExcMessage("Vector has the wrong size."));
+
+ read_write_3.import_elements(b, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(read_write_1[i] == read_write_3[i],
+ ExcMessage("Vector b has been modified."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(read_write_1[i] == read_write_3[i],
+ ExcMessage("Vector b has been modified."));
+ }
+
+ c.import_elements(read_write_2, VectorOperation::insert);
+ AssertThrow(c.size() == 10, ExcMessage("Vector has the wrong size."));
+
+ read_write_3.import_elements(c, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(read_write_2[i] == read_write_3[i],
+ ExcMessage("Vector c has been modified."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(read_write_2[i] == read_write_3[i],
+ ExcMessage("Vector c has been modified."));
+ }
+
+ a *= 2;
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(Number(2.) * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in operator *=."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(Number(2.) * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in operator *=."));
+ }
+
+ c /= 2.;
+ read_write_3.import_elements(c, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(Number(0.5) * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in operator /=."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(Number(0.5) * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in operator /=."));
+ }
+
+ b += a;
+ read_write_3.import_elements(b, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(Number(2.) * read_write_2[i] + read_write_1[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in operator +=."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(Number(2.) * read_write_2[i] + read_write_1[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in operator +=."));
+ }
+
+ b -= c;
+ read_write_3.import_elements(b, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 6; ++i)
+ AssertThrow(Number(1.5) * read_write_2[i] + read_write_1[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in operator -=."));
+ }
+ else
+ {
+ for (unsigned int i = 4; i < 10; ++i)
+ AssertThrow(Number(1.5) * read_write_2[i] + read_write_1[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in operator -=."));
+ }
+
+ b.import_elements(read_write_1, VectorOperation::insert);
+ c.import_elements(read_write_1, VectorOperation::insert);
+ const Number val = b * c;
+ AssertThrow(val == Number(285.), ExcMessage("Problem in operator *."));
+}
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+ deallog.depth_console(0);
+
+ Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1);
+
+ test<double>();
+
+ deallog << "OK" << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 - 2023 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.
+//
+// ---------------------------------------------------------------------
+
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+// Check LinearAlgebra::TpetraWrappers::Vector add and sadd.
+
+template <typename Number>
+void
+test()
+{
+ IndexSet parallel_partitioner_1(10);
+ IndexSet parallel_partitioner_2(10);
+ unsigned int rank = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ if (rank == 0)
+ {
+ parallel_partitioner_1.add_range(0, 5);
+ parallel_partitioner_2.add_range(0, 3);
+ }
+ else
+ {
+ parallel_partitioner_1.add_range(5, 10);
+ parallel_partitioner_2.add_range(3, 10);
+ }
+ parallel_partitioner_1.compress();
+ parallel_partitioner_2.compress();
+ LinearAlgebra::TpetraWrappers::Vector<Number> a(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> b(parallel_partitioner_1,
+ MPI_COMM_WORLD);
+ LinearAlgebra::TpetraWrappers::Vector<Number> c(parallel_partitioner_2,
+ MPI_COMM_WORLD);
+
+ IndexSet read_write_index_set(10);
+ if (rank == 0)
+ read_write_index_set.add_range(0, 5);
+ else
+ read_write_index_set.add_range(5, 10);
+ read_write_index_set.compress();
+
+ LinearAlgebra::ReadWriteVector<Number> read_write_1(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_2(read_write_index_set);
+ LinearAlgebra::ReadWriteVector<Number> read_write_3(read_write_index_set);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ {
+ read_write_1[i] = i;
+ read_write_2[i] = 5. + i;
+ }
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ {
+ read_write_1[i] = i;
+ read_write_2[i] = 5. + i;
+ }
+ }
+
+ a.import_elements(read_write_1, VectorOperation::insert);
+ b.import_elements(read_write_2, VectorOperation::insert);
+ c.import_elements(read_write_2, VectorOperation::insert);
+
+ a.add(1.);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(Number(1.) + read_write_1[i] == read_write_3[i],
+ ExcMessage("Problem in add(scalar)."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow(Number(1.) + read_write_1[i] == read_write_3[i],
+ ExcMessage("Problem in add(scalar)."));
+ }
+
+ a.add(2., b);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(Number(1.) + read_write_1[i] +
+ Number(2.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in add(scalar,Vector)."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow(Number(1.) + read_write_1[i] +
+ Number(2.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in add(scalar,Vector)."));
+ }
+
+
+ LinearAlgebra::TpetraWrappers::Vector<Number> d(a);
+ a.add(2., b, 3., d);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(Number(4.) + Number(4.) * read_write_1[i] +
+ Number(10.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in add(scalar,Vector,scalar,Vector)."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow(Number(4.) + Number(4.) * read_write_1[i] +
+ Number(10.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in add(scalar,Vector,scalar,Vector)."));
+ }
+
+
+ a.import_elements(read_write_1, VectorOperation::insert);
+ a.sadd(3., 2., c);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(Number(3.) * read_write_1[i] +
+ Number(2.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in sadd(scalar,scalar,Vector)."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow(Number(3.) * read_write_1[i] +
+ Number(2.) * read_write_2[i] ==
+ read_write_3[i],
+ ExcMessage("Problem in sadd(scalar,scalar,Vector)."));
+ }
+
+
+ a.import_elements(read_write_1, VectorOperation::insert);
+ a.scale(b);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(read_write_1[i] * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in scale."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow(read_write_1[i] * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in scale."));
+ }
+
+
+ a.equ(2., c);
+ read_write_3.import_elements(a, VectorOperation::insert);
+ if (rank == 0)
+ {
+ for (unsigned int i = 0; i < 5; ++i)
+ AssertThrow(Number(2.) * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in scale."));
+ }
+ else
+ {
+ for (unsigned int i = 5; i < 10; ++i)
+ AssertThrow((Number)2. * read_write_2[i] == read_write_3[i],
+ ExcMessage("Problem in equ."));
+ }
+
+
+ AssertThrow(b.l1_norm() == 95., ExcMessage("Problem in l1_norm."));
+
+ const double eps = 1e-6;
+ AssertThrow(std::fabs(b.l2_norm() - 31.3847096) < eps,
+ ExcMessage("Problem in l2_norm"));
+
+ AssertThrow(b.linfty_norm() == 14., ExcMessage("Problem in linfty_norm."));
+
+ a.import_elements(read_write_1, VectorOperation::insert);
+ const Number val = a.add_and_dot(2., a, b);
+ AssertThrow(val == Number(1530.), ExcMessage("Problem in add_and_dot"));
+}
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+ deallog.depth_console(0);
+
+ Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1);
+
+ test<double>();
+
+ deallog << "OK" << std::endl;
+
+ return 0;
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2018 - 2023 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.
+//
+// ---------------------------------------------------------------------
+
+// Check LinearAlgebra::TpetraWrappers::Vector::import
+// for VectorOperation::add and check LinearAlgebra::ReadWriteVector
+// for VectorOperation::add/min/max.
+
+#include <deal.II/base/index_set.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+template <typename Number>
+void
+test()
+{
+ unsigned int my_id = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+ unsigned int n_procs = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+
+ IndexSet locally_owned(n_procs * 2);
+ locally_owned.add_range(my_id * 2, my_id * 2 + 2);
+ locally_owned.compress();
+
+ LinearAlgebra::TpetraWrappers::Vector<Number> v(locally_owned,
+ MPI_COMM_WORLD);
+
+ IndexSet workaround_set(n_procs * 2);
+ unsigned int my_first_index = (my_id * 2 + 2) % (n_procs * 2);
+ unsigned int my_second_index = my_id * 2 + 1;
+ workaround_set.add_index(my_first_index);
+ workaround_set.add_index(my_second_index);
+ workaround_set.add_index(0);
+ workaround_set.compress();
+ LinearAlgebra::ReadWriteVector<Number> rw_vector(workaround_set);
+
+ rw_vector(my_first_index) = my_id + 10;
+ rw_vector(my_second_index) = my_id + 100;
+ rw_vector(0) = 1.;
+ // rw_vector(2) = 1.;
+ v.import_elements(rw_vector, VectorOperation::add);
+ deallog << "Tpetra first import add:" << std::endl;
+ v.print(deallog.get_file_stream());
+ rw_vector.print(deallog.get_file_stream());
+
+ rw_vector(my_first_index) = my_id + 20;
+ rw_vector(my_second_index) = my_id + 200;
+ rw_vector(0) = 2.;
+ // rw_vector(2) = 3.;
+ v.import_elements(rw_vector, VectorOperation::add);
+ deallog << "Tpetra second import add:" << std::endl;
+ v.print(deallog.get_file_stream());
+ rw_vector.print(deallog.get_file_stream());
+
+ rw_vector.import_elements(v, VectorOperation::add);
+ deallog << "ReadWrite import add:" << std::endl;
+ rw_vector.print(deallog.get_file_stream());
+
+ rw_vector(my_first_index) = my_id + 100;
+ rw_vector(my_second_index) = 1;
+ rw_vector(0) = 4.;
+ // rw_vector(2) = 3.;
+ rw_vector.import_elements(v, VectorOperation::min);
+ deallog << "ReadWrite import min:" << std::endl;
+ rw_vector.print(deallog.get_file_stream());
+
+ rw_vector(my_first_index) = my_id + 100;
+ rw_vector(my_second_index) = 1;
+ rw_vector(0) = 4.;
+ // rw_vector(2) = 3.;
+ rw_vector.import_elements(v, VectorOperation::max);
+ deallog << "ReadWrite import max:" << std::endl;
+ rw_vector.print(deallog.get_file_stream());
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+ MPILogInitAll log;
+ test<double>();
+}
--- /dev/null
+
+DEAL:0::Tpetra first import add:
+size:4 locally_owned_size:2 :
+[0]: 2.000e+00
+[1]: 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+size:4 locally_owned_size:2 :
+[0]: 4.000e+00
+[1]: 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 6.000e+00
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+
+DEAL:1::Tpetra first import add:
+size:4 locally_owned_size:2 :
+[2]: 1.000e+01
+[3]: 1.010e+02
+IndexSet: {0, 3}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+DEAL:1::Tpetra second import add:
+size:4 locally_owned_size:2 :
+[2]: 3.000e+01
+[3]: 2.010e+02
+IndexSet: {0, 3}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+DEAL:1::ReadWrite import add:
+IndexSet: {0, 3}
+
+[0]: 6.000e+00
+[3]: 4.020e+02
+DEAL:1::ReadWrite import min:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+DEAL:1::ReadWrite import max:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 2.010e+02
+
--- /dev/null
+
+DEAL:0::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[0]: 4.000e+00
+[1]: 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[0]: 8.000e+00
+[1]: 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 1.000e+01
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
+[0]: 8.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+
+DEAL:1::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[2]: 1.000e+01
+[3]: 1.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+[4]: 1.100e+01
+DEAL:1::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[2]: 3.000e+01
+[3]: 2.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+[4]: 2.100e+01
+DEAL:1::ReadWrite import add:
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+01
+[3]: 4.020e+02
+[4]: 5.300e+01
+DEAL:1::ReadWrite import min:
+IndexSet: {0, [3,4]}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+[4]: 3.200e+01
+DEAL:1::ReadWrite import max:
+IndexSet: {0, [3,4]}
+
+[0]: 8.000e+00
+[3]: 2.010e+02
+[4]: 1.010e+02
+
+
+DEAL:2::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[4]: 1.100e+01
+[5]: 1.020e+02
+IndexSet: {0, [5,6]}
+
+[0]: 1.000e+00
+[5]: 1.020e+02
+[6]: 1.200e+01
+DEAL:2::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[4]: 3.200e+01
+[5]: 2.020e+02
+IndexSet: {0, [5,6]}
+
+[0]: 2.000e+00
+[5]: 2.020e+02
+[6]: 2.200e+01
+DEAL:2::ReadWrite import add:
+IndexSet: {0, [5,6]}
+
+[0]: 1.000e+01
+[5]: 4.040e+02
+[6]: 5.600e+01
+DEAL:2::ReadWrite import min:
+IndexSet: {0, [5,6]}
+
+[0]: 4.000e+00
+[5]: 1.000e+00
+[6]: 3.400e+01
+DEAL:2::ReadWrite import max:
+IndexSet: {0, [5,6]}
+
+[0]: 8.000e+00
+[5]: 2.020e+02
+[6]: 1.020e+02
+
+
+DEAL:3::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[6]: 1.200e+01
+[7]: 1.030e+02
+IndexSet: {0, 7}
+
+[0]: 1.000e+00
+[7]: 1.030e+02
+DEAL:3::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[6]: 3.400e+01
+[7]: 2.030e+02
+IndexSet: {0, 7}
+
+[0]: 2.000e+00
+[7]: 2.030e+02
+DEAL:3::ReadWrite import add:
+IndexSet: {0, 7}
+
+[0]: 1.000e+01
+[7]: 4.060e+02
+DEAL:3::ReadWrite import min:
+IndexSet: {0, 7}
+
+[0]: 4.000e+00
+[7]: 1.000e+00
+DEAL:3::ReadWrite import max:
+IndexSet: {0, 7}
+
+[0]: 8.000e+00
+[7]: 2.030e+02
+
--- /dev/null
+
+DEAL:0::Tpetra first import add:
+size:4 locally_owned_size:2 :
+[0]: 2.000e+00
+[1]: 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+size:4 locally_owned_size:2 :
+[0]: 4.000e+00
+[1]: 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 6.000e+00
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+
+DEAL:1::Tpetra first import add:
+size:4 locally_owned_size:2 :
+[2]: 1.000e+01
+[3]: 1.010e+02
+IndexSet: {0, 3}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+DEAL:1::Tpetra second import add:
+size:4 locally_owned_size:2 :
+[2]: 3.000e+01
+[3]: 2.010e+02
+IndexSet: {0, 3}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+DEAL:1::ReadWrite import add:
+IndexSet: {0, 3}
+
+[0]: 6.000e+00
+[3]: 4.020e+02
+DEAL:1::ReadWrite import min:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+DEAL:1::ReadWrite import max:
+IndexSet: {0, 3}
+
+[0]: 4.000e+00
+[3]: 2.010e+02
+
--- /dev/null
+
+DEAL:0::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[0]: 4.000e+00
+[1]: 1.000e+02
+IndexSet: {[0,2]}
+
+[0]: 1.000e+00
+[1]: 1.000e+02
+[2]: 1.000e+01
+DEAL:0::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[0]: 8.000e+00
+[1]: 2.000e+02
+IndexSet: {[0,2]}
+
+[0]: 2.000e+00
+[1]: 2.000e+02
+[2]: 2.000e+01
+DEAL:0::ReadWrite import add:
+IndexSet: {[0,2]}
+
+[0]: 1.000e+01
+[1]: 4.000e+02
+[2]: 5.000e+01
+DEAL:0::ReadWrite import min:
+IndexSet: {[0,2]}
+
+[0]: 4.000e+00
+[1]: 1.000e+00
+[2]: 3.000e+01
+DEAL:0::ReadWrite import max:
+IndexSet: {[0,2]}
+
+[0]: 8.000e+00
+[1]: 2.000e+02
+[2]: 1.000e+02
+
+DEAL:1::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[2]: 1.000e+01
+[3]: 1.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+00
+[3]: 1.010e+02
+[4]: 1.100e+01
+DEAL:1::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[2]: 3.000e+01
+[3]: 2.010e+02
+IndexSet: {0, [3,4]}
+
+[0]: 2.000e+00
+[3]: 2.010e+02
+[4]: 2.100e+01
+DEAL:1::ReadWrite import add:
+IndexSet: {0, [3,4]}
+
+[0]: 1.000e+01
+[3]: 4.020e+02
+[4]: 5.300e+01
+DEAL:1::ReadWrite import min:
+IndexSet: {0, [3,4]}
+
+[0]: 4.000e+00
+[3]: 1.000e+00
+[4]: 3.200e+01
+DEAL:1::ReadWrite import max:
+IndexSet: {0, [3,4]}
+
+[0]: 8.000e+00
+[3]: 2.010e+02
+[4]: 1.010e+02
+
+
+DEAL:2::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[4]: 1.100e+01
+[5]: 1.020e+02
+IndexSet: {0, [5,6]}
+
+[0]: 1.000e+00
+[5]: 1.020e+02
+[6]: 1.200e+01
+DEAL:2::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[4]: 3.200e+01
+[5]: 2.020e+02
+IndexSet: {0, [5,6]}
+
+[0]: 2.000e+00
+[5]: 2.020e+02
+[6]: 2.200e+01
+DEAL:2::ReadWrite import add:
+IndexSet: {0, [5,6]}
+
+[0]: 1.000e+01
+[5]: 4.040e+02
+[6]: 5.600e+01
+DEAL:2::ReadWrite import min:
+IndexSet: {0, [5,6]}
+
+[0]: 4.000e+00
+[5]: 1.000e+00
+[6]: 3.400e+01
+DEAL:2::ReadWrite import max:
+IndexSet: {0, [5,6]}
+
+[0]: 8.000e+00
+[5]: 2.020e+02
+[6]: 1.020e+02
+
+
+DEAL:3::Tpetra first import add:
+size:8 locally_owned_size:2 :
+[6]: 1.200e+01
+[7]: 1.030e+02
+IndexSet: {0, 7}
+
+[0]: 1.000e+00
+[7]: 1.030e+02
+DEAL:3::Tpetra second import add:
+size:8 locally_owned_size:2 :
+[6]: 3.400e+01
+[7]: 2.030e+02
+IndexSet: {0, 7}
+
+[0]: 2.000e+00
+[7]: 2.030e+02
+DEAL:3::ReadWrite import add:
+IndexSet: {0, 7}
+
+[0]: 1.000e+01
+[7]: 4.060e+02
+DEAL:3::ReadWrite import min:
+IndexSet: {0, 7}
+
+[0]: 4.000e+00
+[7]: 1.000e+00
+DEAL:3::ReadWrite import max:
+IndexSet: {0, 7}
+
+[0]: 8.000e+00
+[7]: 2.030e+02
+
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 - 2018 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.
+//
+// ---------------------------------------------------------------------
+
+
+
+// LinearAlgebra::TpetraWrappers::internal::VectorReference had its non-const
+// copy operator return a const reference. That was non-intuitive but, because
+// of the particular semantics of copying vector reference objects, made no
+// difference. Either way, we now check these semantics.
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(3), MPI_COMM_WORLD);
+ v(0) = 0;
+ v(1) = 1;
+ v(2) = 2;
+
+ LinearAlgebra::TpetraWrappers::internal::VectorReference a(v(0));
+ LinearAlgebra::TpetraWrappers::internal::VectorReference b(v(1));
+ LinearAlgebra::TpetraWrappers::internal::VectorReference c(v(2));
+
+ // Copy the VectorReference objects. Note that operator= for these
+ // objects does not copy the *content* of the reference object, but
+ // rather assigns the value of the vector element referenced on the
+ // right to the vector element referenced on the left.
+ // So the applied operations result in the following actions:
+ // 1. We first assign c to point to where a points (c points to entry 0)
+ // 2. We next assign c to point to where b points (c points to entry 1)
+ // 3. Lastly, we assign b to point to where a points (b points to entry 0)
+ (c = a) = b;
+ b = a;
+
+ deallog << static_cast<TrilinosScalar>(a)
+ << std::endl; // should point to v(0)
+ deallog << static_cast<TrilinosScalar>(b)
+ << std::endl; // should point to v(0)
+ deallog << static_cast<TrilinosScalar>(c)
+ << std::endl; // should point to v(1)
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+ initlog();
+ ;
+
+ test();
+}
--- /dev/null
+
+DEAL::0.00000
+DEAL::0.00000
+DEAL::1.00000
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2020 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.
+//
+// ---------------------------------------------------------------------
+
+// run LinearAlgebra::TpetraWrappers::Vector<double>.renit() in MPI environment
+// to test IndexSet::make_trilinos_map(), which contained an MPI-related bug.
+// Namely, a Fortran type MPI_LOGICAL was used instead of MPI_INT.
+
+
+#include <deal.II/base/index_set.h>
+
+#include <deal.II/distributed/grid_refinement.h>
+#include <deal.II/distributed/tria.h>
+
+#include <deal.II/dofs/dof_handler.h>
+#include <deal.II/dofs/dof_tools.h>
+
+#include <deal.II/fe/fe_q.h>
+
+#include <deal.II/grid/grid_generator.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include "../tests.h"
+
+
+static const unsigned int dim = 2;
+
+void
+test()
+{
+ MPI_Comm mpi_communicator(MPI_COMM_WORLD);
+
+ parallel::distributed::Triangulation<dim> tria(
+ mpi_communicator,
+ typename Triangulation<dim>::MeshSmoothing(
+ Triangulation<dim>::smoothing_on_refinement |
+ Triangulation<dim>::smoothing_on_coarsening));
+
+ GridGenerator::hyper_cube(tria, -1, 0);
+ tria.refine_global(2);
+
+ const unsigned int poly_degree = 1;
+ FE_Q<dim> fe(poly_degree);
+
+ DoFHandler<dim> dof_handler(tria);
+ dof_handler.distribute_dofs(fe);
+
+ IndexSet locally_owned_dofs = dof_handler.locally_owned_dofs();
+
+ LinearAlgebra::TpetraWrappers::Vector<double> vector_Re;
+ vector_Re.reinit(locally_owned_dofs, mpi_communicator);
+
+ deallog << "OK" << std::endl;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ initlog();
+ deallog.depth_console(0);
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1);
+ {
+ test();
+ }
+}
--- /dev/null
+
+DEAL::OK
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2004 - 2018 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 ::Vector::swap() (fixed in r 25668)
+ */
+
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+void
+print(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+ deallog << "size= " << v.size() << " el(0)= " << v(0)
+ << " l2norm()= " << v.l2_norm() << std::endl;
+}
+
+
+void
+test()
+{
+ LinearAlgebra::TpetraWrappers::Vector<double> v;
+ v.reinit(complete_index_set(5), MPI_COMM_WORLD);
+ for (unsigned int i = 0; i < v.size(); ++i)
+ v(i) = 1;
+ LinearAlgebra::TpetraWrappers::Vector<double> w;
+ w.reinit(complete_index_set(9), MPI_COMM_WORLD);
+ for (unsigned int i = 0; i < w.size(); ++i)
+ w(i) = 2;
+
+
+ deallog << "v: ";
+ print(v);
+ deallog << "w: ";
+ print(w);
+
+ deallog << "**swap**" << std::endl;
+
+ swap(v, w);
+
+ deallog << "v: ";
+ print(v);
+ deallog << "w: ";
+ print(w);
+
+ Assert(v.size() == 9, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+ initlog();
+
+ Utilities::MPI::MPI_InitFinalize mpi_initialization(
+ argc, argv, testing_max_num_threads());
+
+
+ try
+ {
+ test();
+ }
+ catch (const std::exception &exc)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Exception on processing: " << std::endl
+ << exc.what() << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+
+ return 1;
+ }
+ catch (...)
+ {
+ std::cerr << std::endl
+ << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ std::cerr << "Unknown exception!" << std::endl
+ << "Aborting!" << std::endl
+ << "----------------------------------------------------"
+ << std::endl;
+ return 1;
+ };
+}
--- /dev/null
+
+DEAL::v: size= 5 el(0)= 1.00000 l2norm()= 2.23607
+DEAL::w: size= 9 el(0)= 2.00000 l2norm()= 6.00000
+DEAL::**swap**
+DEAL::v: size= 9 el(0)= 2.00000 l2norm()= 6.00000
+DEAL::w: size= 5 el(0)= 1.00000 l2norm()= 2.23607
+DEAL::OK