]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add tests. 4362/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 9 May 2017 20:47:45 +0000 (16:47 -0400)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Tue, 9 May 2017 20:51:11 +0000 (16:51 -0400)
tests/lac/la_vector_all_zero.cc [new file with mode: 0644]
tests/lac/la_vector_all_zero.output [new file with mode: 0644]
tests/trilinos/epetra_vector_03.cc [new file with mode: 0644]
tests/trilinos/epetra_vector_03.mpirun=2.output [new file with mode: 0644]

diff --git a/tests/lac/la_vector_all_zero.cc b/tests/lac/la_vector_all_zero.cc
new file mode 100644 (file)
index 0000000..8f9acdd
--- /dev/null
@@ -0,0 +1,43 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+// Check the function all_zero
+
+#include "../tests.h"
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/la_vector.h>
+
+
+template <typename Number>
+void check_all_zero()
+{
+  LinearAlgebra::Vector<Number> v(10);
+
+  AssertThrow(v.all_zero() == true, ExcInternalError());
+
+  v[0] = 1.;
+  AssertThrow(v.all_zero() == false, ExcInternalError());
+}
+
+int main()
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+
+  check_all_zero<float>();
+  check_all_zero<double>();
+
+  deallog << "OK" << std::endl;
+}
diff --git a/tests/lac/la_vector_all_zero.output b/tests/lac/la_vector_all_zero.output
new file mode 100644 (file)
index 0000000..0fd8fc1
--- /dev/null
@@ -0,0 +1,2 @@
+
+DEAL::OK
diff --git a/tests/trilinos/epetra_vector_03.cc b/tests/trilinos/epetra_vector_03.cc
new file mode 100644 (file)
index 0000000..b829e7e
--- /dev/null
@@ -0,0 +1,64 @@
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+
+#include "../tests.h"
+#include <deal.II/base/utilities.h>
+#include <deal.II/lac/read_write_vector.h>
+#include <deal.II/lac/trilinos_epetra_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+// Check LinearAlgebra::EpetraWrappers::Vector all_zero.
+
+void test()
+{
+  IndexSet parallel_partitioner(10);
+  unsigned int rank = Utilities::MPI::this_mpi_process(MPI_COMM_WORLD);
+  if (rank==0)
+    parallel_partitioner.add_range(0,5);
+  else
+    parallel_partitioner.add_range(5,10);
+  parallel_partitioner.compress();
+  LinearAlgebra::EpetraWrappers::Vector a(parallel_partitioner, MPI_COMM_WORLD);
+
+  AssertThrow(a.all_zero() == true, ExcInternalError());
+
+  IndexSet read_write_index_set(10);
+  LinearAlgebra::ReadWriteVector<double> read_write(parallel_partitioner);
+  if (rank==0)
+    read_write[0] = 1.;
+  a.import(read_write, VectorOperation::insert);
+  AssertThrow(a.all_zero() == false, ExcInternalError());
+}
+
+
+int main(int argc, char **argv)
+{
+  std::ofstream logfile("output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+  deallog.threshold_double(1.e-10);
+
+  Utilities::MPI::MPI_InitFinalize mpi_init(argc, argv, 1);
+
+  test();
+
+  deallog << "OK" <<std::endl;
+
+  return 0;
+}
+
diff --git a/tests/trilinos/epetra_vector_03.mpirun=2.output b/tests/trilinos/epetra_vector_03.mpirun=2.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.