From: Bruno Turcksin Date: Tue, 9 May 2017 20:47:45 +0000 (-0400) Subject: add tests. X-Git-Tag: v9.0.0-rc1~1611^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4362%2Fhead;p=dealii.git add tests. --- diff --git a/tests/lac/la_vector_all_zero.cc b/tests/lac/la_vector_all_zero.cc new file mode 100644 index 0000000000..8f9acdd058 --- /dev/null +++ b/tests/lac/la_vector_all_zero.cc @@ -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 +#include + + +template +void check_all_zero() +{ + LinearAlgebra::Vector 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(); + check_all_zero(); + + 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 index 0000000000..0fd8fc12f0 --- /dev/null +++ b/tests/lac/la_vector_all_zero.output @@ -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 index 0000000000..b829e7e051 --- /dev/null +++ b/tests/trilinos/epetra_vector_03.cc @@ -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 +#include +#include +#include +#include +#include + +// 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 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" <