]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add set of passing Tpetra tests 17292/head
authorJan Philipp Thiele <thiele@wias-berlin.de>
Fri, 19 Jul 2024 11:49:45 +0000 (13:49 +0200)
committerJan Philipp Thiele <thiele@wias-berlin.de>
Fri, 19 Jul 2024 12:57:07 +0000 (14:57 +0200)
32 files changed:
tests/trilinos_tpetra/08.cc [new file with mode: 0644]
tests/trilinos_tpetra/08.output [new file with mode: 0644]
tests/trilinos_tpetra/49.cc [new file with mode: 0644]
tests/trilinos_tpetra/49.output [new file with mode: 0644]
tests/trilinos_tpetra/n_nonzeros_01.cc [new file with mode: 0644]
tests/trilinos_tpetra/n_nonzeros_01.output [new file with mode: 0644]
tests/trilinos_tpetra/n_nonzeros_02.cc [new file with mode: 0644]
tests/trilinos_tpetra/n_nonzeros_02.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_02.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_02.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_03.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_03.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_04.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_04.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_copy_from_02.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_copy_from_02.with_trilinos=true.mpirun=3.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_iterator_01.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_iterator_01.output [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_vector_08.cc [new file with mode: 0644]
tests/trilinos_tpetra/sparse_matrix_vector_08.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_assign_01.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_assign_01.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_assign_02.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_assign_02.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_1.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_1.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_2.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_2.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_3.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_3.output [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_4.cc [new file with mode: 0644]
tests/trilinos_tpetra/vector_equality_4.output [new file with mode: 0644]

diff --git a/tests/trilinos_tpetra/08.cc b/tests/trilinos_tpetra/08.cc
new file mode 100644 (file)
index 0000000..6b08722
--- /dev/null
@@ -0,0 +1,96 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// check LinearAlgebra::TpetraWrappers::SparseMatrix<double>::frobenius_norm
+
+#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. count how many
+  // entries we have
+  TrilinosScalar norm = 0;
+  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);
+          norm += (i * j * .5 + .5) * (i * j * .5 + .5);
+        }
+  norm = std::sqrt(norm);
+
+  m.compress(VectorOperation::insert);
+
+  // compare against the exact value of the
+  // l2-norm (max row-sum)
+  deallog << m.frobenius_norm() << std::endl;
+  Assert(m.frobenius_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::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;
+    };
+}
diff --git a/tests/trilinos_tpetra/08.output b/tests/trilinos_tpetra/08.output
new file mode 100644 (file)
index 0000000..d4083f6
--- /dev/null
@@ -0,0 +1,3 @@
+
+DEAL::9.04157
+DEAL::OK
diff --git a/tests/trilinos_tpetra/49.cc b/tests/trilinos_tpetra/49.cc
new file mode 100644 (file)
index 0000000..56e3198
--- /dev/null
@@ -0,0 +1,97 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// check LinearAlgebra::TpetraWrappers::Vector<double>::operator =
+// (dealii::Vector<TrilinosScalar>)
+
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_vector.h>
+#include <deal.II/lac/vector.h>
+
+#include <iostream>
+#include <vector>
+
+#include "../tests.h"
+
+
+void
+test(LinearAlgebra::TpetraWrappers::Vector<double> &v)
+{
+  dealii::Vector<TrilinosScalar> w(v.size());
+
+  for (unsigned int i = 0; i < w.size(); ++i)
+    w(i) = i;
+
+  v = w;
+
+
+  // make sure we get the expected result
+  for (unsigned int i = 0; i < v.size(); ++i)
+    {
+      AssertThrow(w(i) == i, 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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/49.output b/tests/trilinos_tpetra/49.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/n_nonzeros_01.cc b/tests/trilinos_tpetra/n_nonzeros_01.cc
new file mode 100644 (file)
index 0000000..cca9edf
--- /dev/null
@@ -0,0 +1,79 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// check n_nonzero_elements() for an empty matrix
+
+#include <deal.II/lac/sparsity_pattern.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparsity_pattern.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  // create an empty sparsity pattern
+  LinearAlgebra::TpetraWrappers::SparsityPattern sparsity(4, 5, 1);
+  sparsity.compress();
+
+  // attach a sparse matrix to it
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double> A(sparsity);
+
+  // see how many nonzero elements it reports
+  deallog << A.n_nonzero_elements() << 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)
+    {
+      deallog << std::endl
+              << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Exception on processing: " << std::endl
+              << exc.what() << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      deallog << std::endl
+              << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Unknown exception!" << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/trilinos_tpetra/n_nonzeros_01.output b/tests/trilinos_tpetra/n_nonzeros_01.output
new file mode 100644 (file)
index 0000000..199228a
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::0
diff --git a/tests/trilinos_tpetra/n_nonzeros_02.cc b/tests/trilinos_tpetra/n_nonzeros_02.cc
new file mode 100644 (file)
index 0000000..9089ed4
--- /dev/null
@@ -0,0 +1,106 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// check n_nonzero_elements() for an empty matrix
+
+#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/sparsity_pattern.h>
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparsity_pattern.h>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  Triangulation<2> tria;
+  GridGenerator::hyper_cube(tria);
+
+  FE_Q<2>       fe(1);
+  DoFHandler<2> dof_handler(tria);
+  dof_handler.distribute_dofs(fe);
+
+  Table<2, DoFTools::Coupling> coupling(1, 1);
+  coupling.fill(DoFTools::none);
+
+  // create an empty sparsity pattern
+  LinearAlgebra::TpetraWrappers::SparsityPattern sparsity;
+  sparsity.reinit(dof_handler.n_dofs(), dof_handler.n_dofs());
+  DoFTools::make_sparsity_pattern(dof_handler,
+                                  coupling,
+                                  sparsity,
+                                  AffineConstraints<double>(),
+                                  false,
+                                  Utilities::MPI::this_mpi_process(
+                                    MPI_COMM_WORLD));
+  sparsity.compress();
+
+  // attach a sparse matrix to it
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double> A;
+  A.reinit(sparsity);
+
+  // see how many nonzero elements it reports
+  deallog << A.n_nonzero_elements() << 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)
+    {
+      deallog << std::endl
+              << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Exception on processing: " << std::endl
+              << exc.what() << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+
+      return 1;
+    }
+  catch (...)
+    {
+      deallog << std::endl
+              << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      deallog << "Unknown exception!" << std::endl
+              << "Aborting!" << std::endl
+              << "----------------------------------------------------"
+              << std::endl;
+      return 1;
+    };
+}
diff --git a/tests/trilinos_tpetra/n_nonzeros_02.output b/tests/trilinos_tpetra/n_nonzeros_02.output
new file mode 100644 (file)
index 0000000..199228a
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::0
diff --git a/tests/trilinos_tpetra/sparse_matrix_02.cc b/tests/trilinos_tpetra/sparse_matrix_02.cc
new file mode 100644 (file)
index 0000000..d01a631
--- /dev/null
@@ -0,0 +1,62 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// test LinearAlgebra::TpetraWrappers::SparseMatrix<double>::reinit with a
+// dealii::SparseMatrix and where we copy all values
+
+#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_sparsity_pattern.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(
+    argc, argv, testing_max_num_threads());
+
+  initlog();
+
+  SparsityPattern sparsity(5, 5, 5);
+  sparsity.add(1, 2);
+  sparsity.add(2, 3);
+  sparsity.add(3, 4);
+  sparsity.add(4, 3);
+  sparsity.compress();
+  SparseMatrix<double> matrix(sparsity);
+  {
+    double value = 1;
+    for (SparseMatrix<double>::iterator p = matrix.begin(); p != matrix.end();
+         ++p, ++value)
+      p->value() = value;
+  }
+  deallog << "Original:" << std::endl;
+  matrix.print_formatted(deallog.get_file_stream());
+
+  // now copy everything into a Trilinos matrix
+  const auto local_rows = complete_index_set(5);
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double> tmatrix;
+  tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF);
+
+  deallog << "Copy with all values:" << std::endl;
+  tmatrix.print(deallog.get_file_stream());
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_02.output b/tests/trilinos_tpetra/sparse_matrix_02.output
new file mode 100644 (file)
index 0000000..abdb4e3
--- /dev/null
@@ -0,0 +1,17 @@
+
+DEAL::Original:
+1.000e+00                                              
+           2.000e+00  3.000e+00                        
+                      4.000e+00  5.000e+00             
+                                 6.000e+00  7.000e+00  
+                                 9.000e+00  8.000e+00  
+DEAL::Copy with all values:
+(0,0) 1.00000
+(1,1) 2.00000
+(1,2) 3.00000
+(2,2) 4.00000
+(2,3) 5.00000
+(3,3) 6.00000
+(3,4) 7.00000
+(4,3) 9.00000
+(4,4) 8.00000
diff --git a/tests/trilinos_tpetra/sparse_matrix_03.cc b/tests/trilinos_tpetra/sparse_matrix_03.cc
new file mode 100644 (file)
index 0000000..d7bf2e2
--- /dev/null
@@ -0,0 +1,62 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// test LinearAlgebra::TpetraWrappers::SparseMatrix<double>::reinit with a
+// dealii::SparseMatrix with a drop tolerance
+
+#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_sparsity_pattern.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(
+    argc, argv, testing_max_num_threads());
+
+  initlog();
+
+  SparsityPattern sparsity(5, 5, 5);
+  sparsity.add(1, 2);
+  sparsity.add(2, 3);
+  sparsity.add(3, 4);
+  sparsity.add(4, 3);
+  sparsity.compress();
+  SparseMatrix<double> matrix(sparsity);
+  {
+    double value = 1;
+    for (SparseMatrix<double>::iterator p = matrix.begin(); p != matrix.end();
+         ++p, ++value)
+      p->value() = value;
+  }
+  deallog << "Original:" << std::endl;
+  matrix.print_formatted(deallog.get_file_stream());
+
+  // now copy everything into a Trilinos matrix
+  const auto local_rows = complete_index_set(5);
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double> tmatrix;
+  tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF, 4.);
+
+  deallog << "Copy with a drop tolerance of 4:" << std::endl;
+  tmatrix.print(deallog.get_file_stream());
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_03.output b/tests/trilinos_tpetra/sparse_matrix_03.output
new file mode 100644 (file)
index 0000000..2ec3dc6
--- /dev/null
@@ -0,0 +1,17 @@
+
+DEAL::Original:
+1.000e+00                                              
+           2.000e+00  3.000e+00                        
+                      4.000e+00  5.000e+00             
+                                 6.000e+00  7.000e+00  
+                                 9.000e+00  8.000e+00  
+DEAL::Copy with a drop tolerance of 4:
+(0,0) 0.00000
+(1,1) 0.00000
+(1,2) 0.00000
+(2,2) 0.00000
+(2,3) 5.00000
+(3,3) 6.00000
+(3,4) 7.00000
+(4,3) 9.00000
+(4,4) 8.00000
diff --git a/tests/trilinos_tpetra/sparse_matrix_04.cc b/tests/trilinos_tpetra/sparse_matrix_04.cc
new file mode 100644 (file)
index 0000000..304762a
--- /dev/null
@@ -0,0 +1,62 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// test LinearAlgebra::TpetraWrappers::SparseMatrix<double>::reinit with a
+// dealii::SparseMatrix without copying values
+
+#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_sparsity_pattern.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+int
+main(int argc, char **argv)
+{
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(
+    argc, argv, testing_max_num_threads());
+
+  initlog();
+
+  SparsityPattern sparsity(5, 5, 5);
+  sparsity.add(1, 2);
+  sparsity.add(2, 3);
+  sparsity.add(3, 4);
+  sparsity.add(4, 3);
+  sparsity.compress();
+  SparseMatrix<double> matrix(sparsity);
+  {
+    double value = 1;
+    for (SparseMatrix<double>::iterator p = matrix.begin(); p != matrix.end();
+         ++p, ++value)
+      p->value() = value;
+  }
+  deallog << "Original:" << std::endl;
+  matrix.print_formatted(deallog.get_file_stream());
+
+  // now copy everything into a Trilinos matrix
+  const auto local_rows = complete_index_set(5);
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double> tmatrix;
+  tmatrix.reinit(local_rows, local_rows, matrix, MPI_COMM_SELF, 0, false);
+
+  deallog << "Copy structure only:" << std::endl;
+  tmatrix.print(deallog.get_file_stream());
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_04.output b/tests/trilinos_tpetra/sparse_matrix_04.output
new file mode 100644 (file)
index 0000000..add5135
--- /dev/null
@@ -0,0 +1,17 @@
+
+DEAL::Original:
+1.000e+00                                              
+           2.000e+00  3.000e+00                        
+                      4.000e+00  5.000e+00             
+                                 6.000e+00  7.000e+00  
+                                 9.000e+00  8.000e+00  
+DEAL::Copy structure only:
+(0,0) 0.00000
+(1,1) 0.00000
+(1,2) 0.00000
+(2,2) 0.00000
+(2,3) 0.00000
+(3,3) 0.00000
+(3,4) 0.00000
+(4,3) 0.00000
+(4,4) 0.00000
diff --git a/tests/trilinos_tpetra/sparse_matrix_copy_from_02.cc b/tests/trilinos_tpetra/sparse_matrix_copy_from_02.cc
new file mode 100644 (file)
index 0000000..d64e1a9
--- /dev/null
@@ -0,0 +1,113 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// Test
+// LinearAlgebra::TpetraWrappers::SparseMatrix<double>::copy_from(other_matrix)
+// for the case of a non-contiguous set of rows.
+
+#include <deal.II/base/index_set.h>
+#include <deal.II/base/mpi.h>
+#include <deal.II/base/utilities.h>
+
+#include <deal.II/lac/trilinos_tpetra_sparse_matrix.h>
+#include <deal.II/lac/trilinos_tpetra_sparsity_pattern.h>
+#include <deal.II/lac/vector_operation.h>
+
+#include <iostream>
+
+#include "../tests.h"
+
+
+void
+test()
+{
+  const unsigned int MyPID   = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+  const unsigned int NumProc = Utilities::MPI::n_mpi_processes(MPI_COMM_WORLD);
+
+  if (MyPID == 0)
+    deallog << "NumProc=" << NumProc << std::endl;
+
+  // create non-contiguous index set for NumProc > 1
+  dealii::IndexSet parallel_partitioning(NumProc * 2);
+
+  // non-contiguous
+  parallel_partitioning.add_index(MyPID);
+  parallel_partitioning.add_index(NumProc + MyPID);
+
+  // create sparsity pattern from parallel_partitioning
+
+  // The sparsity pattern corresponds to a [FE_DGQ<1>(p=0)]^2 FESystem,
+  // on a triangulation in which each MPI process owns 2 cells,
+  // with reordered dofs by its components, such that the rows in the
+  // final matrix are locally not in a contiguous set.
+
+  dealii::LinearAlgebra::TpetraWrappers::SparsityPattern sp_M(
+    parallel_partitioning, MPI_COMM_WORLD, 2);
+
+  sp_M.add(MyPID, MyPID);
+  sp_M.add(MyPID, NumProc + MyPID);
+  sp_M.add(NumProc + MyPID, MyPID);
+  sp_M.add(NumProc + MyPID, NumProc + MyPID);
+
+  sp_M.compress();
+
+  // create matrix with dummy entries on the diagonal
+  dealii::LinearAlgebra::TpetraWrappers::SparseMatrix<double> M0;
+  M0.reinit(sp_M);
+  M0 = 0;
+
+  for (const auto &i : parallel_partitioning)
+    M0.set(i, i, dealii::numbers::PI);
+
+  M0.compress(dealii::VectorOperation::insert);
+
+  ////////////////////////////////////////////////////////////////////////
+  // test ::add(TrilinosScalar, SparseMatrix)
+  //
+
+  dealii::LinearAlgebra::TpetraWrappers::SparseMatrix<double> M1;
+  M1.reinit(sp_M); // avoid deep copy
+  M1 = 0;
+  M1.copy_from(M0);
+
+  // check
+  for (const auto &i : parallel_partitioning)
+    {
+      const auto &el = M1.el(i, i);
+
+      if (MyPID == 0)
+        deallog << "i = " << i << " , j = " << i << " , el = " << el
+                << std::endl;
+
+      AssertThrow(el == dealii::numbers::PI, dealii::ExcInternalError());
+    }
+
+  if (MyPID == 0)
+    deallog << "OK" << std::endl;
+}
+
+
+
+int
+main(int argc, char **argv)
+{
+  initlog();
+
+  Utilities::MPI::MPI_InitFinalize mpi_initialization(
+    argc, argv, testing_max_num_threads());
+
+  test();
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_copy_from_02.with_trilinos=true.mpirun=3.output b/tests/trilinos_tpetra/sparse_matrix_copy_from_02.with_trilinos=true.mpirun=3.output
new file mode 100644 (file)
index 0000000..dea2eaf
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::NumProc=3
+DEAL::i = 0 , j = 0 , el = 3.14159
+DEAL::i = 3 , j = 3 , el = 3.14159
+DEAL::OK
diff --git a/tests/trilinos_tpetra/sparse_matrix_iterator_01.cc b/tests/trilinos_tpetra/sparse_matrix_iterator_01.cc
new file mode 100644 (file)
index 0000000..0657d1c
--- /dev/null
@@ -0,0 +1,90 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// test LinearAlgebra::TpetraWrappers::MatrixBase::const_iterator
+
+#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(5U, 5U, 5U);
+  m.set(0, 0, 1);
+  m.set(1, 1, 2);
+  m.set(1, 2, 3);
+  m.compress(VectorOperation::insert);
+  LinearAlgebra::TpetraWrappers::SparseMatrix<double>::const_iterator i =
+    m.begin();
+  deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+  ++i;
+  deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+  i++;
+  deallog << i->row() << ' ' << i->column() << ' ' << i->value() << std::endl;
+
+  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;
+    };
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_iterator_01.output b/tests/trilinos_tpetra/sparse_matrix_iterator_01.output
new file mode 100644 (file)
index 0000000..e6bdc2e
--- /dev/null
@@ -0,0 +1,5 @@
+
+DEAL::0 0 1.00000
+DEAL::1 1 2.00000
+DEAL::1 2 3.00000
+DEAL::OK
diff --git a/tests/trilinos_tpetra/sparse_matrix_vector_08.cc b/tests/trilinos_tpetra/sparse_matrix_vector_08.cc
new file mode 100644 (file)
index 0000000..47e28b6
--- /dev/null
@@ -0,0 +1,115 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// check SparseMatrix::vmult, vmult_add with deal.II vector
+
+#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(Vector<double> &v, Vector<double> &w)
+{
+  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)
+    v(i) = i;
+
+  m.compress(VectorOperation::insert);
+
+  // w:=Mv
+  m.vmult(w, v);
+
+  // make sure we get the expected result
+  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(w(i) == result, ExcInternalError());
+    }
+
+  m.vmult_add(w, v);
+  // make sure we get the expected result
+  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(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
+    {
+      {
+        Vector<double> v(100);
+        Vector<double> w(95);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/sparse_matrix_vector_08.output b/tests/trilinos_tpetra/sparse_matrix_vector_08.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_assign_01.cc b/tests/trilinos_tpetra/vector_assign_01.cc
new file mode 100644 (file)
index 0000000..43fa1cb
--- /dev/null
@@ -0,0 +1,100 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// when calling LinearAlgebra::TpetraWrappers::Vector<double>::operator() (),
+// the return type is a reference object, not a reference to the actual element.
+// this leads to the funny situation that an assignment like v2(i)=v1(i) isn't
+// really what it looks like: it tries to copy the reference objects, not the
+// values they point to, as one would expect
+//
+// this was fixed 2004-04-05, and this test checks that it works
+
+#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 the first vector
+  for (unsigned int i = 0; i < v.size(); ++i)
+    v(i) = i;
+
+  // copy elements by reference
+  for (unsigned int i = 0; i < v.size(); ++i)
+    w(i) = v(i);
+
+  // check that they're equal
+  AssertThrow(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_assign_01.output b/tests/trilinos_tpetra/vector_assign_01.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_assign_02.cc b/tests/trilinos_tpetra/vector_assign_02.cc
new file mode 100644 (file)
index 0000000..9a25a63
--- /dev/null
@@ -0,0 +1,99 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// this is equivalent to the trilinos_vector_assign_02 test, except that we use
+// operator+= instead of operator=. Now, this does not present a problem,
+// since the compiler does not automatically generate a version of this
+// operator, but simply performs the conversion to TrilinosScalar, i.e. the
+// argument to the user-defined operator+=. This is not exciting, but since I
+// wrote the test to make sure it works this way, let's keep it then...
+
+#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 the first vector
+  for (unsigned int i = 0; i < v.size(); ++i)
+    v(i) = i;
+
+  // add elements by reference
+  for (unsigned int i = 0; i < v.size(); ++i)
+    w(i) += v(i);
+
+  // check that they're equal
+  AssertThrow(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_assign_02.output b/tests/trilinos_tpetra/vector_assign_02.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_equality_1.cc b/tests/trilinos_tpetra/vector_equality_1.cc
new file mode 100644 (file)
index 0000000..5b74a95
--- /dev/null
@@ -0,0 +1,95 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// check
+// LinearAlgebra::TpetraWrappers::Vector<double>::operator==(LinearAlgebra::TpetraWrappers::Vector<double>)
+// for vectors that are not equal
+
+#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.;
+    }
+
+  AssertThrow(!(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_equality_1.output b/tests/trilinos_tpetra/vector_equality_1.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_equality_2.cc b/tests/trilinos_tpetra/vector_equality_2.cc
new file mode 100644 (file)
index 0000000..a7b43e2
--- /dev/null
@@ -0,0 +1,98 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+
+// check
+// LinearAlgebra::TpetraWrappers::Vector<double>::operator==(LinearAlgebra::TpetraWrappers::Vector<double>)
+// for vectors that are equal
+
+#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.;
+    }
+  // but then copy elements and make sure the
+  // vectors are actually equal
+  v = w;
+  AssertThrow(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_equality_2.output b/tests/trilinos_tpetra/vector_equality_2.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_equality_3.cc b/tests/trilinos_tpetra/vector_equality_3.cc
new file mode 100644 (file)
index 0000000..0e18917
--- /dev/null
@@ -0,0 +1,95 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// check
+// LinearAlgebra::TpetraWrappers::Vector<double>::operator!=(LinearAlgebra::TpetraWrappers::Vector<double>)
+// for vectors that are not equal
+
+#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.;
+    }
+
+  AssertThrow(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_equality_3.output b/tests/trilinos_tpetra/vector_equality_3.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos_tpetra/vector_equality_4.cc b/tests/trilinos_tpetra/vector_equality_4.cc
new file mode 100644 (file)
index 0000000..e86fc16
--- /dev/null
@@ -0,0 +1,97 @@
+// ------------------------------------------------------------------------
+//
+// SPDX-License-Identifier: LGPL-2.1-or-later
+// Copyright (C) 2024 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// Part of the source code is dual licensed under Apache-2.0 WITH
+// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
+// governing the source code and code contributions can be found in
+// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
+//
+// ------------------------------------------------------------------------
+
+
+// check
+// LinearAlgebra::TpetraWrappers::Vector<double>::operator!=(LinearAlgebra::TpetraWrappers::Vector<double>)
+// for vectors that are equal
+
+#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.;
+    }
+  // but then copy elements and make sure the
+  // vectors are actually equal
+  v = w;
+  AssertThrow(!(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);
+        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;
+    };
+}
diff --git a/tests/trilinos_tpetra/vector_equality_4.output b/tests/trilinos_tpetra/vector_equality_4.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.